From b1198281b1414ba4e719d920d785467e5a3c43d6 Mon Sep 17 00:00:00 2001 From: sergeyb Date: Thu, 3 Dec 2026 21:19:00 +0000 Subject: [PATCH] test(demo): make the sibling-failure test wait for its third change before failing TestSiblingFailureDoesNotCancelInFlightLand hung until the Bazel timeout in about 1 of 10 runs under the race detector. Change 2's Land blocks until change 3's readiness hook closes siblingsCancelled, which happens only after the gate is cancelled. Change 1's hook cancels the gate by failing as soon as Land starts. If change 1 failed before change 3 reached Readiness.Wait, the runner skipped change 3 because its gate was already cancelled, so nothing ever closed siblingsCancelled and Land blocked forever. The production code is correct; the test did not enforce the order it relies on. Change 1's hook now also waits for a thirdWaiting channel that change 3 closes on entering Wait, so the gate cannot cancel before change 3 is inside Wait. Co-Authored-By: Claude Sonnet 5.5 --- service/submitqueue/demo/run_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/service/submitqueue/demo/run_test.go b/service/submitqueue/demo/run_test.go index 20c3bbbba..0e86b284c 100644 --- a/service/submitqueue/demo/run_test.go +++ b/service/submitqueue/demo/run_test.go @@ -333,6 +333,7 @@ func TestSiblingFailureDoesNotCancelInFlightLand(t *testing.T) { opts := fixtureOptions() opts.Count, opts.Concurrency = 3, 3 landStarted := make(chan struct{}) + thirdWaiting := make(chan struct{}) siblingsCancelled := make(chan struct{}) var landErr error gateway := NewMockGateway(gomock.NewController(t)) @@ -347,9 +348,12 @@ func TestSiblingFailureDoesNotCancelInFlightLand(t *testing.T) { readiness.EXPECT().Wait(gomock.Any(), gomock.Any()).DoAndReturn(func(gate context.Context, change Change) error { switch { case strings.HasSuffix(change.Branch, "/1"): + // Change 3 must be inside Wait before the gate cancels, or it is skipped and nothing releases Land. <-landStarted + <-thirdWaiting return fmt.Errorf("not ready") case strings.HasSuffix(change.Branch, "/3"): + close(thirdWaiting) <-gate.Done() close(siblingsCancelled) return gate.Err()