Skip to content

Commit

Permalink
Flakey test fix: TestWorkQueueHealthCheck
Browse files Browse the repository at this point in the history
I believe this shoud fix this flakey test
  • Loading branch information
markmandel authored and enocom committed Jun 13, 2018
1 parent 19671a7 commit cf9b85f
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions pkg/util/workerqueue/workerqueue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,26 @@ func TestWorkQueueHealthCheck(t *testing.T) {
url := server.URL + "/live"

f := func(t *testing.T, url string, status int) {
resp, err := http.Get(url)
assert.Nil(t, err)
defer resp.Body.Close() // nolint: errcheck

body, err := ioutil.ReadAll(resp.Body)
// sometimes the http server takes a bit to start up
err := wait.PollImmediate(time.Second, 5*time.Second, func() (bool, error) {
resp, err := http.Get(url)
assert.Nil(t, err)
defer resp.Body.Close() // nolint: errcheck

if status != resp.StatusCode {
return false, nil
}

body, err := ioutil.ReadAll(resp.Body)
assert.Nil(t, err)
assert.Equal(t, status, resp.StatusCode)
assert.Equal(t, []byte("{}\n"), body)

return true, nil
})

assert.Nil(t, err)
assert.Equal(t, status, resp.StatusCode)
assert.Equal(t, []byte("{}\n"), body)
}

f(t, url, http.StatusOK)
Expand Down

0 comments on commit cf9b85f

Please sign in to comment.