From 7cbd58b9afd896c8ccd2a8039e26277d361d3e7c Mon Sep 17 00:00:00 2001 From: Yuta Iwama Date: Wed, 8 Apr 2020 17:46:23 +0900 Subject: [PATCH 1/2] a value better than block Signed-off-by: Yuta Iwama --- test/plugin/test_output_as_buffered_retries.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/plugin/test_output_as_buffered_retries.rb b/test/plugin/test_output_as_buffered_retries.rb index c227ed9df1..27ad169d1c 100644 --- a/test/plugin/test_output_as_buffered_retries.rb +++ b/test/plugin/test_output_as_buffered_retries.rb @@ -896,16 +896,16 @@ def get_log_time(msg, logs) @i.flush_thread_wakeup waiting(4){ Thread.pass until @i.write_count > 0 } - assert{ @i.write_count > 0 } - assert{ @i.num_errors > 0 } + assert(@i.write_count > 0) + assert(@i.num_errors > 0) now = @i.next_flush_time Timecop.freeze( now ) @i.flush_thread_wakeup waiting(4){ Thread.pass until @i.write_count > 1 } - assert{ @i.write_count > 1 } - assert{ @i.num_errors > 1 } + assert(@i.write_count > 1) + assert(@i.num_errors > 1) end end end From c7c65a8f7d94a136b37bc0bcf9cf8e84f4ad6bbc Mon Sep 17 00:00:00 2001 From: Yuta Iwama Date: Wed, 8 Apr 2020 18:27:59 +0900 Subject: [PATCH 2/2] Wait for #try_flush to finish and wait until next interval https://github.com/fluent/fluentd/blob/02f34e74b2209281ac56974722be1d449cf4dbc0/lib/fluent/plugin/output.rb#L1462 Signed-off-by: Yuta Iwama --- test/plugin/test_output_as_buffered_retries.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/plugin/test_output_as_buffered_retries.rb b/test/plugin/test_output_as_buffered_retries.rb index 27ad169d1c..4ac258e42b 100644 --- a/test/plugin/test_output_as_buffered_retries.rb +++ b/test/plugin/test_output_as_buffered_retries.rb @@ -895,6 +895,10 @@ def get_log_time(msg, logs) @i.flush_thread_wakeup waiting(4){ Thread.pass until @i.write_count > 0 } + waiting(4) do + state = @i.instance_variable_get(:@output_flush_threads).first + state.thread.status == 'sleep' + end assert(@i.write_count > 0) assert(@i.num_errors > 0) @@ -903,6 +907,10 @@ def get_log_time(msg, logs) Timecop.freeze( now ) @i.flush_thread_wakeup waiting(4){ Thread.pass until @i.write_count > 1 } + waiting(4) do + state = @i.instance_variable_get(:@output_flush_threads).first + state.thread.status == 'sleep' + end assert(@i.write_count > 1) assert(@i.num_errors > 1)