fix(test): give the async polling helpers a deadline that survives a loaded suite - #146
Merged
Merged
Conversation
…loaded suite TestVideoImport_NativeVideoUsed failed a full-suite run with "video import job 1 did not finish in time" and then passed 3/3 in isolation. Nothing was broken — the helper polls a background goroutine against a hard 3s wall-clock deadline, which is really a timing assertion on the Go scheduler. Under `go test ./...` (the CI deploy gate) every package compiles and runs at once, and a goroutine can be starved past 3s. Five helpers had 2-3s deadlines: video job completion, the quota-refund counter, multi-recipe resolution, the video status endpoint, and hub room teardown. They now share testutil.AsyncDeadline (30s), which documents why it's generous. This costs nothing. Every one of those loops exits the moment the work lands, so the deadline is never actually waited on in a passing run — TestVideoImport_ NativeVideoUsed still completes in 0.32s. It only bounds how long a genuinely stuck test waits before failing. A flaky deploy gate gets ignored, and an ignored gate is worse than a slow one. Left finder_extraction_fix_test.go alone; it already allows 90s. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0194PdH4wDTnz5SWfzyoKagc
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Why
TestVideoImport_NativeVideoUsedfailed a full-suite run withvideo import job 1 did not finish in time, then passed 3/3 in isolation and 3/3 in the full package. Nothing was broken — the helper polls a background goroutine against a hard 3-second wall-clock deadline, which is really a timing assertion on the Go scheduler. Undergo test ./...(what the CI deploy gate runs) every package compiles and runs at once and a goroutine can be starved well past 3s. On my machine Microsoft Defender was also burning 168% CPU, which is exactly the kind of thing that tips it over.This matters because that suite is the deploy gate. A gate that reddens at random gets ignored, and an ignored gate is worse than a slow one.
What
Five helpers had 2–3s deadlines, all the same shape (poll until the background work lands, fail on timeout):
service/import_video_test.go:187service/import_video_test.go:473service/multi_recipe_resolver_test.go:66handlers/import_video_handler_test.go:188ws/hub_rooms_test.go:19They now share
testutil.AsyncDeadline(30s), with the rationale documented in one place.This costs nothing
None of these is a "prove X does not happen" assertion — I checked all six before touching them. Every loop exits the moment the work lands, so the deadline is never actually waited on in a passing run:
The deadline only bounds how long a genuinely stuck test waits before failing. Raising it trades a slower failure case for a reliable gate.
finder_extraction_fix_test.goalready allows 90s and was left alone.Verification
go test ./... -count=1green twice;go vetandgofmtclean. I tried to force the flake under synthetic CPU load with the old 3s value, but 28 spinners on 14 cores starved the Go toolchain itself and the run never completed — not a useful experiment, so I verified the property that actually matters instead: the deadline is never reached on a passing run, so the increase is free.🤖 Generated with Claude Code
https://claude.ai/code/session_0194PdH4wDTnz5SWfzyoKagc