Skip to content

test_in_tail: fix flaky test for already throttled log reading - #5474

Merged
kenhys merged 1 commit into
fluent:masterfrom
Watson1978:fix-flaky-throttled-already-test
Aug 21, 2026
Merged

test_in_tail: fix flaky test for already throttled log reading#5474
kenhys merged 1 commit into
fluent:masterfrom
Watson1978:fix-flaky-throttled-already-test

Conversation

@Watson1978

Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes:
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

- in_tail resets its throttling 1 second after the first read attempt,
  so the whole d.run must finish within that window
- appending logs for a fixed 0.8 seconds consumed about 0.9 second of it
  and left less than 0.1 second of margin
- on a loaded runner the window expired before the shutdown notification,
  in_tail read the pending logs and d.events was no longer empty
- append logs only on Linux, where the stat watcher notifies in_tail
  within the window, and stop as soon as in_tail has throttled the
  expected number of notifications; 0.8 seconds is now an upper bound

Signed-off-by: Shizuo Fujita <fujita@clear-code.com>

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Watson1978 Watson1978 added this to the v1.20.0 milestone Aug 19, 2026
@Watson1978 Watson1978 added CI Test/CI issues backport to v1.19 We will backport this fix to the LTS branch labels Aug 19, 2026
@Watson1978
Watson1978 requested a review from kenhys August 21, 2026 02:14
@kenhys
kenhys merged commit dd45c6e into fluent:master Aug 21, 2026
20 checks passed
@Watson1978
Watson1978 deleted the fix-flaky-throttled-already-test branch August 21, 2026 02:58
@Watson1978 Watson1978 added the backported "backport to LTS" is done label Aug 24, 2026
Watson1978 added a commit that referenced this pull request Aug 24, 2026
…og 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport to v1.19 We will backport this fix to the LTS branch backported "backport to LTS" is done CI Test/CI issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants