controlclient, ipn: adjust tests for tailscale.com keepalive change

pull/340/head
David Crawshaw 5 years ago
parent c10f90357e
commit 5650f1ecf9

@ -335,16 +335,21 @@ func TestControl(t *testing.T) {
}) })
t.Run("set hostinfo", func(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", BackendLogID: "set-hostinfo-test",
OS: "linux", OS: "linux",
}) })
c1.waitStatus(t, stateSynchronized) c3.waitStatus(t, stateSynchronized)
c2NetMap := c2.status(t).New.NetMap c4NetMap := c4.status(t).New.NetMap
if len(c2NetMap.Peers) != 1 { if len(c4NetMap.Peers) != 1 {
t.Fatalf("wrong number of peers: %v", c2NetMap.Peers) t.Fatalf("wrong number of peers: %v", c4NetMap.Peers)
} }
peer := c2NetMap.Peers[0] peer := c4NetMap.Peers[0]
if !peer.KeepAlive { if !peer.KeepAlive {
t.Errorf("peer KeepAlive=false, want true") 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) t.Errorf("peer hostinfo does not have OS: %v", peer.Hostinfo)
} }
c2.SetHostinfo(&tailcfg.Hostinfo{ c4.SetHostinfo(&tailcfg.Hostinfo{
BackendLogID: "set-hostinfo-test", BackendLogID: "set-hostinfo-test",
OS: "iOS", OS: "iOS",
}) })
c1NetMap = c1.status(t).New.NetMap c3NetMap := c3.status(t).New.NetMap
c2NetMap = c2.status(t).New.NetMap c4NetMap = c4.status(t).New.NetMap
if len(c1NetMap.Peers) != 1 { if len(c3NetMap.Peers) != 1 {
t.Fatalf("wrong number of peers: %v", c1NetMap.Peers) t.Fatalf("wrong number of peers: %v", c3NetMap.Peers)
} }
if len(c2NetMap.Peers) != 1 { if len(c4NetMap.Peers) != 1 {
t.Fatalf("wrong number of peers: %v", c2NetMap.Peers) t.Fatalf("wrong number of peers: %v", c4NetMap.Peers)
} }
peer = c1NetMap.Peers[0] peer = c3NetMap.Peers[0]
if peer.KeepAlive { if peer.KeepAlive {
t.Errorf("peer KeepAlive=true, want false") t.Errorf("peer KeepAlive=true, want false")
} }
if peer.Hostinfo.OS != "iOS" { if peer.Hostinfo.OS != "iOS" {
t.Errorf("peer hostinfo does not have OS: %v", peer.Hostinfo) t.Errorf("peer hostinfo does not have OS: %v", peer.Hostinfo)
} }
peer = c2NetMap.Peers[0] peer = c4NetMap.Peers[0]
if peer.KeepAlive { if peer.KeepAlive {
t.Errorf("peer KeepAlive=true, want false") t.Errorf("peer KeepAlive=true, want false")
} }

@ -68,6 +68,9 @@ func TestIPN(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("create control server: %v\n", ctl) 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) n1 := newNode(t, "n1", https)
defer n1.Backend.Shutdown() defer n1.Backend.Shutdown()
@ -213,7 +216,7 @@ func newNode(t *testing.T, prefix string, https *httptest.Server) testNode {
nch := make(chan Notify, 1000) nch := make(chan Notify, 1000)
c := controlclient.Persist{ c := controlclient.Persist{
Provider: "google", Provider: "google",
LoginName: "test1@tailscale.com", LoginName: "test1@example.com",
} }
prefs := NewPrefs() prefs := NewPrefs()
prefs.ControlURL = https.URL prefs.ControlURL = https.URL

Loading…
Cancel
Save