fluentd 0.14.11-x64-mingw32 → 0.14.12-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.

Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -5
  3. data/ChangeLog +54 -2
  4. data/example/in_dummy_blocks.conf +17 -0
  5. data/example/in_forward_tls.conf +14 -0
  6. data/example/in_forward_workers.conf +21 -0
  7. data/example/logevents.conf +25 -0
  8. data/example/out_forward_heartbeat_none.conf +16 -0
  9. data/example/out_forward_tls.conf +18 -0
  10. data/example/suppress_config_dump.conf +7 -0
  11. data/lib/fluent/agent.rb +3 -32
  12. data/lib/fluent/clock.rb +62 -0
  13. data/lib/fluent/command/fluentd.rb +12 -0
  14. data/lib/fluent/compat/input.rb +10 -1
  15. data/lib/fluent/compat/output.rb +40 -1
  16. data/lib/fluent/config/configure_proxy.rb +30 -7
  17. data/lib/fluent/config/section.rb +4 -0
  18. data/lib/fluent/config/types.rb +2 -2
  19. data/lib/fluent/configurable.rb +31 -5
  20. data/lib/fluent/engine.rb +61 -12
  21. data/lib/fluent/event_router.rb +6 -0
  22. data/lib/fluent/load.rb +0 -1
  23. data/lib/fluent/log.rb +118 -42
  24. data/lib/fluent/match.rb +37 -0
  25. data/lib/fluent/plugin.rb +25 -3
  26. data/lib/fluent/plugin/base.rb +4 -0
  27. data/lib/fluent/plugin/buf_file.rb +38 -14
  28. data/lib/fluent/plugin/buffer.rb +20 -20
  29. data/lib/fluent/plugin/buffer/file_chunk.rb +2 -2
  30. data/lib/fluent/plugin/compressable.rb +1 -0
  31. data/lib/fluent/plugin/filter_record_transformer.rb +3 -6
  32. data/lib/fluent/plugin/formatter_csv.rb +4 -1
  33. data/lib/fluent/plugin/formatter_hash.rb +5 -1
  34. data/lib/fluent/plugin/formatter_json.rb +10 -0
  35. data/lib/fluent/plugin/formatter_ltsv.rb +2 -1
  36. data/lib/fluent/plugin/in_dummy.rb +4 -0
  37. data/lib/fluent/plugin/in_exec.rb +4 -0
  38. data/lib/fluent/plugin/in_forward.rb +11 -3
  39. data/lib/fluent/plugin/in_gc_stat.rb +4 -0
  40. data/lib/fluent/plugin/in_http.rb +4 -0
  41. data/lib/fluent/plugin/in_monitor_agent.rb +29 -2
  42. data/lib/fluent/plugin/in_object_space.rb +4 -1
  43. data/lib/fluent/plugin/in_syslog.rb +4 -0
  44. data/lib/fluent/plugin/in_tail.rb +193 -116
  45. data/lib/fluent/plugin/in_tcp.rb +5 -1
  46. data/lib/fluent/plugin/in_udp.rb +4 -0
  47. data/lib/fluent/plugin/input.rb +4 -0
  48. data/lib/fluent/plugin/out_copy.rb +4 -0
  49. data/lib/fluent/plugin/out_exec.rb +4 -0
  50. data/lib/fluent/plugin/out_exec_filter.rb +4 -0
  51. data/lib/fluent/plugin/out_file.rb +70 -30
  52. data/lib/fluent/plugin/out_forward.rb +132 -28
  53. data/lib/fluent/plugin/out_null.rb +10 -0
  54. data/lib/fluent/plugin/out_relabel.rb +4 -0
  55. data/lib/fluent/plugin/out_roundrobin.rb +4 -0
  56. data/lib/fluent/plugin/out_secondary_file.rb +5 -0
  57. data/lib/fluent/plugin/out_stdout.rb +5 -0
  58. data/lib/fluent/plugin/output.rb +18 -9
  59. data/lib/fluent/plugin/storage_local.rb +25 -2
  60. data/lib/fluent/plugin_helper/cert_option.rb +159 -0
  61. data/lib/fluent/plugin_helper/child_process.rb +6 -6
  62. data/lib/fluent/plugin_helper/compat_parameters.rb +1 -1
  63. data/lib/fluent/plugin_helper/event_loop.rb +29 -4
  64. data/lib/fluent/plugin_helper/inject.rb +14 -1
  65. data/lib/fluent/plugin_helper/server.rb +275 -31
  66. data/lib/fluent/plugin_helper/socket.rb +144 -4
  67. data/lib/fluent/plugin_helper/socket_option.rb +2 -17
  68. data/lib/fluent/plugin_helper/storage.rb +7 -1
  69. data/lib/fluent/plugin_helper/thread.rb +16 -4
  70. data/lib/fluent/registry.rb +26 -9
  71. data/lib/fluent/root_agent.rb +7 -3
  72. data/lib/fluent/supervisor.rb +37 -15
  73. data/lib/fluent/system_config.rb +37 -10
  74. data/lib/fluent/test.rb +2 -0
  75. data/lib/fluent/test/driver/base.rb +24 -26
  76. data/lib/fluent/test/helpers.rb +21 -0
  77. data/lib/fluent/version.rb +1 -1
  78. data/test/command/test_fluentd.rb +274 -4
  79. data/test/config/test_configurable.rb +154 -0
  80. data/test/config/test_configure_proxy.rb +180 -1
  81. data/test/config/test_system_config.rb +10 -0
  82. data/test/config/test_types.rb +1 -0
  83. data/test/plugin/test_base.rb +4 -0
  84. data/test/plugin/test_buf_file.rb +241 -9
  85. data/test/plugin/test_buffer.rb +11 -11
  86. data/test/plugin/test_buffer_file_chunk.rb +6 -6
  87. data/test/plugin/test_compressable.rb +3 -0
  88. data/test/plugin/test_filter.rb +4 -0
  89. data/test/plugin/test_filter_record_transformer.rb +20 -0
  90. data/test/plugin/test_formatter_csv.rb +9 -0
  91. data/test/plugin/test_formatter_hash.rb +35 -0
  92. data/test/plugin/test_formatter_json.rb +8 -0
  93. data/test/plugin/test_formatter_ltsv.rb +7 -0
  94. data/test/plugin/test_in_dummy.rb +7 -3
  95. data/test/plugin/test_in_monitor_agent.rb +43 -5
  96. data/test/plugin/test_in_tail.rb +97 -4
  97. data/test/plugin/test_input.rb +4 -0
  98. data/test/plugin/test_out_file.rb +46 -7
  99. data/test/plugin/test_out_forward.rb +59 -7
  100. data/test/plugin/test_output.rb +10 -4
  101. data/test/plugin/test_output_as_buffered.rb +37 -25
  102. data/test/plugin/test_output_as_buffered_compress.rb +1 -1
  103. data/test/plugin/test_output_as_buffered_retries.rb +6 -6
  104. data/test/plugin/test_output_as_buffered_secondary.rb +91 -31
  105. data/test/plugin/test_storage_local.rb +40 -1
  106. data/test/plugin_helper/test_child_process.rb +29 -28
  107. data/test/plugin_helper/test_compat_parameters.rb +1 -1
  108. data/test/plugin_helper/test_inject.rb +27 -9
  109. data/test/plugin_helper/test_server.rb +822 -50
  110. data/test/plugin_helper/test_storage.rb +11 -0
  111. data/test/plugin_helper/test_timer.rb +1 -0
  112. data/test/test_clock.rb +164 -0
  113. data/test/test_log.rb +146 -15
  114. data/test/test_plugin.rb +251 -0
  115. data/test/test_supervisor.rb +65 -57
  116. data/test/test_test_drivers.rb +2 -2
  117. metadata +18 -7
  118. data/lib/fluent/process.rb +0 -504
  119. data/test/test_process.rb +0 -48
