Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_in_tail: Try to fix unstable test_shutdown_timeout #3783

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions test/plugin/test_in_tail.rb
Original file line number Diff line number Diff line change
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