Skip to content

Commit

Permalink
PWX-37154: handle transient "not ready" condition in the VMI (#1794)
Browse files Browse the repository at this point in the history
This avoid intermittent failures due to VMI flippping to "not ready" for a
very short time.

Signed-off-by: Neelesh Thakur <neelesh.thakur@purestorage.com>
  • Loading branch information
pureneelesh authored Jun 9, 2024
1 parent 819e7db commit b8f6264
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/integration_test/kubevirt_hyperconv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,23 @@ func getVMDiskMountType(pod *corev1.Pod, vmDisk *vmDisk) (string, error) {
}

func verifyVMStayedUp(t *testing.T, testState *kubevirtTestState) {

// VMI ready condition seems to flip to "false" for a moment even if the VM is running.
// Give it some time to stabilize. We will verify the VMI UID to ensure that the VM did not restart.
require.Eventuallyf(t, func() bool {
ready, _, _, _, _, err := getVMIDetails(testState.vmPod.Namespace, testState.vmiName)
if err != nil {
log.Warn("Failed to get VMI %s/%s: %v", testState.vmPod.Namespace, testState.vmiName, err)
return false
}
if !ready {
log.Warn("Waiting for VMI %s/%s to be ready", testState.vmPod.Namespace, testState.vmiName)
return false
}
log.InfoD("VMI %s/%s is ready", testState.vmPod.Namespace, testState.vmiName)
return true
}, 1*time.Minute, 5*time.Second, "VMI %s/%s did not become ready", testState.vmPod.Namespace, testState.vmiName)

// If a VM is stopped and started again, a new VMI object gets created with the same name (i.e. the UID will change).
// We are using that fact here to ensure that the VM did not stop during our test.
ready, vmiUIDAfter, vmiPhaseAfter, transitionTimeAfter, _, err := getVMIDetails(testState.vmPod.Namespace, testState.vmiName)
Expand Down

0 comments on commit b8f6264

Please sign in to comment.