Skip to content

Commit 1824c13

Browse files
committed
refactor: split machineset migration testing into multiple files
1 parent 4b88f8e commit 1824c13

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

e2e/machineset_migration_capi_authoritative_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] MachineSet Migration CAPI Authoritative Tests", Ordered, func() {
1818
BeforeAll(func() {
1919
if platform != configv1.AWSPlatformType {
20-
Skip(fmt.Sprintf("Skipping tests on %s, this only support on aws", platform))
20+
Skip(fmt.Sprintf("Skipping tests on %s, this is only supported on AWS", platform))
2121
}
2222

2323
if !capiframework.IsMachineAPIMigrationEnabled(ctx, cl) {
@@ -120,8 +120,9 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
120120

121121
mapiMachines, err := mapiframework.GetMachinesFromMachineSet(ctx, cl, mapiMachineSet)
122122
Expect(err).ToNot(HaveOccurred(), "failed to get MAPI Machines from MachineSet")
123-
capiMachines := capiframework.GetMachinesFromMachineSet(cl, capiMachineSet)
124123
Expect(mapiMachines).ToNot(BeEmpty(), "no MAPI Machines found")
124+
125+
capiMachines := capiframework.GetMachinesFromMachineSet(cl, capiMachineSet)
125126
Expect(capiMachines).ToNot(BeEmpty(), "no CAPI Machines found")
126127
Expect(capiMachines[0].Name).To(Equal(mapiMachines[0].Name))
127128
firstMAPIMachine = mapiMachines[0]
@@ -268,8 +269,10 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
268269
Expect(err).ToNot(HaveOccurred(), "failed to get mapiMachineSet")
269270
mapiframework.DeleteMachineSets(cl, mapiMachineSet)
270271

271-
// TODO bug https://issues.redhat.com/browse/OCPBUGS-56897
272272
By("Verifying CAPI MachineSet not removed, both MAPI Machines and Mirrors remain")
273+
// TODO: Add full verification once OCPBUGS-56897 is fixed
274+
capiMS := capiframework.GetMachineSet(cl, mapiMSAuthMAPIName, capiframework.CAPINamespace)
275+
Expect(capiMS).ToNot(BeNil(), "CAPI MachineSet should still exist after deleting non-authoritative MAPI MachineSet")
273276
})
274277
})
275278
})

e2e/machineset_migration_helpers.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func createMAPIMachineSetWithAuthoritativeAPI(ctx context.Context, cl client.Cli
6969
},
7070
}
7171
Eventually(komega.Get(capiMachineSet), capiframework.WaitShort, capiframework.RetryShort).Should(
72-
Succeed(), "Mirror CAPI MachineSet should be created within 1 minute")
72+
Succeed(), "Should have mirror CAPI MachineSet created within 1 minute")
7373

7474
switch machineAuthority {
7575
case mapiv1beta1.MachineAuthorityMachineAPI:
@@ -127,7 +127,7 @@ func verifyMachineSetPausedCondition(machineSet client.Object, authority mapiv1b
127127

128128
Eventually(komega.Object(ms), capiframework.WaitMedium, capiframework.RetryMedium).Should(
129129
HaveField("Status.Conditions", ContainElement(conditionMatcher)),
130-
fmt.Sprintf("Should have found the expected Paused condition for MAPI MachineSet %s with authority: %s", ms.Name, authority),
130+
fmt.Sprintf("Should have the expected Paused condition for MAPI MachineSet %s with authority: %s", ms.Name, authority),
131131
)
132132

133133
case *clusterv1.MachineSet:
@@ -153,7 +153,7 @@ func verifyMachineSetPausedCondition(machineSet client.Object, authority mapiv1b
153153

154154
Eventually(komega.Object(ms), capiframework.WaitMedium, capiframework.RetryMedium).Should(
155155
HaveField("Status.V1Beta2.Conditions", ContainElement(conditionMatcher)),
156-
fmt.Sprintf("Should have found the expected Paused condition for CAPI MachineSet %s with authority: %s", ms.Name, authority),
156+
fmt.Sprintf("Should have the expected Paused condition for CAPI MachineSet %s with authority: %s", ms.Name, authority),
157157
)
158158

159159
default:
@@ -168,13 +168,13 @@ func verifyMachinesetReplicas(machineSet client.Object, replicas int) {
168168
case *mapiv1beta1.MachineSet:
169169
By(fmt.Sprintf("Verifying MAPI MachineSet status.Replicas is %d", replicas))
170170
Eventually(komega.Object(ms), capiframework.WaitLong, capiframework.RetryLong).Should(
171-
HaveField("Status.Replicas", HaveValue(Equal(int32(replicas)))),
172-
"MAPI MachineSet %q replicas status should eventually be %d", ms.Name, replicas)
171+
HaveField("Status.Replicas", Equal(int32(replicas))),
172+
"Should have MAPI MachineSet %q replicas status eventually be %d", ms.Name, replicas)
173173
case *clusterv1.MachineSet:
174174
By(fmt.Sprintf("Verifying CAPI MachineSet status.Replicas is %d", replicas))
175175
Eventually(komega.Object(ms), capiframework.WaitLong, capiframework.RetryLong).Should(
176-
HaveField("Status.Replicas", HaveValue(Equal(int32(replicas)))),
177-
"CAPI MachineSet %q replicas status should eventually be %d", ms.Name, replicas)
176+
HaveField("Status.Replicas", Equal(int32(replicas))),
177+
"Should have CAPI MachineSet %q replicas status eventually be %d", ms.Name, replicas)
178178
default:
179179
Fail(fmt.Sprintf("unsupported MachineSet type: %T", machineSet))
180180
}
@@ -207,7 +207,7 @@ func verifyMAPIMachineSetSynchronizedCondition(mapiMachineSet *mapiv1beta1.Machi
207207
),
208208
),
209209
),
210-
fmt.Sprintf("Expected Synchronized condition for %s not found or incorrect", authority),
210+
fmt.Sprintf("Should have Synchronized condition for %s", authority),
211211
)
212212
}
213213

@@ -256,12 +256,12 @@ func waitForMAPIMachineSetMirrors(cl client.Client, machineSetNameMAPI string) (
256256
return fmt.Errorf("CAPI MachineSet %s/%s not found", capiframework.CAPINamespace, machineSetNameMAPI)
257257
}
258258
return nil
259-
}, capiframework.WaitMedium, capiframework.RetryMedium).Should(Succeed(), "CAPI MachineSet %s/%s should exist", capiframework.CAPINamespace, machineSetNameMAPI)
259+
}, capiframework.WaitMedium, capiframework.RetryMedium).Should(Succeed(), "Should have CAPI MachineSet %s/%s exist", capiframework.CAPINamespace, machineSetNameMAPI)
260260

261261
Eventually(func() error {
262262
awsMachineTemplate, err = capiframework.GetAWSMachineTemplateByPrefix(cl, machineSetNameMAPI, capiframework.CAPINamespace)
263263
return err
264-
}, capiframework.WaitMedium, capiframework.RetryMedium).Should(Succeed(), "AWSMachineTemplate with prefix %s should exist", machineSetNameMAPI)
264+
}, capiframework.WaitMedium, capiframework.RetryMedium).Should(Succeed(), "Should have AWSMachineTemplate with prefix %s exist", machineSetNameMAPI)
265265

266266
return capiMachineSet, awsMachineTemplate
267267
}
@@ -275,7 +275,7 @@ func waitForCAPIMachineSetMirror(cl client.Client, machineName string) *clusterv
275275
return fmt.Errorf("CAPI MachineSet %s/%s not found", capiframework.CAPINamespace, machineName)
276276
}
277277
return nil
278-
}, capiframework.WaitMedium, capiframework.RetryMedium).Should(Succeed(), "CAPI MachineSet %s/%s should exist", capiframework.CAPINamespace, machineName)
278+
}, capiframework.WaitMedium, capiframework.RetryMedium).Should(Succeed(), "Should have CAPI MachineSet %s/%s exist", capiframework.CAPINamespace, machineName)
279279
return capiMachineSet
280280
}
281281

