Skip to content

Commit 6b8d018

Browse files
authored
Merge pull request #11398 from sbueringer/pr-fix-kcp-test
🐛 Fix TestControlPlane/MachinesUpToDate flake
2 parents c54a51b + b038612 commit 6b8d018

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

controlplane/kubeadm/internal/control_plane_test.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func TestControlPlane(t *testing.T) {
8383
"machine-1": &clusterv1.Machine{
8484
ObjectMeta: metav1.ObjectMeta{Name: "m1"},
8585
Spec: clusterv1.MachineSpec{
86-
Version: ptr.To("v1.31.0"),
86+
Version: ptr.To("v1.31.0"), // up-to-date
8787
FailureDomain: ptr.To("one"),
8888
InfrastructureRef: corev1.ObjectReference{Kind: "GenericInfrastructureMachine", APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1", Name: "m1"},
8989
}},
@@ -104,15 +104,22 @@ func TestControlPlane(t *testing.T) {
104104
"machine-4": &clusterv1.Machine{
105105
ObjectMeta: metav1.ObjectMeta{Name: "m4", DeletionTimestamp: ptr.To(metav1.Now())}, // deleted
106106
Spec: clusterv1.MachineSpec{
107-
Version: ptr.To("v1.31.0"),
107+
Version: ptr.To("v1.31.0"), // up-to-date
108108
FailureDomain: ptr.To("two"),
109-
InfrastructureRef: corev1.ObjectReference{Kind: "GenericInfrastructureMachine", APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1", Name: "m1"},
109+
InfrastructureRef: corev1.ObjectReference{Kind: "GenericInfrastructureMachine", APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1", Name: "m4"},
110+
}},
111+
"machine-5": &clusterv1.Machine{
112+
ObjectMeta: metav1.ObjectMeta{Name: "m5"},
113+
Spec: clusterv1.MachineSpec{
114+
Version: ptr.To("v1.31.0"), // up-to-date
115+
FailureDomain: ptr.To("three"),
116+
InfrastructureRef: corev1.ObjectReference{Kind: "GenericInfrastructureMachine", APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1", Name: "m5"},
110117
}},
111118
}
112119
controlPlane, err := NewControlPlane(ctx, nil, env.GetClient(), cluster, kcp, machines)
113120
g.Expect(err).NotTo(HaveOccurred())
114121

115-
g.Expect(controlPlane.Machines).To(HaveLen(4))
122+
g.Expect(controlPlane.Machines).To(HaveLen(5))
116123

117124
machinesNotUptoDate, machinesNotUptoDateConditionMessages := controlPlane.NotUpToDateMachines()
118125
g.Expect(machinesNotUptoDate.Names()).To(ConsistOf("m2", "m3"))
@@ -127,12 +134,12 @@ func TestControlPlane(t *testing.T) {
127134
g.Expect(machinesNotUptoDateLogMessages).To(HaveKeyWithValue("m3", []string{"Machine version \"v1.29.3\" is not equal to KCP version \"v1.31.0\""}))
128135

129136
upToDateMachines := controlPlane.UpToDateMachines()
130-
g.Expect(upToDateMachines).To(HaveLen(2))
131-
g.Expect(upToDateMachines.Names()).To(ConsistOf("m1", "m4"))
137+
g.Expect(upToDateMachines).To(HaveLen(3))
138+
g.Expect(upToDateMachines.Names()).To(ConsistOf("m1", "m4", "m5"))
132139

133140
fd, err := controlPlane.NextFailureDomainForScaleUp(ctx)
134141
g.Expect(err).NotTo(HaveOccurred())
135-
g.Expect(fd).To(Equal(ptr.To("two"))) // deleted up-to-date machines should not be counted when picking the next failure domain for scale up
142+
g.Expect(fd).To(Equal(ptr.To("two"))) // deleted up-to-date machines (m4) should not be counted when picking the next failure domain for scale up
136143
})
137144
}
138145

0 commit comments

Comments
 (0)