@@ -72,7 +72,7 @@ class ForwardOutputTest < Test::Unit::TestCase
72
72
  ])
73
73
  nodes = d.instance.nodes
74
74
  assert_equal 60, d.instance.send_timeout
75
- assert_equal :tcp, d.instance.heartbeat_type
75
+ assert_equal :transport, d.instance.heartbeat_type
76
76
  assert_equal 1, nodes.length
77
77
  node = nodes.first
78
78
  assert_equal "test", node.name
@@ -119,8 +119,8 @@ EOL
119
119
  end
120
120
  end
121
121
 
122
- test 'configure_dns_round_robin tcp' do
123
- @d = d = create_driver(CONFIG + "\nheartbeat_type tcp\ndns_round_robin true")
122
+ test 'configure_dns_round_robin transport' do
123
+ @d = d = create_driver(CONFIG + "\nheartbeat_type transport\ndns_round_robin true")
124
124
  assert_equal true, d.instance.dns_round_robin
125
125
  end
126
126
 
@@ -135,6 +135,24 @@ EOL
135
135
  end
136
136
  end
137
137
 
138
+ test 'configure with ignore_network_errors_at_startup' do
139
+ normal_conf = config_element('match', '**', {}, [
140
+ config_element('server', '', {'name' => 'test', 'host' => 'unexisting.yaaaaaaaaaaaaaay.host.example.com'})
141
+ ])
142
+ assert_raise SocketError do
143
+ create_driver(normal_conf)
144
+ end
145
+
146
+ conf = config_element('match', '**', {'ignore_network_errors_at_startup' => 'true'}, [
147
+ config_element('server', '', {'name' => 'test', 'host' => 'unexisting.yaaaaaaaaaaaaaay.host.example.com'})
148
+ ])
149
+ @d = d = create_driver(conf)
150
+ expected_log = "failed to resolve node name when configured"
151
+ expected_detail = 'server="test" error_class=SocketError'
152
+ logs = d.logs
153
+ assert{ logs.any?{|log| log.include?(expected_log) && log.include?(expected_detail) } }
154
+ end
155
+
138
156
  test 'compress_default_value' do
139
157
  @d = d = create_driver
140
158
  assert_equal :text, d.instance.compress
@@ -199,6 +217,40 @@ EOL
199
217
  assert_equal 2, d.instance.ack_response_timeout
200
218
  end
201
219
 
