fluentd 1.13.0-x64-mingw32 → 1.14.0-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/.github/ISSUE_TEMPLATE/bug_report.yaml +69 -0
- data/.github/ISSUE_TEMPLATE/feature_request.yaml +38 -0
- data/.github/workflows/linux-test.yaml +1 -1
- data/.github/workflows/windows-test.yaml +4 -4
- data/.gitlab-ci.yml +0 -22
- data/CHANGELOG.md +131 -0
- data/README.md +2 -2
- data/example/v0_12_filter.conf +2 -2
- data/fluentd.gemspec +1 -1
- data/lib/fluent/command/fluentd.rb +8 -0
- data/lib/fluent/command/plugin_generator.rb +15 -5
- data/lib/fluent/compat/output.rb +9 -6
- data/lib/fluent/config/section.rb +5 -0
- data/lib/fluent/config/types.rb +15 -0
- data/lib/fluent/config/v1_parser.rb +3 -2
- data/lib/fluent/config.rb +1 -1
- data/lib/fluent/env.rb +2 -1
- data/lib/fluent/event_router.rb +28 -1
- data/lib/fluent/oj_options.rb +62 -0
- data/lib/fluent/plugin/bare_output.rb +49 -8
- data/lib/fluent/plugin/buffer.rb +84 -22
- data/lib/fluent/plugin/file_wrapper.rb +22 -0
- data/lib/fluent/plugin/filter.rb +35 -1
- data/lib/fluent/plugin/formatter.rb +1 -0
- data/lib/fluent/plugin/formatter_json.rb +9 -7
- data/lib/fluent/plugin/in_http.rb +21 -2
- data/lib/fluent/plugin/in_monitor_agent.rb +4 -2
- data/lib/fluent/plugin/in_syslog.rb +13 -1
- data/lib/fluent/plugin/in_tail/position_file.rb +20 -18
- data/lib/fluent/plugin/in_tail.rb +45 -4
- data/lib/fluent/plugin/input.rb +39 -1
- data/lib/fluent/plugin/metrics.rb +119 -0
- data/lib/fluent/plugin/metrics_local.rb +96 -0
- data/lib/fluent/plugin/multi_output.rb +43 -6
- data/lib/fluent/plugin/out_forward.rb +1 -3
- data/lib/fluent/plugin/output.rb +74 -33
- data/lib/fluent/plugin/parser_json.rb +2 -3
- data/lib/fluent/plugin/service_discovery.rb +0 -15
- data/lib/fluent/plugin.rb +10 -1
- data/lib/fluent/plugin_helper/event_emitter.rb +8 -1
- data/lib/fluent/plugin_helper/http_server/router.rb +1 -1
- data/lib/fluent/plugin_helper/metrics.rb +129 -0
- data/lib/fluent/plugin_helper/server.rb +4 -2
- data/lib/fluent/plugin_helper.rb +1 -0
- data/lib/fluent/root_agent.rb +6 -0
- data/lib/fluent/supervisor.rb +2 -0
- data/lib/fluent/system_config.rb +9 -1
- data/lib/fluent/test/driver/storage.rb +30 -0
- data/lib/fluent/version.rb +1 -1
- data/templates/new_gem/lib/fluent/plugin/storage.rb.erb +40 -0
- data/templates/new_gem/test/plugin/test_storage.rb.erb +18 -0
- data/test/command/test_cat.rb +11 -8
- data/test/command/test_plugin_generator.rb +2 -1
- data/test/config/test_section.rb +9 -0
- data/test/config/test_system_config.rb +6 -0
- data/test/config/test_types.rb +7 -0
- data/test/plugin/in_tail/test_position_file.rb +48 -8
- data/test/plugin/test_bare_output.rb +13 -0
- data/test/plugin/test_buffer.rb +8 -2
- data/test/plugin/test_file_wrapper.rb +11 -0
- data/test/plugin/test_filter.rb +11 -0
- data/test/plugin/test_in_forward.rb +59 -83
- data/test/plugin/test_in_http.rb +86 -43
- data/test/plugin/test_in_monitor_agent.rb +214 -8
- data/test/plugin/test_in_syslog.rb +101 -56
- data/test/plugin/test_in_tail.rb +149 -48
- data/test/plugin/test_in_tcp.rb +45 -32
- data/test/plugin/test_in_udp.rb +47 -33
- data/test/plugin/test_input.rb +11 -0
- data/test/plugin/test_metrics.rb +294 -0
- data/test/plugin/test_metrics_local.rb +96 -0
- data/test/plugin/test_multi_output.rb +25 -1
- data/test/plugin/test_out_forward.rb +103 -89
- data/test/plugin/test_out_stream.rb +18 -8
- data/test/plugin/test_output.rb +16 -0
- data/test/plugin_helper/http_server/test_route.rb +1 -1
- data/test/plugin_helper/test_child_process.rb +1 -1
- data/test/plugin_helper/test_event_emitter.rb +29 -0
- data/test/plugin_helper/test_http_server_helper.rb +33 -26
- data/test/plugin_helper/test_metrics.rb +137 -0
- data/test/plugin_helper/test_server.rb +137 -138
- data/test/plugin_helper/test_socket.rb +16 -9
- data/test/test_event_time.rb +2 -2
- data/test/test_oj_options.rb +55 -0
- data/test/test_plugin_classes.rb +102 -0
- data/test/test_root_agent.rb +30 -1
- metadata +22 -7
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -40
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -23
@@ -0,0 +1,96 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/plugin/metrics_local'
|
3
|
+
require 'fluent/system_config'
|
4
|
+
|
5
|
+
class LocalMetricsTest < ::Test::Unit::TestCase
|
6
|
+
sub_test_case 'configure' do
|
7
|
+
test "configured for counter mode" do
|
8
|
+
m = Fluent::Plugin::LocalMetrics.new
|
9
|
+
m.configure(config_element('metrics', '', {"labels" => {test: "test-unit", language: "Ruby"}}))
|
10
|
+
|
11
|
+
assert_false m.use_gauge_metric
|
12
|
+
assert_equal({agent: "Fluentd", hostname: "#{Socket.gethostname}"}, m.default_labels)
|
13
|
+
assert_equal({test: "test-unit", language: "Ruby"}, m.labels)
|
14
|
+
assert_true m.has_methods_for_counter
|
15
|
+
assert_false m.has_methods_for_gauge
|
16
|
+
end
|
17
|
+
|
18
|
+
test "configured for gauge mode" do
|
19
|
+
m = Fluent::Plugin::LocalMetrics.new
|
20
|
+
m.use_gauge_metric = true
|
21
|
+
m.configure(config_element('metrics', '', {"labels" => {test: "test-unit", language: "Ruby"}}))
|
22
|
+
|
23
|
+
assert_true m.use_gauge_metric
|
24
|
+
assert_equal({agent: "Fluentd", hostname: "#{Socket.gethostname}"}, m.default_labels)
|
25
|
+
assert_equal({test: "test-unit", language: "Ruby"}, m.labels)
|
26
|
+
assert_false m.has_methods_for_counter
|
27
|
+
assert_true m.has_methods_for_gauge
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
sub_test_case 'LocalMetric' do
|
32
|
+
sub_test_case "counter" do
|
33
|
+
setup do
|
34
|
+
@m = Fluent::Plugin::LocalMetrics.new
|
35
|
+
@m.configure(config_element('metrics', '', {}))
|
36
|
+
end
|
37
|
+
|
38
|
+
test '#configure' do
|
39
|
+
assert_true @m.has_methods_for_counter
|
40
|
+
assert_false @m.has_methods_for_gauge
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'all local counter operations work well' do
|
44
|
+
assert_equal 0, @m.get
|
45
|
+
assert_equal 1, @m.inc
|
46
|
+
|
47
|
+
@m.add(20)
|
48
|
+
assert_equal 21, @m.get
|
49
|
+
assert_raise NotImplementedError do
|
50
|
+
@m.dec
|
51
|
+
end
|
52
|
+
|
53
|
+
@m.set(100)
|
54
|
+
assert_equal 100, @m.get
|
55
|
+
|
56
|
+
@m.set(10)
|
57
|
+
assert_equal 100, @m.get # On counter, value should be overwritten bigger than stored one.
|
58
|
+
assert_raise NotImplementedError do
|
59
|
+
@m.sub(11)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
sub_test_case "gauge" do
|
65
|
+
setup do
|
66
|
+
@m = Fluent::Plugin::LocalMetrics.new
|
67
|
+
@m.use_gauge_metric = true
|
68
|
+
@m.configure(config_element('metrics', '', {}))
|
69
|
+
end
|
70
|
+
|
71
|
+
test '#configure' do
|
72
|
+
assert_false @m.has_methods_for_counter
|
73
|
+
assert_true @m.has_methods_for_gauge
|
74
|
+
end
|
75
|
+
|
76
|
+
test 'all local gauge operations work well' do
|
77
|
+
assert_equal 0, @m.get
|
78
|
+
assert_equal 1, @m.inc
|
79
|
+
|
80
|
+
@m.add(20)
|
81
|
+
assert_equal 21, @m.get
|
82
|
+
@m.dec
|
83
|
+
assert_equal 20, @m.get
|
84
|
+
|
85
|
+
@m.set(100)
|
86
|
+
assert_equal 100, @m.get
|
87
|
+
|
88
|
+
@m.sub(11)
|
89
|
+
assert_equal 89, @m.get
|
90
|
+
|
91
|
+
@m.set(10)
|
92
|
+
assert_equal 10, @m.get # On gauge, value always should be overwritten.
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -146,8 +146,11 @@ class MultiOutputTest < Test::Unit::TestCase
|
|
146
146
|
@i.configure(conf)
|
147
147
|
assert_equal 4, @i.outputs.size
|
148
148
|
|
149
|
+
log_size_for_multi_output_itself = 4
|
150
|
+
log_size_for_metrics_plugin_helper = 4
|
151
|
+
expected_warn_log_size = log_size_for_multi_output_itself + log_size_for_metrics_plugin_helper
|
149
152
|
logs = @i.log.out.logs
|
150
|
-
assert{ logs.select{|log| log.include?('[warn]') && log.include?("'type' is deprecated parameter name. use '@type' instead.") }.size ==
|
153
|
+
assert{ logs.select{|log| log.include?('[warn]') && log.include?("'type' is deprecated parameter name. use '@type' instead.") }.size == expected_warn_log_size }
|
151
154
|
end
|
152
155
|
|
153
156
|
test '#emit_events calls #process always' do
|
@@ -176,5 +179,26 @@ class MultiOutputTest < Test::Unit::TestCase
|
|
176
179
|
|
177
180
|
assert_equal 2, @i.events.size
|
178
181
|
end
|
182
|
+
|
183
|
+
test 'can use metrics plugins and fallback methods' do
|
184
|
+
conf = config_element('ROOT', '', { '@type' => 'dummy_test_multi_output' },
|
185
|
+
[
|
186
|
+
config_element('store', '', { 'type' => 'dummy_test_multi_output_1' }),
|
187
|
+
config_element('store', '', { 'type' => 'dummy_test_multi_output_2' }),
|
188
|
+
config_element('store', '', { 'type' => 'dummy_test_multi_output_3' }),
|
189
|
+
config_element('store', '', { 'type' => 'dummy_test_multi_output_4' }),
|
190
|
+
]
|
191
|
+
)
|
192
|
+
@i.configure(conf)
|
193
|
+
|
194
|
+
%w[num_errors_metrics emit_count_metrics emit_size_metrics emit_records_metrics].each do |metric_name|
|
195
|
+
assert_true @i.instance_variable_get(:"@#{metric_name}").is_a?(Fluent::Plugin::Metrics)
|
196
|
+
end
|
197
|
+
|
198
|
+
assert_equal 0, @i.num_errors
|
199
|
+
assert_equal 0, @i.emit_count
|
200
|
+
assert_equal 0, @i.emit_size
|
201
|
+
assert_equal 0, @i.emit_records
|
202
|
+
end
|
179
203
|
end
|
180
204
|
end
|
@@ -12,32 +12,38 @@ class ForwardOutputTest < Test::Unit::TestCase
|
|
12
12
|
FileUtils.rm_rf(TMP_DIR)
|
13
13
|
FileUtils.mkdir_p(TMP_DIR)
|
14
14
|
@d = nil
|
15
|
+
@target_port = unused_port
|
15
16
|
end
|
16
17
|
|
17
18
|
def teardown
|
18
19
|
@d.instance_shutdown if @d
|
20
|
+
@port = nil
|
19
21
|
end
|
20
22
|
|
21
23
|
TMP_DIR = File.join(__dir__, "../tmp/out_forward#{ENV['TEST_ENV_NUMBER']}")
|
22
24
|
|
23
25
|
TARGET_HOST = '127.0.0.1'
|
24
|
-
TARGET_PORT = unused_port
|
25
|
-
CONFIG = %[
|
26
|
-
send_timeout 51
|
27
|
-
heartbeat_type udp
|
28
|
-
<server>
|
29
|
-
name test
|
30
|
-
host #{TARGET_HOST}
|
31
|
-
port #{TARGET_PORT}
|
32
|
-
</server>
|
33
|
-
]
|
34
26
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
27
|
+
def config
|
28
|
+
%[
|
29
|
+
send_timeout 51
|
30
|
+
heartbeat_type udp
|
31
|
+
<server>
|
32
|
+
name test
|
33
|
+
host #{TARGET_HOST}
|
34
|
+
port #{@target_port}
|
35
|
+
</server>
|
36
|
+
]
|
37
|
+
end
|
38
|
+
|
39
|
+
def target_config
|
40
|
+
%[
|
41
|
+
port #{@target_port}
|
42
|
+
bind #{TARGET_HOST}
|
43
|
+
]
|
44
|
+
end
|
39
45
|
|
40
|
-
def create_driver(conf=
|
46
|
+
def create_driver(conf=config)
|
41
47
|
Fluent::Test::Driver::Output.new(Fluent::Plugin::ForwardOutput) {
|
42
48
|
attr_reader :sent_chunk_ids, :ack_handler, :discovery_manager
|
43
49
|
|
@@ -60,7 +66,7 @@ class ForwardOutputTest < Test::Unit::TestCase
|
|
60
66
|
<server>
|
61
67
|
name test
|
62
68
|
host #{TARGET_HOST}
|
63
|
-
port #{
|
69
|
+
port #{@target_port}
|
64
70
|
</server>
|
65
71
|
])
|
66
72
|
nodes = d.instance.nodes
|
@@ -71,7 +77,7 @@ class ForwardOutputTest < Test::Unit::TestCase
|
|
71
77
|
node = nodes.first
|
72
78
|
assert_equal "test", node.name
|
73
79
|
assert_equal '127.0.0.1', node.host
|
74
|
-
assert_equal
|
80
|
+
assert_equal @target_port, node.port
|
75
81
|
end
|
76
82
|
|
77
83
|
test 'configure_traditional' do
|
@@ -80,7 +86,7 @@ class ForwardOutputTest < Test::Unit::TestCase
|
|
80
86
|
<server>
|
81
87
|
name test
|
82
88
|
host #{TARGET_HOST}
|
83
|
-
port #{
|
89
|
+
port #{@target_port}
|
84
90
|
</server>
|
85
91
|
buffer_chunk_limit 10m
|
86
92
|
EOL
|
@@ -100,7 +106,7 @@ EOL
|
|
100
106
|
ack_response_timeout 20
|
101
107
|
<server>
|
102
108
|
host #{TARGET_HOST}
|
103
|
-
port #{
|
109
|
+
port #{@target_port}
|
104
110
|
</server>
|
105
111
|
])
|
106
112
|
assert_equal 30, d.instance.send_timeout
|
@@ -110,33 +116,33 @@ EOL
|
|
110
116
|
end
|
111
117
|
|
112
118
|
test 'configure_udp_heartbeat' do
|
113
|
-
@d = d = create_driver(
|
119
|
+
@d = d = create_driver(config + "\nheartbeat_type udp")
|
114
120
|
assert_equal :udp, d.instance.heartbeat_type
|
115
121
|
end
|
116
122
|
|
117
123
|
test 'configure_none_heartbeat' do
|
118
|
-
@d = d = create_driver(
|
124
|
+
@d = d = create_driver(config + "\nheartbeat_type none")
|
119
125
|
assert_equal :none, d.instance.heartbeat_type
|
120
126
|
end
|
121
127
|
|
122
128
|
test 'configure_expire_dns_cache' do
|
123
|
-
@d = d = create_driver(
|
129
|
+
@d = d = create_driver(config + "\nexpire_dns_cache 5")
|
124
130
|
assert_equal 5, d.instance.expire_dns_cache
|
125
131
|
end
|
126
132
|
|
127
133
|
test 'configure_dns_round_robin udp' do
|
128
134
|
assert_raise(Fluent::ConfigError) do
|
129
|
-
create_driver(
|
135
|
+
create_driver(config + "\nheartbeat_type udp\ndns_round_robin true")
|
130
136
|
end
|
131
137
|
end
|
132
138
|
|
133
139
|
test 'configure_dns_round_robin transport' do
|
134
|
-
@d = d = create_driver(
|
140
|
+
@d = d = create_driver(config + "\nheartbeat_type transport\ndns_round_robin true")
|
135
141
|
assert_equal true, d.instance.dns_round_robin
|
136
142
|
end
|
137
143
|
|
138
144
|
test 'configure_dns_round_robin none' do
|
139
|
-
@d = d = create_driver(
|
145
|
+
@d = d = create_driver(config + "\nheartbeat_type none\ndns_round_robin true")
|
140
146
|
assert_equal true, d.instance.dns_round_robin
|
141
147
|
end
|
142
148
|
|
@@ -176,7 +182,7 @@ EOL
|
|
176
182
|
#{param} #{dummy_cert_path}
|
177
183
|
<server>
|
178
184
|
host #{TARGET_HOST}
|
179
|
-
port #{
|
185
|
+
port #{@target_port}
|
180
186
|
</server>
|
181
187
|
]
|
182
188
|
|
@@ -195,7 +201,7 @@ EOL
|
|
195
201
|
tls_cert_thumbprint a909502dd82ae41433e6f83886b00d4277a32a7b
|
196
202
|
<server>
|
197
203
|
host #{TARGET_HOST}
|
198
|
-
port #{
|
204
|
+
port #{@target_port}
|
199
205
|
</server>
|
200
206
|
]
|
201
207
|
|
@@ -210,7 +216,7 @@ EOL
|
|
210
216
|
transport tls
|
211
217
|
<server>
|
212
218
|
host #{TARGET_HOST}
|
213
|
-
port #{
|
219
|
+
port #{@target_port}
|
214
220
|
</server>
|
215
221
|
]
|
216
222
|
|
@@ -232,7 +238,7 @@ EOL
|
|
232
238
|
tls_cert_logical_store_name Root
|
233
239
|
<server>
|
234
240
|
host #{TARGET_HOST}
|
235
|
-
port #{
|
241
|
+
port #{@target_port}
|
236
242
|
</server>
|
237
243
|
]
|
238
244
|
|
@@ -250,7 +256,7 @@ EOL
|
|
250
256
|
tls_cert_thumbprint a909502dd82ae41433e6f83886b00d4277a32a7b
|
251
257
|
<server>
|
252
258
|
host #{TARGET_HOST}
|
253
|
-
port #{
|
259
|
+
port #{@target_port}
|
254
260
|
</server>
|
255
261
|
]
|
256
262
|
|
@@ -321,7 +327,7 @@ EOL
|
|
321
327
|
end
|
322
328
|
|
323
329
|
test 'set_compress_is_gzip' do
|
324
|
-
@d = d = create_driver(
|
330
|
+
@d = d = create_driver(config + %[compress gzip])
|
325
331
|
assert_equal :gzip, d.instance.compress
|
326
332
|
assert_equal :gzip, d.instance.buffer.compress
|
327
333
|
|
@@ -333,7 +339,7 @@ EOL
|
|
333
339
|
mock = flexmock($log)
|
334
340
|
mock.should_receive(:log).with("buffer is compressed. If you also want to save the bandwidth of a network, Add `compress` configuration in <match>")
|
335
341
|
|
336
|
-
@d = d = create_driver(
|
342
|
+
@d = d = create_driver(config + %[
|
337
343
|
<buffer>
|
338
344
|
type memory
|
339
345
|
compress gzip
|
@@ -347,7 +353,7 @@ EOL
|
|
347
353
|
end
|
348
354
|
|
349
355
|
test 'phi_failure_detector disabled' do
|
350
|
-
@d = d = create_driver(
|
356
|
+
@d = d = create_driver(config + %[phi_failure_detector false \n phi_threshold 0])
|
351
357
|
node = d.instance.nodes.first
|
352
358
|
stub(node.failure).phi { raise 'Should not be called' }
|
353
359
|
node.tick
|
@@ -355,20 +361,20 @@ EOL
|
|
355
361
|
end
|
356
362
|
|
357
363
|
test 'phi_failure_detector enabled' do
|
358
|
-
@d = d = create_driver(
|
364
|
+
@d = d = create_driver(config + %[phi_failure_detector true \n phi_threshold 0])
|
359
365
|
node = d.instance.nodes.first
|
360
366
|
node.tick
|
361
367
|
assert_false node.available?
|
362
368
|
end
|
363
369
|
|
364
370
|
test 'require_ack_response is disabled in default' do
|
365
|
-
@d = d = create_driver(
|
371
|
+
@d = d = create_driver(config)
|
366
372
|
assert_equal false, d.instance.require_ack_response
|
367
373
|
assert_equal 190, d.instance.ack_response_timeout
|
368
374
|
end
|
369
375
|
|
370
376
|
test 'require_ack_response can be enabled' do
|
371
|
-
@d = d = create_driver(
|
377
|
+
@d = d = create_driver(config + %[
|
372
378
|
require_ack_response true
|
373
379
|
ack_response_timeout 2s
|
374
380
|
])
|
@@ -378,7 +384,7 @@ EOL
|
|
378
384
|
end
|
379
385
|
|
380
386
|
test 'suspend_flush is disable before before_shutdown' do
|
381
|
-
@d = d = create_driver(
|
387
|
+
@d = d = create_driver(config + %[
|
382
388
|
require_ack_response true
|
383
389
|
ack_response_timeout 2s
|
384
390
|
])
|
@@ -387,7 +393,7 @@ EOL
|
|
387
393
|
end
|
388
394
|
|
389
395
|
test 'suspend_flush should be enabled and try_flush returns nil after before_shutdown' do
|
390
|
-
@d = d = create_driver(
|
396
|
+
@d = d = create_driver(config + %[
|
391
397
|
require_ack_response true
|
392
398
|
ack_response_timeout 2s
|
393
399
|
])
|
@@ -398,12 +404,12 @@ EOL
|
|
398
404
|
end
|
399
405
|
|
400
406
|
test 'verify_connection_at_startup is disabled in default' do
|
401
|
-
@d = d = create_driver(
|
407
|
+
@d = d = create_driver(config)
|
402
408
|
assert_false d.instance.verify_connection_at_startup
|
403
409
|
end
|
404
410
|
|
405
411
|
test 'verify_connection_at_startup can be enabled' do
|
406
|
-
@d = d = create_driver(
|
412
|
+
@d = d = create_driver(config + %[
|
407
413
|
verify_connection_at_startup true
|
408
414
|
])
|
409
415
|
assert_true d.instance.verify_connection_at_startup
|
@@ -412,7 +418,7 @@ EOL
|
|
412
418
|
test 'send tags in str (utf-8 strings)' do
|
413
419
|
target_input_driver = create_target_input_driver
|
414
420
|
|
415
|
-
@d = d = create_driver(
|
421
|
+
@d = d = create_driver(config + %[flush_interval 1s])
|
416
422
|
|
417
423
|
time = event_time("2011-01-02 13:14:15 UTC")
|
418
424
|
|
@@ -445,7 +451,7 @@ EOL
|
|
445
451
|
test 'send_with_time_as_integer' do
|
446
452
|
target_input_driver = create_target_input_driver
|
447
453
|
|
448
|
-
@d = d = create_driver(
|
454
|
+
@d = d = create_driver(config + %[flush_interval 1s])
|
449
455
|
|
450
456
|
time = event_time("2011-01-02 13:14:15 UTC")
|
451
457
|
|
@@ -473,7 +479,7 @@ EOL
|
|
473
479
|
test 'send_without_time_as_integer' do
|
474
480
|
target_input_driver = create_target_input_driver
|
475
481
|
|
476
|
-
@d = d = create_driver(
|
482
|
+
@d = d = create_driver(config + %[
|
477
483
|
flush_interval 1s
|
478
484
|
time_as_integer false
|
479
485
|
])
|
@@ -503,7 +509,7 @@ EOL
|
|
503
509
|
test 'send_comprssed_message_pack_stream_if_compress_is_gzip' do
|
504
510
|
target_input_driver = create_target_input_driver
|
505
511
|
|
506
|
-
@d = d = create_driver(
|
512
|
+
@d = d = create_driver(config + %[
|
507
513
|
flush_interval 1s
|
508
514
|
compress gzip
|
509
515
|
])
|
@@ -533,7 +539,7 @@ EOL
|
|
533
539
|
test 'send_to_a_node_supporting_responses' do
|
534
540
|
target_input_driver = create_target_input_driver
|
535
541
|
|
536
|
-
@d = d = create_driver(
|
542
|
+
@d = d = create_driver(config + %[flush_interval 1s])
|
537
543
|
|
538
544
|
time = event_time("2011-01-02 13:14:15 UTC")
|
539
545
|
|
@@ -559,7 +565,7 @@ EOL
|
|
559
565
|
test 'send_to_a_node_not_supporting_responses' do
|
560
566
|
target_input_driver = create_target_input_driver
|
561
567
|
|
562
|
-
@d = d = create_driver(
|
568
|
+
@d = d = create_driver(config + %[flush_interval 1s])
|
563
569
|
|
564
570
|
time = event_time("2011-01-02 13:14:15 UTC")
|
565
571
|
|
@@ -585,7 +591,7 @@ EOL
|
|
585
591
|
test 'a node supporting responses' do
|
586
592
|
target_input_driver = create_target_input_driver
|
587
593
|
|
588
|
-
@d = d = create_driver(
|
594
|
+
@d = d = create_driver(config + %[
|
589
595
|
require_ack_response true
|
590
596
|
ack_response_timeout 1s
|
591
597
|
<buffer tag>
|
@@ -633,9 +639,9 @@ EOL
|
|
633
639
|
test 'a node supporting responses after stop' do
|
634
640
|
target_input_driver = create_target_input_driver
|
635
641
|
|
636
|
-
@d = d = create_driver(
|
642
|
+
@d = d = create_driver(config + %[
|
637
643
|
require_ack_response true
|
638
|
-
ack_response_timeout
|
644
|
+
ack_response_timeout 10s
|
639
645
|
<buffer tag>
|
640
646
|
flush_mode immediate
|
641
647
|
retry_type periodic
|
@@ -687,7 +693,7 @@ EOL
|
|
687
693
|
test 'TLS transport and ack parameter combination' do |ack|
|
688
694
|
omit "TLS and 'ack false' always fails on AppVeyor. Need to debug" if Fluent.windows? && !ack
|
689
695
|
|
690
|
-
input_conf =
|
696
|
+
input_conf = target_config + %[
|
691
697
|
<transport tls>
|
692
698
|
insecure true
|
693
699
|
</transport>
|
@@ -701,7 +707,7 @@ EOL
|
|
701
707
|
tls_insecure_mode true
|
702
708
|
<server>
|
703
709
|
host #{TARGET_HOST}
|
704
|
-
port #{
|
710
|
+
port #{@target_port}
|
705
711
|
</server>
|
706
712
|
<buffer>
|
707
713
|
#flush_mode immediate
|
@@ -730,7 +736,7 @@ EOL
|
|
730
736
|
test 'a destination node not supporting responses by just ignoring' do
|
731
737
|
target_input_driver = create_target_input_driver(response_stub: ->(_option) { nil }, disconnect: false)
|
732
738
|
|
733
|
-
@d = d = create_driver(
|
739
|
+
@d = d = create_driver(config + %[
|
734
740
|
require_ack_response true
|
735
741
|
ack_response_timeout 1s
|
736
742
|
<buffer tag>
|
@@ -775,7 +781,7 @@ EOL
|
|
775
781
|
test 'a destination node not supporting responses by disconnection' do
|
776
782
|
target_input_driver = create_target_input_driver(response_stub: ->(_option) { nil }, disconnect: true)
|
777
783
|
|
778
|
-
@d = d = create_driver(
|
784
|
+
@d = d = create_driver(config + %[
|
779
785
|
require_ack_response true
|
780
786
|
ack_response_timeout 1s
|
781
787
|
<buffer tag>
|
@@ -818,7 +824,7 @@ EOL
|
|
818
824
|
end
|
819
825
|
|
820
826
|
test 'authentication_with_shared_key' do
|
821
|
-
input_conf =
|
827
|
+
input_conf = target_config + %[
|
822
828
|
<security>
|
823
829
|
self_hostname in.localhost
|
824
830
|
shared_key fluentd-sharedkey
|
@@ -838,7 +844,7 @@ EOL
|
|
838
844
|
<server>
|
839
845
|
name test
|
840
846
|
host #{TARGET_HOST}
|
841
|
-
port #{
|
847
|
+
port #{@target_port}
|
842
848
|
shared_key fluentd-sharedkey
|
843
849
|
</server>
|
844
850
|
]
|
@@ -865,7 +871,7 @@ EOL
|
|
865
871
|
end
|
866
872
|
|
867
873
|
test 'keepalive + shared_key' do
|
868
|
-
input_conf =
|
874
|
+
input_conf = target_config + %[
|
869
875
|
<security>
|
870
876
|
self_hostname in.localhost
|
871
877
|
shared_key fluentd-sharedkey
|
@@ -883,7 +889,7 @@ EOL
|
|
883
889
|
<server>
|
884
890
|
name test
|
885
891
|
host #{TARGET_HOST}
|
886
|
-
port #{
|
892
|
+
port #{@target_port}
|
887
893
|
</server>
|
888
894
|
]
|
889
895
|
@d = d = create_driver(output_conf)
|
@@ -913,7 +919,7 @@ EOL
|
|
913
919
|
end
|
914
920
|
|
915
921
|
test 'authentication_with_user_auth' do
|
916
|
-
input_conf =
|
922
|
+
input_conf = target_config + %[
|
917
923
|
<security>
|
918
924
|
self_hostname in.localhost
|
919
925
|
shared_key fluentd-sharedkey
|
@@ -938,7 +944,7 @@ EOL
|
|
938
944
|
<server>
|
939
945
|
name test
|
940
946
|
host #{TARGET_HOST}
|
941
|
-
port #{
|
947
|
+
port #{@target_port}
|
942
948
|
shared_key fluentd-sharedkey
|
943
949
|
username fluentd
|
944
950
|
password fluentd
|
@@ -968,7 +974,7 @@ EOL
|
|
968
974
|
|
969
975
|
# This test is not 100% but test failed with previous Node implementation which has race condition
|
970
976
|
test 'Node with security is thread-safe on multi threads' do
|
971
|
-
input_conf =
|
977
|
+
input_conf = target_config + %[
|
972
978
|
<security>
|
973
979
|
self_hostname in.localhost
|
974
980
|
shared_key fluentd-sharedkey
|
@@ -987,7 +993,7 @@ EOL
|
|
987
993
|
<server>
|
988
994
|
name test
|
989
995
|
host #{TARGET_HOST}
|
990
|
-
port #{
|
996
|
+
port #{@target_port}
|
991
997
|
shared_key fluentd-sharedkey
|
992
998
|
</server>
|
993
999
|
]
|
@@ -1008,10 +1014,12 @@ EOL
|
|
1008
1014
|
end
|
1009
1015
|
|
1010
1016
|
logs = d.logs
|
1011
|
-
assert_false(logs.any? { |log|
|
1017
|
+
assert_false(logs.any? { |log|
|
1018
|
+
log.include?("invalid format for PONG message") || log.include?("shared key mismatch")
|
1019
|
+
}, "Actual log:\n#{logs.join}")
|
1012
1020
|
end
|
1013
1021
|
|
1014
|
-
def create_target_input_driver(response_stub: nil, disconnect: false, conf:
|
1022
|
+
def create_target_input_driver(response_stub: nil, disconnect: false, conf: target_config)
|
1015
1023
|
require 'fluent/plugin/in_forward'
|
1016
1024
|
|
1017
1025
|
# TODO: Support actual TCP heartbeat test
|
@@ -1027,7 +1035,7 @@ EOL
|
|
1027
1035
|
end
|
1028
1036
|
|
1029
1037
|
test 'heartbeat_type_none' do
|
1030
|
-
@d = d = create_driver(
|
1038
|
+
@d = d = create_driver(config + "\nheartbeat_type none")
|
1031
1039
|
node = d.instance.nodes.first
|
1032
1040
|
assert_equal Fluent::Plugin::ForwardOutput::NoneHeartbeatNode, node.class
|
1033
1041
|
|
@@ -1041,7 +1049,7 @@ EOL
|
|
1041
1049
|
end
|
1042
1050
|
|
1043
1051
|
test 'heartbeat_type_udp' do
|
1044
|
-
@d = d = create_driver(
|
1052
|
+
@d = d = create_driver(config + "\nheartbeat_type udp")
|
1045
1053
|
|
1046
1054
|
d.instance_start
|
1047
1055
|
usock = d.instance.instance_variable_get(:@usock)
|
@@ -1052,7 +1060,7 @@ EOL
|
|
1052
1060
|
assert servers.find{|s| s.title == :out_forward_heartbeat_receiver }
|
1053
1061
|
assert timers.include?(:out_forward_heartbeat_request)
|
1054
1062
|
|
1055
|
-
mock(usock).send("\0", 0, Socket.pack_sockaddr_in(
|
1063
|
+
mock(usock).send("\0", 0, Socket.pack_sockaddr_in(@target_port, '127.0.0.1')).once
|
1056
1064
|
d.instance.send(:on_heartbeat_timer)
|
1057
1065
|
end
|
1058
1066
|
|
@@ -1089,7 +1097,7 @@ EOL
|
|
1089
1097
|
}
|
1090
1098
|
|
1091
1099
|
assert_nothing_raised do
|
1092
|
-
output.configure(
|
1100
|
+
output.configure(config + %[
|
1093
1101
|
@id unique_out_forward
|
1094
1102
|
])
|
1095
1103
|
end
|
@@ -1097,7 +1105,7 @@ EOL
|
|
1097
1105
|
|
1098
1106
|
sub_test_case 'verify_connection_at_startup' do
|
1099
1107
|
test 'nodes are not available' do
|
1100
|
-
@d = d = create_driver(
|
1108
|
+
@d = d = create_driver(config + %[
|
1101
1109
|
verify_connection_at_startup true
|
1102
1110
|
])
|
1103
1111
|
e = assert_raise Fluent::UnrecoverableError do
|
@@ -1113,7 +1121,7 @@ EOL
|
|
1113
1121
|
end
|
1114
1122
|
|
1115
1123
|
test 'nodes_shared_key_miss_match' do
|
1116
|
-
input_conf =
|
1124
|
+
input_conf = target_config + %[
|
1117
1125
|
<security>
|
1118
1126
|
self_hostname in.localhost
|
1119
1127
|
shared_key fluentd-sharedkey
|
@@ -1130,7 +1138,7 @@ EOL
|
|
1130
1138
|
|
1131
1139
|
<server>
|
1132
1140
|
host #{TARGET_HOST}
|
1133
|
-
port #{
|
1141
|
+
port #{@target_port}
|
1134
1142
|
</server>
|
1135
1143
|
]
|
1136
1144
|
@d = d = create_driver(output_conf)
|
@@ -1144,7 +1152,7 @@ EOL
|
|
1144
1152
|
end
|
1145
1153
|
|
1146
1154
|
test 'nodes_shared_key_miss_match with TLS' do
|
1147
|
-
input_conf =
|
1155
|
+
input_conf = target_config + %[
|
1148
1156
|
<security>
|
1149
1157
|
self_hostname in.localhost
|
1150
1158
|
shared_key fluentd-sharedkey
|
@@ -1165,7 +1173,7 @@ EOL
|
|
1165
1173
|
|
1166
1174
|
<server>
|
1167
1175
|
host #{TARGET_HOST}
|
1168
|
-
port #{
|
1176
|
+
port #{@target_port}
|
1169
1177
|
</server>
|
1170
1178
|
]
|
1171
1179
|
@d = d = create_driver(output_conf)
|
@@ -1180,7 +1188,7 @@ EOL
|
|
1180
1188
|
end
|
1181
1189
|
|
1182
1190
|
test 'nodes_shared_key_match' do
|
1183
|
-
input_conf =
|
1191
|
+
input_conf = target_config + %[
|
1184
1192
|
<security>
|
1185
1193
|
self_hostname in.localhost
|
1186
1194
|
shared_key fluentd-sharedkey
|
@@ -1196,7 +1204,7 @@ EOL
|
|
1196
1204
|
<server>
|
1197
1205
|
name test
|
1198
1206
|
host #{TARGET_HOST}
|
1199
|
-
port #{
|
1207
|
+
port #{@target_port}
|
1200
1208
|
</server>
|
1201
1209
|
]
|
1202
1210
|
@d = d = create_driver(output_conf)
|
@@ -1220,16 +1228,19 @@ EOL
|
|
1220
1228
|
end
|
1221
1229
|
|
1222
1230
|
test 'Create new connection per send_data' do
|
1223
|
-
|
1224
|
-
|
1225
|
-
target_input_driver = create_target_input_driver(conf: TARGET_CONFIG)
|
1226
|
-
output_conf = CONFIG
|
1231
|
+
target_input_driver = create_target_input_driver(conf: target_config)
|
1232
|
+
output_conf = config
|
1227
1233
|
d = create_driver(output_conf)
|
1228
1234
|
d.instance_start
|
1229
1235
|
|
1230
1236
|
begin
|
1231
1237
|
chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
|
1232
|
-
mock.proxy(d.instance).socket_create_tcp(TARGET_HOST,
|
1238
|
+
mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
|
1239
|
+
linger_timeout: anything,
|
1240
|
+
send_timeout: anything,
|
1241
|
+
recv_timeout: anything,
|
1242
|
+
connect_timeout: anything
|
1243
|
+
) { |sock| mock(sock).close.once; sock }.twice
|
1233
1244
|
|
1234
1245
|
target_input_driver.run(timeout: 15) do
|
1235
1246
|
d.run(shutdown: false) do
|
@@ -1251,7 +1262,7 @@ EOL
|
|
1251
1262
|
name test
|
1252
1263
|
standby
|
1253
1264
|
host #{TARGET_HOST}
|
1254
|
-
port #{
|
1265
|
+
port #{@target_port}
|
1255
1266
|
</server>
|
1256
1267
|
])
|
1257
1268
|
d.instance_start
|
@@ -1260,10 +1271,8 @@ EOL
|
|
1260
1271
|
|
1261
1272
|
sub_test_case 'keepalive' do
|
1262
1273
|
test 'Do not create connection per send_data' do
|
1263
|
-
|
1264
|
-
|
1265
|
-
target_input_driver = create_target_input_driver(conf: TARGET_CONFIG)
|
1266
|
-
output_conf = CONFIG + %[
|
1274
|
+
target_input_driver = create_target_input_driver(conf: target_config)
|
1275
|
+
output_conf = config + %[
|
1267
1276
|
keepalive true
|
1268
1277
|
keepalive_timeout 2
|
1269
1278
|
]
|
@@ -1272,7 +1281,12 @@ EOL
|
|
1272
1281
|
|
1273
1282
|
begin
|
1274
1283
|
chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
|
1275
|
-
mock.proxy(d.instance).socket_create_tcp(TARGET_HOST,
|
1284
|
+
mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
|
1285
|
+
linger_timeout: anything,
|
1286
|
+
send_timeout: anything,
|
1287
|
+
recv_timeout: anything,
|
1288
|
+
connect_timeout: anything
|
1289
|
+
) { |sock| mock(sock).close.once; sock }.once
|
1276
1290
|
|
1277
1291
|
target_input_driver.run(timeout: 15) do
|
1278
1292
|
d.run(shutdown: false) do
|
@@ -1288,7 +1302,7 @@ EOL
|
|
1288
1302
|
end
|
1289
1303
|
|
1290
1304
|
test 'create timer of purging obsolete sockets' do
|
1291
|
-
output_conf =
|
1305
|
+
output_conf = config + %[keepalive true]
|
1292
1306
|
d = create_driver(output_conf)
|
1293
1307
|
|
1294
1308
|
mock(d.instance).timer_execute(:out_forward_heartbeat_request, 1).once
|
@@ -1298,8 +1312,8 @@ EOL
|
|
1298
1312
|
|
1299
1313
|
sub_test_case 'with require_ack_response' do
|
1300
1314
|
test 'Create connection per send_data' do
|
1301
|
-
target_input_driver = create_target_input_driver(conf:
|
1302
|
-
output_conf =
|
1315
|
+
target_input_driver = create_target_input_driver(conf: target_config)
|
1316
|
+
output_conf = config + %[
|
1303
1317
|
require_ack_response true
|
1304
1318
|
keepalive true
|
1305
1319
|
keepalive_timeout 2
|
@@ -1309,7 +1323,7 @@ EOL
|
|
1309
1323
|
|
1310
1324
|
begin
|
1311
1325
|
chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
|
1312
|
-
mock.proxy(d.instance).socket_create_tcp(TARGET_HOST,
|
1326
|
+
mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
|
1313
1327
|
linger_timeout: anything,
|
1314
1328
|
send_timeout: anything,
|
1315
1329
|
recv_timeout: anything,
|