From ab3d72c6991a5cfd09c1f69b509bbc89a2dfa0f5 Mon Sep 17 00:00:00 2001 From: Takuro Ashie Date: Mon, 13 Jun 2022 22:08:57 +0900 Subject: [PATCH] test_in_tail: Try to fix unstable test_shutdown_timeout Probably the cause is that recording start time is too early. Signed-off-by: Takuro Ashie --- test/plugin/test_in_tail.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/plugin/test_in_tail.rb b/test/plugin/test_in_tail.rb index 17b9d022a9..91f97b1e79 100644 --- a/test/plugin/test_in_tail.rb +++ b/test/plugin/test_in_tail.rb @@ -2492,6 +2492,7 @@ def test_EACCES def test_shutdown_timeout File.open("#{@tmp_dir}/tail.txt", "wb") do |f| + # Should be large enough to take too long time to consume (1024 * 1024 * 5).times do f.puts "{\"test\":\"fizzbuzz\"}" end @@ -2509,13 +2510,17 @@ def test_shutdown_timeout io_handler end - start_time = Fluent::Clock.now + shutdown_start_time = 0 assert_nothing_raised do - d.run(expect_emits: 1) + d.run(expect_emits: 1) do + sleep 0.1 until d.emit_count > 0 + shutdown_start_time = Fluent::Clock.now + end end - elapsed = Fluent::Clock.now - start_time - assert_true(elapsed > 0.5 && elapsed < 2.5) + elapsed = Fluent::Clock.now - shutdown_start_time + assert_true(elapsed > 0.5 && elapsed < 2.0, + "elapsed time: #{elapsed}") end sub_test_case "throttling logs at in_tail level" do