220
+ test 'send tags in str (utf-8 strings)' do
221
+ target_input_driver = create_target_input_driver
222
+
223
+ @d = d = create_driver(CONFIG + %[flush_interval 1s])
224
+
225
+ time = event_time("2011-01-02 13:14:15 UTC")
226
+
227
+ tag_in_utf8 = "test.utf8".encode("utf-8")
228
+ tag_in_ascii = "test.ascii".encode("ascii-8bit")
229
+
230
+ emit_events = [
231
+ [tag_in_utf8, time, {"a" => 1}],
232
+ [tag_in_ascii, time, {"a" => 2}],
233
+ ]
234
+
235
+ target_input_driver.run(expect_records: 2) do
236
+ d.run do
237
+ emit_events.each do |tag, t, record|
238
+ d.feed(tag, t, record)
239
+ end
240
+ end
241
+ end
242
+
243
+ events = target_input_driver.events
244
+ assert_equal_event_time(time, events[0][1])
245
+ assert_equal ['test.utf8', time, emit_events[0][2]], events[0]
246
+ assert_equal Encoding::UTF_8, events[0][0].encoding
247
+ assert_equal_event_time(time, events[1][1])
248
+ assert_equal ['test.ascii', time, emit_events[1][2]], events[1]
249
+ assert_equal Encoding::UTF_8, events[1][0].encoding
250
+
251
+ assert_empty d.instance.exceptions
252
+ end
253
+
202
254
  test 'send_with_time_as_integer' do
203
255
  target_input_driver = create_target_input_driver
204
256
 
@@ -587,7 +639,7 @@ EOL
587
639
  node = d.instance.nodes.first
588
640
  assert_equal Fluent::Plugin::ForwardOutput::NoneHeartbeatNode, node.class
589
641
 
590
- d.instance.start
642
+ d.instance_start
591
643
  assert_nil d.instance.instance_variable_get(:@loop) # no HeartbeatHandler, or HeartbeatRequestTimer
592
644
  assert_nil d.instance.instance_variable_get(:@thread) # no HeartbeatHandler, or HeartbeatRequestTimer
593
645
 
@@ -599,16 +651,16 @@ EOL
599
651
  test 'heartbeat_type_udp' do
600
652
  @d = d = create_driver(CONFIG + "\nheartbeat_type udp")
601
653
 
602
- d.instance.start
654
+ d.instance_start
603
655
  usock = d.instance.instance_variable_get(:@usock)
604
656
  servers = d.instance.instance_variable_get(:@_servers)
605
657
  timers = d.instance.instance_variable_get(:@_timers)
606
- assert_equal UDPSocket, usock.class
658
+ assert_equal Fluent::PluginHelper::Socket::WrappedSocket::UDP, usock.class
659
+ assert_kind_of UDPSocket, usock
607
660
  assert servers.find{|s| s.title == :out_forward_heartbeat_receiver }
608
661
  assert timers.include?(:out_forward_heartbeat_request)
609
662
 
610
663
  mock(usock).send("\0", 0, Socket.pack_sockaddr_in(TARGET_PORT, '127.0.0.1')).once
611
- # timer.disable # call send_heartbeat at just once
612
664
  d.instance.send(:on_timer)
613
665
  end
614
666
 
@@ -141,6 +141,10 @@ class OutputTest < Test::Unit::TestCase
141
141
  @i = create_output(:full)
142
142
  end
143
143
 
144
+ test 'are not available with multi workers configuration in default' do
145
+ assert_false @i.multi_workers_ready?
146
+ end
147
+
144
148
  test '#implement? can return features for plugin instances' do
145
149
  i1 = FluentPluginOutputTest::DummyBareOutput.new
146
150
  assert !i1.implement?(:synchronous)
@@ -820,26 +824,28 @@ class OutputTest < Test::Unit::TestCase
820
824
  test '#write flush took longer time than slow_flush_log_threshold' do
821
825
  i = create_output(:buffered)
822
826
  write_called = false
823
- i.register(:write) { |chunk| sleep 1 }
827
+ i.register(:write) { |chunk| sleep 3 }
824
828
  i.define_singleton_method(:test_finished?) { write_called }
825
829
  i.define_singleton_method(:try_flush) { super(); write_called = true }
826
830
 
827
831
  invoke_slow_flush_log_threshold_test(i) {
828
832
  assert write_called
829
- assert_equal 1, i.log.out.logs.select { |line| line =~ /buffer flush took longer time than slow_flush_log_threshold: elapsed_time/ }.size
833
+ logs = i.log.out.logs
834
+ assert{ logs.any?{|log| log.include?("buffer flush took longer time than slow_flush_log_threshold: elapsed_time") } }
830
835
  }
831
836
  end
832
837
 
833
838
  test '#try_write flush took longer time than slow_flush_log_threshold' do
834
839
  i = create_output(:delayed)
835
840
  try_write_called = false
836
- i.register(:try_write){ |chunk| sleep 1 }
841
+ i.register(:try_write){ |chunk| sleep 3 }
837
842
  i.define_singleton_method(:test_finished?) { try_write_called }
838
843
  i.define_singleton_method(:try_flush) { super(); try_write_called = true }
839
844
 
840
845
  invoke_slow_flush_log_threshold_test(i) {
841
846
  assert try_write_called
842
- assert_equal 1, i.log.out.logs.select { |line| line =~ /buffer flush took longer time than slow_flush_log_threshold: elapsed_time/ }.size
847
+ logs = i.log.out.logs
848
+ assert{ logs.any?{|log| log.include?("buffer flush took longer time than slow_flush_log_threshold: elapsed_time") } }
843
849
  }
