From 77b5ad2fb02262b3bdd72c317cc3e9b26cb874ee Mon Sep 17 00:00:00 2001 From: Mengjiao Liu Date: Tue, 25 May 2021 11:16:07 +0800 Subject: [PATCH] Part of master to controlplane in test/integration(1.22) --- test/integration/framework/master_utils.go | 20 ++++++++--------- test/integration/job/job_test.go | 4 ++-- .../integration/master/kube_apiserver_test.go | 22 +++++++++---------- test/integration/quota/quota_test.go | 8 +++---- .../serviceaccount/service_account_test.go | 2 +- test/integration/util/util.go | 6 ++--- test/integration/volumescheduling/util.go | 4 ++-- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/test/integration/framework/master_utils.go b/test/integration/framework/master_utils.go index 194b2f8455c..0c6f4de73ba 100644 --- a/test/integration/framework/master_utils.go +++ b/test/integration/framework/master_utils.go @@ -87,19 +87,19 @@ func alwaysEmpty(req *http.Request) (*authauthenticator.Response, bool, error) { }, true, nil } -// MasterReceiver can be used to provide the master to a custom incoming server function -type MasterReceiver interface { +// APIServerReceiver can be used to provide the API server to a custom incoming server function +type APIServerReceiver interface { SetMaster(m *controlplane.Instance) } -// MasterHolder implements -type MasterHolder struct { +// APIServerHolder implements +type APIServerHolder struct { Initialized chan struct{} M *controlplane.Instance } // SetMaster assigns the current master. -func (h *MasterHolder) SetMaster(m *controlplane.Instance) { +func (h *APIServerHolder) SetMaster(m *controlplane.Instance) { h.M = m close(h.Initialized) } @@ -124,7 +124,7 @@ func DefaultOpenAPIConfig() *openapicommon.Config { } // startApiserverOrDie starts a kubernetes master and an httpserver to handle api requests -func startApiserverOrDie(controlPlaneConfig *controlplane.Config, incomingServer *httptest.Server, masterReceiver MasterReceiver) (*controlplane.Instance, *httptest.Server, CloseFunc) { +func startApiserverOrDie(controlPlaneConfig *controlplane.Config, incomingServer *httptest.Server, apiServerReceiver APIServerReceiver) (*controlplane.Instance, *httptest.Server, CloseFunc) { var m *controlplane.Instance var s *httptest.Server @@ -214,8 +214,8 @@ func startApiserverOrDie(controlPlaneConfig *controlplane.Config, incomingServer closeFn() klog.Fatalf("error in bringing up the master: %v", err) } - if masterReceiver != nil { - masterReceiver.SetMaster(m) + if apiServerReceiver != nil { + apiServerReceiver.SetMaster(m) } // TODO have this start method actually use the normal start sequence for the API server @@ -351,8 +351,8 @@ func RunAnAPIServer(masterConfig *controlplane.Config) (*controlplane.Instance, } // RunAnAPIServerUsingServer starts up an instance using the provided config on the specified server. -func RunAnAPIServerUsingServer(controlPlaneConfig *controlplane.Config, s *httptest.Server, masterReceiver MasterReceiver) (*controlplane.Instance, *httptest.Server, CloseFunc) { - return startApiserverOrDie(controlPlaneConfig, s, masterReceiver) +func RunAnAPIServerUsingServer(controlPlaneConfig *controlplane.Config, s *httptest.Server, apiServerReceiver APIServerReceiver) (*controlplane.Instance, *httptest.Server, CloseFunc) { + return startApiserverOrDie(controlPlaneConfig, s, apiServerReceiver) } // SharedEtcd creates a storage config for a shared etcd instance, with a unique prefix. diff --git a/test/integration/job/job_test.go b/test/integration/job/job_test.go index 057c9ef6e76..ffd29eca7b5 100644 --- a/test/integration/job/job_test.go +++ b/test/integration/job/job_test.go @@ -608,7 +608,7 @@ func createJobWithDefaults(ctx context.Context, clientSet clientset.Interface, n func setup(t *testing.T, nsBaseName string) (framework.CloseFunc, *restclient.Config, clientset.Interface, *v1.Namespace) { masterConfig := framework.NewIntegrationTestControlPlaneConfig() - _, server, masterCloseFn := framework.RunAnAPIServer(masterConfig) + _, server, apiServerCloseFn := framework.RunAnAPIServer(masterConfig) config := restclient.Config{Host: server.URL} clientSet, err := clientset.NewForConfig(&config) @@ -618,7 +618,7 @@ func setup(t *testing.T, nsBaseName string) (framework.CloseFunc, *restclient.Co ns := framework.CreateTestingNamespace(nsBaseName, server, t) closeFn := func() { framework.DeleteTestingNamespace(ns, server, t) - masterCloseFn() + apiServerCloseFn() } return closeFn, &config, clientSet, ns } diff --git a/test/integration/master/kube_apiserver_test.go b/test/integration/master/kube_apiserver_test.go index 0925620f588..3f442906210 100644 --- a/test/integration/master/kube_apiserver_test.go +++ b/test/integration/master/kube_apiserver_test.go @@ -434,9 +434,9 @@ func verifyEndpointsWithIPs(servers []*kubeapiservertesting.TestServer, ips []st return reflect.DeepEqual(listenAddresses, ips) } -func testReconcilersMasterLease(t *testing.T, leaseCount int, masterCount int) { +func testReconcilersMasterLease(t *testing.T, leaseCount int, apiServerCount int) { var leaseServers = make([]*kubeapiservertesting.TestServer, leaseCount) - var masterCountServers = make([]*kubeapiservertesting.TestServer, masterCount) + var apiServerCountServers = make([]*kubeapiservertesting.TestServer, apiServerCount) etcd := framework.SharedEtcd() instanceOptions := &kubeapiservertesting.TestServerInstanceOptions{ @@ -447,25 +447,25 @@ func testReconcilersMasterLease(t *testing.T, leaseCount int, masterCount int) { defer registry.CleanupStorage() wg := sync.WaitGroup{} - // 1. start masterCount api servers - for i := 0; i < masterCount; i++ { - // start master count api server + // 1. start apiServerCount api servers + for i := 0; i < apiServerCount; i++ { + // start count api server wg.Add(1) go func(i int) { defer wg.Done() server := kubeapiservertesting.StartTestServerOrDie(t, instanceOptions, []string{ "--endpoint-reconciler-type", "master-count", "--advertise-address", fmt.Sprintf("10.0.1.%v", i+1), - "--apiserver-count", fmt.Sprintf("%v", masterCount), + "--apiserver-count", fmt.Sprintf("%v", apiServerCount), }, etcd) - masterCountServers[i] = server + apiServerCountServers[i] = server }(i) } wg.Wait() // 2. verify master count servers have registered if err := wait.PollImmediate(3*time.Second, 2*time.Minute, func() (bool, error) { - client, err := kubernetes.NewForConfig(masterCountServers[0].ClientConfig) + client, err := kubernetes.NewForConfig(apiServerCountServers[0].ClientConfig) if err != nil { t.Logf("error creating client: %v", err) return false, nil @@ -475,7 +475,7 @@ func testReconcilersMasterLease(t *testing.T, leaseCount int, masterCount int) { t.Logf("error fetching endpoints: %v", err) return false, nil } - return verifyEndpointsWithIPs(masterCountServers, getEndpointIPs(endpoints)), nil + return verifyEndpointsWithIPs(apiServerCountServers, getEndpointIPs(endpoints)), nil }); err != nil { t.Fatalf("master count endpoints failed to register: %v", err) } @@ -502,8 +502,8 @@ func testReconcilersMasterLease(t *testing.T, leaseCount int, masterCount int) { time.Sleep(3 * time.Second) - // 4. Shutdown the masterCount server - for _, server := range masterCountServers { + // 4. Shutdown the apiServerCount server + for _, server := range apiServerCountServers { server.TearDownFn() } diff --git a/test/integration/quota/quota_test.go b/test/integration/quota/quota_test.go index 3ca33a7c79d..c2fd6518476 100644 --- a/test/integration/quota/quota_test.go +++ b/test/integration/quota/quota_test.go @@ -54,8 +54,8 @@ import ( // quota_test.go:100: Took 4.196205966s to scale up without quota // quota_test.go:115: Took 12.021640372s to scale up with quota func TestQuota(t *testing.T) { - // Set up a master - h := &framework.MasterHolder{Initialized: make(chan struct{})} + // Set up a 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) @@ -245,8 +245,8 @@ func scale(t *testing.T, namespace string, clientset *clientset.Clientset) { } func TestQuotaLimitedResourceDenial(t *testing.T) { - // Set up a master - h := &framework.MasterHolder{Initialized: make(chan struct{})} + // Set up an 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) diff --git a/test/integration/serviceaccount/service_account_test.go b/test/integration/serviceaccount/service_account_test.go index c7b6eadd7b7..cac4de0acfc 100644 --- a/test/integration/serviceaccount/service_account_test.go +++ b/test/integration/serviceaccount/service_account_test.go @@ -322,7 +322,7 @@ func TestServiceAccountTokenAuthentication(t *testing.T) { // It is the responsibility of the caller to ensure the returned stopFunc is called func startServiceAccountTestServer(t *testing.T) (*clientset.Clientset, restclient.Config, func(), error) { // Listener - h := &framework.MasterHolder{Initialized: make(chan struct{})} + h := &framework.APIServerHolder{Initialized: make(chan struct{})} apiServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { <-h.Initialized h.M.GenericAPIServer.Handler.ServeHTTP(w, req) diff --git a/test/integration/util/util.go b/test/integration/util/util.go index 3e1efba9259..9133cccf029 100644 --- a/test/integration/util/util.go +++ b/test/integration/util/util.go @@ -56,7 +56,7 @@ 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.MasterHolder{Initialized: make(chan struct{})} + 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) @@ -329,8 +329,8 @@ func InitTestMaster(t *testing.T, nsPrefix string, admission admission.Interface CancelFn: cancelFunc, } - // 1. Create master - h := &framework.MasterHolder{Initialized: make(chan struct{})} + // 1. Create control plane + 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) diff --git a/test/integration/volumescheduling/util.go b/test/integration/volumescheduling/util.go index da4af6a5807..2b1366b7568 100644 --- a/test/integration/volumescheduling/util.go +++ b/test/integration/volumescheduling/util.go @@ -64,8 +64,8 @@ func initTestMaster(t *testing.T, nsPrefix string, admission admission.Interface cancelFn: cancelFunc, } - // 1. Create master - h := &framework.MasterHolder{Initialized: make(chan struct{})} + // 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)