mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #102986 from mengjiao-liu/rename-master
Rename master to apiserver in test/integration
This commit is contained in:
commit
73eac7ae66
@ -58,10 +58,10 @@ func multiEtcdSetup(t testing.TB) (clientset.Interface, framework.CloseFunc) {
|
||||
controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfigWithOptions(&opts)
|
||||
// Switch off endpoints reconciler to avoid unnecessary operations.
|
||||
controlPlaneConfig.ExtraConfig.EndpointReconcilerType = reconcilers.NoneEndpointReconcilerType
|
||||
_, s, stopMaster := framework.RunAnAPIServer(controlPlaneConfig)
|
||||
_, s, stopAPIServer := framework.RunAnAPIServer(controlPlaneConfig)
|
||||
|
||||
closeFn := func() {
|
||||
stopMaster()
|
||||
stopAPIServer()
|
||||
stopEtcd1()
|
||||
stopEtcd0()
|
||||
}
|
||||
|
@ -69,18 +69,18 @@ func TestOverlappingBuiltInResources(t *testing.T) {
|
||||
|
||||
// TestOverlappingCustomResourceAPIService ensures creating and deleting a custom resource overlapping with APIServices does not destroy APIService data
|
||||
func TestOverlappingCustomResourceAPIService(t *testing.T) {
|
||||
master := StartRealMasterOrDie(t)
|
||||
defer master.Cleanup()
|
||||
apiServer := StartRealAPIServerOrDie(t)
|
||||
defer apiServer.Cleanup()
|
||||
|
||||
apiServiceClient, err := apiregistrationclient.NewForConfig(master.Config)
|
||||
apiServiceClient, err := apiregistrationclient.NewForConfig(apiServer.Config)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
crdClient, err := crdclient.NewForConfig(master.Config)
|
||||
crdClient, err := crdclient.NewForConfig(apiServer.Config)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
dynamicClient, err := dynamic.NewForConfig(master.Config)
|
||||
dynamicClient, err := dynamic.NewForConfig(apiServer.Config)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -180,7 +180,7 @@ func TestOverlappingCustomResourceAPIService(t *testing.T) {
|
||||
}
|
||||
|
||||
// discovery is handled by the built-in handler
|
||||
v1Resources, err := master.Client.Discovery().ServerResourcesForGroupVersion("apiregistration.k8s.io/v1")
|
||||
v1Resources, err := apiServer.Client.Discovery().ServerResourcesForGroupVersion("apiregistration.k8s.io/v1")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -191,7 +191,7 @@ func TestOverlappingCustomResourceAPIService(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
v2Resources, err := master.Client.Discovery().ServerResourcesForGroupVersion("apiregistration.k8s.io/v2")
|
||||
v2Resources, err := apiServer.Client.Discovery().ServerResourcesForGroupVersion("apiregistration.k8s.io/v2")
|
||||
if err == nil {
|
||||
t.Fatalf("expected error looking up apiregistration.k8s.io/v2 discovery, got %#v", v2Resources)
|
||||
}
|
||||
@ -231,14 +231,14 @@ func TestOverlappingCustomResourceAPIService(t *testing.T) {
|
||||
|
||||
// TestOverlappingCustomResourceCustomResourceDefinition ensures creating and deleting a custom resource overlapping with CustomResourceDefinition does not destroy CustomResourceDefinition data
|
||||
func TestOverlappingCustomResourceCustomResourceDefinition(t *testing.T) {
|
||||
master := StartRealMasterOrDie(t)
|
||||
defer master.Cleanup()
|
||||
apiServer := StartRealAPIServerOrDie(t)
|
||||
defer apiServer.Cleanup()
|
||||
|
||||
crdClient, err := crdclient.NewForConfig(master.Config)
|
||||
crdClient, err := crdclient.NewForConfig(apiServer.Config)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
dynamicClient, err := dynamic.NewForConfig(master.Config)
|
||||
dynamicClient, err := dynamic.NewForConfig(apiServer.Config)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -331,7 +331,7 @@ func TestOverlappingCustomResourceCustomResourceDefinition(t *testing.T) {
|
||||
}
|
||||
|
||||
// discovery is handled by the built-in handler
|
||||
v1Resources, err := master.Client.Discovery().ServerResourcesForGroupVersion("apiextensions.k8s.io/v1")
|
||||
v1Resources, err := apiServer.Client.Discovery().ServerResourcesForGroupVersion("apiextensions.k8s.io/v1")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -342,7 +342,7 @@ func TestOverlappingCustomResourceCustomResourceDefinition(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
v2Resources, err := master.Client.Discovery().ServerResourcesForGroupVersion("apiextensions.k8s.io/v2")
|
||||
v2Resources, err := apiServer.Client.Discovery().ServerResourcesForGroupVersion("apiextensions.k8s.io/v2")
|
||||
if err == nil {
|
||||
t.Fatalf("expected error looking up apiregistration.k8s.io/v2 discovery, got %#v", v2Resources)
|
||||
}
|
||||
|
@ -35,19 +35,19 @@ import (
|
||||
|
||||
// TestCrossGroupStorage tests to make sure that all objects stored in an expected location in etcd can be converted/read.
|
||||
func TestCrossGroupStorage(t *testing.T) {
|
||||
master := StartRealMasterOrDie(t, func(opts *options.ServerRunOptions) {
|
||||
apiServer := StartRealAPIServerOrDie(t, func(opts *options.ServerRunOptions) {
|
||||
// force enable all resources so we can check storage.
|
||||
})
|
||||
defer master.Cleanup()
|
||||
defer apiServer.Cleanup()
|
||||
|
||||
etcdStorageData := GetEtcdStorageData()
|
||||
|
||||
crossGroupResources := map[schema.GroupVersionKind][]Resource{}
|
||||
|
||||
master.Client.CoreV1().Namespaces().Create(context.TODO(), &v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: testNamespace}}, metav1.CreateOptions{})
|
||||
apiServer.Client.CoreV1().Namespaces().Create(context.TODO(), &v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: testNamespace}}, metav1.CreateOptions{})
|
||||
|
||||
// Group by persisted GVK
|
||||
for _, resourceToPersist := range master.Resources {
|
||||
for _, resourceToPersist := range apiServer.Resources {
|
||||
gvk := resourceToPersist.Mapping.GroupVersionKind
|
||||
data, exists := etcdStorageData[resourceToPersist.Mapping.Resource]
|
||||
if !exists {
|
||||
@ -90,7 +90,7 @@ func TestCrossGroupStorage(t *testing.T) {
|
||||
|
||||
data := etcdStorageData[resource.Mapping.Resource]
|
||||
// create object
|
||||
resourceClient, obj, err := JSONToUnstructured(data.Stub, ns, resource.Mapping, master.Dynamic)
|
||||
resourceClient, obj, err := JSONToUnstructured(data.Stub, ns, resource.Mapping, apiServer.Dynamic)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -107,7 +107,7 @@ func TestCrossGroupStorage(t *testing.T) {
|
||||
watches = map[schema.GroupVersionResource]watch.Interface{}
|
||||
)
|
||||
for _, resource := range resources {
|
||||
clients[resource.Mapping.Resource] = master.Dynamic.Resource(resource.Mapping.Resource).Namespace(ns)
|
||||
clients[resource.Mapping.Resource] = apiServer.Dynamic.Resource(resource.Mapping.Resource).Namespace(ns)
|
||||
versionedData[resource.Mapping.Resource], err = clients[resource.Mapping.Resource].Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("error finding resource via %s: %v", resource.Mapping.Resource.GroupVersion().String(), err)
|
||||
@ -130,7 +130,7 @@ func TestCrossGroupStorage(t *testing.T) {
|
||||
}
|
||||
|
||||
// Update in etcd
|
||||
if _, err := master.KV.Put(context.Background(), data.ExpectedEtcdPath, string(versionedJSON)); err != nil {
|
||||
if _, err := apiServer.KV.Put(context.Background(), data.ExpectedEtcdPath, string(versionedJSON)); err != nil {
|
||||
t.Error(err)
|
||||
continue
|
||||
}
|
||||
|
@ -70,14 +70,14 @@ var allowMissingTestdataFixtures = map[schema.GroupVersionKind]bool{
|
||||
// It will also fail when a type gets moved to a different location. Be very careful in this situation because
|
||||
// it essentially means that you will be break old clusters unless you create some migration path for the old data.
|
||||
func TestEtcdStoragePath(t *testing.T) {
|
||||
master := StartRealMasterOrDie(t, func(opts *options.ServerRunOptions) {
|
||||
apiServer := StartRealAPIServerOrDie(t, func(opts *options.ServerRunOptions) {
|
||||
})
|
||||
defer master.Cleanup()
|
||||
defer dumpEtcdKVOnFailure(t, master.KV)
|
||||
defer apiServer.Cleanup()
|
||||
defer dumpEtcdKVOnFailure(t, apiServer.KV)
|
||||
|
||||
client := &allClient{dynamicClient: master.Dynamic}
|
||||
client := &allClient{dynamicClient: apiServer.Dynamic}
|
||||
|
||||
if _, err := master.Client.CoreV1().Namespaces().Create(context.TODO(), &v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: testNamespace}}, metav1.CreateOptions{}); err != nil {
|
||||
if _, err := apiServer.Client.CoreV1().Namespaces().Create(context.TODO(), &v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: testNamespace}}, metav1.CreateOptions{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ func TestEtcdStoragePath(t *testing.T) {
|
||||
etcdSeen := map[schema.GroupVersionResource]empty{}
|
||||
cohabitatingResources := map[string]map[schema.GroupVersionKind]empty{}
|
||||
|
||||
for _, resourceToPersist := range master.Resources {
|
||||
for _, resourceToPersist := range apiServer.Resources {
|
||||
t.Run(resourceToPersist.Mapping.Resource.String(), func(t *testing.T) {
|
||||
mapping := resourceToPersist.Mapping
|
||||
gvk := resourceToPersist.Mapping.GroupVersionKind
|
||||
@ -136,7 +136,7 @@ func TestEtcdStoragePath(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
if err := client.createPrerequisites(master.Mapper, testNamespace, testData.Prerequisites, all); err != nil {
|
||||
if err := client.createPrerequisites(apiServer.Mapper, testNamespace, testData.Prerequisites, all); err != nil {
|
||||
t.Fatalf("failed to create prerequisites for %s: %#v", gvResource, err)
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ func TestEtcdStoragePath(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
output, err := getFromEtcd(master.KV, testData.ExpectedEtcdPath)
|
||||
output, err := getFromEtcd(apiServer.KV, testData.ExpectedEtcdPath)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get from etcd for %s: %#v", gvResource, err)
|
||||
}
|
||||
|
@ -61,8 +61,8 @@ AwEHoUQDQgAEH6cuzP8XuD5wal6wf9M6xDljTOPLX2i8uIp/C/ASqiIGUeeKQtX0
|
||||
/IR3qCXyThP/dbCiHrF3v1cuhBOHY8CLVg==
|
||||
-----END EC PRIVATE KEY-----`
|
||||
|
||||
// StartRealMasterOrDie starts an API master that is appropriate for use in tests that require one of every resource
|
||||
func StartRealMasterOrDie(t *testing.T, configFuncs ...func(*options.ServerRunOptions)) *Master {
|
||||
// StartRealAPIServerOrDie starts an API server that is appropriate for use in tests that require one of every resource
|
||||
func StartRealAPIServerOrDie(t *testing.T, configFuncs ...func(*options.ServerRunOptions)) *Master {
|
||||
certDir, err := ioutil.TempDir("", t.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -156,7 +156,7 @@ func StartRealMasterOrDie(t *testing.T, configFuncs ...func(*options.ServerRunOp
|
||||
// Catch panics that occur in this go routine so we get a comprehensible failure
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
t.Errorf("Unexpected panic trying to start API master: %#v", err)
|
||||
t.Errorf("Unexpected panic trying to start API server: %#v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -434,7 +434,7 @@ func verifyEndpointsWithIPs(servers []*kubeapiservertesting.TestServer, ips []st
|
||||
return reflect.DeepEqual(listenAddresses, ips)
|
||||
}
|
||||
|
||||
func testReconcilersMasterLease(t *testing.T, leaseCount int, apiServerCount int) {
|
||||
func testReconcilersAPIServerLease(t *testing.T, leaseCount int, apiServerCount int) {
|
||||
var leaseServers = make([]*kubeapiservertesting.TestServer, leaseCount)
|
||||
var apiServerCountServers = make([]*kubeapiservertesting.TestServer, apiServerCount)
|
||||
etcd := framework.SharedEtcd()
|
||||
@ -463,7 +463,7 @@ func testReconcilersMasterLease(t *testing.T, leaseCount int, apiServerCount int
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
// 2. verify master count servers have registered
|
||||
// 2. verify API Server count servers have registered
|
||||
if err := wait.PollImmediate(3*time.Second, 2*time.Minute, func() (bool, error) {
|
||||
client, err := kubernetes.NewForConfig(apiServerCountServers[0].ClientConfig)
|
||||
if err != nil {
|
||||
@ -477,7 +477,7 @@ func testReconcilersMasterLease(t *testing.T, leaseCount int, apiServerCount int
|
||||
}
|
||||
return verifyEndpointsWithIPs(apiServerCountServers, getEndpointIPs(endpoints)), nil
|
||||
}); err != nil {
|
||||
t.Fatalf("master count endpoints failed to register: %v", err)
|
||||
t.Fatalf("API Server count endpoints failed to register: %v", err)
|
||||
}
|
||||
|
||||
// 3. start lease api servers
|
||||
@ -525,19 +525,19 @@ func testReconcilersMasterLease(t *testing.T, leaseCount int, apiServerCount int
|
||||
}
|
||||
}
|
||||
|
||||
func TestReconcilerMasterLeaseCombined(t *testing.T) {
|
||||
testReconcilersMasterLease(t, 1, 2)
|
||||
func TestReconcilerAPIServerLeaseCombined(t *testing.T) {
|
||||
testReconcilersAPIServerLease(t, 1, 2)
|
||||
}
|
||||
|
||||
func TestReconcilerMasterLeaseMultiMoreMasters(t *testing.T) {
|
||||
testReconcilersMasterLease(t, 2, 1)
|
||||
func TestReconcilerAPIServerLeaseMultiMoreAPIServers(t *testing.T) {
|
||||
testReconcilersAPIServerLease(t, 2, 1)
|
||||
}
|
||||
|
||||
func TestReconcilerMasterLeaseMultiCombined(t *testing.T) {
|
||||
testReconcilersMasterLease(t, 2, 2)
|
||||
func TestReconcilerAPIServerLeaseMultiCombined(t *testing.T) {
|
||||
testReconcilersAPIServerLease(t, 2, 2)
|
||||
}
|
||||
|
||||
func TestMultiMasterNodePortAllocation(t *testing.T) {
|
||||
func TestMultiAPIServerNodePortAllocation(t *testing.T) {
|
||||
var kubeAPIServers []*kubeapiservertesting.TestServer
|
||||
var clientAPIServers []*kubernetes.Clientset
|
||||
etcd := framework.SharedEtcd()
|
||||
|
@ -600,7 +600,7 @@ func countEndpoints(eps *corev1.Endpoints) int {
|
||||
return count
|
||||
}
|
||||
|
||||
func TestMasterService(t *testing.T) {
|
||||
func TestAPIServerService(t *testing.T) {
|
||||
_, s, closeFn := framework.RunAnAPIServer(framework.NewIntegrationTestControlPlaneConfig())
|
||||
defer closeFn()
|
||||
|
||||
|
@ -44,11 +44,11 @@ func scrapeMetrics(s *httptest.Server) (testutil.Metrics, error) {
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to contact metrics endpoint of master: %v", err)
|
||||
return nil, fmt.Errorf("Unable to contact metrics endpoint of API server: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("Non-200 response trying to scrape metrics from master: %v", resp)
|
||||
return nil, fmt.Errorf("Non-200 response trying to scrape metrics from API Server: %v", resp)
|
||||
}
|
||||
metrics := testutil.NewMetrics()
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
@ -62,12 +62,12 @@ func scrapeMetrics(s *httptest.Server) (testutil.Metrics, error) {
|
||||
func checkForExpectedMetrics(t *testing.T, metrics testutil.Metrics, expectedMetrics []string) {
|
||||
for _, expected := range expectedMetrics {
|
||||
if _, found := metrics[expected]; !found {
|
||||
t.Errorf("Master metrics did not include expected metric %q", expected)
|
||||
t.Errorf("API server metrics did not include expected metric %q", expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMasterProcessMetrics(t *testing.T) {
|
||||
func TestAPIServerProcessMetrics(t *testing.T) {
|
||||
if runtime.GOOS == "darwin" || runtime.GOOS == "windows" {
|
||||
t.Skipf("not supported on GOOS=%s", runtime.GOOS)
|
||||
}
|
||||
@ -87,7 +87,7 @@ func TestMasterProcessMetrics(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestApiserverMetrics(t *testing.T) {
|
||||
func TestAPIServerMetrics(t *testing.T) {
|
||||
_, s, closeFn := framework.RunAnAPIServer(nil)
|
||||
defer closeFn()
|
||||
|
||||
@ -115,7 +115,7 @@ func TestApiserverMetrics(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestApiserverMetricsLabels(t *testing.T) {
|
||||
func TestAPIServerMetricsLabels(t *testing.T) {
|
||||
_, s, closeFn := framework.RunAnAPIServer(nil)
|
||||
defer closeFn()
|
||||
|
||||
@ -242,7 +242,7 @@ func TestApiserverMetricsLabels(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApiserverMetricsPods(t *testing.T) {
|
||||
func TestAPIServerMetricsPods(t *testing.T) {
|
||||
callOrDie := func(_ interface{}, err error) {
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
@ -356,7 +356,7 @@ func TestApiserverMetricsPods(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApiserverMetricsNamespaces(t *testing.T) {
|
||||
func TestAPIServerMetricsNamespaces(t *testing.T) {
|
||||
callOrDie := func(_ interface{}, err error) {
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user