Deflake TestPrepareRun
Kubernetes-commit: ba4aade23a76969d7598fb7ac170891c183e7327
This commit is contained in:
parent
1cafa89bf5
commit
a70d9c48f0
|
|
@ -40,6 +40,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/apimachinery/pkg/version"
|
||||
"k8s.io/apiserver/pkg/apis/example"
|
||||
examplev1 "k8s.io/apiserver/pkg/apis/example/v1"
|
||||
|
|
@ -320,6 +321,7 @@ func TestPrepareRun(t *testing.T) {
|
|||
server := httptest.NewServer(s.Handler.Director)
|
||||
defer server.Close()
|
||||
done := make(chan struct{})
|
||||
defer close(done)
|
||||
|
||||
s.PrepareRun()
|
||||
s.RunPostStartHooks(done)
|
||||
|
|
@ -329,10 +331,19 @@ func TestPrepareRun(t *testing.T) {
|
|||
assert.NoError(err)
|
||||
assert.Equal(http.StatusOK, resp.StatusCode)
|
||||
|
||||
// healthz checks are installed in PrepareRun
|
||||
resp, err = http.Get(server.URL + "/healthz")
|
||||
assert.NoError(err)
|
||||
assert.Equal(http.StatusOK, resp.StatusCode)
|
||||
// wait for health (max-in-flight-filter is initialized asynchronously, can take a few milliseconds to initialize)
|
||||
assert.NoError(wait.PollImmediate(100*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) {
|
||||
// healthz checks are installed in PrepareRun
|
||||
resp, err = http.Get(server.URL + "/healthz")
|
||||
assert.NoError(err)
|
||||
data, _ := ioutil.ReadAll(resp.Body)
|
||||
if http.StatusOK != resp.StatusCode {
|
||||
t.Logf("got %d", resp.StatusCode)
|
||||
t.Log(string(data))
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}))
|
||||
resp, err = http.Get(server.URL + "/healthz/ping")
|
||||
assert.NoError(err)
|
||||
assert.Equal(http.StatusOK, resp.StatusCode)
|
||||
|
|
|
|||
Loading…
Reference in New Issue