@@ -290,7 +290,7 @@ func waitForAWSMachineTemplate(cl client.Client, prefix string) *awsv1.AWSMachin
290290
}
291291
return nil
292292
}, capiframework.WaitMedium, capiframework.RetryMedium).Should(Succeed(),
293-
"AWSMachineTemplate with prefix %s should exist", prefix)
293+
"Should have AWSMachineTemplate with prefix %s exist", prefix)
294294
return awsMachineTemplate
295295
}
296296

e2e/machineset_migration_mapi_authoritative_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
2020

2121
BeforeAll(func() {
2222
if platform != configv1.AWSPlatformType {
23-
Skip(fmt.Sprintf("Skipping tests on %s, this only support on aws", platform))
23+
Skip(fmt.Sprintf("Skipping tests on %s, this is only supported on AWS", platform))
2424
}
2525

2626
if !capiframework.IsMachineAPIMigrationEnabled(ctx, cl) {
@@ -296,8 +296,8 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
296296
}), capiframework.WaitMedium, capiframework.RetryShort).Should(Succeed(), "Failed to update CAPI MachineSet DeletePolicy")
297297

298298
By("Verifying both MAPI and CAPI MachineSet spec value are restored to original value")
299-
Eventually(k.Object(mapiMachineSet), capiframework.WaitShort, capiframework.RetryShort).Should(HaveField("Spec.DeletePolicy", SatisfyAny(BeEmpty(), Equal("Random"))), "DeletePolicy should be either empty or 'Random'")
300-
Eventually(k.Object(capiMachineSet), capiframework.WaitShort, capiframework.RetryShort).Should(HaveField("Spec.DeletePolicy", HaveValue(Equal("Random"))), "DeletePolicy should be 'Random'")
299+
Eventually(k.Object(mapiMachineSet), capiframework.WaitShort, capiframework.RetryShort).Should(HaveField("Spec.DeletePolicy", SatisfyAny(BeEmpty(), Equal("Random"))), "Should have DeletePolicy be either empty or 'Random'")
300+
Eventually(k.Object(capiMachineSet), capiframework.WaitShort, capiframework.RetryShort).Should(HaveField("Spec.DeletePolicy", HaveValue(Equal("Random"))), "Should have DeletePolicy be 'Random'")
301301
})
302302

303303
It("should create a new InfraTemplate when update MAPI MachineSet providerSpec", func() {
@@ -310,7 +310,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
310310
By("Waiting for new InfraTemplate to be created")
311311
originalAWSMachineTemplateName := capiMachineSet.Spec.Template.Spec.InfrastructureRef.Name
312312
capiMachineSet = capiframework.GetMachineSet(cl, mapiMSAuthMAPIName, capiframework.CAPINamespace)
313-
Eventually(k.Object(capiMachineSet), capiframework.WaitMedium, capiframework.RetryMedium).Should(HaveField("Spec.Template.Spec.InfrastructureRef.Name", Not(Equal(originalAWSMachineTemplateName))), "InfraTemplate name should be changed")
313+
Eventually(k.Object(capiMachineSet), capiframework.WaitMedium, capiframework.RetryMedium).Should(HaveField("Spec.Template.Spec.InfrastructureRef.Name", Not(Equal(originalAWSMachineTemplateName))), "Should have InfraTemplate name changed")
314314

315315
By("Verifying new InfraTemplate has the updated InstanceType")
316316
newAWSMachineTemplate, err := capiframework.GetAWSMachineTemplateByPrefix(cl, mapiMSAuthMAPIName, capiframework.CAPINamespace)
@@ -364,7 +364,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
364364
mapiMachineSet, _ = mapiframework.GetMachineSet(ctx, cl, mapiMSAuthMAPIName)
365365
Eventually(k.Object(mapiMachineSet), capiframework.WaitMedium, capiframework.RetryMedium).Should(
366366
HaveField("Spec.Template.Spec.ProviderSpec.Value.Raw", ContainSubstring(newInstanceType)),
367-
"MAPI MachineSet providerSpec should be updated to reflect the new InfraTemplate with InstanceType %s", newInstanceType,
367+
"Should have MAPI MachineSet providerSpec updated to reflect the new InfraTemplate with InstanceType %s", newInstanceType,
368368
)
369369
})
370370
})

0 commit comments

Comments
 (0)