From 00aebee17f2e16358375a639c12ddfc13b046fac Mon Sep 17 00:00:00 2001 From: Michael McCune Date: Wed, 14 Apr 2021 11:21:52 -0400 Subject: [PATCH] add test fixes for fake client changes This change adds a few fixes to the tests that are using the fake client, in specific these changes are related to this controller runtime change[0]. [0] https://github.com/kubernetes-sigs/controller-runtime/pull/1306 --- .../machinehealthcheck_controller_test.go | 8 ++++++++ pkg/util/testing/testing.go | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/pkg/controller/machinehealthcheck/machinehealthcheck_controller_test.go b/pkg/controller/machinehealthcheck/machinehealthcheck_controller_test.go index c6e01310a7..e6dab45051 100644 --- a/pkg/controller/machinehealthcheck/machinehealthcheck_controller_test.go +++ b/pkg/controller/machinehealthcheck/machinehealthcheck_controller_test.go @@ -1171,6 +1171,8 @@ func TestGetTargetsFromMHC(t *testing.T) { machineAnnotationKey: fmt.Sprintf("%s/%s", namespace, "match1"), }, Labels: map[string]string{}, + // the following line is to account for a change in the fake client, see https://github.com/kubernetes-sigs/controller-runtime/pull/1306 + ResourceVersion: "999", }, TypeMeta: metav1.TypeMeta{ Kind: "Node", @@ -1238,6 +1240,8 @@ func TestGetTargetsFromMHC(t *testing.T) { machineAnnotationKey: fmt.Sprintf("%s/%s", namespace, "match1"), }, Labels: map[string]string{}, + // the following line is to account for a change in the fake client, see https://github.com/kubernetes-sigs/controller-runtime/pull/1306 + ResourceVersion: "999", }, TypeMeta: metav1.TypeMeta{ Kind: "Node", @@ -1300,6 +1304,8 @@ func TestGetTargetsFromMHC(t *testing.T) { Namespace: namespace, Labels: map[string]string{"foo": "bar"}, OwnerReferences: []metav1.OwnerReference{{Kind: "MachineSet"}}, + // the following line is to account for a change in the fake client, see https://github.com/kubernetes-sigs/controller-runtime/pull/1306 + ResourceVersion: "999", }, Spec: mapiv1beta1.MachineSpec{}, Status: mapiv1beta1.MachineStatus{}, @@ -1323,6 +1329,8 @@ func TestGetTargetsFromMHC(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "node1", Namespace: metav1.NamespaceNone, + // the following line is to account for a change in the fake client, see https://github.com/kubernetes-sigs/controller-runtime/pull/1306 + ResourceVersion: "999", }, }, }, diff --git a/pkg/util/testing/testing.go b/pkg/util/testing/testing.go index c610ef9bcb..80c8b578ed 100644 --- a/pkg/util/testing/testing.go +++ b/pkg/util/testing/testing.go @@ -118,6 +118,8 @@ func NewMachine(name string, nodeName string) *mapiv1.Machine { Controller: pointer.BoolPtr(true), }, }, + // the following line is to account for a change in the fake client, see https://github.com/kubernetes-sigs/controller-runtime/pull/1306 + ResourceVersion: "999", }, Spec: mapiv1.MachineSpec{}, } @@ -138,6 +140,8 @@ func NewMachineHealthCheck(name string) *mapiv1.MachineHealthCheck { ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: Namespace, + // the following line is to account for a change in the fake client, see https://github.com/kubernetes-sigs/controller-runtime/pull/1306 + ResourceVersion: "999", }, TypeMeta: metav1.TypeMeta{ Kind: "MachineHealthCheck",