mirror of https://github.com/status-im/consul.git
Test joining a Serf pool
This commit is contained in:
parent
8c853d31a7
commit
c644f1e57b
|
@ -42,3 +42,36 @@ func TestClient_StartStop(t *testing.T) {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClient_JoinLAN(t *testing.T) {
|
||||||
|
dir1, s1 := testServer(t)
|
||||||
|
defer os.RemoveAll(dir1)
|
||||||
|
defer s1.Shutdown()
|
||||||
|
|
||||||
|
dir2, c1 := testClient(t)
|
||||||
|
defer os.RemoveAll(dir2)
|
||||||
|
defer c1.Shutdown()
|
||||||
|
|
||||||
|
// Try to join
|
||||||
|
addr := fmt.Sprintf("127.0.0.1:%d",
|
||||||
|
s1.config.SerfLANConfig.MemberlistConfig.Port)
|
||||||
|
if err := c1.JoinLAN(addr); err != nil {
|
||||||
|
t.Fatalf("err: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the members
|
||||||
|
if len(s1.LANMembers()) != 2 {
|
||||||
|
t.Fatalf("bad len")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(c1.LANMembers()) != 2 {
|
||||||
|
t.Fatalf("bad len")
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(10 * time.Millisecond)
|
||||||
|
|
||||||
|
// Check we have a new consul
|
||||||
|
if len(c1.consuls) != 1 {
|
||||||
|
t.Fatalf("expected consul server")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue