fluentd 1.12.4-x86-mingw32 → 1.13.3-x86-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.

Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.yaml +69 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.yaml +38 -0
  4. data/.github/workflows/linux-test.yaml +1 -1
  5. data/.github/workflows/windows-test.yaml +14 -3
  6. data/.gitlab-ci.yml +0 -22
  7. data/CHANGELOG.md +129 -0
  8. data/CONTRIBUTING.md +2 -2
  9. data/MAINTAINERS.md +1 -1
  10. data/README.md +3 -3
  11. data/bin/fluentd +8 -1
  12. data/example/counter.conf +1 -1
  13. data/example/v0_12_filter.conf +2 -2
  14. data/fluentd.gemspec +1 -1
  15. data/lib/fluent/command/cat.rb +19 -3
  16. data/lib/fluent/command/fluentd.rb +1 -2
  17. data/lib/fluent/command/plugin_generator.rb +15 -5
  18. data/lib/fluent/config.rb +1 -1
  19. data/lib/fluent/config/section.rb +5 -0
  20. data/lib/fluent/config/types.rb +15 -0
  21. data/lib/fluent/config/v1_parser.rb +3 -2
  22. data/lib/fluent/env.rb +2 -1
  23. data/lib/fluent/log.rb +1 -0
  24. data/lib/fluent/oj_options.rb +62 -0
  25. data/lib/fluent/plugin/file_wrapper.rb +35 -4
  26. data/lib/fluent/plugin/formatter.rb +1 -0
  27. data/lib/fluent/plugin/formatter_json.rb +9 -7
  28. data/lib/fluent/plugin/in_http.rb +10 -0
  29. data/lib/fluent/plugin/in_tail.rb +159 -41
  30. data/lib/fluent/plugin/in_tail/position_file.rb +20 -18
  31. data/lib/fluent/plugin/out_forward.rb +14 -33
  32. data/lib/fluent/plugin/parser_json.rb +2 -3
  33. data/lib/fluent/plugin/service_discovery.rb +0 -15
  34. data/lib/fluent/plugin_helper/http_server/router.rb +1 -1
  35. data/lib/fluent/plugin_helper/service_discovery.rb +39 -1
  36. data/lib/fluent/plugin_helper/service_discovery/manager.rb +11 -5
  37. data/lib/fluent/supervisor.rb +15 -0
  38. data/lib/fluent/system_config.rb +14 -0
  39. data/lib/fluent/test/driver/storage.rb +30 -0
  40. data/lib/fluent/version.rb +1 -1
  41. data/templates/new_gem/lib/fluent/plugin/storage.rb.erb +40 -0
  42. data/templates/new_gem/test/plugin/test_storage.rb.erb +18 -0
  43. data/test/command/test_cat.rb +99 -0
  44. data/test/command/test_plugin_generator.rb +2 -1
  45. data/test/config/test_section.rb +9 -0
  46. data/test/config/test_system_config.rb +46 -0
  47. data/test/config/test_types.rb +7 -0
  48. data/test/plugin/in_tail/test_io_handler.rb +4 -4
  49. data/test/plugin/in_tail/test_position_file.rb +23 -5
  50. data/test/plugin/test_file_wrapper.rb +22 -1
  51. data/test/plugin/test_in_forward.rb +59 -83
  52. data/test/plugin/test_in_http.rb +58 -40
  53. data/test/plugin/test_in_syslog.rb +66 -56
  54. data/test/plugin/test_in_tail.rb +341 -1
  55. data/test/plugin/test_in_tcp.rb +45 -32
  56. data/test/plugin/test_in_udp.rb +47 -33
  57. data/test/plugin/test_out_forward.rb +114 -95
  58. data/test/plugin/test_out_stream.rb +18 -8
  59. data/test/plugin_helper/http_server/test_route.rb +1 -1
  60. data/test/plugin_helper/test_child_process.rb +1 -1
  61. data/test/plugin_helper/test_http_server_helper.rb +33 -26
  62. data/test/plugin_helper/test_server.rb +137 -138
  63. data/test/plugin_helper/test_service_discovery.rb +74 -14
  64. data/test/plugin_helper/test_socket.rb +16 -9
  65. data/test/test_config.rb +2 -1
  66. data/test/test_event_time.rb +2 -2
  67. data/test/test_oj_options.rb +55 -0
  68. data/test/test_supervisor.rb +35 -0
  69. metadata +15 -7
  70. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -40
  71. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -23