844
850
  end
845
851
  end
@@ -642,6 +642,22 @@ class BufferedOutputTest < Test::Unit::TestCase
642
642
  ary.reject!{|e| true }
643
643
  end
644
644
  end
645
+ end
646
+
647
+ sub_test_case 'with much longer flush_interval' do
648
+ setup do
649
+ hash = {
650
+ 'flush_mode' => 'interval',
651
+ 'flush_interval' => 3000,
652
+ 'flush_thread_count' => 1,
653
+ 'flush_thread_burst_interval' => 0.01,
654
+ 'chunk_limit_size' => 1024,
655
+ }
656
+ @i = create_output(:buffered)
657
+ @i.configure(config_element('ROOT','',{},[config_element('buffer','',hash)]))
658
+ @i.start
659
+ @i.after_start
660
+ end
645
661
 
646
662
  test 'flush_at_shutdown work well when plugin is shutdown' do
647
663
  ary = []
@@ -658,16 +674,15 @@ class BufferedOutputTest < Test::Unit::TestCase
658
674
  (1024 * 0.9 / event_size).to_i.times do |i|
659
675
  @i.emit_events("test.tag", Fluent::ArrayEventStream.new([ [t, r] ]))
660
676
  end
661
- assert{ @i.buffer.queue.size == 0 && ary.size == 0 }
677
+ queue_size = @i.buffer.queue.size
678
+ assert{ queue_size == 0 && ary.size == 0 }
662
679
 
663
680
  @i.stop
664
681
  @i.before_shutdown
665
682
  @i.shutdown
666
683
  @i.after_shutdown
667
684
 
668
- waiting(10) do
669
- Thread.pass until ary.size == 1
670
- end
685
+ waiting(10){ sleep 0.1 until ary.size == 1 }
671
686
  assert_equal [tag,t,r].to_json * (1024 * 0.9 / event_size), ary.first
672
687
  end
673
688
  end
@@ -730,11 +745,9 @@ class BufferedOutputTest < Test::Unit::TestCase
730
745
  assert_equal rand_records, es.size
731
746
  @i.emit_events("test.tag", es)
732
747
 
733
- assert{ @i.buffer.stage.size == 0 && (@i.buffer.queue.size == 1 || @i.buffer.dequeued.size == 1 || ary.size > 0) }
734
-
735
- waiting(10) do
736
- Thread.pass until @i.buffer.queue.size == 0 && @i.buffer.dequeued.size == 0
737
- end
748
+ waiting(10){ sleep 0.1 until @i.buffer.stage.size == 0 } # make sure that the emitted es is enqueued by "flush_mode immediate"
749
+ waiting(10){ sleep 0.1 until @i.buffer.queue.size == 0 && @i.buffer.dequeued.size == 0 }
750
+ waiting(10){ sleep 0.1 until ary.size == rand_records }
738
751
 
739
752
  assert_equal rand_records, ary.size
740
753
  ary.reject!{|e| true }
@@ -863,12 +876,12 @@ class BufferedOutputTest < Test::Unit::TestCase
863
876
 
864
877
  @i.enqueue_thread_wait
865
878
 
866
- waiting(4) do
867
- Thread.pass until @i.write_count > 0
868
- end
879
+ waiting(4){ sleep 0.1 until @i.write_count > 0 }
869
880
 
870
881
  assert{ @i.buffer.stage.size == 2 && @i.write_count == 1 }
871
882
 
883
+ waiting(4){ sleep 0.1 until ary.size == 3 }
884
+
872
885
  assert_equal 3, ary.size
873
886
  assert_equal 2, ary.select{|e| e[0] == "test.tag.1" }.size
874
887
  assert_equal 1, ary.select{|e| e[0] == "test.tag.2" }.size
@@ -882,9 +895,7 @@ class BufferedOutputTest < Test::Unit::TestCase
882
895
  Timecop.freeze( Time.parse('2016-04-13 14:04:06 +0900') )
883
896
 
884
897
  @i.enqueue_thread_wait
885
- waiting(4) do
886
- Thread.pass until @i.write_count > 1
887
- end
898
+ waiting(4){ sleep 0.1 until @i.write_count > 1 }
888
899
 
889
900
  assert{ @i.buffer.stage.size == 1 && @i.write_count == 2 }
890
901
 
@@ -904,7 +915,13 @@ class BufferedOutputTest < Test::Unit::TestCase
904
915
  metachecks = []
905
916
 
906
917
  @i.register(:format){|tag,time,record| [tag,time,record].to_json + "\n" }
907
- @i.register(:write){|chunk| chunk.read.split("\n").reject{|l| l.empty? }.each{|data| e = JSON.parse(data); ary << e; metachecks << (chunk.metadata.timekey.to_i <= e[1].to_i && e[1].to_i < chunk.metadata.timekey.to_i + 30) } }
918
+ @i.register(:write){|chunk|
919
+ chunk.read.split("\n").reject{|l| l.empty? }.each{|data|
920
+ e = JSON.parse(data)
921
+ ary << e
922
+ metachecks << (chunk.metadata.timekey.to_i <= e[1].to_i && e[1].to_i < chunk.metadata.timekey.to_i + 30)
923
+ }
924
+ }
908
925
 
909
926
  r = {}
910
927
  (0...10).each do |i|
