@@ -83,7 +83,7 @@ func TestControlPlane(t *testing.T) {
83
83
"machine-1" : & clusterv1.Machine {
84
84
ObjectMeta : metav1.ObjectMeta {Name : "m1" },
85
85
Spec : clusterv1.MachineSpec {
86
- Version : ptr .To ("v1.31.0" ),
86
+ Version : ptr .To ("v1.31.0" ), // up-to-date
87
87
FailureDomain : ptr .To ("one" ),
88
88
InfrastructureRef : corev1.ObjectReference {Kind : "GenericInfrastructureMachine" , APIVersion : "infrastructure.cluster.x-k8s.io/v1beta1" , Name : "m1" },
89
89
}},
@@ -104,15 +104,22 @@ func TestControlPlane(t *testing.T) {
104
104
"machine-4" : & clusterv1.Machine {
105
105
ObjectMeta : metav1.ObjectMeta {Name : "m4" , DeletionTimestamp : ptr .To (metav1 .Now ())}, // deleted
106
106
Spec : clusterv1.MachineSpec {
107
- Version : ptr .To ("v1.31.0" ),
107
+ Version : ptr .To ("v1.31.0" ), // up-to-date
108
108
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" },
110
117
}},
111
118
}
112
119
controlPlane , err := NewControlPlane (ctx , nil , env .GetClient (), cluster , kcp , machines )
113
120
g .Expect (err ).NotTo (HaveOccurred ())
114
121
115
- g .Expect (controlPlane .Machines ).To (HaveLen (4 ))
122
+ g .Expect (controlPlane .Machines ).To (HaveLen (5 ))
116
123
117
124
machinesNotUptoDate , machinesNotUptoDateConditionMessages := controlPlane .NotUpToDateMachines ()
118
125
g .Expect (machinesNotUptoDate .Names ()).To (ConsistOf ("m2" , "m3" ))
@@ -127,12 +134,12 @@ func TestControlPlane(t *testing.T) {
127
134
g .Expect (machinesNotUptoDateLogMessages ).To (HaveKeyWithValue ("m3" , []string {"Machine version \" v1.29.3\" is not equal to KCP version \" v1.31.0\" " }))
128
135
129
136
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" ))
132
139
133
140
fd , err := controlPlane .NextFailureDomainForScaleUp (ctx )
134
141
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
136
143
})
137
144
}
138
145
0 commit comments