Skip to content

Commit

Permalink
add test fixes for fake client changes
Browse files Browse the repository at this point in the history
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] kubernetes-sigs/controller-runtime#1306
  • Loading branch information
elmiko committed Apr 14, 2021
1 parent de04079 commit 92bdf66
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -1259,6 +1263,8 @@ func TestGetTargetsFromMHC(t *testing.T) {
machineAnnotationKey: fmt.Sprintf("%s/%s", namespace, "match2"),
},
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",
Expand Down Expand Up @@ -1300,6 +1306,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{},
Expand Down Expand Up @@ -1402,6 +1410,8 @@ func TestGetNodeFromMachine(t *testing.T) {
machineAnnotationKey: fmt.Sprintf("%s/%s", namespace, "machine"),
},
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",
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/nodelink/nodelink_controller_test.go
Expand Up @@ -40,6 +40,8 @@ func node(name, providerID string, addresses []corev1.NodeAddress, taints []core
ObjectMeta: metav1.ObjectMeta{
Name: name,
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",
},
TypeMeta: metav1.TypeMeta{
Kind: "Node",
Expand Down Expand Up @@ -81,6 +83,8 @@ func machine(name, providerID string, addresses []corev1.NodeAddress, taints []c
Kind: ownerControllerKind,
},
},
// 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: "Machine",
Expand Down
4 changes: 4 additions & 0 deletions pkg/util/testing/testing.go
Expand Up @@ -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{},
}
Expand All @@ -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",
Expand Down

0 comments on commit 92bdf66

Please sign in to comment.