fluentd 0.14.17-x64-mingw32 → 1.3.1-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +16 -5
- data/ADOPTERS.md +5 -0
- data/{ChangeLog → CHANGELOG.md} +495 -6
- data/CONTRIBUTING.md +5 -2
- data/GOVERNANCE.md +55 -0
- data/LICENSE +202 -0
- data/MAINTAINERS.md +7 -5
- data/README.md +17 -10
- data/bin/fluent-ca-generate +6 -0
- data/example/counter.conf +18 -0
- data/example/secondary_file.conf +3 -2
- data/fluentd.gemspec +3 -3
- data/lib/fluent/agent.rb +1 -1
- data/lib/fluent/command/binlog_reader.rb +11 -2
- data/lib/fluent/command/ca_generate.rb +181 -0
- data/lib/fluent/command/cat.rb +28 -15
- data/lib/fluent/command/debug.rb +4 -4
- data/lib/fluent/command/fluentd.rb +2 -2
- data/lib/fluent/command/plugin_config_formatter.rb +24 -2
- data/lib/fluent/command/plugin_generator.rb +26 -8
- data/lib/fluent/config/configure_proxy.rb +7 -1
- data/lib/fluent/config/dsl.rb +8 -5
- data/lib/fluent/config/element.rb +5 -0
- data/lib/fluent/config/literal_parser.rb +7 -1
- data/lib/fluent/config/types.rb +28 -2
- data/lib/fluent/config/v1_parser.rb +1 -2
- data/lib/fluent/configurable.rb +1 -0
- data/lib/fluent/counter.rb +23 -0
- data/lib/fluent/counter/base_socket.rb +46 -0
- data/lib/fluent/counter/client.rb +297 -0
- data/lib/fluent/counter/error.rb +86 -0
- data/lib/fluent/counter/mutex_hash.rb +163 -0
- data/lib/fluent/counter/server.rb +273 -0
- data/lib/fluent/counter/store.rb +205 -0
- data/lib/fluent/counter/validator.rb +145 -0
- data/lib/fluent/env.rb +1 -0
- data/lib/fluent/event_router.rb +1 -1
- data/lib/fluent/log.rb +119 -29
- data/lib/fluent/plugin/base.rb +12 -0
- data/lib/fluent/plugin/buf_file.rb +20 -16
- data/lib/fluent/plugin/buffer.rb +130 -32
- data/lib/fluent/plugin/buffer/file_chunk.rb +23 -4
- data/lib/fluent/plugin/compressable.rb +1 -1
- data/lib/fluent/plugin/filter_grep.rb +135 -21
- data/lib/fluent/plugin/filter_parser.rb +13 -2
- data/lib/fluent/plugin/filter_record_transformer.rb +16 -14
- data/lib/fluent/plugin/formatter_stdout.rb +3 -2
- data/lib/fluent/plugin/formatter_tsv.rb +5 -1
- data/lib/fluent/plugin/in_debug_agent.rb +8 -1
- data/lib/fluent/plugin/in_forward.rb +1 -1
- data/lib/fluent/plugin/in_http.rb +84 -3
- data/lib/fluent/plugin/in_monitor_agent.rb +7 -1
- data/lib/fluent/plugin/in_syslog.rb +31 -10
- data/lib/fluent/plugin/in_tail.rb +142 -53
- data/lib/fluent/plugin/in_tcp.rb +5 -6
- data/lib/fluent/plugin/in_udp.rb +6 -2
- data/lib/fluent/plugin/in_unix.rb +1 -1
- data/lib/fluent/plugin/multi_output.rb +1 -0
- data/lib/fluent/plugin/out_copy.rb +25 -2
- data/lib/fluent/plugin/out_file.rb +26 -7
- data/lib/fluent/plugin/out_forward.rb +81 -42
- data/lib/fluent/plugin/out_secondary_file.rb +2 -2
- data/lib/fluent/plugin/out_stdout.rb +0 -1
- data/lib/fluent/plugin/out_stream.rb +1 -1
- data/lib/fluent/plugin/output.rb +221 -57
- data/lib/fluent/plugin/parser_apache.rb +1 -1
- data/lib/fluent/plugin/parser_apache2.rb +5 -1
- data/lib/fluent/plugin/parser_apache_error.rb +1 -1
- data/lib/fluent/plugin/parser_json.rb +10 -3
- data/lib/fluent/plugin/parser_ltsv.rb +7 -0
- data/lib/fluent/plugin/parser_multiline.rb +2 -1
- data/lib/fluent/plugin/parser_nginx.rb +1 -1
- data/lib/fluent/plugin/parser_none.rb +1 -0
- data/lib/fluent/plugin/parser_regexp.rb +15 -14
- data/lib/fluent/plugin/parser_syslog.rb +9 -5
- data/lib/fluent/plugin_helper.rb +2 -0
- data/lib/fluent/plugin_helper/cert_option.rb +28 -9
- data/lib/fluent/plugin_helper/compat_parameters.rb +3 -1
- data/lib/fluent/plugin_helper/counter.rb +51 -0
- data/lib/fluent/plugin_helper/event_loop.rb +9 -0
- data/lib/fluent/plugin_helper/record_accessor.rb +210 -0
- data/lib/fluent/plugin_helper/retry_state.rb +15 -7
- data/lib/fluent/plugin_helper/server.rb +87 -25
- data/lib/fluent/plugin_helper/socket_option.rb +5 -2
- data/lib/fluent/plugin_helper/timer.rb +8 -7
- data/lib/fluent/root_agent.rb +18 -9
- data/lib/fluent/supervisor.rb +63 -23
- data/lib/fluent/system_config.rb +30 -2
- data/lib/fluent/test/helpers.rb +1 -1
- data/lib/fluent/time.rb +15 -7
- data/lib/fluent/timezone.rb +26 -2
- data/lib/fluent/version.rb +1 -1
- data/templates/new_gem/README.md.erb +2 -2
- data/templates/new_gem/lib/fluent/plugin/filter.rb.erb +1 -1
- data/templates/new_gem/lib/fluent/plugin/input.rb.erb +1 -1
- data/templates/new_gem/lib/fluent/plugin/output.rb.erb +1 -1
- data/templates/new_gem/lib/fluent/plugin/parser.rb.erb +4 -4
- data/test/command/test_ca_generate.rb +70 -0
- data/test/command/test_fluentd.rb +2 -2
- data/test/command/test_plugin_config_formatter.rb +8 -7
- data/test/command/test_plugin_generator.rb +65 -39
- data/test/config/test_config_parser.rb +7 -2
- data/test/config/test_configurable.rb +7 -2
- data/test/config/test_configure_proxy.rb +41 -3
- data/test/config/test_dsl.rb +10 -10
- data/test/config/test_element.rb +10 -0
- data/test/config/test_literal_parser.rb +8 -0
- data/test/config/test_plugin_configuration.rb +56 -0
- data/test/config/test_system_config.rb +19 -1
- data/test/config/test_types.rb +37 -0
- data/test/counter/test_client.rb +559 -0
- data/test/counter/test_error.rb +44 -0
- data/test/counter/test_mutex_hash.rb +179 -0
- data/test/counter/test_server.rb +589 -0
- data/test/counter/test_store.rb +258 -0
- data/test/counter/test_validator.rb +137 -0
- data/test/plugin/test_buf_file.rb +124 -0
- data/test/plugin/test_buffer.rb +3 -2
- data/test/plugin/test_filter_grep.rb +580 -2
- data/test/plugin/test_filter_parser.rb +33 -2
- data/test/plugin/test_filter_record_transformer.rb +22 -1
- data/test/plugin/test_formatter_ltsv.rb +3 -0
- data/test/plugin/test_formatter_tsv.rb +68 -0
- data/test/plugin/test_in_debug_agent.rb +21 -0
- data/test/plugin/test_in_exec.rb +3 -5
- data/test/plugin/test_in_http.rb +178 -0
- data/test/plugin/test_in_monitor_agent.rb +1 -1
- data/test/plugin/test_in_syslog.rb +64 -0
- data/test/plugin/test_in_tail.rb +116 -6
- data/test/plugin/test_in_tcp.rb +21 -0
- data/test/plugin/test_in_udp.rb +78 -0
- data/test/plugin/test_metadata.rb +89 -0
- data/test/plugin/test_out_copy.rb +31 -0
- data/test/plugin/test_out_file.rb +108 -2
- data/test/plugin/test_out_forward.rb +195 -2
- data/test/plugin/test_out_secondary_file.rb +14 -0
- data/test/plugin/test_output.rb +159 -45
- data/test/plugin/test_output_as_buffered.rb +19 -0
- data/test/plugin/test_output_as_buffered_backup.rb +307 -0
- data/test/plugin/test_output_as_buffered_retries.rb +70 -0
- data/test/plugin/test_output_as_buffered_secondary.rb +1 -1
- data/test/plugin/test_parser_apache2.rb +1 -0
- data/test/plugin/test_parser_labeled_tsv.rb +17 -0
- data/test/plugin/test_parser_nginx.rb +40 -0
- data/test/plugin/test_parser_regexp.rb +6 -7
- data/test/plugin/test_parser_syslog.rb +155 -5
- data/test/plugin_helper/test_child_process.rb +4 -4
- data/test/plugin_helper/test_compat_parameters.rb +22 -0
- data/test/plugin_helper/test_record_accessor.rb +197 -0
- data/test/plugin_helper/test_retry_state.rb +20 -0
- data/test/plugin_helper/test_server.rb +30 -2
- data/test/test_config.rb +3 -3
- data/test/test_configdsl.rb +2 -2
- data/test/test_log.rb +51 -1
- data/test/test_root_agent.rb +33 -0
- data/test/test_supervisor.rb +105 -0
- metadata +68 -8
- data/COPYING +0 -14
@@ -0,0 +1,197 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/plugin_helper/record_accessor'
|
3
|
+
require 'fluent/plugin/base'
|
4
|
+
|
5
|
+
require 'time'
|
6
|
+
|
7
|
+
class RecordAccessorHelperTest < Test::Unit::TestCase
|
8
|
+
class Dummy < Fluent::Plugin::TestBase
|
9
|
+
helpers :record_accessor
|
10
|
+
end
|
11
|
+
|
12
|
+
sub_test_case 'parse nested key expression' do
|
13
|
+
data('normal' => 'key1',
|
14
|
+
'space' => 'ke y2',
|
15
|
+
'dot key' => 'this.is.key3')
|
16
|
+
test 'parse single key' do |param|
|
17
|
+
result = Fluent::PluginHelper::RecordAccessor::Accessor.parse_parameter(param)
|
18
|
+
assert_equal param, result
|
19
|
+
end
|
20
|
+
|
21
|
+
test "nested bracket keys with dot" do
|
22
|
+
result = Fluent::PluginHelper::RecordAccessor::Accessor.parse_parameter("$['key1']['this.is.key3']")
|
23
|
+
assert_equal ['key1', 'this.is.key3'], result
|
24
|
+
end
|
25
|
+
|
26
|
+
data('dot' => '$.key1.key2[0]',
|
27
|
+
'bracket' => "$['key1']['key2'][0]",
|
28
|
+
'bracket w/ double quotes' => '$["key1"]["key2"][0]')
|
29
|
+
test "nested keys ['key1', 'key2', 0]" do |param|
|
30
|
+
result = Fluent::PluginHelper::RecordAccessor::Accessor.parse_parameter(param)
|
31
|
+
assert_equal ['key1', 'key2', 0], result
|
32
|
+
end
|
33
|
+
|
34
|
+
data('bracket' => "$['key1'][0]['ke y2']",
|
35
|
+
'bracket w/ double quotes' => '$["key1"][0]["ke y2"]')
|
36
|
+
test "nested keys ['key1', 0, 'ke y2']" do |param|
|
37
|
+
result = Fluent::PluginHelper::RecordAccessor::Accessor.parse_parameter(param)
|
38
|
+
assert_equal ['key1', 0, 'ke y2'], result
|
39
|
+
end
|
40
|
+
|
41
|
+
data('dot' => '$.[0].key1.[1].key2',
|
42
|
+
'bracket' => "$[0]['key1'][1]['key2']",
|
43
|
+
'bracket w/ double quotes' => '$[0]["key1"][1]["key2"]')
|
44
|
+
test "nested keys [0, 'key1', 1, 'key2']" do |param|
|
45
|
+
result = Fluent::PluginHelper::RecordAccessor::Accessor.parse_parameter(param)
|
46
|
+
assert_equal [0, 'key1', 1, 'key2'], result
|
47
|
+
end
|
48
|
+
|
49
|
+
data("missing ']'" => "$['key1'",
|
50
|
+
"missing array index with dot" => "$.hello[]",
|
51
|
+
"missing array index with braket" => "$[]",
|
52
|
+
"more chars" => "$.key1[0]foo",
|
53
|
+
"whitespace char included key in dot notation" => "$.key[0].ke y",
|
54
|
+
"empty keys with dot" => "$.",
|
55
|
+
"empty keys with bracket" => "$[",
|
56
|
+
"mismatched quotes1" => "$['key1']['key2\"]",
|
57
|
+
"mismatched quotes2" => '$["key1"]["key2\']')
|
58
|
+
test 'invalid syntax' do |param|
|
59
|
+
assert_raise Fluent::ConfigError do
|
60
|
+
Fluent::PluginHelper::RecordAccessor::Accessor.parse_parameter(param)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
sub_test_case 'attr_reader :keys' do
|
66
|
+
setup do
|
67
|
+
@d = Dummy.new
|
68
|
+
end
|
69
|
+
|
70
|
+
data('normal' => 'key1',
|
71
|
+
'space' => 'ke y2',
|
72
|
+
'dot key' => 'this.is.key3')
|
73
|
+
test 'access single key' do |param|
|
74
|
+
accessor = @d.record_accessor_create(param)
|
75
|
+
assert_equal param, accessor.keys
|
76
|
+
end
|
77
|
+
|
78
|
+
test "nested bracket keys with dot" do
|
79
|
+
accessor = @d.record_accessor_create("$['key1']['this.is.key3']")
|
80
|
+
assert_equal ['key1','this.is.key3'], accessor.keys
|
81
|
+
end
|
82
|
+
|
83
|
+
data('dot' => '$.key1.key2[0]',
|
84
|
+
'bracket' => "$['key1']['key2'][0]",
|
85
|
+
'bracket w/ double quotes' => '$["key1"]["key2"][0]')
|
86
|
+
test "nested keys ['key1', 'key2', 0]" do |param|
|
87
|
+
accessor = @d.record_accessor_create(param)
|
88
|
+
assert_equal ['key1', 'key2', 0], accessor.keys
|
89
|
+
end
|
90
|
+
|
91
|
+
data('bracket' => "$['key1'][0]['ke y2']",
|
92
|
+
'bracket w/ double quotes' => '$["key1"][0]["ke y2"]')
|
93
|
+
test "nested keys ['key1', 0, 'ke y2']" do |param|
|
94
|
+
accessor = @d.record_accessor_create(param)
|
95
|
+
assert_equal ['key1', 0, 'ke y2'], accessor.keys
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
sub_test_case Fluent::PluginHelper::RecordAccessor::Accessor do
|
100
|
+
setup do
|
101
|
+
@d = Dummy.new
|
102
|
+
end
|
103
|
+
|
104
|
+
data('normal' => 'key1',
|
105
|
+
'space' => 'ke y2',
|
106
|
+
'dot key' => 'this.is.key3')
|
107
|
+
test 'access single key' do |param|
|
108
|
+
r = {'key1' => 'v1', 'ke y2' => 'v2', 'this.is.key3' => 'v3'}
|
109
|
+
accessor = @d.record_accessor_create(param)
|
110
|
+
assert_equal r[param], accessor.call(r)
|
111
|
+
end
|
112
|
+
|
113
|
+
test "access single dot key using bracket style" do
|
114
|
+
r = {'key1' => 'v1', 'ke y2' => 'v2', 'this.is.key3' => 'v3'}
|
115
|
+
accessor = @d.record_accessor_create('$["this.is.key3"]')
|
116
|
+
assert_equal 'v3', accessor.call(r)
|
117
|
+
end
|
118
|
+
|
119
|
+
test "nested bracket keys with dot" do
|
120
|
+
r = {'key1' => {'this.is.key3' => 'value'}}
|
121
|
+
accessor = @d.record_accessor_create("$['key1']['this.is.key3']")
|
122
|
+
assert_equal 'value', accessor.call(r)
|
123
|
+
end
|
124
|
+
|
125
|
+
data('dot' => '$.key1.key2[0]',
|
126
|
+
'bracket' => "$['key1']['key2'][0]",
|
127
|
+
'bracket w/ double quotes' => '$["key1"]["key2"][0]')
|
128
|
+
test "nested keys ['key1', 'key2', 0]" do |param|
|
129
|
+
r = {'key1' => {'key2' => [1, 2, 3]}}
|
130
|
+
accessor = @d.record_accessor_create(param)
|
131
|
+
assert_equal 1, accessor.call(r)
|
132
|
+
end
|
133
|
+
|
134
|
+
data('bracket' => "$['key1'][0]['ke y2']",
|
135
|
+
'bracket w/ double quotes' => '$["key1"][0]["ke y2"]')
|
136
|
+
test "nested keys ['key1', 0, 'ke y2']" do |param|
|
137
|
+
r = {'key1' => [{'ke y2' => "value"}]}
|
138
|
+
accessor = @d.record_accessor_create(param)
|
139
|
+
assert_equal 'value', accessor.call(r)
|
140
|
+
end
|
141
|
+
|
142
|
+
data("missing ']'" => "$['key1'",
|
143
|
+
"missing array index with dot" => "$.hello[]",
|
144
|
+
"missing array index with braket" => "$['hello'][]",
|
145
|
+
"whitespace char included key in dot notation" => "$.key[0].ke y",
|
146
|
+
"more chars" => "$.key1[0]foo",
|
147
|
+
"empty keys with dot" => "$.",
|
148
|
+
"empty keys with bracket" => "$[",
|
149
|
+
"mismatched quotes1" => "$['key1']['key2\"]",
|
150
|
+
"mismatched quotes2" => '$["key1"]["key2\']')
|
151
|
+
test 'invalid syntax' do |param|
|
152
|
+
assert_raise Fluent::ConfigError do
|
153
|
+
@d.record_accessor_create(param)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
sub_test_case 'Fluent::PluginHelper::RecordAccessor::Accessor#delete' do
|
159
|
+
setup do
|
160
|
+
@d = Dummy.new
|
161
|
+
end
|
162
|
+
|
163
|
+
data('normal' => 'key1',
|
164
|
+
'space' => 'ke y2',
|
165
|
+
'dot key' => 'this.is.key3')
|
166
|
+
test 'delete top key' do |param|
|
167
|
+
r = {'key1' => 'v1', 'ke y2' => 'v2', 'this.is.key3' => 'v3'}
|
168
|
+
accessor = @d.record_accessor_create(param)
|
169
|
+
accessor.delete(r)
|
170
|
+
assert_not_include(r, param)
|
171
|
+
end
|
172
|
+
|
173
|
+
test "delete top key using bracket style" do
|
174
|
+
r = {'key1' => 'v1', 'ke y2' => 'v2', 'this.is.key3' => 'v3'}
|
175
|
+
accessor = @d.record_accessor_create('$["this.is.key3"]')
|
176
|
+
accessor.delete(r)
|
177
|
+
assert_not_include(r, 'this.is.key3')
|
178
|
+
end
|
179
|
+
|
180
|
+
data('bracket' => "$['key1'][0]['ke y2']",
|
181
|
+
'bracket w/ double quotes' => '$["key1"][0]["ke y2"]')
|
182
|
+
test "delete nested keys ['key1', 0, 'ke y2']" do |param|
|
183
|
+
r = {'key1' => [{'ke y2' => "value"}]}
|
184
|
+
accessor = @d.record_accessor_create(param)
|
185
|
+
accessor.delete(r)
|
186
|
+
assert_not_include(r['key1'][0], 'ke y2')
|
187
|
+
end
|
188
|
+
|
189
|
+
test "don't raise an error when unexpected record is coming" do
|
190
|
+
r = {'key1' => [{'key3' => "value"}]}
|
191
|
+
accessor = @d.record_accessor_create("$['key1']['key2']['key3']")
|
192
|
+
assert_nothing_raised do
|
193
|
+
assert_nil accessor.delete(r)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
@@ -419,4 +419,24 @@ class RetryStateHelperTest < Test::Unit::TestCase
|
|
419
419
|
assert_equal (dummy_current_time + 100), s.timeout_at
|
420
420
|
assert_equal (dummy_current_time + timeout * 0.8), s.secondary_transition_at
|
421
421
|
end
|
422
|
+
|
423
|
+
sub_test_case 'exponential backoff' do
|
424
|
+
test 'too big steps(check inf handling)' do
|
425
|
+
s = @d.retry_state_create(:t11, :exponential_backoff, 1, 300, randomize: false, forever: true, backoff_base: 2)
|
426
|
+
dummy_current_time = s.start
|
427
|
+
override_current_time(s, dummy_current_time)
|
428
|
+
|
429
|
+
i = 1
|
430
|
+
while i < 1027
|
431
|
+
if i >= 1025
|
432
|
+
# With this setting, 1025+ number causes inf in `calc_interval`, so 1024 value is used for next_time
|
433
|
+
assert_nothing_raised(FloatDomainError) { s.step }
|
434
|
+
assert_equal (dummy_current_time + (2 ** (1024 - 1))), s.next_time
|
435
|
+
else
|
436
|
+
s.step
|
437
|
+
end
|
438
|
+
i += 1
|
439
|
+
end
|
440
|
+
end
|
441
|
+
end
|
422
442
|
end
|
@@ -776,6 +776,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
776
776
|
def create_server_pair_signed_by_self(cert_path, private_key_path, passphrase)
|
777
777
|
cert, key, _ = CertUtil.cert_option_generate_server_pair_self_signed(create_server_options)
|
778
778
|
write_cert_and_key(cert_path, cert, private_key_path, key, passphrase)
|
779
|
+
return cert
|
779
780
|
end
|
780
781
|
|
781
782
|
def create_ca_pair_signed_by_self(cert_path, private_key_path, passphrase)
|
@@ -786,6 +787,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
786
787
|
def create_server_pair_signed_by_ca(ca_cert_path, ca_key_path, ca_key_passphrase, cert_path, private_key_path, passphrase)
|
787
788
|
cert, key, _ = CertUtil.cert_option_generate_server_pair_by_ca(ca_cert_path, ca_key_path, ca_key_passphrase, create_server_options)
|
788
789
|
write_cert_and_key(cert_path, cert, private_key_path, key, passphrase)
|
790
|
+
return cert
|
789
791
|
end
|
790
792
|
|
791
793
|
def create_server_pair_chained_with_root_ca(ca_cert_path, ca_key_path, ca_key_passphrase, cert_path, private_key_path, passphrase)
|
@@ -842,6 +844,20 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
842
844
|
sock.close rescue nil
|
843
845
|
end
|
844
846
|
|
847
|
+
def assert_certificate(cert, expected_extensions)
|
848
|
+
get_extension = lambda do |oid|
|
849
|
+
cert.extensions.detect { |e| e.oid == oid }
|
850
|
+
end
|
851
|
+
|
852
|
+
assert_true cert.serial > 1
|
853
|
+
assert_equal 2, cert.version
|
854
|
+
|
855
|
+
expected_extensions.each do |ext|
|
856
|
+
expected_oid, expected_value = ext
|
857
|
+
assert_equal expected_value, get_extension.call(expected_oid).value
|
858
|
+
end
|
859
|
+
end
|
860
|
+
|
845
861
|
sub_test_case '#server_create_tls with various certificate options' do
|
846
862
|
setup do
|
847
863
|
@d = Dummy.new # to get plugin not configured/started yet
|
@@ -896,7 +912,12 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
896
912
|
test 'load self-signed cert/key pair (files), verified from clients using cert files' do |private_key_passphrase|
|
897
913
|
cert_path = File.join(@server_cert_dir, "cert.pem")
|
898
914
|
private_key_path = File.join(@certs_dir, "server.key.pem")
|
899
|
-
create_server_pair_signed_by_self(cert_path, private_key_path, private_key_passphrase)
|
915
|
+
cert = create_server_pair_signed_by_self(cert_path, private_key_path, private_key_passphrase)
|
916
|
+
|
917
|
+
assert_certificate(cert,[
|
918
|
+
['basicConstraints', 'CA:FALSE'],
|
919
|
+
['nsCertType', 'SSL Server']
|
920
|
+
])
|
900
921
|
|
901
922
|
tls_options = {
|
902
923
|
protocol: :tls,
|
@@ -963,7 +984,14 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
963
984
|
|
964
985
|
cert_path = File.join(@server_cert_dir, "cert.pem")
|
965
986
|
private_key_path = File.join(@certs_dir, "server.key.pem")
|
966
|
-
create_server_pair_signed_by_ca(ca_cert_path, ca_key_path, ca_key_passphrase, cert_path, private_key_path, private_key_passphrase)
|
987
|
+
cert = create_server_pair_signed_by_ca(ca_cert_path, ca_key_path, ca_key_passphrase, cert_path, private_key_path, private_key_passphrase)
|
988
|
+
|
989
|
+
assert_certificate(cert,[
|
990
|
+
['basicConstraints', 'CA:FALSE'],
|
991
|
+
['nsCertType', 'SSL Server'],
|
992
|
+
['keyUsage', 'Digital Signature, Key Encipherment'],
|
993
|
+
['extendedKeyUsage', 'TLS Web Server Authentication']
|
994
|
+
])
|
967
995
|
|
968
996
|
tls_options = {
|
969
997
|
protocol: :tls,
|
data/test/test_config.rb
CHANGED
@@ -53,7 +53,7 @@ class ConfigTest < Test::Unit::TestCase
|
|
53
53
|
</elem2>
|
54
54
|
]
|
55
55
|
write_config "#{TMP_DIR}/dir/config_test_9.conf", %[
|
56
|
-
k9
|
56
|
+
k9 embedded
|
57
57
|
<elem3 name>
|
58
58
|
nested nested_value
|
59
59
|
include hoge
|
@@ -98,7 +98,7 @@ class ConfigTest < Test::Unit::TestCase
|
|
98
98
|
elem2 = c.elements.find { |e| e.name == 'elem2' }
|
99
99
|
assert_not_nil elem2
|
100
100
|
assert_equal 'name', elem2.arg
|
101
|
-
assert_equal '
|
101
|
+
assert_equal 'embedded', elem2['k9']
|
102
102
|
assert !elem2.has_key?('include')
|
103
103
|
|
104
104
|
elem3 = elem2.elements.find { |e| e.name == 'elem3' }
|
@@ -145,7 +145,7 @@ class ConfigTest < Test::Unit::TestCase
|
|
145
145
|
not_fetched = []; rule_conf.check_not_fetched {|key, e| not_fetched << key }
|
146
146
|
assert_equal %w[pattern replace], not_fetched
|
147
147
|
|
148
|
-
#
|
148
|
+
# repeatedly accessing should not grow memory usage
|
149
149
|
before_size = match_conf.unused.size
|
150
150
|
10.times { match_conf['type'] }
|
151
151
|
assert_equal before_size, match_conf.unused.size
|
data/test/test_configdsl.rb
CHANGED
@@ -65,13 +65,13 @@ match('aa')
|
|
65
65
|
e0 = root.elements[0]
|
66
66
|
assert_equal 'source', e0.name
|
67
67
|
assert_equal '', e0.arg
|
68
|
-
assert_equal 'forward', e0['type']
|
68
|
+
assert_equal 'forward', e0['@type']
|
69
69
|
assert_equal '24224', e0['port']
|
70
70
|
|
71
71
|
e1 = root.elements[1]
|
72
72
|
assert_equal 'match', e1.name
|
73
73
|
assert_equal 'test.**', e1.arg
|
74
|
-
assert_equal 'forward', e1['type']
|
74
|
+
assert_equal 'forward', e1['@type']
|
75
75
|
assert_equal '1s', e1['flush_interval']
|
76
76
|
assert_equal 2, e1.elements.size
|
77
77
|
e1s0 = e1.elements[0]
|
data/test/test_log.rb
CHANGED
@@ -379,6 +379,56 @@ class LogTest < Test::Unit::TestCase
|
|
379
379
|
assert_equal(Fluent::Log::LEVEL_TRACE, log2.level)
|
380
380
|
end
|
381
381
|
|
382
|
+
def test_format_json
|
383
|
+
logdev = @log_device
|
384
|
+
logger = ServerEngine::DaemonLogger.new(logdev)
|
385
|
+
log = Fluent::Log.new(logger)
|
386
|
+
log.format = :json
|
387
|
+
log.level = Fluent::Log::LEVEL_TRACE
|
388
|
+
log.trace "trace log"
|
389
|
+
log.debug "debug log"
|
390
|
+
log.info "info log"
|
391
|
+
log.warn "warn log"
|
392
|
+
log.error "error log"
|
393
|
+
log.fatal "fatal log"
|
394
|
+
expected = [
|
395
|
+
"#{@timestamp_str} [trace]: trace log\n",
|
396
|
+
"#{@timestamp_str} [debug]: debug log\n",
|
397
|
+
"#{@timestamp_str} [info]: info log\n",
|
398
|
+
"#{@timestamp_str} [warn]: warn log\n",
|
399
|
+
"#{@timestamp_str} [error]: error log\n",
|
400
|
+
"#{@timestamp_str} [fatal]: fatal log\n"
|
401
|
+
]
|
402
|
+
assert_equal(expected, log.out.logs.map { |l|
|
403
|
+
r = JSON.parse(l)
|
404
|
+
"#{r['time']} [#{r['level']}]: #{r['message']}\n"
|
405
|
+
})
|
406
|
+
end
|
407
|
+
|
408
|
+
def test_time_format
|
409
|
+
logdev = @log_device
|
410
|
+
logger = ServerEngine::DaemonLogger.new(logdev)
|
411
|
+
log = Fluent::Log.new(logger)
|
412
|
+
log.time_format = "%Y"
|
413
|
+
log.level = Fluent::Log::LEVEL_TRACE
|
414
|
+
log.trace "trace log"
|
415
|
+
log.debug "debug log"
|
416
|
+
log.info "info log"
|
417
|
+
log.warn "warn log"
|
418
|
+
log.error "error log"
|
419
|
+
log.fatal "fatal log"
|
420
|
+
timestamp_str = @timestamp.strftime("%Y")
|
421
|
+
expected = [
|
422
|
+
"#{timestamp_str} [trace]: trace log\n",
|
423
|
+
"#{timestamp_str} [debug]: debug log\n",
|
424
|
+
"#{timestamp_str} [info]: info log\n",
|
425
|
+
"#{timestamp_str} [warn]: warn log\n",
|
426
|
+
"#{timestamp_str} [error]: error log\n",
|
427
|
+
"#{timestamp_str} [fatal]: fatal log\n"
|
428
|
+
]
|
429
|
+
assert_equal(expected, log.out.logs)
|
430
|
+
end
|
431
|
+
|
382
432
|
def test_disable_events
|
383
433
|
dl_opts = {}
|
384
434
|
dl_opts[:log_level] = ServerEngine::DaemonLogger::TRACE
|
@@ -443,7 +493,7 @@ class LogTest < Test::Unit::TestCase
|
|
443
493
|
end
|
444
494
|
end
|
445
495
|
|
446
|
-
def
|
496
|
+
def test_log_rotates_specified_size_with_logdevio
|
447
497
|
with_timezone('utc') do
|
448
498
|
rotate_age = 2
|
449
499
|
rotate_size = 100
|
data/test/test_root_agent.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative 'helper'
|
2
2
|
require 'fluent/event_router'
|
3
3
|
require 'fluent/system_config'
|
4
|
+
require 'timecop'
|
4
5
|
require_relative 'test_plugin_classes'
|
5
6
|
|
6
7
|
class RootAgentTest < ::Test::Unit::TestCase
|
@@ -609,6 +610,38 @@ EOC
|
|
609
610
|
end
|
610
611
|
end
|
611
612
|
|
613
|
+
sub_test_case 'configure emit_error_interval' do
|
614
|
+
setup do
|
615
|
+
system_config = SystemConfig.new
|
616
|
+
system_config.emit_error_log_interval = 30
|
617
|
+
@ra = RootAgent.new(log: $log, system_config: system_config)
|
618
|
+
stub(Engine).root_agent { @ra }
|
619
|
+
@ra.log.out.reset
|
620
|
+
one_minute_ago = Time.now.to_i - 60
|
621
|
+
Timecop.freeze(one_minute_ago)
|
622
|
+
end
|
623
|
+
|
624
|
+
teardown do
|
625
|
+
Timecop.return
|
626
|
+
end
|
627
|
+
|
628
|
+
test 'suppresses errors' do
|
629
|
+
mock(@ra.log).warn_backtrace()
|
630
|
+
e = StandardError.new('standard error')
|
631
|
+
begin
|
632
|
+
@ra.handle_emits_error("tag", nil, e)
|
633
|
+
rescue
|
634
|
+
end
|
635
|
+
|
636
|
+
begin
|
637
|
+
@ra.handle_emits_error("tag", nil, e)
|
638
|
+
rescue
|
639
|
+
end
|
640
|
+
|
641
|
+
assert_equal 1, @ra.log.out.logs.size
|
642
|
+
end
|
643
|
+
end
|
644
|
+
|
612
645
|
sub_test_case 'configured at worker2 with 4 workers environment' do
|
613
646
|
setup do
|
614
647
|
ENV['SERVERENGINE_WORKER_ID'] = '2'
|
data/test/test_supervisor.rb
CHANGED
@@ -77,6 +77,46 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
77
77
|
$log.out.reset
|
78
78
|
end
|
79
79
|
|
80
|
+
def test_read_config_with_multibyte_string
|
81
|
+
tmp_path = "#{TMP_DIR}/dir/test_multibyte_config.conf"
|
82
|
+
conf_str = %[
|
83
|
+
<source>
|
84
|
+
@type forward
|
85
|
+
@id forward_input
|
86
|
+
@label @INPUT
|
87
|
+
</source>
|
88
|
+
<label @INPUT>
|
89
|
+
<filter>
|
90
|
+
@type record_transformer
|
91
|
+
<record>
|
92
|
+
message こんにちは. ${record["name"]} has made a order of ${record["item"]} just now.
|
93
|
+
</record>
|
94
|
+
</filter>
|
95
|
+
<match>
|
96
|
+
@type stdout
|
97
|
+
</match>
|
98
|
+
</label>
|
99
|
+
]
|
100
|
+
FileUtils.mkdir_p(File.dirname(tmp_path))
|
101
|
+
File.open(tmp_path, "w:utf-8") {|file| file.write(conf_str) }
|
102
|
+
|
103
|
+
opts = Fluent::Supervisor.default_options
|
104
|
+
sv = Fluent::Supervisor.new(opts)
|
105
|
+
|
106
|
+
use_v1_config = {}
|
107
|
+
use_v1_config['use_v1_config'] = true
|
108
|
+
|
109
|
+
sv.instance_variable_set(:@config_path, tmp_path)
|
110
|
+
sv.instance_variable_set(:@use_v1_config, use_v1_config)
|
111
|
+
sv.send(:read_config)
|
112
|
+
|
113
|
+
conf = sv.instance_variable_get(:@conf)
|
114
|
+
label = conf.elements.detect {|e| e.name == "label" }
|
115
|
+
filter = label.elements.detect {|e| e.name == "filter" }
|
116
|
+
record_transformer = filter.elements.detect {|e| e.name = "record_transformer" }
|
117
|
+
assert_equal(Encoding::UTF_8, record_transformer["message"].encoding)
|
118
|
+
end
|
119
|
+
|
80
120
|
def test_system_config
|
81
121
|
opts = Fluent::Supervisor.default_options
|
82
122
|
sv = Fluent::Supervisor.new(opts)
|
@@ -90,6 +130,21 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
90
130
|
process_name "process_name"
|
91
131
|
log_level info
|
92
132
|
root_dir #{TMP_ROOT_DIR}
|
133
|
+
<log>
|
134
|
+
format json
|
135
|
+
time_format %Y
|
136
|
+
</log>
|
137
|
+
<counter_server>
|
138
|
+
bind 127.0.0.1
|
139
|
+
port 24321
|
140
|
+
scope server1
|
141
|
+
backup_path /tmp/backup
|
142
|
+
</counter_server>
|
143
|
+
<counter_client>
|
144
|
+
host 127.0.0.1
|
145
|
+
port 24321
|
146
|
+
timeout 2
|
147
|
+
</counter_client>
|
93
148
|
</system>
|
94
149
|
EOC
|
95
150
|
conf = Fluent::Config.parse(conf_data, "(test)", "(test_dir)", true)
|
@@ -105,6 +160,17 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
105
160
|
assert_equal "process_name", sys_conf.process_name
|
106
161
|
assert_equal 2, sys_conf.log_level
|
107
162
|
assert_equal TMP_ROOT_DIR, sys_conf.root_dir
|
163
|
+
assert_equal :json, sys_conf.log.format
|
164
|
+
assert_equal '%Y', sys_conf.log.time_format
|
165
|
+
counter_server = sys_conf.counter_server
|
166
|
+
assert_equal '127.0.0.1', counter_server.bind
|
167
|
+
assert_equal 24321, counter_server.port
|
168
|
+
assert_equal 'server1', counter_server.scope
|
169
|
+
assert_equal '/tmp/backup', counter_server.backup_path
|
170
|
+
counter_client = sys_conf.counter_client
|
171
|
+
assert_equal '127.0.0.1', counter_client.host
|
172
|
+
assert_equal 24321, counter_client.port
|
173
|
+
assert_equal 2, counter_client.timeout
|
108
174
|
end
|
109
175
|
|
110
176
|
def test_main_process_signal_handlers
|
@@ -319,6 +385,45 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
319
385
|
assert_equal Fluent::Log::LEVEL_INFO, se_config[:log_level]
|
320
386
|
end
|
321
387
|
|
388
|
+
def test_load_config_with_multibyte_string
|
389
|
+
tmp_path = "#{TMP_DIR}/dir/test_multibyte_config.conf"
|
390
|
+
conf_str = %[
|
391
|
+
<source>
|
392
|
+
@type forward
|
393
|
+
@id forward_input
|
394
|
+
@label @INPUT
|
395
|
+
</source>
|
396
|
+
<label @INPUT>
|
397
|
+
<filter>
|
398
|
+
@type record_transformer
|
399
|
+
<record>
|
400
|
+
message こんにちは. ${record["name"]} has made a order of ${record["item"]} just now.
|
401
|
+
</record>
|
402
|
+
</filter>
|
403
|
+
<match>
|
404
|
+
@type stdout
|
405
|
+
</match>
|
406
|
+
</label>
|
407
|
+
]
|
408
|
+
FileUtils.mkdir_p(File.dirname(tmp_path))
|
409
|
+
File.open(tmp_path, "w:utf-8") {|file| file.write(conf_str) }
|
410
|
+
|
411
|
+
params = {}
|
412
|
+
params['workers'] = 1
|
413
|
+
params['use_v1_config'] = true
|
414
|
+
params['log_path'] = 'test/tmp/supervisor/log'
|
415
|
+
params['suppress_repeated_stacktrace'] = true
|
416
|
+
params['log_level'] = Fluent::Log::LEVEL_INFO
|
417
|
+
load_config_proc = Proc.new { Fluent::Supervisor.load_config(tmp_path, params) }
|
418
|
+
|
419
|
+
se_config = load_config_proc.call
|
420
|
+
conf = se_config[:fluentd_conf]
|
421
|
+
label = conf.elements.detect {|e| e.name == "label" }
|
422
|
+
filter = label.elements.detect {|e| e.name == "filter" }
|
423
|
+
record_transformer = filter.elements.detect {|e| e.name = "record_transformer" }
|
424
|
+
assert_equal(Encoding::UTF_8, record_transformer["message"].encoding)
|
425
|
+
end
|
426
|
+
|
322
427
|
def test_logger
|
323
428
|
opts = Fluent::Supervisor.default_options
|
324
429
|
sv = Fluent::Supervisor.new(opts)
|