Commit 2bc338f
test_fluentd: fix flaky zero_downtime_restart from per-chunk log parsing (#5450)
**Which issue(s) this PR fixes**:
Fixes #
**What this PR does / why we need it**:
The read loop in `run_fluentd` split each `eager_read` chunk on its own
(`logs = buf.split("\n")`) and yielded that to the caller for counting.
A single read can end in the middle of a line -- this happens when the
source-only buffer is replayed and a whole chunk of records is flushed
to `stdout` in one burst while the reader catches the pipe mid-write,
which is much more likely on a loaded CI runner.
When a record's line straddles two reads, neither half matches the
record regexp, so the caller drops it from its count while the full line
is still present in the accumulated output.
Carry the incomplete trailing line across reads and yield only complete
lines, the same way `assert_log_matches` already reads against the
accumulated buffer.
This PR will fix following error:
```
4) Failure: test: should restart with zero downtime (no data loss)(TestFluentdCommand::zero_downtime_restart)
/Users/runner/work/fluentd/fluentd/test/command/test_fluentd.rb:1574:in `block (2 levels) in <class:TestFluentdCommand>'
1571: end
1572: end
1573:
=> 1574: assert_equal(
1575: [(0..499).to_a, (0..499).to_a, (0..499).to_a],
1576: [
1577: records_by_type["udp"].sort,
<[[0,
1,
2,
3,
4,
5,
...
```
Ref.
https://github.com/fluent/fluentd/actions/runs/29796336422/job/88528337017#step:6:5375
**Docs Changes**:
N/A
**Release Note**:
N/A
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>1 parent 0579b12 commit 2bc338f
1 file changed
Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1413 | 1413 | | |
1414 | 1414 | | |
1415 | 1415 | | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
1416 | 1423 | | |
1417 | 1424 | | |
1418 | 1425 | | |
| |||
1421 | 1428 | | |
1422 | 1429 | | |
1423 | 1430 | | |
1424 | | - | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
1425 | 1437 | | |
1426 | 1438 | | |
1427 | 1439 | | |
1428 | | - | |
| 1440 | + | |
1429 | 1441 | | |
1430 | 1442 | | |
1431 | 1443 | | |
| |||
0 commit comments