@@ -5,21 +5,33 @@ require 'fluent/plugin/in_udp'
5
5
  class UdpInputTest < Test::Unit::TestCase
6
6
  def setup
7
7
  Fluent::Test.setup
8
+ @port = unused_port
8
9
  end
9
10
 
10
- PORT = unused_port
11
- BASE_CONFIG = %[
12
- port #{PORT}
13
- tag udp
14
- ]
15
- CONFIG = BASE_CONFIG + %!
16
- bind 127.0.0.1
17
- format /^\\[(?<time>[^\\]]*)\\] (?<message>.*)/
18
- !
19
- IPv6_CONFIG = BASE_CONFIG + %!
20
- bind ::1
21
- format /^\\[(?<time>[^\\]]*)\\] (?<message>.*)/
22
- !
11
+ def teardown
12
+ @port = nil
13
+ end
14
+
15
+ def base_config
16
+ %[
17
+ port #{@port}
18
+ tag udp
19
+ ]
20
+ end
21
+
22
+ def ipv4_config
23
+ base_config + %!
24
+ bind 127.0.0.1
25
+ format /^\\[(?<time>[^\\]]*)\\] (?<message>.*)/
26
+ !
27
+ end
28
+
29
+ def ipv6_config
30
+ base_config + %!
31
+ bind ::1
32
+ format /^\\[(?<time>[^\\]]*)\\] (?<message>.*)/
33
+ !
34
+ end
23
35
 
24
36
  def create_driver(conf)
25
37
  Fluent::Test::Driver::Input.new(Fluent::Plugin::UdpInput).configure(conf)
@@ -45,15 +57,16 @@ class UdpInputTest < Test::Unit::TestCase
45
57
  end
46
58
 
47
59
  data(
48
- 'ipv4' => [CONFIG, '127.0.0.1', :ipv4],
49
- 'ipv6' => [IPv6_CONFIG, '::1', :ipv6],
60
+ 'ipv4' => ['127.0.0.1', :ipv4],
61
+ 'ipv6' => ['::1', :ipv6],
50
62
  )
51
63
  test 'configure' do |data|
52
- conf, bind, protocol = data
64
+ bind, protocol = data
65
+ conf = send("#{protocol}_config")
53
66
  omit "IPv6 is not supported on this environment" if protocol == :ipv6 && !ipv6_enabled?
54
67
 
55
68
  d = create_driver(conf)
56
- assert_equal PORT, d.instance.port
69
+ assert_equal @port, d.instance.port
57
70
  assert_equal bind, d.instance.bind
58
71
  assert_equal 4096, d.instance.message_length_limit
59
72
  assert_equal nil, d.instance.receive_buffer_size
@@ -61,16 +74,17 @@ class UdpInputTest < Test::Unit::TestCase
61
74
 
62
75
  test ' configure w/o parse section' do
63
76
  assert_raise(Fluent::ConfigError.new("<parse> section is required.")) {
64
- create_driver(BASE_CONFIG)
77
+ create_driver(base_config)
65
78
  }
66
79
  end
67
80
 
68
81
  data(
69
- 'ipv4' => [CONFIG, '127.0.0.1', :ipv4],
70
- 'ipv6' => [IPv6_CONFIG, '::1', :ipv6],
82
+ 'ipv4' => ['127.0.0.1', :ipv4],
83
+ 'ipv6' => ['::1', :ipv6],
71
84
  )
72
85
  test 'time_format' do |data|
73
- conf, bind, protocol = data
86
+ bind, protocol = data
87
+ conf = send("#{protocol}_config")
74
88
  omit "IPv6 is not supported on this environment" if protocol == :ipv6 && !ipv6_enabled?
75
89
 
76
90
  d = create_driver(conf)
@@ -81,7 +95,7 @@ class UdpInputTest < Test::Unit::TestCase
81
95
  ]
82
96
 
83
97
  d.run(expect_records: 2) do
84
- create_udp_socket(bind, PORT) do |u|
98
+ create_udp_socket(bind, @port) do |u|
85
99
  tests.each do |test|
86
100
  u.send(test['msg'], 0)
87
101
  end
@@ -100,7 +114,7 @@ class UdpInputTest < Test::Unit::TestCase
100
114
  )
101
115
  test 'message_length_limit/body_size_limit compatibility' do |param|
102
116
 
103
- d = create_driver(CONFIG + param)
117
+ d = create_driver(ipv4_config + param)
104
118
  assert_equal 2048, d.instance.message_length_limit
