From c10f90357e85791eb98f4d15a017ead1265c7640 Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Fri, 1 May 2020 13:44:02 +1000 Subject: [PATCH] ipn/e2e_test: fix flaky logout state drain --- ipn/e2e_test.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ipn/e2e_test.go b/ipn/e2e_test.go index 5dd7c642e..ead1b61e7 100644 --- a/ipn/e2e_test.go +++ b/ipn/e2e_test.go @@ -159,16 +159,21 @@ drain: n1.Backend.Logout() t.Run("logout", func(t *testing.T) { - select { - case n := <-n1.NotifyCh: - if n.State != nil { - if *n.State != NeedsLogin { - t.Errorf("n.State=%v, want %v", n.State, NeedsLogin) + var s State + for { + select { + case n := <-n1.NotifyCh: + if n.State == nil { + continue + } + s = *n.State + t.Logf("n.State=%v", s) + if s == NeedsLogin { return } + case <-time.After(3 * time.Second): + t.Fatalf("timeout waiting for logout State=NeedsLogin, got State=%v", s) } - case <-time.After(3 * time.Second): - t.Fatalf("timeout waiting for logout notification") } }) }