@@ -942,9 +959,7 @@ class BufferedOutputTest < Test::Unit::TestCase
942
959
 
943
960
  @i.enqueue_thread_wait
944
961
 
945
- waiting(4) do
946
- Thread.pass until @i.write_count > 0
947
- end
962
+ waiting(4){ sleep 0.1 until @i.write_count > 0 }
948
963
 
949
964
  assert{ @i.buffer.stage.size == 2 && @i.write_count == 1 }
950
965
 
@@ -957,14 +972,13 @@ class BufferedOutputTest < Test::Unit::TestCase
957
972
  Timecop.freeze( Time.parse('2016-04-13 14:04:06 +0900') )
958
973
 
959
974
  @i.enqueue_thread_wait
960
- waiting(4) do
961
- Thread.pass until @i.write_count > 1
962
- end
975
+ waiting(4){ sleep 0.1 until @i.write_count > 1 }
963
976
 
964
977
  assert{ @i.buffer.stage.size == 1 && @i.write_count == 2 }
965
978
 
966
979
  Timecop.freeze( Time.parse('2016-04-13 14:04:13 +0900') )
967
980
 
981
+ waiting(4){ sleep 0.1 until ary.size == 9 }
968
982
  assert_equal 9, ary.size
969
983
 
970
984
  @i.stop
@@ -972,9 +986,7 @@ class BufferedOutputTest < Test::Unit::TestCase
972
986
  @i.shutdown
973
987
  @i.after_shutdown
974
988
 
975
- waiting(4) do
976
- Thread.pass until @i.write_count > 2
977
- end
989
+ waiting(4){ sleep 0.1 until @i.write_count > 2 && ary.size == 11 }
978
990
 
979
991
  assert_equal 11, ary.size
980
992
  assert metachecks.all?{|e| e }
@@ -157,7 +157,7 @@ class BufferedOutputCompressTest < Test::Unit::TestCase
157
157
  @i.emit_events('tag', es)
158
158
  @i.enqueue_thread_wait
159
159
  @i.flush_thread_wakeup
160
- waiting(4) { Thread.pass until io.size > 0 }
160
+ waiting(4) { sleep 0.1 until io.size > 0 }
161
161
 
162
162
  assert_equal expected, decompress(compressed_data)
163
163
  assert_equal expected, io.string
@@ -687,7 +687,7 @@ class BufferedOutputRetryTest < Test::Unit::TestCase
687
687
 
688
688
  @i.enqueue_thread_wait
689
689
  @i.flush_thread_wakeup
690
- waiting(4){ Thread.pass until @i.write_count > 0 && @i.num_errors > 0 }
690
+ waiting(4){ sleep 0.1 until @i.write_count > 0 && @i.num_errors > 0 }
691
691
 
692
692
  assert{ @i.buffer.queue.size > 0 }
693
693
  assert{ @i.buffer.queue.first.metadata.tag == 'test.tag.1' }
@@ -703,10 +703,10 @@ class BufferedOutputRetryTest < Test::Unit::TestCase
703
703
  15.times do |i|
704
704
  now = @i.next_flush_time
705
705
 
706
- Timecop.freeze( now )
706
+ Timecop.freeze( now + 1 )
707
707
  @i.enqueue_thread_wait
708
708
  @i.flush_thread_wakeup
709
- waiting(4){ Thread.pass until @i.write_count > prev_write_count && @i.num_errors > prev_num_errors }
709
+ waiting(4){ sleep 0.1 until @i.write_count > prev_write_count && @i.num_errors > prev_num_errors }
710
710
 
711
711
  assert{ @i.write_count > prev_write_count }
712
712
  assert{ @i.num_errors > prev_num_errors }
@@ -758,7 +758,7 @@ class BufferedOutputRetryTest < Test::Unit::TestCase
758
758
 
759
759
  @i.enqueue_thread_wait
760
760
  @i.flush_thread_wakeup
761
- waiting(4){ Thread.pass until @i.write_count > 0 && @i.num_errors > 0 }
761
+ waiting(4){ sleep 0.1 until @i.write_count > 0 && @i.num_errors > 0 }
762
762
 
763
763
  assert{ @i.buffer.queue.size > 0 }
764
764
  assert{ @i.buffer.queue.first.metadata.tag == 'test.tag.1' }
@@ -774,10 +774,10 @@ class BufferedOutputRetryTest < Test::Unit::TestCase
774
774
  15.times do |i|
775
775
  now = @i.next_flush_time
776
776
 
777
- Timecop.freeze( now )
777
+ Timecop.freeze( now + 1 )
778
778
  @i.enqueue_thread_wait
779
779
  @i.flush_thread_wakeup
780
- waiting(4){ Thread.pass until @i.write_count > prev_write_count && @i.num_errors > prev_num_errors }
780
+ waiting(4){ sleep 0.1 until @i.write_count > prev_write_count && @i.num_errors > prev_num_errors }
781
781
 
782
782
  assert{ @i.write_count > prev_write_count }
783
783
  assert{ @i.num_errors > prev_num_errors }
@@ -230,7 +230,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
230
230
 
231
231
  @i.enqueue_thread_wait
232
232
  @i.flush_thread_wakeup
233
- waiting(4){ Thread.pass until @i.write_count > 0 && @i.num_errors > 0 }
233
+ waiting(4){ sleep 0.1 until @i.write_count > 0 && @i.num_errors > 0 }
234
234
 
