fluentd 1.11.3-x86-mingw32 → 1.12.2-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 (97) hide show
  1. checksums.yaml +4 -4
  2. data/.deepsource.toml +13 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
  4. data/.github/ISSUE_TEMPLATE/config.yml +5 -0
  5. data/.github/workflows/linux-test.yaml +36 -0
  6. data/.github/workflows/macos-test.yaml +30 -0
  7. data/.github/workflows/stale-actions.yml +22 -0
  8. data/.github/workflows/windows-test.yaml +30 -0
  9. data/CHANGELOG.md +138 -0
  10. data/MAINTAINERS.md +5 -2
  11. data/README.md +2 -2
  12. data/bin/fluent-cap-ctl +7 -0
  13. data/bin/fluent-ctl +7 -0
  14. data/fluentd.gemspec +4 -3
  15. data/lib/fluent/capability.rb +87 -0
  16. data/lib/fluent/command/bundler_injection.rb +1 -1
  17. data/lib/fluent/command/ca_generate.rb +6 -3
  18. data/lib/fluent/command/cap_ctl.rb +174 -0
  19. data/lib/fluent/command/cat.rb +0 -1
  20. data/lib/fluent/command/ctl.rb +177 -0
  21. data/lib/fluent/command/fluentd.rb +4 -0
  22. data/lib/fluent/command/plugin_config_formatter.rb +18 -2
  23. data/lib/fluent/compat/parser.rb +2 -2
  24. data/lib/fluent/config/section.rb +2 -2
  25. data/lib/fluent/config/types.rb +2 -2
  26. data/lib/fluent/env.rb +4 -0
  27. data/lib/fluent/event.rb +3 -13
  28. data/lib/fluent/load.rb +0 -1
  29. data/lib/fluent/plugin.rb +5 -0
  30. data/lib/fluent/plugin/buffer.rb +2 -21
  31. data/lib/fluent/plugin/formatter.rb +24 -0
  32. data/lib/fluent/plugin/formatter_csv.rb +1 -1
  33. data/lib/fluent/plugin/formatter_hash.rb +3 -1
  34. data/lib/fluent/plugin/formatter_json.rb +3 -1
  35. data/lib/fluent/plugin/formatter_ltsv.rb +7 -5
  36. data/lib/fluent/plugin/formatter_out_file.rb +6 -4
  37. data/lib/fluent/plugin/formatter_single_value.rb +4 -2
  38. data/lib/fluent/plugin/formatter_tsv.rb +4 -2
  39. data/lib/fluent/plugin/in_http.rb +24 -3
  40. data/lib/fluent/plugin/in_monitor_agent.rb +1 -1
  41. data/lib/fluent/plugin/in_tail.rb +128 -41
  42. data/lib/fluent/plugin/in_tail/position_file.rb +39 -14
  43. data/lib/fluent/plugin/in_tcp.rb +1 -0
  44. data/lib/fluent/plugin/out_copy.rb +18 -5
  45. data/lib/fluent/plugin/out_exec_filter.rb +3 -3
  46. data/lib/fluent/plugin/out_forward.rb +61 -28
  47. data/lib/fluent/plugin/out_http.rb +29 -4
  48. data/lib/fluent/plugin/output.rb +14 -6
  49. data/lib/fluent/plugin/storage_local.rb +3 -3
  50. data/lib/fluent/plugin_helper/http_server/compat/server.rb +1 -1
  51. data/lib/fluent/plugin_helper/inject.rb +4 -1
  52. data/lib/fluent/plugin_helper/retry_state.rb +4 -0
  53. data/lib/fluent/supervisor.rb +153 -48
  54. data/lib/fluent/system_config.rb +2 -1
  55. data/lib/fluent/time.rb +58 -1
  56. data/lib/fluent/version.rb +1 -1
  57. data/lib/fluent/winsvc.rb +22 -4
  58. data/templates/plugin_config_formatter/param.md-table.erb +10 -0
  59. data/test/command/test_binlog_reader.rb +22 -6
  60. data/test/command/test_cap_ctl.rb +100 -0
  61. data/test/command/test_ctl.rb +57 -0
  62. data/test/command/test_fluentd.rb +38 -0
  63. data/test/command/test_plugin_config_formatter.rb +124 -2
  64. data/test/config/test_configurable.rb +1 -1
  65. data/test/plugin/in_tail/test_position_file.rb +46 -26
  66. data/test/plugin/out_forward/test_connection_manager.rb +6 -0
  67. data/test/plugin/test_filter_stdout.rb +6 -1
  68. data/test/plugin/test_formatter_hash.rb +6 -3
  69. data/test/plugin/test_formatter_json.rb +14 -4
  70. data/test/plugin/test_formatter_ltsv.rb +13 -5
  71. data/test/plugin/test_formatter_out_file.rb +35 -14
  72. data/test/plugin/test_formatter_single_value.rb +12 -6
  73. data/test/plugin/test_formatter_tsv.rb +12 -4
  74. data/test/plugin/test_in_exec.rb +1 -1
  75. data/test/plugin/test_in_http.rb +25 -0
  76. data/test/plugin/test_in_tail.rb +470 -32
  77. data/test/plugin/test_out_copy.rb +87 -0
  78. data/test/plugin/test_out_file.rb +23 -18
  79. data/test/plugin/test_out_forward.rb +74 -0
  80. data/test/plugin/test_out_http.rb +20 -1
  81. data/test/plugin/test_output.rb +12 -0
  82. data/test/plugin/test_parser_syslog.rb +2 -2
  83. data/test/plugin/test_sd_file.rb +1 -1
  84. data/test/plugin_helper/test_child_process.rb +5 -2
  85. data/test/plugin_helper/test_compat_parameters.rb +7 -2
  86. data/test/plugin_helper/test_http_server_helper.rb +3 -1
  87. data/test/plugin_helper/test_inject.rb +42 -0
  88. data/test/plugin_helper/test_server.rb +18 -5
  89. data/test/test_capability.rb +74 -0
  90. data/test/test_event.rb +16 -0
  91. data/test/test_formatter.rb +64 -10
  92. data/test/test_output.rb +6 -1
  93. data/test/test_supervisor.rb +150 -1
  94. data/test/test_time_parser.rb +109 -0
  95. metadata +61 -29
  96. data/.travis.yml +0 -57
  97. data/appveyor.yml +0 -28
