@@ -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
259258func 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