From 5650f1ecf9e73ead9cd621dc8f667c264a7806ab Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Fri, 1 May 2020 13:44:21 +1000 Subject: [PATCH] controlclient, ipn: adjust tests for tailscale.com keepalive change --- control/controlclient/auto_test.go | 35 +++++++++++++++++------------- ipn/e2e_test.go | 5 ++++- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/control/controlclient/auto_test.go b/control/controlclient/auto_test.go index f201fef4e..b04a872a2 100644 --- a/control/controlclient/auto_test.go +++ b/control/controlclient/auto_test.go @@ -335,16 +335,21 @@ func TestControl(t *testing.T) { }) t.Run("set hostinfo", func(t *testing.T) { - c1.SetHostinfo(&tailcfg.Hostinfo{ + c3.UpdateEndpoints(9876, []string{"1.2.3.4:3333"}) + c4.UpdateEndpoints(9876, []string{"5.6.7.8:1111"}) + c3.waitStatus(t, stateSynchronized) + c4.waitStatus(t, stateSynchronized) + + c3.SetHostinfo(&tailcfg.Hostinfo{ BackendLogID: "set-hostinfo-test", OS: "linux", }) - c1.waitStatus(t, stateSynchronized) - c2NetMap := c2.status(t).New.NetMap - if len(c2NetMap.Peers) != 1 { - t.Fatalf("wrong number of peers: %v", c2NetMap.Peers) + c3.waitStatus(t, stateSynchronized) + c4NetMap := c4.status(t).New.NetMap + if len(c4NetMap.Peers) != 1 { + t.Fatalf("wrong number of peers: %v", c4NetMap.Peers) } - peer := c2NetMap.Peers[0] + peer := c4NetMap.Peers[0] if !peer.KeepAlive { t.Errorf("peer KeepAlive=false, want true") } @@ -352,26 +357,26 @@ func TestControl(t *testing.T) { t.Errorf("peer hostinfo does not have OS: %v", peer.Hostinfo) } - c2.SetHostinfo(&tailcfg.Hostinfo{ + c4.SetHostinfo(&tailcfg.Hostinfo{ BackendLogID: "set-hostinfo-test", OS: "iOS", }) - c1NetMap = c1.status(t).New.NetMap - c2NetMap = c2.status(t).New.NetMap - if len(c1NetMap.Peers) != 1 { - t.Fatalf("wrong number of peers: %v", c1NetMap.Peers) + c3NetMap := c3.status(t).New.NetMap + c4NetMap = c4.status(t).New.NetMap + if len(c3NetMap.Peers) != 1 { + t.Fatalf("wrong number of peers: %v", c3NetMap.Peers) } - if len(c2NetMap.Peers) != 1 { - t.Fatalf("wrong number of peers: %v", c2NetMap.Peers) + if len(c4NetMap.Peers) != 1 { + t.Fatalf("wrong number of peers: %v", c4NetMap.Peers) } - peer = c1NetMap.Peers[0] + peer = c3NetMap.Peers[0] if peer.KeepAlive { t.Errorf("peer KeepAlive=true, want false") } if peer.Hostinfo.OS != "iOS" { t.Errorf("peer hostinfo does not have OS: %v", peer.Hostinfo) } - peer = c2NetMap.Peers[0] + peer = c4NetMap.Peers[0] if peer.KeepAlive { t.Errorf("peer KeepAlive=true, want false") } diff --git a/ipn/e2e_test.go b/ipn/e2e_test.go index ead1b61e7..f0ecafb19 100644 --- a/ipn/e2e_test.go +++ b/ipn/e2e_test.go @@ -68,6 +68,9 @@ func TestIPN(t *testing.T) { if err != nil { t.Fatalf("create control server: %v\n", ctl) } + if _, err := ctl.DB().FindOrCreateUser("google", "test1@example.com", "", ""); err != nil { + t.Fatal(err) + } n1 := newNode(t, "n1", https) defer n1.Backend.Shutdown() @@ -213,7 +216,7 @@ func newNode(t *testing.T, prefix string, https *httptest.Server) testNode { nch := make(chan Notify, 1000) c := controlclient.Persist{ Provider: "google", - LoginName: "test1@tailscale.com", + LoginName: "test1@example.com", } prefs := NewPrefs() prefs.ControlURL = https.URL