@@ -2,8 +2,11 @@ require_relative '../helper'
2
2
  require 'fluent/test/driver/multi_output'
3
3
  require 'fluent/plugin/out_copy'
4
4
  require 'fluent/event'
5
+ require 'flexmock/test_unit'
5
6
 
6
7
  class CopyOutputTest < Test::Unit::TestCase
8
+ include FlexMock::TestCase
9
+
7
10
  class << self
8
11
  def startup
9
12
  $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'scripts'))
@@ -54,6 +57,48 @@ class CopyOutputTest < Test::Unit::TestCase
54
57
  assert_equal :no_copy, d.instance.copy_mode
55
58
  end
56
59
 
60
+ ERRORNEOUS_IGNORE_IF_PREV_SUCCESS_CONFIG = %[
61
+ <store ignore_if_prev_success ignore_error>
62
+ @type test
63
+ name c0
64
+ </store>
65
+ <store ignore_if_prev_success ignore_error>
66
+ @type test
67
+ name c1
68
+ </store>
69
+ <store ignore_if_prev_success>
70
+ @type test
71
+ name c2
72
+ </store>
73
+ ]
74
+ def test_configure_with_errorneus_ignore_if_prev_success
75
+ assert_raise(Fluent::ConfigError) do
76
+ create_driver(ERRORNEOUS_IGNORE_IF_PREV_SUCCESS_CONFIG)
77
+ end
78
+ end
79
+
80
+ ALL_IGNORE_ERROR_WITHOUT_IGNORE_IF_PREV_SUCCESS_CONFIG = %[
81
+ @log_level info
82
+ <store ignore_error>
83
+ @type test
84
+ name c0
85
+ </store>
86
+ <store ignore_error>
87
+ @type test
88
+ name c1
89
+ </store>
90
+ <store ignore_error>
91
+ @type test
92
+ name c2
93
+ </store>
94
+ ]
95
+ def test_configure_all_ignore_errors_without_ignore_if_prev_success
96
+ d = create_driver(ALL_IGNORE_ERROR_WITHOUT_IGNORE_IF_PREV_SUCCESS_CONFIG)
97
+ expected = /ignore_errors are specified in all <store>, but ignore_if_prev_success is not specified./
98
+ matches = d.logs.grep(expected)
99
+ assert_equal(1, matches.length, "Logs do not contain '#{expected}' '#{d.logs}'")
100
+ end
101
+
57
102
  def test_configure_with_deep_copy_and_use_shallow_copy_mode
