Skip to content

Commit ebde40b

Browse files
committed
Added wait for status to reflect authorityapi change
reduce time,changes to follow consistent pattern
1 parent 2eb2ed9 commit ebde40b

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

e2e/machine_migration_vap_tests.go

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
corev1 "k8s.io/api/core/v1"
1414
"k8s.io/apimachinery/pkg/runtime"
1515
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
16-
"sigs.k8s.io/controller-runtime/pkg/client"
1716
"sigs.k8s.io/controller-runtime/pkg/envtest/komega"
1817
)
1918

@@ -60,7 +59,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] MA
6059
testCAPIMachine = capiframework.GetMachine(cl, testMachineName, capiframework.CAPINamespace)
6160

6261
// Wait until VAP match conditions are met
63-
Eventually(komega.Object(testMAPIMachine), capiframework.WaitLong, capiframework.RetryMedium).Should(
62+
Eventually(komega.Object(testMAPIMachine), capiframework.WaitMedium, capiframework.RetryMedium).Should(
6463
WithTransform(func(m *mapiv1beta1.Machine) mapiv1beta1.MachineAuthority {
6564
return m.Status.AuthoritativeAPI
6665
}, Equal(mapiv1beta1.MachineAuthorityClusterAPI)),
@@ -259,19 +258,9 @@ func getAWSProviderSpecFromMachine(machine *mapiv1beta1.Machine) *mapiv1beta1.AW
259258
func verifyAWSProviderSpecUpdatePrevented(machine *mapiv1beta1.Machine, fieldName string, updateFunc func(*mapiv1beta1.AWSMachineProviderConfig), expectedError string) {
260259
By(fmt.Sprintf("Verifying that updating AWS providerSpec.%s is prevented by VAP", fieldName))
261260

262-
Eventually(func() error {
263-
// Get fresh copy to avoid conflicts
264-
freshMachine := &mapiv1beta1.Machine{}
265-
if err := cl.Get(ctx, client.ObjectKeyFromObject(machine), freshMachine); err != nil {
266-
return err
267-
}
268-
269-
if err := updateAWSMachineProviderSpec(freshMachine, updateFunc); err != nil {
270-
return err
271-
}
272-
273-
return cl.Update(ctx, freshMachine)
274-
}, capiframework.WaitMedium, capiframework.RetryMedium).Should(
261+
Eventually(komega.Update(machine, func() {
262+
Expect(updateAWSMachineProviderSpec(machine, updateFunc)).To(Succeed())
263+
}), capiframework.WaitMedium, capiframework.RetryMedium).Should(
275264
MatchError(ContainSubstring(expectedError)),
276265
"Expected AWS providerSpec.%s update to be blocked by VAP", fieldName)
277266
}
@@ -283,6 +272,14 @@ func verifyVAPNotAppliedForMachineAPIAuthority() {
283272
// Create a test machine with MachineAPI authority
284273
testMachine := createMAPIMachineWithAuthority(ctx, cl, "vap-test-mapi-authority", mapiv1beta1.MachineAuthorityMachineAPI)
285274

275+
// Wait until status reflects the expected authority
276+
Eventually(komega.Object(testMachine), capiframework.WaitMedium, capiframework.RetryMedium).Should(
277+
WithTransform(func(m *mapiv1beta1.Machine) mapiv1beta1.MachineAuthority {
278+
return m.Status.AuthoritativeAPI
279+
}, Equal(mapiv1beta1.MachineAuthorityMachineAPI)),
280+
"Expected status.authoritativeAPI=MachineAPI before VAP bypass test",
281+
)
282+
286283
DeferCleanup(func() {
287284
By("Cleaning up test machine")
288285
mapiframework.DeleteMachines(ctx, cl, testMachine)

0 commit comments

Comments
 (0)