From 551790729f1d26d75c1d3fa1411e341eb367f9f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Tyczy=C5=84ski?= Date: Thu, 13 Jan 2022 11:33:26 +0100 Subject: [PATCH] Remove selflink references in different testing-related files --- pkg/controller/cronjob/injection.go | 2 -- pkg/controller/cronjob/utils_test.go | 1 - pkg/controller/podautoscaler/horizontal_test.go | 2 -- pkg/controller/volume/persistentvolume/framework_test.go | 2 -- pkg/controller/volume/persistentvolume/index_test.go | 1 - .../framework/plugins/volumebinding/binder_test.go | 1 - .../test/integration/registration_test.go | 5 ----- staging/src/k8s.io/client-go/testing/fixture_test.go | 1 - .../k8s.io/client-go/tools/events/eventseries_test.go | 2 -- staging/src/k8s.io/client-go/tools/record/event_test.go | 9 ++------- staging/src/k8s.io/client-go/tools/reference/ref_test.go | 4 ++-- .../src/k8s.io/client-go/util/jsonpath/jsonpath_test.go | 3 +-- .../controllers/service/controller_test.go | 7 ------- test/integration/events/events_test.go | 1 - 14 files changed, 5 insertions(+), 36 deletions(-) diff --git a/pkg/controller/cronjob/injection.go b/pkg/controller/cronjob/injection.go index 56c93451d74..83b26d66ccc 100644 --- a/pkg/controller/cronjob/injection.go +++ b/pkg/controller/cronjob/injection.go @@ -18,7 +18,6 @@ package cronjob import ( "context" - "fmt" "sync" batchv1 "k8s.io/api/batch/v1" @@ -143,7 +142,6 @@ func (f *fakeJobControl) CreateJob(namespace string, job *batchv1.Job) (*batchv1 if f.CreateErr != nil { return nil, f.CreateErr } - job.SelfLink = fmt.Sprintf("/apis/batch/v1/namespaces/%s/jobs/%s", namespace, job.Name) f.Jobs = append(f.Jobs, *job) job.UID = "test-uid" return job, nil diff --git a/pkg/controller/cronjob/utils_test.go b/pkg/controller/cronjob/utils_test.go index 863a5d290bb..092df867ea1 100644 --- a/pkg/controller/cronjob/utils_test.go +++ b/pkg/controller/cronjob/utils_test.go @@ -43,7 +43,6 @@ func TestGetJobFromTemplate2(t *testing.T) { Name: "mycronjob", Namespace: "snazzycats", UID: types.UID("1a2b3c"), - SelfLink: "/apis/batch/v1/namespaces/snazzycats/jobs/mycronjob", }, Spec: batchv1.CronJobSpec{ Schedule: "* * * * ?", diff --git a/pkg/controller/podautoscaler/horizontal_test.go b/pkg/controller/podautoscaler/horizontal_test.go index 6f4cbe1115f..dbc664ee1bc 100644 --- a/pkg/controller/podautoscaler/horizontal_test.go +++ b/pkg/controller/podautoscaler/horizontal_test.go @@ -209,7 +209,6 @@ func (tc *testCase) prepareTestClient(t *testing.T) (*fake.Clientset, *metricsfa ObjectMeta: metav1.ObjectMeta{ Name: hpaName, Namespace: namespace, - SelfLink: "experimental/v1/namespaces/" + namespace + "/horizontalpodautoscalers/" + hpaName, }, Spec: autoscalingv2.HorizontalPodAutoscalerSpec{ ScaleTargetRef: autoscalingv2.CrossVersionObjectReference{ @@ -2876,7 +2875,6 @@ func TestAvoidUnnecessaryUpdates(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "test-hpa", Namespace: "test-namespace", - SelfLink: "experimental/v1/namespaces/test-namespace/horizontalpodautoscalers/test-hpa", }, Spec: autoscalingv2.HorizontalPodAutoscalerSpec{ ScaleTargetRef: autoscalingv2.CrossVersionObjectReference{ diff --git a/pkg/controller/volume/persistentvolume/framework_test.go b/pkg/controller/volume/persistentvolume/framework_test.go index 4aa66c7cad5..4dd786ce160 100644 --- a/pkg/controller/volume/persistentvolume/framework_test.go +++ b/pkg/controller/volume/persistentvolume/framework_test.go @@ -404,8 +404,6 @@ func newClaim(name, claimUID, capacity, boundToVolume string, phase v1.Persisten Phase: phase, }, } - // Make sure ref.GetReference(claim) works - claim.ObjectMeta.SelfLink = "/api/v1/namespaces/" + testNamespace + "/persistentvolumeclaims/" + name if len(annotations) > 0 { claim.Annotations = make(map[string]string) diff --git a/pkg/controller/volume/persistentvolume/index_test.go b/pkg/controller/volume/persistentvolume/index_test.go index cc0af4cf61d..7350fe39299 100644 --- a/pkg/controller/volume/persistentvolume/index_test.go +++ b/pkg/controller/volume/persistentvolume/index_test.go @@ -1296,7 +1296,6 @@ func TestFindingPreboundVolumes(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "claim01", Namespace: "myns", - SelfLink: "/api/v1/namespaces/myns/persistentvolumeclaims/claim01", }, Spec: v1.PersistentVolumeClaimSpec{ AccessModes: []v1.PersistentVolumeAccessMode{v1.ReadWriteOnce}, diff --git a/pkg/scheduler/framework/plugins/volumebinding/binder_test.go b/pkg/scheduler/framework/plugins/volumebinding/binder_test.go index e354f18198c..8d45e646112 100644 --- a/pkg/scheduler/framework/plugins/volumebinding/binder_test.go +++ b/pkg/scheduler/framework/plugins/volumebinding/binder_test.go @@ -622,7 +622,6 @@ func makeTestPVC(name, size, node string, pvcBoundState int, pvName, resourceVer Namespace: "testns", UID: types.UID("pvc-uid"), ResourceVersion: resourceVersion, - SelfLink: "/api/v1/namespaces/testns/persistentvolumeclaims/" + name, }, Spec: v1.PersistentVolumeClaimSpec{ Resources: v1.ResourceRequirements{ diff --git a/staging/src/k8s.io/apiextensions-apiserver/test/integration/registration_test.go b/staging/src/k8s.io/apiextensions-apiserver/test/integration/registration_test.go index def24eda620..c1b5f3f7bd6 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/test/integration/registration_test.go +++ b/staging/src/k8s.io/apiextensions-apiserver/test/integration/registration_test.go @@ -360,7 +360,6 @@ func TestEtcdStorage(t *testing.T) { Metadata: Metadata{ Name: "noxus.mygroup.example.com", Namespace: "", - SelfLink: "", }, }, }, @@ -372,7 +371,6 @@ func TestEtcdStorage(t *testing.T) { Metadata: Metadata{ Name: "foo", Namespace: "the-cruel-default", - SelfLink: "", // TODO double check: empty? }, }, }, @@ -385,7 +383,6 @@ func TestEtcdStorage(t *testing.T) { Metadata: Metadata{ Name: "curlets.mygroup.example.com", Namespace: "", - SelfLink: "", }, }, }, @@ -398,7 +395,6 @@ func TestEtcdStorage(t *testing.T) { Metadata: Metadata{ Name: "bar", Namespace: "", - SelfLink: "", // TODO double check: empty? }, }, }, @@ -452,5 +448,4 @@ type metaObject struct { type Metadata struct { Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"` Namespace string `json:"namespace,omitempty" protobuf:"bytes,2,opt,name=namespace"` - SelfLink string `json:"selfLink,omitempty" protobuf:"bytes,3,opt,name=selfLink"` } diff --git a/staging/src/k8s.io/client-go/testing/fixture_test.go b/staging/src/k8s.io/client-go/testing/fixture_test.go index 5aab05aa6c3..fb947f818c2 100644 --- a/staging/src/k8s.io/client-go/testing/fixture_test.go +++ b/staging/src/k8s.io/client-go/testing/fixture_test.go @@ -46,7 +46,6 @@ func getArbitraryResource(s schema.GroupVersionResource, name, namespace string) "generateName": "test_generateName", "uid": "test_uid", "resourceVersion": "test_resourceVersion", - "selfLink": "test_selfLink", }, "data": strconv.Itoa(rand.Int()), }, diff --git a/staging/src/k8s.io/client-go/tools/events/eventseries_test.go b/staging/src/k8s.io/client-go/tools/events/eventseries_test.go index 3fe01a29464..17097aae537 100644 --- a/staging/src/k8s.io/client-go/tools/events/eventseries_test.go +++ b/staging/src/k8s.io/client-go/tools/events/eventseries_test.go @@ -216,7 +216,6 @@ func TestFinishSeries(t *testing.T) { hostname, _ := os.Hostname() testPod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ - SelfLink: "/api/v1/namespaces/baz/pods/foo", Name: "foo", Namespace: "baz", UID: "bar", @@ -288,7 +287,6 @@ func TestRefreshExistingEventSeries(t *testing.T) { hostname, _ := os.Hostname() testPod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ - SelfLink: "/api/v1/namespaces/baz/pods/foo", Name: "foo", Namespace: "baz", UID: "bar", diff --git a/staging/src/k8s.io/client-go/tools/record/event_test.go b/staging/src/k8s.io/client-go/tools/record/event_test.go index f003b1d371d..54435bca6ae 100644 --- a/staging/src/k8s.io/client-go/tools/record/event_test.go +++ b/staging/src/k8s.io/client-go/tools/record/event_test.go @@ -129,7 +129,6 @@ func TestNonRacyShutdown(t *testing.T) { func TestEventf(t *testing.T) { testPod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ - SelfLink: "/api/v1/namespaces/baz/pods/foo", Name: "foo", Namespace: "baz", UID: "bar", @@ -137,7 +136,6 @@ func TestEventf(t *testing.T) { } testPod2 := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ - SelfLink: "/api/v1/namespaces/baz/pods/foo", Name: "foo", Namespace: "baz", UID: "differentUid", @@ -554,9 +552,8 @@ func TestLotsOfEvents(t *testing.T) { func TestEventfNoNamespace(t *testing.T) { testPod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ - SelfLink: "/api/v1/namespaces/default/pods/foo", - Name: "foo", - UID: "bar", + Name: "foo", + UID: "bar", }, } testRef, err := ref.GetPartialReference(scheme.Scheme, testPod, "spec.containers[2]") @@ -651,7 +648,6 @@ func TestEventfNoNamespace(t *testing.T) { func TestMultiSinkCache(t *testing.T) { testPod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ - SelfLink: "/api/v1/namespaces/baz/pods/foo", Name: "foo", Namespace: "baz", UID: "bar", @@ -659,7 +655,6 @@ func TestMultiSinkCache(t *testing.T) { } testPod2 := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ - SelfLink: "/api/v1/namespaces/baz/pods/foo", Name: "foo", Namespace: "baz", UID: "differentUid", diff --git a/staging/src/k8s.io/client-go/tools/reference/ref_test.go b/staging/src/k8s.io/client-go/tools/reference/ref_test.go index 7a478374e2b..c7042c62160 100644 --- a/staging/src/k8s.io/client-go/tools/reference/ref_test.go +++ b/staging/src/k8s.io/client-go/tools/reference/ref_test.go @@ -43,7 +43,7 @@ func TestGetReferenceRefVersion(t *testing.T) { { name: "v1 GV from scheme", input: &TestRuntimeObj{ - ObjectMeta: metav1.ObjectMeta{SelfLink: "/bad-selflink/unused"}, + ObjectMeta: metav1.ObjectMeta{}, }, groupVersion: schema.GroupVersion{Group: "", Version: "v1"}, expectedRefVersion: "v1", @@ -51,7 +51,7 @@ func TestGetReferenceRefVersion(t *testing.T) { { name: "foo.group/v3 GV from scheme", input: &TestRuntimeObj{ - ObjectMeta: metav1.ObjectMeta{SelfLink: "/bad-selflink/unused"}, + ObjectMeta: metav1.ObjectMeta{}, }, groupVersion: schema.GroupVersion{Group: "foo.group", Version: "v3"}, expectedRefVersion: "foo.group/v3", diff --git a/staging/src/k8s.io/client-go/util/jsonpath/jsonpath_test.go b/staging/src/k8s.io/client-go/util/jsonpath/jsonpath_test.go index 197e73e84dd..6473d259049 100644 --- a/staging/src/k8s.io/client-go/util/jsonpath/jsonpath_test.go +++ b/staging/src/k8s.io/client-go/util/jsonpath/jsonpath_test.go @@ -793,8 +793,7 @@ func TestRunningPodsJSONPathOutput(t *testing.T) { } }, { - "resourceVersion": "", - "selfLink": "" + "resourceVersion": "" } ] }`) diff --git a/staging/src/k8s.io/cloud-provider/controllers/service/controller_test.go b/staging/src/k8s.io/cloud-provider/controllers/service/controller_test.go index 0b738639339..bce21cc051f 100644 --- a/staging/src/k8s.io/cloud-provider/controllers/service/controller_test.go +++ b/staging/src/k8s.io/cloud-provider/controllers/service/controller_test.go @@ -54,7 +54,6 @@ func newService(name string, uid types.UID, serviceType v1.ServiceType) *v1.Serv Name: name, Namespace: "default", UID: uid, - SelfLink: "/api/v1/namespaces/default/services/" + name, }, Spec: v1.ServiceSpec{ Type: serviceType, @@ -167,7 +166,6 @@ func TestSyncLoadBalancerIfNeeded(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "udp-service", Namespace: "default", - SelfLink: "/api/v1/namespaces/default/services/udp-service", }, Spec: v1.ServiceSpec{ Ports: []v1.ServicePort{{ @@ -188,7 +186,6 @@ func TestSyncLoadBalancerIfNeeded(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "basic-service1", Namespace: "default", - SelfLink: "/api/v1/namespaces/default/services/basic-service1", }, Spec: v1.ServiceSpec{ Ports: []v1.ServicePort{{ @@ -209,7 +206,6 @@ func TestSyncLoadBalancerIfNeeded(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "sctp-service", Namespace: "default", - SelfLink: "/api/v1/namespaces/default/services/sctp-service", }, Spec: v1.ServiceSpec{ Ports: []v1.ServicePort{{ @@ -294,7 +290,6 @@ func TestSyncLoadBalancerIfNeeded(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "basic-service1", Namespace: "default", - SelfLink: "/api/v1/namespaces/default/services/basic-service1", DeletionTimestamp: &metav1.Time{ Time: time.Now(), }, @@ -327,7 +322,6 @@ func TestSyncLoadBalancerIfNeeded(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "basic-service1", Namespace: "default", - SelfLink: "/api/v1/namespaces/default/services/basic-service1", }, Spec: v1.ServiceSpec{ Ports: []v1.ServicePort{{ @@ -348,7 +342,6 @@ func TestSyncLoadBalancerIfNeeded(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "basic-service1", Namespace: "default", - SelfLink: "/api/v1/namespaces/default/services/basic-service1", Finalizers: []string{servicehelper.LoadBalancerCleanupFinalizer}, }, Spec: v1.ServiceSpec{ diff --git a/test/integration/events/events_test.go b/test/integration/events/events_test.go index bb8830076ef..bce66117840 100644 --- a/test/integration/events/events_test.go +++ b/test/integration/events/events_test.go @@ -43,7 +43,6 @@ func TestEventCompatibility(t *testing.T) { testPod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ - SelfLink: "/api/v1/namespaces/default/pods/foo", Name: "foo", Namespace: "default", UID: "bar",