Skip to content

Commit

Permalink
Increased wait time on test util WaitForCluster
Browse files Browse the repository at this point in the history
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
  • Loading branch information
olljanat committed Oct 10, 2018
1 parent 486ad69 commit 15b0b09
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions manager/state/raft/testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ func AdvanceTicks(clockSource *fakeclock.FakeClock, ticks int) {
func WaitForCluster(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[uint64]*TestNode) {
err := testutils.PollFunc(clockSource, func() error {
var prev *etcdraft.Status
var leadNode *TestNode
nodeLoop:
for _, n := range nodes {
if prev == nil {
prev = new(etcdraft.Status)
*prev = n.Status()
for _, n2 := range nodes {
if n2.Config.ID == prev.Lead && n2.ReadyForProposals() {
if n2.Config.ID == prev.Lead {
leadNode = n2
continue nodeLoop
}
}
Expand All @@ -84,7 +86,15 @@ func WaitForCluster(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[ui
}
return errors.New("did not find leader in member list")
}
return nil
// Don't raise error just because test machine is running slowly
for i := 0; i < 5; i++ {
if leadNode.ReadyForProposals() {
return nil
} else {
time.Sleep(2 * time.Second)
}
}
return errors.New("leader is not ready")
})
require.NoError(t, err)
}
Expand Down

0 comments on commit 15b0b09

Please sign in to comment.