Skip to content

Commit

Permalink
test: move WaitForPodToDisappearWithTimeout func
Browse files Browse the repository at this point in the history
Move WaitForPodToDisappearWithTimeout from
utils to storage to make utils shorter.

Signed-off-by: Ben Oukhanov <[email protected]>
  • Loading branch information
codingben committed Jun 2, 2022
1 parent 89838f4 commit a4486b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
11 changes: 10 additions & 1 deletion tests/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ var _ = SIGDescribe("Storage", func() {
tests.WaitForVirtualMachineToDisappearWithTimeout(vmi, 120)
}
Expect(virtClient.CoreV1().Pods(pod.Namespace).Delete(context.Background(), pod.Name, metav1.DeleteOptions{})).To(Succeed())
tests.WaitForPodToDisappearWithTimeout(pod.Name, 120)
waitForPodToDisappearWithTimeout(pod.Name, 120)
})

configureToleration := func(toleration int) {
Expand Down Expand Up @@ -1393,3 +1393,12 @@ var _ = SIGDescribe("Storage", func() {
})
})
})

func waitForPodToDisappearWithTimeout(podName string, seconds int) {
virtClient, err := kubecli.GetKubevirtClient()
ExpectWithOffset(1, err).ToNot(HaveOccurred())
EventuallyWithOffset(1, func() bool {
_, err := virtClient.CoreV1().Pods(util.NamespaceTestDefault).Get(context.Background(), podName, metav1.GetOptions{})
return errors.IsNotFound(err)
}, seconds, 1*time.Second).Should(BeTrue())
}
9 changes: 0 additions & 9 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1795,15 +1795,6 @@ func WaitForSuccessfulVMIStartWithTimeoutIgnoreWarnings(vmi runtime.Object, seco
return waitForVMIStart(ctx, vmi, seconds, wp)
}

func WaitForPodToDisappearWithTimeout(podName string, seconds int) {
virtClient, err := kubecli.GetKubevirtClient()
ExpectWithOffset(1, err).ToNot(HaveOccurred())
EventuallyWithOffset(1, func() bool {
_, err := virtClient.CoreV1().Pods(util2.NamespaceTestDefault).Get(context.Background(), podName, metav1.GetOptions{})
return errors.IsNotFound(err)
}, seconds, 1*time.Second).Should(BeTrue())
}

func WaitForVirtualMachineToDisappearWithTimeout(vmi *v1.VirtualMachineInstance, seconds int) {
virtClient, err := kubecli.GetKubevirtClient()
ExpectWithOffset(1, err).ToNot(HaveOccurred())
Expand Down

0 comments on commit a4486b4

Please sign in to comment.