105
119
  end
106
120
 
@@ -141,9 +155,9 @@ class UdpInputTest < Test::Unit::TestCase
141
155
  payloads = data['payloads']
142
156
  expecteds = data['expecteds']
143
157
 
144
- d = create_driver(BASE_CONFIG + "format #{format}")
158
+ d = create_driver(base_config + "format #{format}")
145
159
  d.run(expect_records: 2) do
146
- create_udp_socket('127.0.0.1', PORT) do |u|
160
+ create_udp_socket('127.0.0.1', @port) do |u|
147
161
  payloads.each do |payload|
148
162
  u.send(payload, 0)
149
163
  end
@@ -159,13 +173,13 @@ class UdpInputTest < Test::Unit::TestCase
159
173
  end
160
174
 
161
175
  test 'remove_newline' do
162
- d = create_driver(BASE_CONFIG + %!
176
+ d = create_driver(base_config + %!
163
177
  format none
164
178
  remove_newline false
165
179
  !)
166
180
  payloads = ["test1\n", "test2\n"]
167
181
  d.run(expect_records: 2) do
168
- create_udp_socket('127.0.0.1', PORT) do |u|
182
+ create_udp_socket('127.0.0.1', @port) do |u|
169
183
  payloads.each do |payload|
170
184
  u.send(payload, 0)
171
185
  end
@@ -182,13 +196,13 @@ class UdpInputTest < Test::Unit::TestCase
182
196
  end
183
197
 
184
198
  test 'source_hostname_key' do
185
- d = create_driver(BASE_CONFIG + %!
199
+ d = create_driver(base_config + %!
186
200
  format none
187
201
  source_hostname_key host
188
202
  !)
189
203
  hostname = nil
190
204
  d.run(expect_records: 1) do
191
- create_udp_socket('127.0.0.1', PORT) do |u|
205
+ create_udp_socket('127.0.0.1', @port) do |u|
192
206
  u.send("test", 0)
193
207
  hostname = u.peeraddr[2]
194
208
  end
@@ -201,13 +215,13 @@ class UdpInputTest < Test::Unit::TestCase
201
215
  end
202
216
 
203
217
  test 'source_address_key' do
204
- d = create_driver(BASE_CONFIG + %!
218
+ d = create_driver(base_config + %!
205
219
  format none
206
220
  source_address_key addr
207
221
  !)
208
222
  address = nil
209
223
  d.run(expect_records: 1) do
210
- create_udp_socket('127.0.0.1', PORT) do |u|
224
+ create_udp_socket('127.0.0.1', @port) do |u|
211
225
  u.send("test", 0)
212
226
  address = u.peeraddr[3]
213
227
  end
@@ -223,7 +237,7 @@ class UdpInputTest < Test::Unit::TestCase
223
237
  # doesn't check exact value because it depends on platform and condition
224
238
 
225
239
  # check if default socket and in_udp's one without receive_buffer_size have same size buffer
226
- d0 = create_driver(BASE_CONFIG + %!
240
+ d0 = create_driver(base_config + %!
227
241
  format none
228
242
  !)
229
243
  d0.run do
@@ -237,7 +251,7 @@ class UdpInputTest < Test::Unit::TestCase
237
251
  end
238
252
 
239
253
  # check if default socket and in_udp's one with receive_buffer_size have different size buffer
240
- d1 = create_driver(BASE_CONFIG + %!
254
+ d1 = create_driver(base_config + %!
241
255
  format none
242
256
  receive_buffer_size 1001
243
257
  !)
@@ -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
- TARGET_CONFIG = %[
36
- port #{TARGET_PORT}
37
- bind #{TARGET_HOST}
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
39
38
 
40
- def create_driver(conf=CONFIG)
39
+ def target_config
40
+ %[
41
+ port #{@target_port}
42
+ bind #{TARGET_HOST}
43
+ ]
44
+ end
45
+
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 #{TARGET_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 TARGET_PORT, node.port
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 #{TARGET_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 #{TARGET_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(CONFIG + "\nheartbeat_type udp")
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(CONFIG + "\nheartbeat_type none")
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(CONFIG + "\nexpire_dns_cache 5")
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(CONFIG + "\nheartbeat_type udp\ndns_round_robin true")
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(CONFIG + "\nheartbeat_type transport\ndns_round_robin true")
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(CONFIG + "\nheartbeat_type none\ndns_round_robin true")
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 #{TARGET_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 #{TARGET_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 #{TARGET_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 #{TARGET_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 #{TARGET_PORT}
259
+ port #{@target_port}
254
260
  </server>
255
261
  ]
256
262
 
@@ -277,11 +283,16 @@ EOL
277
283
  </service_discovery>
278
284
  ])
279
285
 
280
- assert_equal 2, d.instance.discovery_manager.services.size
281
- assert_equal '127.0.0.1', d.instance.discovery_manager.services[0].host
282
- assert_equal 1234, d.instance.discovery_manager.services[0].port
283
- assert_equal '127.0.0.1', d.instance.discovery_manager.services[1].host
284
- assert_equal 1235, d.instance.discovery_manager.services[1].port
286
+
287
+ assert_equal(
288
+ [
289
+ { host: '127.0.0.1', port: 1234 },
290
+ { host: '127.0.0.1', port: 1235 },
291
+ ],
292
+ d.instance.discovery_manager.services.collect do |service|
293
+ { host: service.host, port: service.port }
294
+ end
295
+ )
285
296
  end
286
297
 
287
298
  test 'pass username and password as empty string to HandshakeProtocol' do
@@ -316,7 +327,7 @@ EOL
316
327
  end
317
328
 
318
329
  test 'set_compress_is_gzip' do
319
- @d = d = create_driver(CONFIG + %[compress gzip])
330
+ @d = d = create_driver(config + %[compress gzip])
320
331
  assert_equal :gzip, d.instance.compress
321
332
  assert_equal :gzip, d.instance.buffer.compress
322
333
 
@@ -328,7 +339,7 @@ EOL
328
339
  mock = flexmock($log)
329
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>")
330
341
 
331
- @d = d = create_driver(CONFIG + %[
342
+ @d = d = create_driver(config + %[
332
343
  <buffer>
333
344
  type memory
334
345
  compress gzip
@@ -342,7 +353,7 @@ EOL
342
353
  end
343
354
 
344
355
  test 'phi_failure_detector disabled' do
345
- @d = d = create_driver(CONFIG + %[phi_failure_detector false \n phi_threshold 0])
356
+ @d = d = create_driver(config + %[phi_failure_detector false \n phi_threshold 0])
346
357
  node = d.instance.nodes.first
347
358
  stub(node.failure).phi { raise 'Should not be called' }
348
359
  node.tick
@@ -350,20 +361,20 @@ EOL
350
361
  end
351
362
 
352
363
  test 'phi_failure_detector enabled' do
353
- @d = d = create_driver(CONFIG + %[phi_failure_detector true \n phi_threshold 0])
364
+ @d = d = create_driver(config + %[phi_failure_detector true \n phi_threshold 0])
354
365
  node = d.instance.nodes.first
355
366
  node.tick
356
367
  assert_false node.available?
357
368
  end
358
369
 
359
370
  test 'require_ack_response is disabled in default' do
360
- @d = d = create_driver(CONFIG)
371
+ @d = d = create_driver(config)
361
372
  assert_equal false, d.instance.require_ack_response
362
373
  assert_equal 190, d.instance.ack_response_timeout
363
374
  end
364
375
 
365
376
  test 'require_ack_response can be enabled' do
366
- @d = d = create_driver(CONFIG + %[
377
+ @d = d = create_driver(config + %[
367
378
  require_ack_response true
368
379
  ack_response_timeout 2s
369
380
  ])
@@ -373,7 +384,7 @@ EOL
373
384
  end
374
385
 
375
386
  test 'suspend_flush is disable before before_shutdown' do
376
- @d = d = create_driver(CONFIG + %[
387
+ @d = d = create_driver(config + %[
377
388
  require_ack_response true
378
389
  ack_response_timeout 2s
379
390
  ])
@@ -382,7 +393,7 @@ EOL
382
393
  end
383
394
 
384
395
  test 'suspend_flush should be enabled and try_flush returns nil after before_shutdown' do
385
- @d = d = create_driver(CONFIG + %[
396
+ @d = d = create_driver(config + %[
386
397
  require_ack_response true
387
398
  ack_response_timeout 2s
388
399
  ])
@@ -393,12 +404,12 @@ EOL
393
404
  end
394
405
 
395
406
  test 'verify_connection_at_startup is disabled in default' do
396
- @d = d = create_driver(CONFIG)
407
+ @d = d = create_driver(config)
397
408
  assert_false d.instance.verify_connection_at_startup
398
409
  end
399
410
 
400
411
  test 'verify_connection_at_startup can be enabled' do
401
- @d = d = create_driver(CONFIG + %[
412
+ @d = d = create_driver(config + %[
402
413
  verify_connection_at_startup true
403
414
  ])
404
415
  assert_true d.instance.verify_connection_at_startup
@@ -407,7 +418,7 @@ EOL
407
418
  test 'send tags in str (utf-8 strings)' do
408
419
  target_input_driver = create_target_input_driver
409
420
 
410
- @d = d = create_driver(CONFIG + %[flush_interval 1s])
421
+ @d = d = create_driver(config + %[flush_interval 1s])
411
422
 
412
423
  time = event_time("2011-01-02 13:14:15 UTC")
413
424
 
@@ -440,7 +451,7 @@ EOL
440
451
  test 'send_with_time_as_integer' do
441
452
  target_input_driver = create_target_input_driver
442
453
 
443
- @d = d = create_driver(CONFIG + %[flush_interval 1s])
454
+ @d = d = create_driver(config + %[flush_interval 1s])
444
455
 
445
456
  time = event_time("2011-01-02 13:14:15 UTC")
446
457
 
@@ -468,7 +479,7 @@ EOL
468
479
  test 'send_without_time_as_integer' do
469
480
  target_input_driver = create_target_input_driver
470
481
 
471
- @d = d = create_driver(CONFIG + %[
482
+ @d = d = create_driver(config + %[
472
483
  flush_interval 1s
473
484
  time_as_integer false
474
485
  ])
@@ -498,7 +509,7 @@ EOL
498
509
  test 'send_comprssed_message_pack_stream_if_compress_is_gzip' do
499
510
  target_input_driver = create_target_input_driver
500
511
 
501
- @d = d = create_driver(CONFIG + %[
512
+ @d = d = create_driver(config + %[
502
513
  flush_interval 1s
503
514
  compress gzip
504
515
  ])
@@ -528,7 +539,7 @@ EOL
528
539
  test 'send_to_a_node_supporting_responses' do
529
540
  target_input_driver = create_target_input_driver
530
541
 
531
- @d = d = create_driver(CONFIG + %[flush_interval 1s])
542
+ @d = d = create_driver(config + %[flush_interval 1s])
532
543
 
533
544
  time = event_time("2011-01-02 13:14:15 UTC")
534
545
 
@@ -554,7 +565,7 @@ EOL
554
565
  test 'send_to_a_node_not_supporting_responses' do
555
566
  target_input_driver = create_target_input_driver
556
567
 
557
- @d = d = create_driver(CONFIG + %[flush_interval 1s])
568
+ @d = d = create_driver(config + %[flush_interval 1s])
558
569
 
559
570
  time = event_time("2011-01-02 13:14:15 UTC")
560
571
 
@@ -580,7 +591,7 @@ EOL
580
591
  test 'a node supporting responses' do
581
592
  target_input_driver = create_target_input_driver
582
593
 
583
- @d = d = create_driver(CONFIG + %[
594
+ @d = d = create_driver(config + %[
584
595
  require_ack_response true
585
596
  ack_response_timeout 1s
586
597
  <buffer tag>
@@ -628,9 +639,9 @@ EOL
628
639
  test 'a node supporting responses after stop' do
629
640
  target_input_driver = create_target_input_driver
630
641
 
631
- @d = d = create_driver(CONFIG + %[
642
+ @d = d = create_driver(config + %[
632
643
  require_ack_response true
633
- ack_response_timeout 1s
644
+ ack_response_timeout 10s
634
645
  <buffer tag>
635
646
  flush_mode immediate
636
647
  retry_type periodic
@@ -682,7 +693,7 @@ EOL
682
693
  test 'TLS transport and ack parameter combination' do |ack|
683
694
  omit "TLS and 'ack false' always fails on AppVeyor. Need to debug" if Fluent.windows? && !ack
684
695
 
685
- input_conf = TARGET_CONFIG + %[
696
+ input_conf = target_config + %[
686
697
  <transport tls>
687
698
  insecure true
688
699
  </transport>
@@ -696,7 +707,7 @@ EOL
696
707
  tls_insecure_mode true
697
708
  <server>
698
709
  host #{TARGET_HOST}
699
- port #{TARGET_PORT}
710
+ port #{@target_port}
700
711
  </server>
701
712
  <buffer>
702
713
  #flush_mode immediate
@@ -725,7 +736,7 @@ EOL
725
736
  test 'a destination node not supporting responses by just ignoring' do
726
737
  target_input_driver = create_target_input_driver(response_stub: ->(_option) { nil }, disconnect: false)
727
738
 
728
- @d = d = create_driver(CONFIG + %[
739
+ @d = d = create_driver(config + %[
729
740
  require_ack_response true
730
741
  ack_response_timeout 1s
731
742
  <buffer tag>
@@ -770,7 +781,7 @@ EOL
770
781
  test 'a destination node not supporting responses by disconnection' do
771
782
  target_input_driver = create_target_input_driver(response_stub: ->(_option) { nil }, disconnect: true)
772
783
 
773
- @d = d = create_driver(CONFIG + %[
784
+ @d = d = create_driver(config + %[
774
785
  require_ack_response true
775
786
  ack_response_timeout 1s
776
787
  <buffer tag>
@@ -813,7 +824,7 @@ EOL
813
824
  end
814
825
 
815
826
  test 'authentication_with_shared_key' do
816
- input_conf = TARGET_CONFIG + %[
827
+ input_conf = target_config + %[
817
828
  <security>
818
829
  self_hostname in.localhost
819
830
  shared_key fluentd-sharedkey
@@ -833,7 +844,7 @@ EOL
833
844
  <server>
834
845
  name test
835
846
  host #{TARGET_HOST}
836
- port #{TARGET_PORT}
847
+ port #{@target_port}
837
848
  shared_key fluentd-sharedkey
838
849
  </server>
839
850
  ]
@@ -860,7 +871,7 @@ EOL
860
871
  end
861
872
 
862
873
  test 'keepalive + shared_key' do
863
- input_conf = TARGET_CONFIG + %[
874
+ input_conf = target_config + %[
864
875
  <security>
865
876
  self_hostname in.localhost
866
877
  shared_key fluentd-sharedkey
@@ -878,7 +889,7 @@ EOL
878
889
  <server>
879
890
  name test
880
891
  host #{TARGET_HOST}
881
- port #{TARGET_PORT}
892
+ port #{@target_port}
882
893
  </server>
883
894
  ]
884
895
  @d = d = create_driver(output_conf)
@@ -908,7 +919,7 @@ EOL
908
919
  end
909
920
 
910
921
  test 'authentication_with_user_auth' do
911
- input_conf = TARGET_CONFIG + %[
922
+ input_conf = target_config + %[
912
923
  <security>
913
924
  self_hostname in.localhost
914
925
  shared_key fluentd-sharedkey
@@ -933,7 +944,7 @@ EOL
933
944
  <server>
934
945
  name test
935
946
  host #{TARGET_HOST}
936
- port #{TARGET_PORT}
947
+ port #{@target_port}
937
948
  shared_key fluentd-sharedkey
938
949
  username fluentd
939
950
  password fluentd
@@ -963,7 +974,7 @@ EOL
963
974
 
964
975
  # This test is not 100% but test failed with previous Node implementation which has race condition
965
976
  test 'Node with security is thread-safe on multi threads' do
966
- input_conf = TARGET_CONFIG + %[
977
+ input_conf = target_config + %[
967
978
  <security>
968
979
  self_hostname in.localhost
969
980
  shared_key fluentd-sharedkey
@@ -982,7 +993,7 @@ EOL
982
993
  <server>
983
994
  name test
984
995
  host #{TARGET_HOST}
985
- port #{TARGET_PORT}
996
+ port #{@target_port}
986
997
  shared_key fluentd-sharedkey
987
998
  </server>
988
999
  ]
@@ -1003,10 +1014,12 @@ EOL
1003
1014
  end
1004
1015
 
1005
1016
  logs = d.logs
1006
- assert_false(logs.any? { |log| log.include?("invalid format for PONG message") || log.include?("shared key mismatch") }, "'#{logs.last.strip}' happens")
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}")
1007
1020
  end
1008
1021
 
1009
- def create_target_input_driver(response_stub: nil, disconnect: false, conf: TARGET_CONFIG)
1022
+ def create_target_input_driver(response_stub: nil, disconnect: false, conf: target_config)
1010
1023
  require 'fluent/plugin/in_forward'
1011
1024
 
1012
1025
  # TODO: Support actual TCP heartbeat test
@@ -1022,7 +1035,7 @@ EOL
1022
1035
  end
1023
1036
 
1024
1037
  test 'heartbeat_type_none' do
1025
- @d = d = create_driver(CONFIG + "\nheartbeat_type none")
1038
+ @d = d = create_driver(config + "\nheartbeat_type none")
1026
1039
  node = d.instance.nodes.first
1027
1040
  assert_equal Fluent::Plugin::ForwardOutput::NoneHeartbeatNode, node.class
1028
1041
 
@@ -1036,7 +1049,7 @@ EOL
1036
1049
  end
1037
1050
 
1038
1051
  test 'heartbeat_type_udp' do
1039
- @d = d = create_driver(CONFIG + "\nheartbeat_type udp")
1052
+ @d = d = create_driver(config + "\nheartbeat_type udp")
1040
1053
 
1041
1054
  d.instance_start
1042
1055
  usock = d.instance.instance_variable_get(:@usock)
@@ -1047,7 +1060,7 @@ EOL
1047
1060
  assert servers.find{|s| s.title == :out_forward_heartbeat_receiver }
1048
1061
  assert timers.include?(:out_forward_heartbeat_request)
1049
1062
 
1050
- mock(usock).send("\0", 0, Socket.pack_sockaddr_in(TARGET_PORT, '127.0.0.1')).once
1063
+ mock(usock).send("\0", 0, Socket.pack_sockaddr_in(@target_port, '127.0.0.1')).once
1051
1064
  d.instance.send(:on_heartbeat_timer)
1052
1065
  end
1053
1066
 
@@ -1073,7 +1086,7 @@ EOL
1073
1086
  test 'when out_forward has @id' do
1074
1087
  # cancel https://github.com/fluent/fluentd/blob/077508ac817b7637307434d0c978d7cdc3d1c534/lib/fluent/plugin_id.rb#L43-L53
1075
1088
  # it always return true in test
1076
- mock.proxy(Fluent::Plugin).new_sd(:static, parent: anything) { |v|
1089
+ mock.proxy(Fluent::Plugin).new_sd('static', parent: anything) { |v|
1077
1090
  stub(v).plugin_id_for_test? { false }
1078
1091
  }.once
1079
1092
 
@@ -1084,7 +1097,7 @@ EOL
1084
1097
  }
1085
1098
 
1086
1099
  assert_nothing_raised do
1087
- output.configure(CONFIG + %[
1100
+ output.configure(config + %[
1088
1101
  @id unique_out_forward
1089
1102
  ])
1090
1103
  end
@@ -1092,7 +1105,7 @@ EOL
1092
1105
 
1093
1106
  sub_test_case 'verify_connection_at_startup' do
1094
1107
  test 'nodes are not available' do
1095
- @d = d = create_driver(CONFIG + %[
1108
+ @d = d = create_driver(config + %[
1096
1109
  verify_connection_at_startup true
1097
1110
  ])
1098
1111
  e = assert_raise Fluent::UnrecoverableError do
@@ -1108,7 +1121,7 @@ EOL
1108
1121
  end
1109
1122
 
1110
1123
  test 'nodes_shared_key_miss_match' do
1111
- input_conf = TARGET_CONFIG + %[
1124
+ input_conf = target_config + %[
1112
1125
  <security>
1113
1126
  self_hostname in.localhost
1114
1127
  shared_key fluentd-sharedkey
@@ -1125,7 +1138,7 @@ EOL
1125
1138
 
1126
1139
  <server>
1127
1140
  host #{TARGET_HOST}
1128
- port #{TARGET_PORT}
1141
+ port #{@target_port}
1129
1142
  </server>
1130
1143
  ]
1131
1144
  @d = d = create_driver(output_conf)
@@ -1139,7 +1152,7 @@ EOL
1139
1152
  end
1140
1153
 
1141
1154
  test 'nodes_shared_key_miss_match with TLS' do
1142
- input_conf = TARGET_CONFIG + %[
1155
+ input_conf = target_config + %[
1143
1156
  <security>
1144
1157
  self_hostname in.localhost
1145
1158
  shared_key fluentd-sharedkey
@@ -1160,7 +1173,7 @@ EOL
1160
1173
 
1161
1174
  <server>
1162
1175
  host #{TARGET_HOST}
1163
- port #{TARGET_PORT}
1176
+ port #{@target_port}
1164
1177
  </server>
1165
1178
  ]
1166
1179
  @d = d = create_driver(output_conf)
@@ -1175,7 +1188,7 @@ EOL
1175
1188
  end
1176
1189
 
1177
1190
  test 'nodes_shared_key_match' do
1178
- input_conf = TARGET_CONFIG + %[
1191
+ input_conf = target_config + %[
1179
1192
  <security>
1180
1193
  self_hostname in.localhost
1181
1194
  shared_key fluentd-sharedkey
@@ -1191,7 +1204,7 @@ EOL
1191
1204
  <server>
1192
1205
  name test
1193
1206
  host #{TARGET_HOST}
1194
- port #{TARGET_PORT}
1207
+ port #{@target_port}
1195
1208
  </server>
1196
1209
  ]
1197
1210
  @d = d = create_driver(output_conf)
@@ -1215,16 +1228,19 @@ EOL
1215
1228
  end
1216
1229
 
1217
1230
  test 'Create new connection per send_data' do
1218
- omit "Proxy of RR doesn't support kwargs of Ruby 3 yet" if RUBY_VERSION.split('.')[0].to_i >= 3
1219
-
1220
- target_input_driver = create_target_input_driver(conf: TARGET_CONFIG)
1221
- output_conf = CONFIG
1231
+ target_input_driver = create_target_input_driver(conf: target_config)
1232
+ output_conf = config
1222
1233
  d = create_driver(output_conf)
1223
1234
  d.instance_start
1224
1235
 
1225
1236
  begin
1226
1237
  chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
1227
- mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, TARGET_PORT, anything) { |sock| mock(sock).close.once; sock }.twice
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
1228
1244
 
1229
1245
  target_input_driver.run(timeout: 15) do
1230
1246
  d.run(shutdown: false) do
@@ -1246,7 +1262,7 @@ EOL
1246
1262
  name test
1247
1263
  standby
1248
1264
  host #{TARGET_HOST}
1249
- port #{TARGET_PORT}
1265
+ port #{@target_port}
1250
1266
  </server>
1251
1267
  ])
1252
1268
  d.instance_start
@@ -1255,10 +1271,8 @@ EOL
1255
1271
 
1256
1272
  sub_test_case 'keepalive' do
1257
1273
  test 'Do not create connection per send_data' do
1258
- omit "Proxy of RR doesn't support kwargs of Ruby 3 yet" if RUBY_VERSION.split('.')[0].to_i >= 3
1259
-
1260
- target_input_driver = create_target_input_driver(conf: TARGET_CONFIG)
1261
- output_conf = CONFIG + %[
1274
+ target_input_driver = create_target_input_driver(conf: target_config)
1275
+ output_conf = config + %[
1262
1276
  keepalive true
1263
1277
  keepalive_timeout 2
1264
1278
  ]
@@ -1267,7 +1281,12 @@ EOL
1267
1281
 
1268
1282
  begin
1269
1283
  chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
1270
- mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, TARGET_PORT, anything) { |sock| mock(sock).close.once; sock }.once
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
1271
1290
 
1272
1291
  target_input_driver.run(timeout: 15) do
1273
1292
  d.run(shutdown: false) do
@@ -1283,7 +1302,7 @@ EOL
1283
1302
  end
1284
1303
 
1285
1304
  test 'create timer of purging obsolete sockets' do
1286
- output_conf = CONFIG + %[keepalive true]
1305
+ output_conf = config + %[keepalive true]
1287
1306
  d = create_driver(output_conf)
1288
1307
 
1289
1308
  mock(d.instance).timer_execute(:out_forward_heartbeat_request, 1).once
@@ -1293,8 +1312,8 @@ EOL
1293
1312
 
1294
1313
  sub_test_case 'with require_ack_response' do
1295
1314
  test 'Create connection per send_data' do
1296
- target_input_driver = create_target_input_driver(conf: TARGET_CONFIG)
1297
- output_conf = CONFIG + %[
1315
+ target_input_driver = create_target_input_driver(conf: target_config)
1316
+ output_conf = config + %[
1298
1317
  require_ack_response true
1299
1318
  keepalive true
1300
1319
  keepalive_timeout 2
@@ -1304,7 +1323,7 @@ EOL
1304
1323
 
1305
1324
  begin
1306
1325
  chunk = Fluent::Plugin::Buffer::MemoryChunk.new(Fluent::Plugin::Buffer::Metadata.new(nil, nil, nil))
1307
- mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, TARGET_PORT,
1326
+ mock.proxy(d.instance).socket_create_tcp(TARGET_HOST, @target_port,
1308
1327
  linger_timeout: anything,
1309
1328
  send_timeout: anything,
1310
1329
  recv_timeout: anything,