58
103
  d = create_driver(%[
59
104
  deep_copy true
@@ -217,5 +262,47 @@ class CopyOutputTest < Test::Unit::TestCase
217
262
  end
218
263
  end
219
264
  end
265
+
266
+ IGNORE_IF_PREV_SUCCESS_CONFIG = %[
267
+ <store ignore_error>
268
+ @type test
269
+ name c0
270
+ </store>
271
+ <store ignore_if_prev_success ignore_error>
272
+ @type test
273
+ name c1
274
+ </store>
275
+ <store ignore_if_prev_success>
276
+ @type test
277
+ name c2
278
+ </store>
279
+ ]
280
+
281
+ def test_ignore_if_prev_success
282
+ d = create_driver(IGNORE_IF_PREV_SUCCESS_CONFIG)
283
+
284
+ # override to raise an error
285
+ d.instance.outputs[0].define_singleton_method(:process) do |tag, es|
286
+ raise ArgumentError, 'Failed'
287
+ end
288
+
289
+ # check ingore_if_prev_success functionality:
290
+ # 1. output 2 is succeeded.
291
+ # 2. output 3 is not called.
292
+ flexstub(d.instance.outputs[1]) do |output|
293
+ output.should_receive(:process).once
294
+ end
295
+ flexstub(d.instance.outputs[2]) do |output|
296
+ output.should_receive(:process).never
297
+ end
298
+
299
+ time = Time.parse("2011-01-02 13:14:15 UTC").to_i
300
+ assert_nothing_raised do
301
+ d.run(default_tag: 'test') do
302
+ d.feed(time, {"a"=>1})
303
+ end
304
+ end
305
+ end
306
+
220
307
  end
221
308
 
@@ -11,6 +11,11 @@ class FileOutputTest < Test::Unit::TestCase
11
11
  Fluent::Test.setup
12
12
  FileUtils.rm_rf(TMP_DIR)
13
13
  FileUtils.mkdir_p(TMP_DIR)
14
+ @default_newline = if Fluent.windows?
15
+ "\r\n"
16
+ else
17
+ "\n"
18
+ end
14
19
  end
15
20
 
16
21
  TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/../tmp/out_file#{ENV['TEST_ENV_NUMBER']}")
@@ -91,7 +96,7 @@ class FileOutputTest < Test::Unit::TestCase
91
96
  end
92
97
  end
93
98
  assert_equal 1, d.formatted.size
94
- assert_equal %[2011-01-02T21:14:15+08:00\ttest\t{"a":1}\n], d.formatted[0]
99
+ assert_equal %[2011-01-02T21:14:15+08:00\ttest\t{"a":1}#{@default_newline}], d.formatted[0]
95
100
  end
96
101
 
97
102
  test 'no configuration error raised for basic configuration using "*" (v0.12 style)' do
@@ -296,11 +301,11 @@ class FileOutputTest < Test::Unit::TestCase
296
301
 
297
302
  assert_equal 5, d.formatted.size
298
303
 
299
- r1 = %!2016-10-03 23:58:09 +0000,my.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"my.data","time":"2016/10/04 08:58:09 +0900"}\n!
300
- r2 = %!2016-10-03 23:59:33 +0000,my.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"my.data","time":"2016/10/04 08:59:33 +0900"}\n!
301
- r3 = %!2016-10-03 23:59:57 +0000,your.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"your.data","time":"2016/10/04 08:59:57 +0900"}\n!
302
- r4 = %!2016-10-04 00:00:17 +0000,my.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"my.data","time":"2016/10/04 09:00:17 +0900"}\n!
303
- r5 = %!2016-10-04 00:01:59 +0000,your.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"your.data","time":"2016/10/04 09:01:59 +0900"}\n!
304
+ r1 = %!2016-10-03 23:58:09 +0000,my.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"my.data","time":"2016/10/04 08:58:09 +0900"}#{@default_newline}!
305
+ r2 = %!2016-10-03 23:59:33 +0000,my.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"my.data","time":"2016/10/04 08:59:33 +0900"}#{@default_newline}!
306
+ r3 = %!2016-10-03 23:59:57 +0000,your.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"your.data","time":"2016/10/04 08:59:57 +0900"}#{@default_newline}!
307
+ r4 = %!2016-10-04 00:00:17 +0000,my.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"my.data","time":"2016/10/04 09:00:17 +0900"}#{@default_newline}!
308
+ r5 = %!2016-10-04 00:01:59 +0000,your.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"your.data","time":"2016/10/04 09:01:59 +0900"}#{@default_newline}!
304
309
  assert_equal r1, d.formatted[0]
