Refactor scheduler integration test that starts APIServer in a non-standarized manner

This commit is contained in:
Wei Huang 2022-05-08 22:28:13 -07:00
parent bf52c1fd46
commit c96109a321
No known key found for this signature in database
GPG Key ID: 17AFE05D01EA77B2

View File

@ -350,29 +350,25 @@ 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()
if admission != nil {
controlPlaneConfig.GenericConfig.AdmissionControl = admission
}
_, testCtx.HTTPServer, testCtx.CloseFn = framework.RunAnAPIServerUsingServer(controlPlaneConfig, s, h)
_, testCtx.HTTPServer, testCtx.CloseFn = framework.RunAnAPIServer(controlPlaneConfig)
if nsPrefix != "default" {
testCtx.NS = framework.CreateTestingNamespace(nsPrefix+string(uuid.NewUUID()), s, t)
testCtx.NS = framework.CreateTestingNamespace(nsPrefix+string(uuid.NewUUID()), testCtx.HTTPServer, t)
} else {
testCtx.NS = framework.CreateTestingNamespace("default", s, t)
testCtx.NS = framework.CreateTestingNamespace("default", testCtx.HTTPServer, t)
}
// 2. Create kubeclient
kubeConfig := &restclient.Config{
QPS: -1, Host: s.URL,
QPS: 100,
Burst: 100,
Host: testCtx.HTTPServer.URL,
ContentConfig: restclient.ContentConfig{
GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"},
},