235
235
  assert{ @i.buffer.queue.size > 0 }
236
236
  assert{ @i.buffer.queue.first.metadata.tag == 'test.tag.1' }
@@ -244,16 +244,30 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
244
244
  first_failure = @i.retry.start
245
245
 
246
246
  # retry_timeout == 60(sec), retry_secondary_threshold == 0.8
247
+ now = first_failure + 60 * 0.8 + 1 # to step from primary to secondary
248
+ Timecop.freeze( now )
247
249
 
248
- now = first_failure + 60 * 0.8 + 1
250
+ unless @i.retry.secondary?
251
+ @i.enqueue_thread_wait
252
+ @i.flush_thread_wakeup
253
+ waiting(4){ sleep 0.1 until @i.write_count > prev_write_count }
254
+
255
+ prev_write_count = @i.write_count
256
+ prev_num_errors = @i.num_errors
257
+
258
+ # next step is on secondary
259
+ now = first_failure + 60 * 0.8 + 10
260
+ Timecop.freeze( now )
261
+ end
249
262
 
250
- Timecop.freeze( now )
251
263
  @i.enqueue_thread_wait
252
264
  @i.flush_thread_wakeup
253
- waiting(4){ Thread.pass until @i.write_count > prev_write_count }
265
+ waiting(4){ sleep 0.1 until @i.write_count > prev_write_count }
254
266
 
255
- assert{ @i.write_count > prev_write_count }
256
- assert{ @i.num_errors == prev_num_errors }
267
+ current_write_count = @i.write_count
268
+ current_num_errors = @i.num_errors
269
+ assert{ current_write_count > prev_write_count }
270
+ assert{ current_num_errors == prev_num_errors }
257
271
 
258
272
  assert_nil @i.retry
259
273
 
@@ -261,7 +275,9 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
261
275
  assert_equal [ 'test.tag.1', event_time('2016-04-13 18:33:13').to_i, {"name" => "moris", "age" => 36, "message" => "data2"} ], written[1]
262
276
  assert_equal [ 'test.tag.1', event_time('2016-04-13 18:33:32').to_i, {"name" => "moris", "age" => 36, "message" => "data3"} ], written[2]
263
277
 
264
- assert{ @i.log.out.logs.any?{|l| l.include?("[warn]: retry succeeded by secondary.") } }
278
+ logs = @i.log.out.logs
279
+ waiting(4){ sleep 0.1 until logs.any?{|l| l.include?("[warn]: retry succeeded by secondary.") } }
280
+ assert{ logs.any?{|l| l.include?("[warn]: retry succeeded by secondary.") } }
265
281
  end
266
282
 
267
283
  test 'secondary can do non-delayed commit even if primary do delayed commit' do
@@ -295,7 +311,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
295
311
 
296
312
  @i.enqueue_thread_wait
297
313
  @i.flush_thread_wakeup
298
- waiting(4){ Thread.pass until @i.write_count > 0 && @i.num_errors > 0 }
314
+ waiting(4){ sleep 0.1 until @i.write_count > 0 && @i.num_errors > 0 }
299
315
 
300
316
  assert{ @i.buffer.queue.size > 0 }
301
317
  assert{ @i.buffer.queue.first.metadata.tag == 'test.tag.1' }
@@ -309,13 +325,25 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
309
325
  first_failure = @i.retry.start
310
326
 
311
327
  # retry_timeout == 60(sec), retry_secondary_threshold == 0.8
328
+ now = first_failure + 60 * 0.8 + 1 # to step from primary to secondary
329
+ Timecop.freeze( now )
312
330
 
313
- now = first_failure + 60 * 0.8 + 1
331
+ unless @i.retry.secondary?
332
+ @i.enqueue_thread_wait
333
+ @i.flush_thread_wakeup
334
+ waiting(4){ sleep 0.1 until @i.write_count > prev_write_count }
335
+
336
+ prev_write_count = @i.write_count
337
+ prev_num_errors = @i.num_errors
338
+
339
+ # next step is on secondary
340
+ now = first_failure + 60 * 0.8 + 10
341
+ Timecop.freeze( now )
342
+ end
314
343
 
315
- Timecop.freeze( now )
316
344
  @i.enqueue_thread_wait
317
345
  @i.flush_thread_wakeup
318
- waiting(4){ Thread.pass until @i.write_count > prev_write_count }
346
+ waiting(4){ sleep 0.1 until @i.write_count > prev_write_count }
319
347
 
320
348
  assert{ @i.write_count > prev_write_count }
321
349
  assert{ @i.num_errors == prev_num_errors }
@@ -326,7 +354,9 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
326
354
  assert_equal [ 'test.tag.1', event_time('2016-04-13 18:33:13').to_i, {"name" => "moris", "age" => 36, "message" => "data2"} ], written[1]
327
355
  assert_equal [ 'test.tag.1', event_time('2016-04-13 18:33:32').to_i, {"name" => "moris", "age" => 36, "message" => "data3"} ], written[2]
328
356
 
329
- assert{ @i.log.out.logs.any?{|l| l.include?("[warn]: retry succeeded by secondary.") } }
357
+ logs = @i.log.out.logs
358
+ waiting(4){ sleep 0.1 until logs.any?{|l| l.include?("[warn]: retry succeeded by secondary.") } }
359
+ assert{ logs.any?{|l| l.include?("[warn]: retry succeeded by secondary.") } }
330
360
  end
