Tests: Use WithOffset equivalents
Using WithOffset reports line in test
where assertion would fail without helper.
@@ -69,7 +69,7 @@ var _ = Describe("[Serial][sig-compute]MediatedDevices", func() {
done`, expectedInstancesCount, mdevTypeName)
testPod := tests.RenderPod("test-all-mdev-created", []string{"/bin/bash", "-c"}, []string{check})
testPod, err = virtClient.CoreV1().Pods(util.NamespaceTestDefault).Create(context.Background(), testPod, metav1.CreateOptions{})
- Expect(err).ToNot(HaveOccurred())
+ ExpectWithOffset(1, err).ToNot(HaveOccurred())
var latestPod k8sv1.Pod
err := wait.PollImmediate(5*time.Second, 3*time.Minute, waitForPod(&latestPod, ThisPod(testPod)))
@@ -88,7 +88,7 @@ var _ = Describe("[Serial][sig-compute]MediatedDevices", func() {
exit 0`
testPod := tests.RenderPod("test-all-mdev-removed", []string{"/bin/bash", "-c"}, []string{check})
testPod, err = virtClient.CoreV1().Pods(util.NamespaceTestDefault).Create(context.Background(), testPod, metav1.CreateOptions{})
- Expect(err).ToNot(HaveOccurred())
+ ExpectWithOffset(1, err).ToNot(HaveOccurred())
var latestPod k8sv1.Pod
err := wait.PollImmediate(time.Second, 2*time.Minute, waitForPod(&latestPod, ThisPod(testPod)))
@@ -96,16 +96,16 @@ var _ = Describe("[Serial][sig-compute]MediatedDevices", func() {
}
noGPUDevicesAreAvailable := func() {
- Eventually(checkAllMDEVRemoved, 2*time.Minute, 10*time.Second).Should(BeInPhase(k8sv1.PodSucceeded))
+ EventuallyWithOffset(2, checkAllMDEVRemoved, 2*time.Minute, 10*time.Second).Should(BeInPhase(k8sv1.PodSucceeded))
- Eventually(func() int64 {
+ EventuallyWithOffset(2, func() int64 {
nodes, err := virtClient.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{})
- Expect(err).ToNot(HaveOccurred())
+ ExpectWithOffset(3, err).ToNot(HaveOccurred())
for _, node := range nodes.Items {
for key, amount := range node.Status.Capacity {
if strings.HasPrefix(string(key), "nvidia.com/") {
ret, ok := amount.AsInt64()
- Expect(ok).To(BeTrue())
+ ExpectWithOffset(3, ok).To(BeTrue())
return ret
}
}
@@ -154,7 +154,7 @@ var _ = Describe("[Serial][sig-compute]MediatedDevices", func() {
cleanupConfiguredMdevs := func() {
By("Deleting the VMI")
- Expect(virtClient.VirtualMachineInstance(vmi.Namespace).Delete(vmi.Name, &metav1.DeleteOptions{})).To(Succeed(), "Should delete VMI")
+ ExpectWithOffset(1, virtClient.VirtualMachineInstance(vmi.Namespace).Delete(vmi.Name, &metav1.DeleteOptions{})).To(Succeed(), "Should delete VMI")
By("Creating a configuration for mediated devices")
config.MediatedDevicesConfiguration = &v1.MediatedDevicesConfiguration{}
tests.UpdateKubeVirtConfigValueAndWait(config)
