Merge pull request #73516 from mfojtik/fix-post-hook-test
Wait for post-hooks to run before checking the healthz output Kubernetes-commit: bc406490a5339160931b6661bd239ce977885df6
This commit is contained in:
commit
9d07fe72a5
File diff suppressed because it is too large
Load Diff
|
|
@ -56,7 +56,9 @@ func TestNewWithDelegate(t *testing.T) {
|
||||||
w.WriteHeader(http.StatusForbidden)
|
w.WriteHeader(http.StatusForbidden)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
delegatePostStartHookChan := make(chan struct{})
|
||||||
delegateServer.AddPostStartHook("delegate-post-start-hook", func(context PostStartHookContext) error {
|
delegateServer.AddPostStartHook("delegate-post-start-hook", func(context PostStartHookContext) error {
|
||||||
|
defer close(delegatePostStartHookChan)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -82,7 +84,9 @@ func TestNewWithDelegate(t *testing.T) {
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
wrappingPostStartHookChan := make(chan struct{})
|
||||||
wrappingServer.AddPostStartHook("wrapping-post-start-hook", func(context PostStartHookContext) error {
|
wrappingServer.AddPostStartHook("wrapping-post-start-hook", func(context PostStartHookContext) error {
|
||||||
|
defer close(wrappingPostStartHookChan)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -94,6 +98,10 @@ func TestNewWithDelegate(t *testing.T) {
|
||||||
server := httptest.NewServer(wrappingServer.Handler)
|
server := httptest.NewServer(wrappingServer.Handler)
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
|
// Wait for the hooks to finish before checking the response
|
||||||
|
<-delegatePostStartHookChan
|
||||||
|
<-wrappingPostStartHookChan
|
||||||
|
|
||||||
checkPath(server.URL, http.StatusOK, `{
|
checkPath(server.URL, http.StatusOK, `{
|
||||||
"paths": [
|
"paths": [
|
||||||
"/apis",
|
"/apis",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue