Skip to content

Commit dd2065d

Browse files
committed
fixup! machinepool: set v1beta2 Paused condition
1 parent 81e4d2a commit dd2065d

File tree

1 file changed

+60
-7
lines changed

1 file changed

+60
-7
lines changed

exp/internal/controllers/machinepool_controller_test.go

+60-7
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ func TestMachinePoolOwnerReference(t *testing.T) {
158158
Replicas: ptr.To[int32](1),
159159
ClusterName: "invalid",
160160
},
161+
Status: expv1.MachinePoolStatus{
162+
V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{
163+
Type: clusterv1.PausedV1Beta2Condition,
164+
Status: metav1.ConditionFalse,
165+
Reason: clusterv1.NotPausedV1Beta2Reason,
166+
}}},
167+
},
161168
}
162169

163170
machinePoolValidCluster := &expv1.MachinePool{
@@ -176,6 +183,13 @@ func TestMachinePoolOwnerReference(t *testing.T) {
176183
},
177184
ClusterName: "test-cluster",
178185
},
186+
Status: expv1.MachinePoolStatus{
187+
V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{
188+
Type: clusterv1.PausedV1Beta2Condition,
189+
Status: metav1.ConditionFalse,
190+
Reason: clusterv1.NotPausedV1Beta2Reason,
191+
}}},
192+
},
179193
}
180194

181195
machinePoolValidMachinePool := &expv1.MachinePool{
@@ -197,6 +211,13 @@ func TestMachinePoolOwnerReference(t *testing.T) {
197211
},
198212
ClusterName: "test-cluster",
199213
},
214+
Status: expv1.MachinePoolStatus{
215+
V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{
216+
Type: clusterv1.PausedV1Beta2Condition,
217+
Status: metav1.ConditionFalse,
218+
Reason: clusterv1.NotPausedV1Beta2Reason,
219+
}}},
220+
},
200221
}
201222

202223
testCases := []struct {
@@ -345,6 +366,11 @@ func TestReconcileMachinePoolRequest(t *testing.T) {
345366
{Name: "test"},
346367
},
347368
ObservedGeneration: 1,
369+
V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{
370+
Type: clusterv1.PausedV1Beta2Condition,
371+
Status: metav1.ConditionFalse,
372+
Reason: clusterv1.NotPausedV1Beta2Reason,
373+
}}},
348374
},
349375
},
350376
expected: expected{
@@ -390,6 +416,11 @@ func TestReconcileMachinePoolRequest(t *testing.T) {
390416
Name: "test-node",
391417
},
392418
},
419+
V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{
420+
Type: clusterv1.PausedV1Beta2Condition,
421+
Status: metav1.ConditionFalse,
422+
Reason: clusterv1.NotPausedV1Beta2Reason,
423+
}}},
393424
},
394425
},
395426
nodes: []corev1.Node{
@@ -447,6 +478,11 @@ func TestReconcileMachinePoolRequest(t *testing.T) {
447478
Name: "test-node",
448479
},
449480
},
481+
V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{
482+
Type: clusterv1.PausedV1Beta2Condition,
483+
Status: metav1.ConditionFalse,
484+
Reason: clusterv1.NotPausedV1Beta2Reason,
485+
}}},
450486
},
451487
},
452488
nodes: []corev1.Node{
@@ -504,6 +540,11 @@ func TestReconcileMachinePoolRequest(t *testing.T) {
504540
Name: "test-node",
505541
},
506542
},
543+
V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{
544+
Type: clusterv1.PausedV1Beta2Condition,
545+
Status: metav1.ConditionFalse,
546+
Reason: clusterv1.NotPausedV1Beta2Reason,
547+
}}},
507548
},
508549
},
509550
nodes: []corev1.Node{
@@ -820,6 +861,13 @@ func TestRemoveMachinePoolFinalizerAfterDeleteReconcile(t *testing.T) {
820861
},
821862
},
822863
},
864+
Status: expv1.MachinePoolStatus{
865+
V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{
866+
Type: clusterv1.PausedV1Beta2Condition,
867+
Status: metav1.ConditionFalse,
868+
Reason: clusterv1.NotPausedV1Beta2Reason,
869+
}}},
870+
},
823871
}
824872
key := client.ObjectKey{Namespace: m.Namespace, Name: m.Name}
825873
clientFake := fake.NewClientBuilder().WithObjects(testCluster, m).WithStatusSubresource(&expv1.MachinePool{}).Build()
@@ -912,6 +960,13 @@ func TestMachinePoolConditions(t *testing.T) {
912960
},
913961
},
914962
},
963+
Status: expv1.MachinePoolStatus{
964+
V1Beta2: &expv1.MachinePoolV1Beta2Status{Conditions: []metav1.Condition{{
965+
Type: clusterv1.PausedV1Beta2Condition,
966+
Status: metav1.ConditionFalse,
967+
Reason: clusterv1.NotPausedV1Beta2Reason,
968+
}}},
969+
},
915970
}
916971

917972
nodeList := corev1.NodeList{
@@ -951,14 +1006,12 @@ func TestMachinePoolConditions(t *testing.T) {
9511006
infrastructureReady: true,
9521007
beforeFunc: func(_, _ *unstructured.Unstructured, mp *expv1.MachinePool, _ *corev1.NodeList) {
9531008
mp.Spec.ProviderIDList = []string{"azure://westus2/id-node-4", "aws://us-east-1/id-node-1"}
954-
mp.Status = expv1.MachinePoolStatus{
955-
NodeRefs: []corev1.ObjectReference{
956-
{Name: "node-1"},
957-
{Name: "azure-node-4"},
958-
},
959-
Replicas: 2,
960-
ReadyReplicas: 2,
1009+
mp.Status.NodeRefs = []corev1.ObjectReference{
1010+
{Name: "node-1"},
1011+
{Name: "azure-node-4"},
9611012
}
1013+
mp.Status.Replicas = 2
1014+
mp.Status.ReadyReplicas = 2
9621015
},
9631016
conditionAssertFunc: func(t *testing.T, getter conditions.Getter) {
9641017
t.Helper()

0 commit comments

Comments
 (0)