diff --git a/test/integration/util/util.go b/test/integration/util/util.go index 7de4df06bd9..aa59f6131bc 100644 --- a/test/integration/util/util.go +++ b/test/integration/util/util.go @@ -20,7 +20,6 @@ import ( "context" "errors" "fmt" - "net/http" "net/http/httptest" "testing" "time" @@ -68,18 +67,11 @@ type ShutdownFunc func() // StartApiserver starts a local API server for testing and returns the handle to the URL and the shutdown function to stop it. func StartApiserver() (string, ShutdownFunc) { - h := &framework.APIServerHolder{Initialized: make(chan struct{})} - s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - <-h.Initialized - h.M.GenericAPIServer.Handler.ServeHTTP(w, req) - })) - - _, _, closeFn := framework.RunAnAPIServerUsingServer(framework.NewIntegrationTestControlPlaneConfig(), s, h) + _, s, closeFn := framework.RunAnAPIServer(framework.NewIntegrationTestControlPlaneConfig()) shutdownFunc := func() { klog.Infof("destroying API server") closeFn() - s.Close() klog.Infof("destroyed API server") } return s.URL, shutdownFunc diff --git a/test/integration/volumescheduling/util.go b/test/integration/volumescheduling/util.go index ac23685fe7e..18e6c81341f 100644 --- a/test/integration/volumescheduling/util.go +++ b/test/integration/volumescheduling/util.go @@ -18,7 +18,6 @@ package volumescheduling import ( "context" - "net/http" "net/http/httptest" "testing" "time" @@ -63,12 +62,6 @@ func initTestAPIServer(t *testing.T, nsPrefix string, admission admission.Interf } // 1. Create API server - h := &framework.APIServerHolder{Initialized: make(chan struct{})} - s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - <-h.Initialized - h.M.GenericAPIServer.Handler.ServeHTTP(w, req) - })) - controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfig() resourceConfig := controlplane.DefaultAPIResourceConfigSource() controlPlaneConfig.ExtraConfig.APIResourceConfigSource = resourceConfig @@ -77,7 +70,8 @@ func initTestAPIServer(t *testing.T, nsPrefix string, admission admission.Interf controlPlaneConfig.GenericConfig.AdmissionControl = admission } - _, testCtx.httpServer, testCtx.closeFn = framework.RunAnAPIServerUsingServer(controlPlaneConfig, s, h) + _, testCtx.httpServer, testCtx.closeFn = framework.RunAnAPIServer(controlPlaneConfig) + s := testCtx.httpServer if nsPrefix != "default" { testCtx.ns = framework.CreateTestingNamespace(nsPrefix+string(uuid.NewUUID()), s, t)