@@ -163,6 +163,7 @@ var _ = Describe("VirtualMachineAffinityAndToleration", Ordered, func() {
163163
164164 waitForFreshVMMigration (ctx , f , crclient .ObjectKeyFromObject (vmC ), startedAt , sourceNode , nodeA , false , framework .MaxTimeout )
165165 waitForVMMigrationFinished (ctx , f , crclient .ObjectKeyFromObject (vmC ), framework .LongTimeout )
166+ waitForVMActivePodReady (ctx , f , crclient .ObjectKeyFromObject (vmC ), framework .LongTimeout )
166167 })
167168
168169 var migratedNodeC string
@@ -184,6 +185,7 @@ var _ = Describe("VirtualMachineAffinityAndToleration", Ordered, func() {
184185
185186 waitForFreshVMMigration (ctx , f , crclient .ObjectKeyFromObject (vmC ), startedAt , migratedNodeC , nodeA , true , framework .MaxTimeout )
186187 waitForVMMigrationFinished (ctx , f , crclient .ObjectKeyFromObject (vmC ), framework .LongTimeout )
188+ waitForVMActivePodReady (ctx , f , crclient .ObjectKeyFromObject (vmC ), framework .LongTimeout )
187189 })
188190
189191 By ("Verifying vm-c returned to vm-a node via status.nodeName" , func () {
@@ -244,6 +246,7 @@ var _ = Describe("VirtualMachineAffinityAndToleration", Ordered, func() {
244246
245247 waitForFreshVMMigration (ctx , f , crclient .ObjectKeyFromObject (vmNodeSelector ), startedAt , sourceNode , targetNode , true , framework .MaxTimeout )
246248 waitForVMMigrationFinished (ctx , f , crclient .ObjectKeyFromObject (vmNodeSelector ), framework .LongTimeout )
249+ waitForVMActivePodReady (ctx , f , crclient .ObjectKeyFromObject (vmNodeSelector ), framework .LongTimeout )
247250 })
248251
249252 By ("Verifying the nodeSelector migration result via status.nodeName" , func () {
@@ -307,6 +310,7 @@ var _ = Describe("VirtualMachineAffinityAndToleration", Ordered, func() {
307310
308311 waitForFreshVMMigration (ctx , f , crclient .ObjectKeyFromObject (vmNodeAffinity ), startedAt , sourceNode , targetNode , true , framework .MaxTimeout )
309312 waitForVMMigrationFinished (ctx , f , crclient .ObjectKeyFromObject (vmNodeAffinity ), framework .LongTimeout )
313+ waitForVMActivePodReady (ctx , f , crclient .ObjectKeyFromObject (vmNodeAffinity ), framework .LongTimeout )
310314 })
311315
312316 By ("Verifying the nodeAffinity migration result via status.nodeName" , func () {
@@ -474,6 +478,44 @@ func waitForVMMigrationFinished(
474478 }).WithTimeout (timeout ).WithPolling (time .Second ).Should (Succeed ())
475479}
476480
481+ func waitForVMActivePodReady (
482+ ctx context.Context ,
483+ f * framework.Framework ,
484+ key crclient.ObjectKey ,
485+ timeout time.Duration ,
486+ ) {
487+ GinkgoHelper ()
488+
489+ Eventually (func (g Gomega ) {
490+ vm := getVirtualMachine (ctx , f , key .Name )
491+ g .Expect (vm .Status .Node ).NotTo (BeEmpty ())
492+
493+ activePodName := ""
494+ for _ , pod := range vm .Status .VirtualMachinePods {
495+ if pod .Active {
496+ activePodName = pod .Name
497+ break
498+ }
499+ }
500+ g .Expect (activePodName ).NotTo (BeEmpty (), "no active pod found for vm %s/%s" , vm .Namespace , vm .Name )
501+
502+ pod := & corev1.Pod {}
503+ err := f .GenericClient ().Get (ctx , crclient.ObjectKey {Namespace : vm .Namespace , Name : activePodName }, pod )
504+ g .Expect (err ).NotTo (HaveOccurred ())
505+ g .Expect (pod .Spec .NodeName ).To (Equal (vm .Status .Node ))
506+ g .Expect (pod .Status .Phase ).To (Equal (corev1 .PodRunning ))
507+
508+ ready := false
509+ for _ , condition := range pod .Status .Conditions {
510+ if condition .Type == corev1 .PodReady && condition .Status == corev1 .ConditionTrue {
511+ ready = true
512+ break
513+ }
514+ }
515+ g .Expect (ready ).To (BeTrue (), "active pod %s/%s is not ready" , pod .Namespace , pod .Name )
516+ }).WithTimeout (timeout ).WithPolling (time .Second ).Should (Succeed ())
517+ }
518+
477519func assertNoVMMigration (
478520 ctx context.Context ,
479521 f * framework.Framework ,
0 commit comments