consul: improve test reliability for session ttls

This commit is contained in:
Ryan Uber 2015-01-09 17:18:11 -08:00
parent 44efa3cca4
commit 084643abee

View file

@ -352,19 +352,24 @@ func TestServer_SessionTTL_Failover(t *testing.T) {
} }
// Find the new leader // Find the new leader
time.Sleep(200 * time.Millisecond) testutil.WaitForResult(func() (bool, error) {
leader = nil leader = nil
for _, s := range servers { for _, s := range servers {
if s.IsLeader() { if s.IsLeader() {
leader = s leader = s
}
}
if leader == nil {
return false, fmt.Errorf("Should have a new leader")
} }
}
if leader == nil {
t.Fatalf("Should have a new leader")
}
// Ensure session timer is restored // Ensure session timer is restored
if _, ok := leader.sessionTimers[id1]; !ok { if _, ok := leader.sessionTimers[id1]; !ok {
t.Fatalf("missing session timer") return false, fmt.Errorf("missing session timer")
} }
return true, nil
}, func(err error) {
t.Fatalf("err: %s", err)
})
} }