Repository navigation
test(branch): fix two flaky tests (snapshot race, witness port) - #231
Merged
Merged
Conversation
…ut back TestSnapshotServesThePreviousAnswerRatherThanHang ended with its hung read still running; let go as the test ended, it read the test's clock while withFakeDocker's cleanup restored it, which go test -race caught now and then (2 in 300 runs) and failed CI on unrelated PRs.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…reed TestWitnessAnswersOneQuestion closed a listener and took its port for a primary that is down, but the test servers it started next were sometimes handed that very port, so the down primary answered (seen in CI).
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes two flaky unit tests that fail CI on PRs that never touched them. The first just failed #230, whose change is in
enterprise/maskingonly; the second failed this PR's own first CI run.1.
TestSnapshotServesThePreviousAnswerRatherThanHang(race detector)Cause:
TestSnapshotServesThePreviousAnswerRatherThanHang(added in #222) ended while its deliberately hung read was still running. The deferredclose(gate)let that read finish as the test ended. As it finished,Snapshot.fetchreadstateNowwhilewithFakeDocker's cleanup was writing the real clock back into it, which the race detector reports. Reproduced on main: 2 races in 300 runs.Fix: the test only. A cleanup registered after
withFakeDocker's, so it runs before it, lets the read go and waits for it to finish. Nothing outside the test changed.2.
TestWitnessAnswersOneQuestionCause: it closed a listener and took the freed port as a primary that is down. The
httptestservers it started next were sometimes handed that very port, so the "down" primary answered. CI failed withview = the witness reaches the primary.Fix: the down primary is
127.0.0.1:0. Nothing can listen on port 0, so connecting fails at once on Linux, macOS and Windows, and the witness treats any failed connection as down. The one other test using the freed-port pattern (internal/controlplane/stale_test.go) already skips when something answers there, so it is left alone.Tests
-race: clean.internal/branch20 times under-race: clean.internal/controlplane,internal/proxy) 10 times under-race: clean.