Repository navigation
export: make the cancelled-resume test deterministic - #4
Merged
Merged
Conversation
TestRunResumesDownloadsCancelledMidway failed the v0.4.0 release run with "resume without the right range" for both archives. The failing downloads were those of the cancelled first run, not the resumed ones: - The fake files a request when its handler ends, and a stalled download ends only once the fake notices the client left. That can be after Run returned, so the test's count of earlier downloads was short and their Range-less events were checked as resumed ones. The fake now counts the requests it is handling; WaitIdle waits for zero, and the test calls it before it counts. - The run was cancelled 100 ms after the second download arrived, assuming both partial files had their bytes by then. It is now cancelled once both partial files hold the 30 and 40 bytes sent before the stalls. The resumed run must now make exactly two downloads, each with the Range of its own partial file. Production code is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TestRunResumesDownloadsCancelledMidwayfailed the v0.4.0 release run and passed on a re-run. The test read the fake server's log before the fake had filed the cancelled downloads, so it checked those downloads as resumed ones.Note
The flaky test was added in 54e0b1c on version v0.2.0 (2026-11-04).
What changed
Fake server (
internal/testserver) — counts the requests it is handling. The newWaitIdlewaits until none are left, soEventsholds every request made so far.Cancelled-resume test: log boundary — calls
WaitIdlebefore it counts the first run's downloads. Before: a first-run download filed late was checked as a resumed one, with noRange. After: only the second run's downloads are checked.Cancelled-resume test: cancel point — cancels the first run when both partial files hold the 30 and 40 bytes sent before the stalls. Before: it cancelled 100 ms after the second download arrived.
Cancelled-resume test: resume check — the resumed run must make exactly two downloads, and each must carry the
Rangeof its own partial file. Before: any download withbytes=30-orbytes=40-passed.Note
The fake files a request when its handler ends. A stalled download ends only when the fake sees that the client closed the connection, and that can happen after
Runreturned. The failing events in the release log (Start:3, emptyRange) are the first run's downloads. The 100 ms cancel did not fail in local stress runs, but it also depended on the scheduler. Production code does not change: the client resumed correctly in every run.QA
On
main, run the test under CPU stress:GOMAXPROCS=1 go test -race -count=100 -cpu 1,2,4 -run TestRunResumesDownloadsCancelledMidway ./internal/exportExpect: some runs fail with
resume without the right range.Check out this branch. Run the same command with
-count=500.Expect:
okforinternal/export, with no failure.🤖 Generated with Claude Code