331
361
 
332
362
  test 'secondary plugin can do delayed commit if primary do it' do
@@ -361,7 +391,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
361
391
 
362
392
  @i.enqueue_thread_wait
363
393
  @i.flush_thread_wakeup
364
- waiting(4){ Thread.pass until @i.write_count > 0 && @i.num_errors > 0 }
394
+ waiting(4){ sleep 0.1 until @i.write_count > 0 && @i.num_errors > 0 }
365
395
 
366
396
  assert{ @i.buffer.queue.size > 0 }
367
397
  assert{ @i.buffer.queue.first.metadata.tag == 'test.tag.1' }
@@ -375,13 +405,25 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
375
405
  first_failure = @i.retry.start
376
406
 
377
407
  # retry_timeout == 60(sec), retry_secondary_threshold == 0.8
408
+ now = first_failure + 60 * 0.8 + 1 # to step from primary to secondary
409
+ Timecop.freeze( now )
378
410
 
379
- now = first_failure + 60 * 0.8 + 1
411
+ unless @i.retry.secondary?
412
+ @i.enqueue_thread_wait
413
+ @i.flush_thread_wakeup
414
+ waiting(4){ sleep 0.1 until @i.write_count > prev_write_count }
415
+
416
+ prev_write_count = @i.write_count
417
+ prev_num_errors = @i.num_errors
418
+
419
+ # next step is on secondary
420
+ now = first_failure + 60 * 0.8 + 10
421
+ Timecop.freeze( now )
422
+ end
380
423
 
381
- Timecop.freeze( now )
382
424
  @i.enqueue_thread_wait
383
425
  @i.flush_thread_wakeup
384
- waiting(4){ Thread.pass until @i.write_count > prev_write_count }
426
+ waiting(4){ sleep 0.1 until @i.write_count > prev_write_count }
385
427
 
386
428
  assert{ @i.write_count > prev_write_count }
387
429
  assert{ @i.num_errors == prev_num_errors }
@@ -403,7 +445,9 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
403
445
 
404
446
  assert_nil @i.retry
405
447
 
406
- assert{ @i.log.out.logs.any?{|l| l.include?("[warn]: retry succeeded by secondary.") } }
448
+ logs = @i.log.out.logs
449
+ waiting(4){ sleep 0.1 until logs.any?{|l| l.include?("[warn]: retry succeeded by secondary.") } }
450
+ assert{ logs.any?{|l| l.include?("[warn]: retry succeeded by secondary.") } }
407
451
  end
408
452
 
409
453
  test 'secondary plugin can do delayed commit even if primary does not do it' do
@@ -438,7 +482,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
438
482
 
439
483
  @i.enqueue_thread_wait
440
484
  @i.flush_thread_wakeup
441
- waiting(4){ Thread.pass until @i.write_count > 0 && @i.num_errors > 0 }
485
+ waiting(4){ sleep 0.1 until @i.write_count > 0 && @i.num_errors > 0 }
442
486
 
443
487
  assert{ @i.buffer.queue.size > 0 }
444
488
  assert{ @i.buffer.queue.first.metadata.tag == 'test.tag.1' }
@@ -452,13 +496,25 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
452
496
  first_failure = @i.retry.start
453
497
 
454
498
  # retry_timeout == 60(sec), retry_secondary_threshold == 0.8
499
+ now = first_failure + 60 * 0.8 + 1 # to step from primary to secondary
500
+ Timecop.freeze( now )
455
501
 
456
- now = first_failure + 60 * 0.8 + 1
502
+ unless @i.retry.secondary?
503
+ @i.enqueue_thread_wait
504
+ @i.flush_thread_wakeup
505
+ waiting(4){ sleep 0.1 until @i.write_count > prev_write_count }
506
+
507
+ prev_write_count = @i.write_count
508
+ prev_num_errors = @i.num_errors
509
+
510
+ # next step is on secondary
511
+ now = first_failure + 60 * 0.8 + 10
512
+ Timecop.freeze( now )
513
+ end
457
514
 
458
- Timecop.freeze( now )
459
515
  @i.enqueue_thread_wait
460
516
  @i.flush_thread_wakeup
461
- waiting(4){ Thread.pass until @i.write_count > prev_write_count }
517
+ waiting(4){ sleep 0.1 until @i.write_count > prev_write_count }
462
518
 
463
519
  assert{ @i.write_count > prev_write_count }
464
520
  assert{ @i.num_errors == prev_num_errors }
@@ -480,7 +536,9 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
480
536
 
481
537
  assert_nil @i.retry
482
538
 
483
- assert{ @i.log.out.logs.any?{|l| l.include?("[warn]: retry succeeded by secondary.") } }
539
+ logs = @i.log.out.logs
540
+ waiting(4){ sleep 0.1 until logs.any?{|l| l.include?("[warn]: retry succeeded by secondary.") } }
541
+ assert{ logs.any?{|l| l.include?("[warn]: retry succeeded by secondary.") } }
484
542
  end
485
543
 
486
544
  test 'secondary plugin can do delayed commit even if primary does not do it, and non-committed chunks will be rollbacked by primary' do
@@ -515,7 +573,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
515
573
 
