@@ -169,6 +169,7 @@ var _ = Describe("VirtualMachineAffinityAndToleration", Ordered, func() {
169169 Expect (err ).NotTo (HaveOccurred ())
170170
171171 waitForStabilizedVMMigration (ctx , f , crclient .ObjectKeyFromObject (vmC ), startedAt , sourceNode , nodeA , migrationTargetMustDiffer , framework .MaxTimeout )
172+ util .UntilConditionStatus (vmcondition .TypeMigratable .String (), string (metav1 .ConditionTrue ), framework .LongTimeout , vmC )
172173 })
173174
174175 var migratedNodeC string
@@ -189,6 +190,7 @@ var _ = Describe("VirtualMachineAffinityAndToleration", Ordered, func() {
189190 Expect (err ).NotTo (HaveOccurred ())
190191
191192 waitForStabilizedVMMigration (ctx , f , crclient .ObjectKeyFromObject (vmC ), startedAt , migratedNodeC , nodeA , migrationTargetMustMatch , framework .MaxTimeout )
193+ util .UntilConditionStatus (vmcondition .TypeMigratable .String (), string (metav1 .ConditionTrue ), framework .LongTimeout , vmC )
192194 })
193195
194196 By ("Verifying vm-c returned to vm-a node via status.nodeName" , func () {
@@ -248,6 +250,7 @@ var _ = Describe("VirtualMachineAffinityAndToleration", Ordered, func() {
248250 Expect (err ).NotTo (HaveOccurred ())
249251
250252 waitForStabilizedVMMigration (ctx , f , crclient .ObjectKeyFromObject (vmNodeSelector ), startedAt , sourceNode , targetNode , migrationTargetMustMatch , framework .MaxTimeout )
253+ util .UntilConditionStatus (vmcondition .TypeMigratable .String (), string (metav1 .ConditionTrue ), framework .LongTimeout , vmNodeSelector )
251254 })
252255
253256 By ("Verifying the nodeSelector migration result via status.nodeName" , func () {
@@ -310,6 +313,7 @@ var _ = Describe("VirtualMachineAffinityAndToleration", Ordered, func() {
310313 Expect (err ).NotTo (HaveOccurred ())
311314
312315 waitForStabilizedVMMigration (ctx , f , crclient .ObjectKeyFromObject (vmNodeAffinity ), startedAt , sourceNode , targetNode , migrationTargetMustMatch , framework .MaxTimeout )
316+ util .UntilConditionStatus (vmcondition .TypeMigratable .String (), string (metav1 .ConditionTrue ), framework .LongTimeout , vmNodeAffinity )
313317 })
314318
315319 By ("Verifying the nodeAffinity migration result via status.nodeName" , func () {
@@ -419,35 +423,33 @@ func waitForStabilizedVMMigration(
419423) {
420424 GinkgoHelper ()
421425
422- Eventually (func () {
426+ Eventually (func (g Gomega ) {
423427 vm := getVirtualMachine (ctx , f , key .Name )
424428 util .SkipIfKnownMigrationFailureWithContext (ctx , vm )
425429
426430 state := vm .Status .MigrationState
427- Expect (state ).NotTo (BeNil ())
428- Expect (state .StartTimestamp ).NotTo (BeNil ())
429- Expect (state .StartTimestamp .UTC ().Before (notBefore )).To (BeFalse (), "expected a fresh migration" )
430- Expect (state .EndTimestamp .IsZero ()).To (BeFalse (), "migration is not completed" )
431+ g . Expect (state ).NotTo (BeNil ())
432+ g . Expect (state .StartTimestamp ).NotTo (BeNil ())
433+ g . Expect (state .StartTimestamp .UTC ().Before (notBefore )).To (BeFalse (), "expected a fresh migration" )
434+ g . Expect (state .EndTimestamp .IsZero ()).To (BeFalse (), "migration is not completed" )
431435
432436 if state .Result == v1alpha2 .MigrationResultFailed {
433437 Fail (fmt .Sprintf ("migration failed for vm %s/%s: %s" , vm .Namespace , vm .Name , migrationFailureDetails (vm )))
434438 }
435439
436- Expect (state .Result ).To (Equal (v1alpha2 .MigrationResultSucceeded ))
440+ g . Expect (state .Result ).To (Equal (v1alpha2 .MigrationResultSucceeded ))
437441
438- Expect (state .Source .Node ).To (Equal (sourceNode ))
439- Expect (vm .Status .Node ).To (Equal (state .Target .Node ))
442+ g . Expect (state .Source .Node ).To (Equal (sourceNode ))
443+ g . Expect (vm .Status .Node ).To (Equal (state .Target .Node ))
440444
441445 switch targetExpectation {
442446 case migrationTargetMustMatch :
443- Expect (state .Target .Node ).To (Equal (targetNode ))
447+ g . Expect (state .Target .Node ).To (Equal (targetNode ))
444448 case migrationTargetMustDiffer :
445- Expect (state .Target .Node ).NotTo (Equal (targetNode ))
449+ g . Expect (state .Target .Node ).NotTo (Equal (targetNode ))
446450 default :
447451 Fail (fmt .Sprintf ("unknown migration target expectation: %d" , targetExpectation ))
448452 }
449-
450- util .UntilConditionStatus (vmcondition .TypeMigratable .String (), string (metav1 .ConditionTrue ), framework .LongTimeout , vm )
451453 }).WithTimeout (timeout ).WithPolling (time .Second ).Should (Succeed ())
452454}
453455
@@ -472,14 +474,14 @@ func assertNoVMMigration(
472474) {
473475 GinkgoHelper ()
474476
475- Consistently (func () {
477+ Consistently (func (g Gomega ) {
476478 vm := getVirtualMachine (ctx , f , key .Name )
477- Expect (vm .Status .Node ).To (Equal (expectedNode ))
478- Expect (vm .Status .MigrationState ).To (BeNil ())
479+ g . Expect (vm .Status .Node ).To (Equal (expectedNode ))
480+ g . Expect (vm .Status .MigrationState ).To (BeNil ())
479481
480482 for _ , condition := range vm .Status .Conditions {
481483 if condition .Type == vmcondition .TypeMigrating .String () {
482- Expect (condition .Status ).To (Equal (metav1 .ConditionFalse ))
484+ g . Expect (condition .Status ).To (Equal (metav1 .ConditionFalse ))
483485 }
484486 }
485487 }).WithTimeout (duration ).WithPolling (placementNoMigrationPolling ).Should (Succeed ())
0 commit comments