From 1dee36a984a9961c727b864c0946735148d36188 Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Sun, 8 Mar 2020 08:38:54 -0400 Subject: [PATCH] ipn: put e2e login section in its own subtest Signed-off-by: David Crawshaw --- ipn/e2e_test.go | 66 +++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/ipn/e2e_test.go b/ipn/e2e_test.go index c2f28fb67..89d2e9fa1 100644 --- a/ipn/e2e_test.go +++ b/ipn/e2e_test.go @@ -68,43 +68,45 @@ func TestIPN(t *testing.T) { defer n2.Backend.Shutdown() n2.Backend.StartLoginInteractive() - var s1, s2 State - for { - t.Logf("\n\nn1.state=%v n2.state=%v\n\n", s1, s2) - - // TODO(crawshaw): switch from || to &&. To do this we need to - // transmit some data so that the handshake completes on both - // sides. (Because handshakes are 1RTT, it is the data - // transmission that completes the handshake.) - if s1 == Running || s2 == Running { - // TODO(apenwarr): ensure state sequence. - // Right now we'll just exit as soon as - // state==Running, even if the backend is lying or - // something. Not a great test. - break - } + t.Run("login", func(t *testing.T) { + var s1, s2 State + for { + t.Logf("\n\nn1.state=%v n2.state=%v\n\n", s1, s2) + + // TODO(crawshaw): switch from || to &&. To do this we need to + // transmit some data so that the handshake completes on both + // sides. (Because handshakes are 1RTT, it is the data + // transmission that completes the handshake.) + if s1 == Running || s2 == Running { + // TODO(apenwarr): ensure state sequence. + // Right now we'll just exit as soon as + // state==Running, even if the backend is lying or + // something. Not a great test. + break + } - select { - case n := <-n1.NotifyCh: - t.Logf("n1n: %v\n", n) - if n.State != nil { - s1 = *n.State - if s1 == NeedsMachineAuth { - authNode(t, ctl, n1.Backend) + select { + case n := <-n1.NotifyCh: + t.Logf("n1n: %v\n", n) + if n.State != nil { + s1 = *n.State + if s1 == NeedsMachineAuth { + authNode(t, ctl, n1.Backend) + } } - } - case n := <-n2.NotifyCh: - t.Logf("n2n: %v\n", n) - if n.State != nil { - s2 = *n.State - if s2 == NeedsMachineAuth { - authNode(t, ctl, n2.Backend) + case n := <-n2.NotifyCh: + t.Logf("n2n: %v\n", n) + if n.State != nil { + s2 = *n.State + if s2 == NeedsMachineAuth { + authNode(t, ctl, n2.Backend) + } } + case <-time.After(3 * time.Second): + t.Fatalf("\n\n\nFATAL: timed out waiting for notifications.\n\n\n") } - case <-time.After(3 * time.Second): - t.Fatalf("\n\n\nFATAL: timed out waiting for notifications.\n\n\n") } - } + }) n1addr := n1.Backend.NetMap().Addresses[0].IP n2addr := n2.Backend.NetMap().Addresses[0].IP