516
574
  @i.enqueue_thread_wait
517
575
  @i.flush_thread_wakeup
518
- waiting(4){ Thread.pass until @i.write_count > 0 && @i.num_errors > 0 }
576
+ waiting(4){ sleep 0.1 until @i.write_count > 0 && @i.num_errors > 0 }
519
577
 
520
578
  assert{ @i.buffer.queue.size == 2 }
521
579
  assert{ @i.buffer.queue.first.metadata.tag == 'test.tag.1' }
@@ -539,7 +597,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
539
597
  @i.enqueue_thread_wait
540
598
  @i.flush_thread_wakeup
541
599
 
542
- waiting(4){ Thread.pass until chunks.size == 2 }
600
+ waiting(4){ sleep 0.1 until chunks.size == 2 }
543
601
 
544
602
  assert{ @i.write_count > prev_write_count }
545
603
  assert{ @i.num_errors == prev_num_errors }
@@ -568,6 +626,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
568
626
 
569
627
  assert @i.retry
570
628
  logs = @i.log.out.logs
629
+ waiting(4){ sleep 0.1 until logs.select{|l| l.include?("[warn]: failed to flush the buffer chunk, timeout to commit.") }.size == 2 }
571
630
  assert{ logs.select{|l| l.include?("[warn]: failed to flush the buffer chunk, timeout to commit.") }.size == 2 }
572
631
  end
573
632
 
@@ -601,7 +660,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
601
660
 
602
661
  @i.enqueue_thread_wait
603
662
  @i.flush_thread_wakeup
604
- waiting(4){ Thread.pass until @i.write_count > 0 && @i.num_errors > 0 }
663
+ waiting(4){ sleep 0.1 until @i.write_count > 0 && @i.num_errors > 0 }
605
664
 
606
665
  assert{ @i.buffer.queue.size > 0 }
607
666
  assert{ @i.buffer.queue.first.metadata.tag == 'test.tag.1' }
@@ -621,7 +680,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
621
680
  Timecop.freeze( now )
622
681
  @i.enqueue_thread_wait
623
682
  @i.flush_thread_wakeup
624
- waiting(4){ Thread.pass until @i.write_count > prev_write_count }
683
+ waiting(4){ sleep 0.1 until @i.write_count > prev_write_count }
625
684
 
626
685
  assert{ @i.write_count > prev_write_count }
627
686
  assert{ @i.num_errors > prev_num_errors }
@@ -631,6 +690,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
631
690
  assert_equal 3, (@i.next_flush_time - Time.now)
632
691
 
633
692
  logs = @i.log.out.logs
693
+ waiting(4){ sleep 0.1 until logs.any?{|l| l.include?("[warn]: failed to flush the buffer with secondary output.") } }
634
694
  assert{ logs.any?{|l| l.include?("[warn]: failed to flush the buffer with secondary output.") } }
635
695
  end
636
696
  end
@@ -672,7 +732,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
672
732
 
673
733
  @i.enqueue_thread_wait
674
734
  @i.flush_thread_wakeup
675
- waiting(4){ Thread.pass until @i.write_count > 0 && @i.num_errors > 0 }
735
+ waiting(4){ sleep 0.1 until @i.write_count > 0 && @i.num_errors > 0 }
676
736
 
677
737
  assert{ @i.buffer.queue.size > 0 }
678
738
  assert{ @i.buffer.queue.first.metadata.tag == 'test.tag.1' }
@@ -690,7 +750,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
690
750
  Timecop.freeze( now )
691
751
  @i.enqueue_thread_wait
692
752
  @i.flush_thread_wakeup
693
- waiting(4){ Thread.pass until @i.write_count > prev_write_count }
753
+ waiting(4){ sleep 0.1 until @i.write_count > prev_write_count }
694
754
 
695
755
  assert{ @i.write_count > prev_write_count }
696
756
 
@@ -743,7 +803,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
743
803
 
744
804
  @i.enqueue_thread_wait
745
805
  @i.flush_thread_wakeup
746
- waiting(4){ Thread.pass until @i.write_count > 0 && @i.num_errors > 0 }
806
+ waiting(4){ sleep 0.1 until @i.write_count > 0 && @i.num_errors > 0 }
747
807
 
748
808
  assert{ @i.buffer.queue.size > 0 }
749
809
  assert{ @i.buffer.queue.first.metadata.tag == 'test.tag.1' }
@@ -768,7 +828,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
768
828
  Timecop.freeze( now )
769
829
  @i.enqueue_thread_wait
770
830
  @i.flush_thread_wakeup
771
- waiting(4){ Thread.pass until @i.write_count > prev_write_count }
831
+ waiting(4){ sleep 0.1 until @i.write_count > prev_write_count }
772
832
 
773
833
  assert{ @i.write_count > prev_write_count }
774
834
  assert{ @i.num_errors > prev_num_errors }
@@ -800,7 +860,7 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
800
860
  Timecop.freeze( now )
801
861
  @i.enqueue_thread_wait
802
862
  @i.flush_thread_wakeup
803
- waiting(4){ Thread.pass until @i.write_count > prev_write_count }
863
+ waiting(4){ sleep 0.1 until @i.write_count > prev_write_count }
804
864
 
805
865
  assert{ @i.write_count > prev_write_count }
806
866
  assert{ @i.num_errors > prev_num_errors }