From 4a5c40b7cb0320fec5e7d60dca59afa1e52943ab Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Sat, 11 Jul 2026 13:50:35 +0200 Subject: [PATCH] test: fix TestBackupTier2Restore_DoubleClickRefused scheduling flake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit IsRunning flips before the restore goroutine parks in StopStack; under parallel load the ==1 assertion raced it and read 0. Wait for the first stop to land, then assert — the red-proof property (no-fast-path mutant → count 2) is preserved. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01PSK5g6qYLknKj8u3QAFEr6 --- controller/internal/web/async_restore_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controller/internal/web/async_restore_test.go b/controller/internal/web/async_restore_test.go index f59e7e3..7583e87 100644 --- a/controller/internal/web/async_restore_test.go +++ b/controller/internal/web/async_restore_test.go @@ -148,6 +148,9 @@ func TestBackupTier2Restore_DoubleClickRefused(t *testing.T) { if loc := w2.Header().Get("Location"); !strings.Contains(loc, "m%C3%A1r+fut") && !strings.Contains(loc, "már fut") { t.Fatalf("second POST should be refused with 'már fut'; got %q", loc) } + // IsRunning flips before the goroutine reaches StopStack — wait for the FIRST stop to land, so + // the ==1 assertion below measures "no second launch", not goroutine scheduling (parallel-load flake). + waitFor(t, func() bool { return atomic.LoadInt32(&prov.stops) >= 1 }, "first restore reached StopStack") if got := atomic.LoadInt32(&prov.stops); got != 1 { t.Fatalf("double-click launched a second restore: StopStack count = %d, want 1", got) }