Skip to content

Commit

Permalink
Increased wait time on test utils WaitForCluster and WatchTaskCreate
Browse files Browse the repository at this point in the history
Signed-off-by: Olli Janatuinen <[email protected]>
  • Loading branch information
olljanat committed Oct 11, 2018
1 parent 486ad69 commit 5f167ca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func TestSessionReconnectsIfDispatcherErrors(t *testing.T) {
return fmt.Errorf("expecting 2 closed sessions, got %d", len(closedSessions))
}
return nil
}, 5*time.Second))
}, 10*time.Second))
}

type testSessionTracker struct {
Expand Down
2 changes: 1 addition & 1 deletion manager/orchestrator/testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func WatchTaskCreate(t *testing.T, watch chan events.Event) *api.Task {
if _, ok := event.(api.EventUpdateTask); ok {
assert.FailNow(t, "got EventUpdateTask when expecting EventCreateTask", fmt.Sprint(event))
}
case <-time.After(time.Second):
case <-time.After(2 * time.Second):
assert.FailNow(t, "no task creation")
}
}
Expand Down
13 changes: 11 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,14 @@ 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
}
time.Sleep(2 * time.Second)
}
return errors.New("leader is not ready")
})
require.NoError(t, err)
}
Expand Down

0 comments on commit 5f167ca

Please sign in to comment.