From ec86f0ff93f571478af1277712f74558db0325fd Mon Sep 17 00:00:00 2001 From: James 'zofrex' Sanderson Date: Mon, 20 Apr 2026 15:58:21 +0100 Subject: [PATCH] ipn/ipnlocal: make TestStateMachine less flaky (#19434) TestStateMachine & TestStateMachineSeamless both flake a lot asserting the "Shutdown" call on cc after a Logout. This is because Shutdown is called on a goroutine to avoid a deadlock if it's called while holding the LocalBackend lock (#18052). This fixes that cause of flakes by waiting for LocalBackend's goroutine tracker to have no goroutines running (so the goroutine that calls Shutdown must have finished). This does not make TestStateMachine non-flaky because it can flake later in the test, too: the assertion on "unpause" after clearing the netmap between "Start4" and "Start4 -> netmap" sometimes fails. Updates tailscale/corp#36230 Updates #19377 Updates #18052 Signed-off-by: James Sanderson --- ipn/ipnlocal/state_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/ipn/ipnlocal/state_test.go b/ipn/ipnlocal/state_test.go index 428949a61..5d29e3d2a 100644 --- a/ipn/ipnlocal/state_test.go +++ b/ipn/ipnlocal/state_test.go @@ -700,6 +700,7 @@ func runTestStateMachine(t *testing.T, seamless bool) { notifies.expect(5) b.Logout(context.Background(), ipnauth.Self) { + b.awaitNoGoroutinesInTest() nn := notifies.drain(5) previousCC.assertCalls("pause", "Logout", "unpause", "Shutdown") // nn[0] is state notification (Stopped)