Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve rare flakiness on TestWorkerQueueHealthy #185

Merged
merged 1 commit into from
Apr 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions pkg/util/workerqueue/workerqueue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,28 @@ func TestWorkerQueueHealthy(t *testing.T) {
go wq.Run(1, stop)

// Yield to the scheduler to ensure the worker queue goroutine can run.
time.Sleep(10 * time.Millisecond)
assert.Equal(t, 1, wq.RunCount())
assert.Nil(t, wq.Healthy())
err := wait.Poll(100*time.Millisecond, 3*time.Second, func() (done bool, err error) {
if (wq.RunCount() == 1) && wq.Healthy() == nil {
return true, nil
}

return false, nil
})
assert.Nil(t, err)

close(done) // Ensure the handler no longer blocks.
close(stop) // Stop the worker queue.

// Yield to the scheduler again to ensure the worker queue goroutine can
// finish.
time.Sleep(10 * time.Millisecond)
assert.Equal(t, 0, wq.RunCount())
assert.EqualError(t, wq.Healthy(), "want 1 worker goroutine(s), got 0")
err = wait.Poll(100*time.Millisecond, 3*time.Second, func() (done bool, err error) {
if (wq.RunCount() == 0) && wq.Healthy() != nil {
return true, nil
}

return false, nil
})
assert.Nil(t, err)
}

func TestWorkQueueHealthCheck(t *testing.T) {
Expand Down