diff --git a/staging/src/k8s.io/apiserver/pkg/server/config_test.go b/staging/src/k8s.io/apiserver/pkg/server/config_test.go index ae5e23c084a..532cf49d3d4 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/config_test.go +++ b/staging/src/k8s.io/apiserver/pkg/server/config_test.go @@ -30,6 +30,7 @@ import ( "github.com/google/go-cmp/cmp" "k8s.io/apimachinery/pkg/util/json" "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/waitgroup" auditinternal "k8s.io/apiserver/pkg/apis/audit" "k8s.io/apiserver/pkg/audit" @@ -179,6 +180,24 @@ func TestNewWithDelegate(t *testing.T) { "/readyz/shutdown", } checkExpectedPathsAtRoot(server.URL, expectedPaths, t) + + // wait for health (max-in-flight-filter is initialized asynchronously, can take a few milliseconds to initialize) + if err := wait.PollImmediate(100*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) { + // healthz checks are installed in PrepareRun + resp, err := http.Get(server.URL + "/healthz?exclude=wrapping-health&exclude=delegate-health") + if err != nil { + t.Fatal(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 + }); err != nil { + t.Fatal(err) + } checkPath(server.URL+"/healthz", http.StatusInternalServerError, `[+]ping ok [+]log ok [-]wrapping-health failed: reason withheld