Skip to content

Commit 577cbc7

Browse files
github-actions[bot]Watson1978claude
authored
Backport(v1.19): test_in_tail: fix flaky test for already throttled log reading (#5474) (#5477)
**Which issue(s) this PR fixes**: Backport #5474 Fixes # **What this PR does / why we need it**: `test_emit_with_read_bytes_limit_per_second` in `reads_bytes_per_second w/ throttled already` was intermittently failing, especially on macOS CI runners. ``` 4) Failure: test_emit_with_read_bytes_limit_per_second[flat 65536 bytes](TailInputTest::singleline::log throttling per file::reads_bytes_per_second w/ throttled already) /Users/runner/work/fluentd/fluentd/test/plugin/test_in_tail.rb:636 636: assert_equal([], d.events) <[]> expected but was <[["t1", 2026-08-13 04:57:42.938460000 +0000, {"message"=>"xxxx..."}]]> ``` Ref. https://github.com/fluent/fluentd/actions/runs/31667602802/job/94345429056#step:6:5450 The `in_tail` throttling test must finish within a strict 1-second window before the timer (`@start_reading_time`) resets. Previously, the test appended logs for a fixed 0.8 seconds, leaving less than a 0.1-second margin. On loaded CI runners, this easily exceeded 1 second, causing the window to reset and unexpectedly emit pending logs. **Docs Changes**: N/A **Release Note**: N/A Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Shizuo Fujita <fujita@clear-code.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 8ff5d3b commit 577cbc7

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

test/plugin/test_in_tail.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -615,13 +615,18 @@ def test_emit_with_read_bytes_limit_per_second(data)
615615

616616
# We should not do shutdown here due to hard timeout.
617617
d.run do
618-
start_time = Fluent::Clock.now
619-
while Fluent::Clock.now - start_time < 0.8 do
620-
Fluent::FileWrapper.open("#{@tmp_dir}/tail.txt", "ab") do |f|
621-
f.puts msg
622-
f.flush
618+
if Fluent.linux?
619+
# Other platforms receive no stat notification while appending, so it
620+
# would just consume the throttling window and make this test flaky.
621+
start_time = Fluent::Clock.now
622+
while d.instance.statistics['input']['throttled_log_count'] < 5 &&
623+
Fluent::Clock.now - start_time < 0.8 do
624+
Fluent::FileWrapper.open("#{@tmp_dir}/tail.txt", "ab") do |f|
625+
f.puts msg
626+
f.flush
627+
end
628+
sleep 0.05
623629
end
624-
sleep 0.05
625630
end
626631
end
627632

0 commit comments

Comments
 (0)