@@ -419,38 +419,35 @@ func waitForStabilizedVMMigration(
419419) {
420420 GinkgoHelper ()
421421
422- Eventually (func (g Gomega ) {
422+ Eventually (func () {
423423 vm := getVirtualMachine (ctx , f , key .Name )
424424 util .SkipIfKnownMigrationFailureWithContext (ctx , vm )
425425
426426 state := vm .Status .MigrationState
427- g . Expect (state ).NotTo (BeNil ())
428- g . Expect (state .StartTimestamp ).NotTo (BeNil ())
429- g . Expect (state .StartTimestamp .UTC ().Before (notBefore )).To (BeFalse (), "expected a fresh migration" )
430- g . Expect (state .EndTimestamp .IsZero ()).To (BeFalse (), "migration is not completed" )
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" )
431431
432432 if state .Result == v1alpha2 .MigrationResultFailed {
433433 Fail (fmt .Sprintf ("migration failed for vm %s/%s: %s" , vm .Namespace , vm .Name , migrationFailureDetails (vm )))
434434 }
435435
436- g . Expect (state .Result ).To (Equal (v1alpha2 .MigrationResultSucceeded ))
436+ Expect (state .Result ).To (Equal (v1alpha2 .MigrationResultSucceeded ))
437437
438- g . Expect (state .Source .Node ).To (Equal (sourceNode ))
439- g . Expect (vm .Status .Node ).To (Equal (state .Target .Node ))
438+ Expect (state .Source .Node ).To (Equal (sourceNode ))
439+ Expect (vm .Status .Node ).To (Equal (state .Target .Node ))
440440
441441 switch targetExpectation {
442442 case migrationTargetMustMatch :
443- g . Expect (state .Target .Node ).To (Equal (targetNode ))
443+ Expect (state .Target .Node ).To (Equal (targetNode ))
444444 case migrationTargetMustDiffer :
445- g . Expect (state .Target .Node ).NotTo (Equal (targetNode ))
445+ Expect (state .Target .Node ).NotTo (Equal (targetNode ))
446446 default :
447447 Fail (fmt .Sprintf ("unknown migration target expectation: %d" , targetExpectation ))
448448 }
449449
450- activePod := getActiveVirtualMachinePod (ctx , f , vm )
451- g .Expect (activePod .Spec .NodeName ).To (Equal (vm .Status .Node ))
452- g .Expect (activePod .Status .Phase ).To (Equal (corev1 .PodRunning ))
453- g .Expect (isPodReady (activePod )).To (BeTrue (), "active pod %s/%s is not ready" , activePod .Namespace , activePod .Name )
450+ util .UntilConditionStatus (vmcondition .TypeMigratable .String (), string (metav1 .ConditionTrue ), framework .LongTimeout , vm )
454451 }).WithTimeout (timeout ).WithPolling (time .Second ).Should (Succeed ())
455452}
456453
@@ -466,34 +463,6 @@ func migrationFailureDetails(vm *v1alpha2.VirtualMachine) string {
466463 return fmt .Sprintf ("result=%s source=%s target=%s current=%s" , vm .Status .MigrationState .Result , vm .Status .MigrationState .Source .Node , vm .Status .MigrationState .Target .Node , vm .Status .Node )
467464}
468465
469- func getActiveVirtualMachinePod (ctx context.Context , f * framework.Framework , vm * v1alpha2.VirtualMachine ) * corev1.Pod {
470- GinkgoHelper ()
471-
472- activePodName := ""
473- for _ , pod := range vm .Status .VirtualMachinePods {
474- if pod .Active {
475- activePodName = pod .Name
476- break
477- }
478- }
479- Expect (activePodName ).NotTo (BeEmpty (), "no active pod found for vm %s/%s" , vm .Namespace , vm .Name )
480-
481- pod := & corev1.Pod {}
482- err := f .GenericClient ().Get (ctx , crclient.ObjectKey {Namespace : vm .Namespace , Name : activePodName }, pod )
483- Expect (err ).NotTo (HaveOccurred ())
484- return pod
485- }
486-
487- func isPodReady (pod * corev1.Pod ) bool {
488- for _ , condition := range pod .Status .Conditions {
489- if condition .Type == corev1 .PodReady && condition .Status == corev1 .ConditionTrue {
490- return true
491- }
492- }
493-
494- return false
495- }
496-
497466func assertNoVMMigration (
498467 ctx context.Context ,
499468 f * framework.Framework ,
@@ -503,14 +472,14 @@ func assertNoVMMigration(
503472) {
504473 GinkgoHelper ()
505474
506- Consistently (func (g Gomega ) {
475+ Consistently (func () {
507476 vm := getVirtualMachine (ctx , f , key .Name )
508- g . Expect (vm .Status .Node ).To (Equal (expectedNode ))
509- g . Expect (vm .Status .MigrationState ).To (BeNil ())
477+ Expect (vm .Status .Node ).To (Equal (expectedNode ))
478+ Expect (vm .Status .MigrationState ).To (BeNil ())
510479
511480 for _ , condition := range vm .Status .Conditions {
512481 if condition .Type == vmcondition .TypeMigrating .String () {
513- g . Expect (condition .Status ).To (Equal (metav1 .ConditionFalse ))
482+ Expect (condition .Status ).To (Equal (metav1 .ConditionFalse ))
514483 }
515484 }
516485 }).WithTimeout (duration ).WithPolling (placementNoMigrationPolling ).Should (Succeed ())
0 commit comments