Repository navigation
test(agent): make the cancelled-retry assertion match the property - #313
Merged
Merged
Conversation
TestCancelledRunMakesNoFurtherRequest failed on master's post-merge run of 8d1ccb8 with "OnRetry fired 1 times, want 0" — the second time this has happened (issue #295, first seen on #294). The assertion was stricter than the property the test is named for. If the cancel lands after the retry decision but before the backoff's sleep observes it, OnRetry announces the attempt the sleep then abandons — and no second request is made, which is the fact that matters. The counter also crossed goroutines untyped. It is now atomic and asserts at most one announcement, while the request count keeps its stricter "exactly one" check. Tested at -count=50 and with the whole package at -count=3 (the gate that failed), plus the race detector across the repository. Refs #295
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.
What changed
agent/retry_http_test.go, one test:retriesis now anint32read withatomic, because the retry path and the test goroutine bothtouch it;
retries <= 1instead ofretries == 0, with the reason in the comment: if thecancel lands after the retry decision but before the backoff's sleep observes it,
OnRetryannouncesthe attempt the sleep then abandons — and no second request follows, which is the property the test
is named for.
requests == 1keeps its stricter check.Why
This is the flake filed as #295, and it just failed again — master's post-merge run for
8d1ccb8(
Test repeated in one process) failed withOnRetry fired 1 times, want 0. #295's acceptance says todecide which of the two readings is true and make the test say it; the measured ordering says the
announcement is allowed, so the assertion moves rather than the code. The alternative reading — forbid the
announcement — would mean adding a cancellation check before announcing, which does not remove the race
(it would move it one line earlier).
Verification
go test ./agent -run TestCancelledRunMakesNoFurtherRequest -count=50→ ok.go test ./agent -count=3(the gate that failed) → ok.go test ./... -count=1 -race→ ok.git log --format='%h %G? %s'→G.Honest scope
The change makes the test tolerant of the ordering that the code actually exhibits; it does not make the
outcome deterministic. A run that does retry would still fail
requests == 1, which is the property thetest exists for.
Refs #295