ipn: put e2e login section in its own subtest

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
crawshaw/e2e_test
David Crawshaw 6 years ago
parent 66505358c0
commit 1dee36a984

@ -68,43 +68,45 @@ func TestIPN(t *testing.T) {
defer n2.Backend.Shutdown() defer n2.Backend.Shutdown()
n2.Backend.StartLoginInteractive() n2.Backend.StartLoginInteractive()
var s1, s2 State t.Run("login", func(t *testing.T) {
for { var s1, s2 State
t.Logf("\n\nn1.state=%v n2.state=%v\n\n", s1, s2) 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 // TODO(crawshaw): switch from || to &&. To do this we need to
// sides. (Because handshakes are 1RTT, it is the data // transmit some data so that the handshake completes on both
// transmission that completes the handshake.) // sides. (Because handshakes are 1RTT, it is the data
if s1 == Running || s2 == Running { // transmission that completes the handshake.)
// TODO(apenwarr): ensure state sequence. if s1 == Running || s2 == Running {
// Right now we'll just exit as soon as // TODO(apenwarr): ensure state sequence.
// state==Running, even if the backend is lying or // Right now we'll just exit as soon as
// something. Not a great test. // state==Running, even if the backend is lying or
break // something. Not a great test.
} break
}
select { select {
case n := <-n1.NotifyCh: case n := <-n1.NotifyCh:
t.Logf("n1n: %v\n", n) t.Logf("n1n: %v\n", n)
if n.State != nil { if n.State != nil {
s1 = *n.State s1 = *n.State
if s1 == NeedsMachineAuth { if s1 == NeedsMachineAuth {
authNode(t, ctl, n1.Backend) authNode(t, ctl, n1.Backend)
}
} }
} case n := <-n2.NotifyCh:
case n := <-n2.NotifyCh: t.Logf("n2n: %v\n", n)
t.Logf("n2n: %v\n", n) if n.State != nil {
if n.State != nil { s2 = *n.State
s2 = *n.State if s2 == NeedsMachineAuth {
if s2 == NeedsMachineAuth { authNode(t, ctl, n2.Backend)
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 n1addr := n1.Backend.NetMap().Addresses[0].IP
n2addr := n2.Backend.NetMap().Addresses[0].IP n2addr := n2.Backend.NetMap().Addresses[0].IP

Loading…
Cancel
Save