Skip to content

Commit 5f167ca

Browse files
committed
Increased wait time on test utils WaitForCluster and WatchTaskCreate
Signed-off-by: Olli Janatuinen <[email protected]>
1 parent 486ad69 commit 5f167ca

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

agent/agent_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func TestSessionReconnectsIfDispatcherErrors(t *testing.T) {
355355
return fmt.Errorf("expecting 2 closed sessions, got %d", len(closedSessions))
356356
}
357357
return nil
358-
}, 5*time.Second))
358+
}, 10*time.Second))
359359
}
360360

361361
type testSessionTracker struct {

manager/orchestrator/testutils/testutils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func WatchTaskCreate(t *testing.T, watch chan events.Event) *api.Task {
2222
if _, ok := event.(api.EventUpdateTask); ok {
2323
assert.FailNow(t, "got EventUpdateTask when expecting EventCreateTask", fmt.Sprint(event))
2424
}
25-
case <-time.After(time.Second):
25+
case <-time.After(2 * time.Second):
2626
assert.FailNow(t, "no task creation")
2727
}
2828
}

manager/state/raft/testutils/testutils.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@ func AdvanceTicks(clockSource *fakeclock.FakeClock, ticks int) {
6060
func WaitForCluster(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[uint64]*TestNode) {
6161
err := testutils.PollFunc(clockSource, func() error {
6262
var prev *etcdraft.Status
63+
var leadNode *TestNode
6364
nodeLoop:
6465
for _, n := range nodes {
6566
if prev == nil {
6667
prev = new(etcdraft.Status)
6768
*prev = n.Status()
6869
for _, n2 := range nodes {
69-
if n2.Config.ID == prev.Lead && n2.ReadyForProposals() {
70+
if n2.Config.ID == prev.Lead {
71+
leadNode = n2
7072
continue nodeLoop
7173
}
7274
}
@@ -84,7 +86,14 @@ func WaitForCluster(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[ui
8486
}
8587
return errors.New("did not find leader in member list")
8688
}
87-
return nil
89+
// Don't raise error just because test machine is running slowly
90+
for i := 0; i < 5; i++ {
91+
if leadNode.ReadyForProposals() {
92+
return nil
93+
}
94+
time.Sleep(2 * time.Second)
95+
}
96+
return errors.New("leader is not ready")
8897
})
8998
require.NoError(t, err)
9099
}

0 commit comments

Comments
 (0)