|
|
|
@ -124,10 +124,10 @@ func TestClient_JoinLAN(t *testing.T) {
|
|
|
|
|
if got, want := c1.router.GetLANManager().NumServers(), 1; got != want {
|
|
|
|
|
r.Fatalf("got %d servers want %d", got, want)
|
|
|
|
|
}
|
|
|
|
|
if got, want := len(s1.LANMembers()), 2; got != want {
|
|
|
|
|
if got, want := len(s1.LANMembersInAgentPartition()), 2; got != want {
|
|
|
|
|
r.Fatalf("got %d server LAN members want %d", got, want)
|
|
|
|
|
}
|
|
|
|
|
if got, want := len(c1.LANMembers()), 2; got != want {
|
|
|
|
|
if got, want := len(c1.LANMembersInAgentPartition()), 2; got != want {
|
|
|
|
|
r.Fatalf("got %d client LAN members want %d", got, want)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
@ -157,8 +157,8 @@ func TestClient_LANReap(t *testing.T) {
|
|
|
|
|
testrpc.WaitForLeader(t, c1.RPC, "dc1")
|
|
|
|
|
|
|
|
|
|
retry.Run(t, func(r *retry.R) {
|
|
|
|
|
require.Len(r, s1.LANMembers(), 2)
|
|
|
|
|
require.Len(r, c1.LANMembers(), 2)
|
|
|
|
|
require.Len(r, s1.LANMembersInAgentPartition(), 2)
|
|
|
|
|
require.Len(r, c1.LANMembersInAgentPartition(), 2)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Check the router has both
|
|
|
|
@ -172,7 +172,7 @@ func TestClient_LANReap(t *testing.T) {
|
|
|
|
|
s1.Shutdown()
|
|
|
|
|
|
|
|
|
|
retry.Run(t, func(r *retry.R) {
|
|
|
|
|
require.Len(r, c1.LANMembers(), 1)
|
|
|
|
|
require.Len(r, c1.LANMembersInAgentPartition(), 1)
|
|
|
|
|
server := c1.router.FindLANServer()
|
|
|
|
|
require.Nil(t, server)
|
|
|
|
|
})
|
|
|
|
@ -193,15 +193,15 @@ func TestClient_JoinLAN_Invalid(t *testing.T) {
|
|
|
|
|
defer c1.Shutdown()
|
|
|
|
|
|
|
|
|
|
// Try to join
|
|
|
|
|
if _, err := c1.JoinLAN([]string{joinAddrLAN(s1)}); err == nil {
|
|
|
|
|
if _, err := c1.JoinLAN([]string{joinAddrLAN(s1)}, nil); err == nil {
|
|
|
|
|
t.Fatal("should error")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
time.Sleep(50 * time.Millisecond)
|
|
|
|
|
if len(s1.LANMembers()) != 1 {
|
|
|
|
|
if len(s1.LANMembersInAgentPartition()) != 1 {
|
|
|
|
|
t.Fatalf("should not join")
|
|
|
|
|
}
|
|
|
|
|
if len(c1.LANMembers()) != 1 {
|
|
|
|
|
if len(c1.LANMembersInAgentPartition()) != 1 {
|
|
|
|
|
t.Fatalf("should not join")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -217,7 +217,7 @@ func TestClient_JoinWAN_Invalid(t *testing.T) {
|
|
|
|
|
defer c1.Shutdown()
|
|
|
|
|
|
|
|
|
|
// Try to join
|
|
|
|
|
if _, err := c1.JoinLAN([]string{joinAddrWAN(s1)}); err == nil {
|
|
|
|
|
if _, err := c1.JoinLAN([]string{joinAddrWAN(s1)}, nil); err == nil {
|
|
|
|
|
t.Fatal("should error")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -225,7 +225,7 @@ func TestClient_JoinWAN_Invalid(t *testing.T) {
|
|
|
|
|
if len(s1.WANMembers()) != 1 {
|
|
|
|
|
t.Fatalf("should not join")
|
|
|
|
|
}
|
|
|
|
|
if len(c1.LANMembers()) != 1 {
|
|
|
|
|
if len(c1.LANMembersInAgentPartition()) != 1 {
|
|
|
|
|
t.Fatalf("should not join")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -250,11 +250,11 @@ func TestClient_RPC(t *testing.T) {
|
|
|
|
|
joinLAN(t, c1, s1)
|
|
|
|
|
|
|
|
|
|
// Check the members
|
|
|
|
|
if len(s1.LANMembers()) != 2 {
|
|
|
|
|
if len(s1.LANMembersInAgentPartition()) != 2 {
|
|
|
|
|
t.Fatalf("bad len")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(c1.LANMembers()) != 2 {
|
|
|
|
|
if len(c1.LANMembersInAgentPartition()) != 2 {
|
|
|
|
|
t.Fatalf("bad len")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -354,10 +354,10 @@ func TestClient_RPC_Pool(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Wait for both agents to finish joining
|
|
|
|
|
retry.Run(t, func(r *retry.R) {
|
|
|
|
|
if got, want := len(s1.LANMembers()), 2; got != want {
|
|
|
|
|
if got, want := len(s1.LANMembersInAgentPartition()), 2; got != want {
|
|
|
|
|
r.Fatalf("got %d server LAN members want %d", got, want)
|
|
|
|
|
}
|
|
|
|
|
if got, want := len(c1.LANMembers()), 2; got != want {
|
|
|
|
|
if got, want := len(c1.LANMembersInAgentPartition()), 2; got != want {
|
|
|
|
|
r.Fatalf("got %d client LAN members want %d", got, want)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
@ -418,12 +418,12 @@ func TestClient_RPC_ConsulServerPing(t *testing.T) {
|
|
|
|
|
c.router.GetLANManager().ResetRebalanceTimer()
|
|
|
|
|
time.Sleep(time.Second)
|
|
|
|
|
|
|
|
|
|
if len(c.LANMembers()) != numServers+numClients {
|
|
|
|
|
t.Errorf("bad len: %d", len(c.LANMembers()))
|
|
|
|
|
if len(c.LANMembersInAgentPartition()) != numServers+numClients {
|
|
|
|
|
t.Errorf("bad len: %d", len(c.LANMembersInAgentPartition()))
|
|
|
|
|
}
|
|
|
|
|
for _, s := range servers {
|
|
|
|
|
if len(s.LANMembers()) != numServers+numClients {
|
|
|
|
|
t.Errorf("bad len: %d", len(s.LANMembers()))
|
|
|
|
|
if len(s.LANMembersInAgentPartition()) != numServers+numClients {
|
|
|
|
|
t.Errorf("bad len: %d", len(s.LANMembersInAgentPartition()))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -476,10 +476,10 @@ func TestClient_RPC_TLS(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Wait for joins to finish/RPC to succeed
|
|
|
|
|
retry.Run(t, func(r *retry.R) {
|
|
|
|
|
if got, want := len(s1.LANMembers()), 2; got != want {
|
|
|
|
|
if got, want := len(s1.LANMembersInAgentPartition()), 2; got != want {
|
|
|
|
|
r.Fatalf("got %d server LAN members want %d", got, want)
|
|
|
|
|
}
|
|
|
|
|
if got, want := len(c1.LANMembers()), 2; got != want {
|
|
|
|
|
if got, want := len(c1.LANMembersInAgentPartition()), 2; got != want {
|
|
|
|
|
r.Fatalf("got %d client LAN members want %d", got, want)
|
|
|
|
|
}
|
|
|
|
|
if err := c1.RPC("Status.Ping", struct{}{}, &out); err != nil {
|
|
|
|
@ -684,10 +684,10 @@ func TestClient_SnapshotRPC_TLS(t *testing.T) {
|
|
|
|
|
// Try to join.
|
|
|
|
|
joinLAN(t, c1, s1)
|
|
|
|
|
retry.Run(t, func(r *retry.R) {
|
|
|
|
|
if got, want := len(s1.LANMembers()), 2; got != want {
|
|
|
|
|
if got, want := len(s1.LANMembersInAgentPartition()), 2; got != want {
|
|
|
|
|
r.Fatalf("got %d server members want %d", got, want)
|
|
|
|
|
}
|
|
|
|
|
if got, want := len(c1.LANMembers()), 2; got != want {
|
|
|
|
|
if got, want := len(c1.LANMembersInAgentPartition()), 2; got != want {
|
|
|
|
|
r.Fatalf("got %d client members want %d", got, want)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -746,10 +746,10 @@ func TestClientServer_UserEvent(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Check the members
|
|
|
|
|
retry.Run(t, func(r *retry.R) {
|
|
|
|
|
if got, want := len(s1.LANMembers()), 2; got != want {
|
|
|
|
|
if got, want := len(s1.LANMembersInAgentPartition()), 2; got != want {
|
|
|
|
|
r.Fatalf("got %d server LAN members want %d", got, want)
|
|
|
|
|
}
|
|
|
|
|
if got, want := len(c1.LANMembers()), 2; got != want {
|
|
|
|
|
if got, want := len(c1.LANMembersInAgentPartition()), 2; got != want {
|
|
|
|
|
r.Fatalf("got %d client LAN members want %d", got, want)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
@ -845,8 +845,8 @@ func TestClient_ShortReconnectTimeout(t *testing.T) {
|
|
|
|
|
// up to 10x the time in the case of slow CI.
|
|
|
|
|
require.Eventually(t,
|
|
|
|
|
func() bool {
|
|
|
|
|
return len(cluster.Servers[0].LANMembers()) == 2 &&
|
|
|
|
|
len(cluster.Clients[0].LANMembers()) == 2
|
|
|
|
|
return len(cluster.Servers[0].LANMembersInAgentPartition()) == 2 &&
|
|
|
|
|
len(cluster.Clients[0].LANMembersInAgentPartition()) == 2
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
time.Second,
|
|
|
|
|