Skip to content

test(harness): deflake overlong-stream test with a deterministic truncation bound#734

Merged
dennisonbertram merged 1 commit into
mainfrom
fix-flaky-jobmanager-streaming-test
Jul 16, 2026
Merged

test(harness): deflake overlong-stream test with a deterministic truncation bound#734
dennisonbertram merged 1 commit into
mainfrom
fix-flaky-jobmanager-streaming-test

Conversation

@dennisonbertram

Copy link
Copy Markdown
Owner

Problem

TestJobManagerRunForegroundStreamingOverlongLineReturnsPromptly asserted the call returned within a 4s wall-clock bound. Under the race detector on a loaded CI runner, the 2 MiB shell pipeline can exceed 4s with nothing actually wrong — so the test flaked intermittently (observed on unrelated PRs #732/#733 CI).

Fix

The wall-clock check proved nothing the deterministic metadata didn't already guarantee. Replaced it with a byte-count assertion: readStreamLine caps an overlong line at defaultMaxStreamLineBytes (1 MiB) and discards the rest, so for the 2 MiB line the streamer observes ~1 MiB (the cap) plus the short trailing EOF line — never the full 2 MiB. If truncation failed to short-circuit, streamed would be ~2 MiB and the bound fails. This is immune to machine load.

The existing timed_out / stream_truncated / stream_error checks are kept. Verified 25× under -race locally; full tools package green under -race.

🤖 Generated with Claude Code

…cation bound

TestJobManagerRunForegroundStreamingOverlongLineReturnsPromptly asserted the call
returned within a 4s wall-clock bound. That is inherently load-sensitive: under
the race detector on a busy CI runner the 2 MiB shell pipeline can take >4s even
when nothing is wrong, so the test flaked intermittently.

The wall-clock check proved nothing the deterministic metadata didn't already
guarantee. Replace it with a byte-count assertion on what the streamer received:
readStreamLine caps an overlong line at defaultMaxStreamLineBytes (1 MiB) and
discards the rest, so for the 2 MiB line the streamer observes ~1 MiB (the cap)
plus the short trailing "EOF" line — never the full 2 MiB. If truncation failed
to short-circuit, streamed would be ~2 MiB and the bound fails. This is immune to
machine load. The existing timed_out / stream_truncated / stream_error checks are
kept. Verified 25x under -race.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0182aJaeQgukK1vkNjy95wt6
@cursor

cursor Bot commented Jul 16, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@dennisonbertram
dennisonbertram merged commit e64d30e into main Jul 16, 2026
2 checks passed
@dennisonbertram
dennisonbertram deleted the fix-flaky-jobmanager-streaming-test branch July 16, 2026 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant