agent: make TestClient_RPC_ConsulServerPing more robust

This commit is contained in:
Frank Schroeder 2017-07-05 12:37:19 +02:00 committed by Frank Schröder
parent bbf715fdaf
commit 37202cc751
1 changed files with 8 additions and 8 deletions

View File

@ -229,11 +229,8 @@ func TestClient_RPC_ConsulServerPing(t *testing.T) {
var serverDirs []string var serverDirs []string
const numServers = 5 const numServers = 5
for n := numServers; n > 0; n-- { for n := 0; n < numServers; n++ {
var bootstrap bool bootstrap := n == 0
if n == numServers {
bootstrap = true
}
dir, s := testServerDCBootstrap(t, "dc1", bootstrap) dir, s := testServerDCBootstrap(t, "dc1", bootstrap)
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
defer s.Shutdown() defer s.Shutdown()
@ -252,10 +249,13 @@ func TestClient_RPC_ConsulServerPing(t *testing.T) {
joinLAN(t, c, s) joinLAN(t, c, s)
} }
for _, s := range servers {
retry.Run(t, func(r *retry.R) { r.Check(wantPeers(s, numServers)) })
}
// Sleep to allow Serf to sync, shuffle, and let the shuffle complete // Sleep to allow Serf to sync, shuffle, and let the shuffle complete
time.Sleep(100 * time.Millisecond)
c.servers.ResetRebalanceTimer() c.servers.ResetRebalanceTimer()
time.Sleep(100 * time.Millisecond) time.Sleep(time.Second)
if len(c.LANMembers()) != numServers+numClients { if len(c.LANMembers()) != numServers+numClients {
t.Errorf("bad len: %d", len(c.LANMembers())) t.Errorf("bad len: %d", len(c.LANMembers()))
@ -269,7 +269,7 @@ func TestClient_RPC_ConsulServerPing(t *testing.T) {
// Ping each server in the list // Ping each server in the list
var pingCount int var pingCount int
for range servers { for range servers {
time.Sleep(100 * time.Millisecond) time.Sleep(200 * time.Millisecond)
s := c.servers.FindServer() s := c.servers.FindServer()
ok, err := c.connPool.Ping(s.Datacenter, s.Addr, s.Version, s.UseTLS) ok, err := c.connPool.Ping(s.Datacenter, s.Addr, s.Version, s.UseTLS)
if !ok { if !ok {