305
310
  assert_equal r2, d.formatted[1]
306
311
  assert_equal r3, d.formatted[2]
@@ -329,8 +334,8 @@ class FileOutputTest < Test::Unit::TestCase
329
334
  d.feed(time, {"a"=>2})
330
335
  end
331
336
  assert_equal 2, d.formatted.size
332
- assert_equal %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n], d.formatted[0]
333
- assert_equal %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n], d.formatted[1]
337
+ assert_equal %[2011-01-02T13:14:15Z\ttest\t{"a":1}#{@default_newline}], d.formatted[0]
338
+ assert_equal %[2011-01-02T13:14:15Z\ttest\t{"a":2}#{@default_newline}], d.formatted[1]
334
339
  end
335
340
 
336
341
  test 'time formatted with specified timezone, using area name' do
@@ -344,7 +349,7 @@ class FileOutputTest < Test::Unit::TestCase
344
349
  d.feed(time, {"a"=>1})
345
350
  end
346
351
  assert_equal 1, d.formatted.size
347
- assert_equal %[2011-01-02T21:14:15+08:00\ttest\t{"a":1}\n], d.formatted[0]
352
+ assert_equal %[2011-01-02T21:14:15+08:00\ttest\t{"a":1}#{@default_newline}], d.formatted[0]
348
353
  end
349
354
 
350
355
  test 'time formatted with specified timezone, using offset' do
@@ -358,7 +363,7 @@ class FileOutputTest < Test::Unit::TestCase
358
363
  d.feed(time, {"a"=>1})
359
364
  end
360
365
  assert_equal 1, d.formatted.size
361
- assert_equal %[2011-01-02T09:44:15-03:30\ttest\t{"a":1}\n], d.formatted[0]
366
+ assert_equal %[2011-01-02T09:44:15-03:30\ttest\t{"a":1}#{@default_newline}], d.formatted[0]
362
367
  end
363
368
 
364
369
  test 'configuration error raised for invalid timezone' do
@@ -402,7 +407,7 @@ class FileOutputTest < Test::Unit::TestCase
402
407
  end
403
408
 
404
409
  assert File.exist?("#{TMP_DIR}/out_file_test.20110102_0.log.gz")
405
- check_gzipped_result("#{TMP_DIR}/out_file_test.20110102_0.log.gz", %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n] + %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n])
410
+ check_gzipped_result("#{TMP_DIR}/out_file_test.20110102_0.log.gz", %[2011-01-02T13:14:15Z\ttest\t{"a":1}#{@default_newline}] + %[2011-01-02T13:14:15Z\ttest\t{"a":2}#{@default_newline}])
406
411
  end
407
412
  end
408
413
 
@@ -469,7 +474,7 @@ class FileOutputTest < Test::Unit::TestCase
469
474
  end
470
475
 
471
476
  path = d.instance.last_written_path
472
- check_gzipped_result(path, %[#{Yajl.dump({"a" => 1, 'time' => time.to_i})}\n] + %[#{Yajl.dump({"a" => 2, 'time' => time.to_i})}\n])
477
+ check_gzipped_result(path, %[#{Yajl.dump({"a" => 1, 'time' => time.to_i})}#{@default_newline}] + %[#{Yajl.dump({"a" => 2, 'time' => time.to_i})}#{@default_newline}])
473
478
  end
474
479
 
475
480
  test 'ltsv' do
@@ -482,7 +487,7 @@ class FileOutputTest < Test::Unit::TestCase
482
487
  end
483
488
 
484
489
  path = d.instance.last_written_path
485
- check_gzipped_result(path, %[a:1\ttime:2011-01-02T13:14:15Z\n] + %[a:2\ttime:2011-01-02T13:14:15Z\n])
490
+ check_gzipped_result(path, %[a:1\ttime:2011-01-02T13:14:15Z#{@default_newline}] + %[a:2\ttime:2011-01-02T13:14:15Z#{@default_newline}])
486
491
  end
487
492
 
488
493
  test 'single_value' do
@@ -495,13 +500,13 @@ class FileOutputTest < Test::Unit::TestCase
495
500
  end
496
501
 
497
502
  path = d.instance.last_written_path
498
- check_gzipped_result(path, %[1\n] + %[2\n])
503
+ check_gzipped_result(path, %[1#{@default_newline}] + %[2#{@default_newline}])
499
504
  end
500
505
  end
501
506
 
502
507
  test 'path with index number' do
503
508
  time = event_time("2011-01-02 13:14:15 UTC")
504
- formatted_lines = %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n] + %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n]
509
+ formatted_lines = %[2011-01-02T13:14:15Z\ttest\t{"a":1}#{@default_newline}] + %[2011-01-02T13:14:15Z\ttest\t{"a":2}#{@default_newline}]
505
510
 
506
511
  write_once = ->(){
507
512
  d = create_driver
@@ -532,7 +537,7 @@ class FileOutputTest < Test::Unit::TestCase
532
537
 
533
538
  test 'append' do
534
539
  time = event_time("2011-01-02 13:14:15 UTC")
535
- formatted_lines = %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n] + %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n]
540
+ formatted_lines = %[2011-01-02T13:14:15Z\ttest\t{"a":1}#{@default_newline}] + %[2011-01-02T13:14:15Z\ttest\t{"a":2}#{@default_newline}]
536
541
 
537
542
  write_once = ->(){
538
543
  d = create_driver %[
@@ -567,7 +572,7 @@ class FileOutputTest < Test::Unit::TestCase
567
572
  test 'append when JST' do
568
573
  with_timezone(Fluent.windows? ? "JST-9" : "Asia/Tokyo") do
569
574
  time = event_time("2011-01-02 03:14:15+09:00")
570
- formatted_lines = %[2011-01-02T03:14:15+09:00\ttest\t{"a":1}\n] + %[2011-01-02T03:14:15+09:00\ttest\t{"a":2}\n]
575
+ formatted_lines = %[2011-01-02T03:14:15+09:00\ttest\t{"a":1}#{@default_newline}] + %[2011-01-02T03:14:15+09:00\ttest\t{"a":2}#{@default_newline}]
571
576
 
572
577
  write_once = ->(){
573
578
  d = create_driver %[
@@ -603,7 +608,7 @@ class FileOutputTest < Test::Unit::TestCase
603
608
  test 'append when UTC-02 but timekey_zone is +0900' do
604
609
  with_timezone("UTC-02") do # +0200
605
610
  time = event_time("2011-01-02 17:14:15+02:00")
606
- formatted_lines = %[2011-01-02T17:14:15+02:00\ttest\t{"a":1}\n] + %[2011-01-02T17:14:15+02:00\ttest\t{"a":2}\n]
611
+ formatted_lines = %[2011-01-02T17:14:15+02:00\ttest\t{"a":1}#{@default_newline}] + %[2011-01-02T17:14:15+02:00\ttest\t{"a":2}#{@default_newline}]
607
612
 
608
613
  write_once = ->(){
609
614
  d = create_driver %[
@@ -367,10 +367,31 @@ EOL
367
367
  require_ack_response true
368
368
  ack_response_timeout 2s
369
369
  ])
370
+ d.instance_start
370
371
  assert d.instance.require_ack_response
371
372
  assert_equal 2, d.instance.ack_response_timeout
372
373
  end
373
374
 
375
+ test 'suspend_flush is disable before before_shutdown' do
376
+ @d = d = create_driver(CONFIG + %[
377
+ require_ack_response true
378
+ ack_response_timeout 2s
379
+ ])
380
+ d.instance_start
381
+ assert_false d.instance.instance_variable_get(:@suspend_flush)
382
+ end
383
+
384
+ test 'suspend_flush should be enabled and try_flush returns nil after before_shutdown' do
385
+ @d = d = create_driver(CONFIG + %[
386
+ require_ack_response true
387
+ ack_response_timeout 2s
388
+ ])
389
+ d.instance_start
390
+ d.instance.before_shutdown
391
+ assert_true d.instance.instance_variable_get(:@suspend_flush)
392
+ assert_nil d.instance.try_flush
393
+ end
394
+
374
395
  test 'verify_connection_at_startup is disabled in default' do
375
396
  @d = d = create_driver(CONFIG)
376
397
  assert_false d.instance.verify_connection_at_startup
@@ -599,6 +620,53 @@ EOL
599
620
  assert_equal d.instance.sent_chunk_ids.first, acked_chunk_ids.first
600
621
  end
601
622
 
623
+ test 'a node supporting responses after stop' do
624
+ target_input_driver = create_target_input_driver
625
+
626
+ @d = d = create_driver(CONFIG + %[
627
+ require_ack_response true
628
+ ack_response_timeout 1s
629
+ <buffer tag>
630
+ flush_mode immediate
631
+ retry_type periodic
632
+ retry_wait 30s
633
+ flush_at_shutdown false # suppress errors in d.instance_shutdown
634
+ </buffer>
635
+ ])
636
+
637
+ time = event_time("2011-01-02 13:14:15 UTC")
638
+
639
+ acked_chunk_ids = []
640
+ mock.proxy(d.instance.ack_handler).read_ack_from_sock(anything) do |info, success|
641
+ if success
642
+ acked_chunk_ids << info.chunk_id
643
+ end
644
+ [chunk_id, success]
645
+ end
646
+
647
+ records = [
648
+ {"a" => 1},
649
+ {"a" => 2}
650
+ ]
651
+ target_input_driver.run(expect_records: 2) do
652
+ d.end_if { acked_chunk_ids.size > 0 }
653
+ d.run(default_tag: 'test', wait_flush_completion: false, shutdown: false) do
654
+ d.instance.stop
655
+ d.feed([[time, records[0]], [time,records[1]]])
656
+ d.instance.before_shutdown
657
+ d.instance.shutdown
658
+ d.instance.after_shutdown
659
+ end
660
+ end
661
+
662
+ events = target_input_driver.events
663
+ assert_equal ['test', time, records[0]], events[0]
664
+ assert_equal ['test', time, records[1]], events[1]
665
+
666
+ assert_equal 1, acked_chunk_ids.size
667
+ assert_equal d.instance.sent_chunk_ids.first, acked_chunk_ids.first
668
+ end
669
+
602
670
  data('ack true' => true,
603
671
  'ack false' => false)
604
672
  test 'TLS transport and ack parameter combination' do |ack|
@@ -993,6 +1061,8 @@ EOL
993
1061
  end
994
1062
 
995
1063
  test 'when out_forward has @id' do
1064
+ omit "Proxy of RR doesn't support kwargs of Ruby 3 yet" if RUBY_VERSION.split('.')[0].to_i >= 3
1065
+
996
1066
  # cancel https://github.com/fluent/fluentd/blob/077508ac817b7637307434d0c978d7cdc3d1c534/lib/fluent/plugin_id.rb#L43-L53
997
1067
  # it always return true in test
998
1068
  mock.proxy(Fluent::Plugin).new_sd(:static, anything) { |v|
@@ -1137,6 +1207,8 @@ EOL
1137
1207
  end
1138
1208
 
1139
1209
  test 'Create new connection per send_data' do
1210
+ omit "Proxy of RR doesn't support kwargs of Ruby 3 yet" if RUBY_VERSION.split('.')[0].to_i >= 3
1211
+
1140
1212
  target_input_driver = create_target_input_driver(conf: TARGET_CONFIG)
1141
1213
  output_conf = CONFIG
1142
1214
  d = create_driver(output_conf)
@@ -1175,6 +1247,8 @@ EOL
1175
1247
 
1176
1248
  sub_test_case 'keepalive' do
1177
1249
  test 'Do not create connection per send_data' do
1250
+ omit "Proxy of RR doesn't support kwargs of Ruby 3 yet" if RUBY_VERSION.split('.')[0].to_i >= 3
1251
+
1178
1252
  target_input_driver = create_target_input_driver(conf: TARGET_CONFIG)
1179
1253
  output_conf = CONFIG + %[
1180
1254
  keepalive true
@@ -127,7 +127,7 @@ class HTTPOutputTest < Test::Unit::TestCase
127
127
  now = Time.now
128
128
  started = false
129
129
  until started
130
- raise "Server not started" if (now - Time.now > 10.0)
130
+ raise "Server not started" if (Time.now - now > 10.0)
131
131
  begin
132
132
  http_client { |c| c.request_get('/') }
133
133
  started = true
@@ -280,6 +280,25 @@ class HTTPOutputTest < Test::Unit::TestCase
280
280
  assert_equal "fluentd!", result.headers['test_header']
281
281
  end
282
282
 
283
+ def test_write_with_headers_from_placeholders
284
+ d = create_driver(config + %[
285
+ headers_from_placeholders {"x-test":"${$.foo.bar}-test","x-tag":"${tag}"}
286
+ <buffer tag,$.foo.bar>
287
+ </buffer>
288
+ ])
289
+ d.run(default_tag: 'test.http') do
290
+ test_events.each { |event|
291
+ ev = event.dup
292
+ ev['foo'] = {'bar' => 'abcd'}
293
+ d.feed(ev)
294
+ }
295
+ end
296
+
297
+ result = @@result
298
+ assert_equal "abcd-test", result.headers['x-test']
299
+ assert_equal "test.http", result.headers['x-tag']
300
+ end
301
+
283
302
  def test_write_with_retryable_response
284
303
  old_report_on_exception = Thread.report_on_exception
285
304
  Thread.report_on_exception = false # thread finished as invalid state since RetryableResponse raises.
@@ -378,6 +378,18 @@ class OutputTest < Test::Unit::TestCase
378
378
  assert { logs.any? { |log| log.include?("${chunk_id} is not allowed in this plugin") } }
379
379
  end
380
380
 
381
+ test '#extract_placeholders does not log for ${chunk_id} placeholder' do
382
+ @i.configure(config_element('ROOT', '', {}, [config_element('buffer', '')]))
383
+ tmpl = "/mypath/${chunk_id}/tail"
384
+ t = event_time('2016-04-11 20:30:00 +0900')
385
+ v = {key1: "value1", key2: "value2"}
386
+ c = create_chunk(timekey: t, tag: 'fluentd.test.output', variables: v)
387
+ @i.log.out.logs.clear
388
+ @i.extract_placeholders(tmpl, c)
389
+ logs = @i.log.out.logs
390
+ assert { logs.none? { |log| log.include?("${chunk_id}") } }
391
+ end
392
+
381
393
  test '#extract_placeholders logs warn message with not replaced key' do
382
394
  @i.configure(config_element('ROOT', '', {}, [config_element('buffer', '')]))
383
395
  tmpl = "/mypath/${key1}/test"
@@ -38,7 +38,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
38
38
  data('regexp' => 'regexp', 'string' => 'string')
39
39
  def test_parse_with_time_format2(param)
40
40
  @parser.configure('time_format' => '%Y-%m-%dT%H:%M:%SZ', 'parser_type' => param)
41
- @parser.instance.parse('2020-03-03T10:14:29Z 192.168.0.1 fluentd[11111]: [error] Syslog test') { |time, record|
41
+ @parser.instance.parse("#{Time.now.year}-03-03T10:14:29Z 192.168.0.1 fluentd[11111]: [error] Syslog test") { |time, record|
42
42
  assert_equal(event_time('Mar 03 10:14:29', format: '%b %d %H:%M:%S'), time)
43
43
  assert_equal(@expected, record)
44
44
  }
@@ -47,7 +47,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
47
47
 
48
48
  def test_parse_with_time_format_rfc5424
49
49
  @parser.configure('time_format' => '%Y-%m-%dT%H:%M:%SZ', 'message_format' => 'rfc5424')
50
- @parser.instance.parse('2020-03-03T10:14:29Z 192.168.0.1 fluentd 11111 - - [error] Syslog test') { |time, record|
50
+ @parser.instance.parse("#{Time.now.year}-03-03T10:14:29Z 192.168.0.1 fluentd 11111 - - [error] Syslog test") { |time, record|
51
51
  assert_equal(event_time('Mar 03 10:14:29', format: '%b %d %H:%M:%S'), time)
52
52
  assert_equal(@expected.merge('host' => '192.168.0.1', 'msgid' => '-', 'extradata' => '-'), record)
53
53
  }
@@ -149,7 +149,7 @@ class FileServiceDiscoveryTest < ::Test::Unit::TestCase
149
149
  assert_empty queue
150
150
  end
151
151
 
152
- test 'Skip if error is occured' do
152
+ test 'Skip if error is occurred' do
153
153
  @sd_file.extend(TestStatEventHelperWrapper)
154
154
 
155
155
  create_tmp_config('config.json', JSON.generate([{ port: 1233, host: '127.0.0.1' }]))
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  require_relative '../helper'
2
3
  require 'fluent/plugin_helper/child_process'
3
4
  require 'fluent/plugin/base'
@@ -269,10 +270,12 @@ class ChildProcessTest < Test::Unit::TestCase
269
270
  Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
270
271
  ran = false
271
272
  @d.child_process_execute(:t4, "ruby -e 'Signal.trap(:TERM, nil); while sleep 0.1; puts 1; STDOUT.flush rescue nil; end'", mode: [:read]) do |io|
272
- m.lock
273
- ran = true
274
273
  begin
275
274
  while line = io.readline
275
+ unless ran
276
+ m.lock
277
+ ran = true
278
+ end
276
279
  ary << line
277
280
  end
278
281
  rescue