Skip to content

Commit

Permalink
Merge pull request #3783 from fluent/try-to-fix-unstable-in-tail-test
Browse files Browse the repository at this point in the history
test_in_tail: Try to fix unstable test_shutdown_timeout
  • Loading branch information
ashie committed Jun 14, 2022
2 parents 1f4254c + e2760c8 commit aafc3b8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions test/plugin/test_in_tail.rb
Expand Up @@ -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
Expand All @@ -2503,19 +2504,24 @@ def test_shutdown_timeout
'format' => 'json',
'skip_refresh_on_startup' => true,
})
shutdown_start_time = 0

d = create_driver(config)
mock.proxy(d.instance).io_handler(anything, anything) do |io_handler|
mock.proxy(io_handler).ready_to_shutdown(anything) do
shutdown_start_time = Fluent::Clock.now
end
io_handler.shutdown_timeout = 0.5
io_handler
end

start_time = Fluent::Clock.now
assert_nothing_raised do
d.run(expect_emits: 1)
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
Expand Down

0 comments on commit aafc3b8

Please sign in to comment.