forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor async assertions of IsNotFound().BeTrue() to MatchError
Signed-off-by: Alex Kalenyuk <[email protected]>
- Loading branch information
Showing
17 changed files
with
89 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,14 +285,10 @@ var _ = Describe("[rfe_id:3064][crit:medium][vendor:[email protected]][level:com | |
Expect(command()).To(Succeed()) | ||
|
||
By("Checking deletion of VMI") | ||
Eventually(func() bool { | ||
Eventually(func() error { | ||
_, err = virtClient.VirtualMachineInstance(vm.Namespace).Get(context.Background(), vm.Name, &v12.GetOptions{}) | ||
if errors.IsNotFound(err) { | ||
return true | ||
} | ||
Expect(err).ToNot(HaveOccurred()) | ||
return false | ||
}, 300*time.Second, 1*time.Second).Should(BeTrue(), "The VMI did not disappear") | ||
return err | ||
}, 300*time.Second, 1*time.Second).Should(MatchError(errors.IsNotFound, "k8serrors.IsNotFound"), "The VMI did not disappear") | ||
|
||
By("Checking status of VM") | ||
Eventually(func() bool { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -305,13 +305,10 @@ var _ = Describe("[rfe_id:588][crit:medium][vendor:[email protected]][level:comp | |
Delete(newRS.ObjectMeta.Name, &v12.DeleteOptions{PropagationPolicy: &orphanPolicy})).To(Succeed()) | ||
// Wait until the replica set is deleted | ||
By("Waiting until the replica set got deleted") | ||
Eventually(func() bool { | ||
Eventually(func() error { | ||
_, err := virtClient.ReplicaSet(newRS.ObjectMeta.Namespace).Get(newRS.ObjectMeta.Name, v12.GetOptions{}) | ||
if errors.IsNotFound(err) { | ||
return true | ||
} | ||
return false | ||
}, 60*time.Second, 1*time.Second).Should(BeTrue()) | ||
return err | ||
}, 60*time.Second, 1*time.Second).Should(MatchError(errors.IsNotFound, "k8serrors.IsNotFound")) | ||
|
||
By("Checking if two VMIs are orphaned and still exist") | ||
vmis, err = virtClient.VirtualMachineInstance(newRS.ObjectMeta.Namespace).List(context.Background(), &v12.ListOptions{}) | ||
|
@@ -396,13 +393,10 @@ var _ = Describe("[rfe_id:588][crit:medium][vendor:[email protected]][level:comp | |
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Checking that the VM disappeared") | ||
Eventually(func() bool { | ||
Eventually(func() error { | ||
_, err := virtClient.VirtualMachineInstance(testsuite.GetTestNamespace(rs)).Get(context.Background(), vmi.Name, &v12.GetOptions{}) | ||
if errors.IsNotFound(err) { | ||
return true | ||
} | ||
return false | ||
}, 120*time.Second, time.Second).Should(BeTrue()) | ||
return err | ||
}, 120*time.Second, time.Second).Should(MatchError(errors.IsNotFound, "k8serrors.IsNotFound")) | ||
|
||
By("Checking number of RS VM's to see that we got a replacement") | ||
vmis, err = virtClient.VirtualMachineInstance(testsuite.GetTestNamespace(rs)).List(context.Background(), &v12.ListOptions{}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -926,10 +926,10 @@ var _ = Describe("[rfe_id:1177][crit:medium][vendor:[email protected]][level:com | |
Expect(migrateCommand()).To(Succeed()) | ||
|
||
By("Check that no migration was actually created") | ||
Consistently(func() bool { | ||
Consistently(func() error { | ||
_, err = virtClient.VirtualMachineInstanceMigration(vm.Namespace).Get(vm.Name, &metav1.GetOptions{}) | ||
return errors.IsNotFound(err) | ||
}, 60*time.Second, 5*time.Second).Should(BeTrue(), "migration should not be created in a dry run mode") | ||
return err | ||
}, 60*time.Second, 5*time.Second).Should(MatchError(errors.IsNotFound, "k8serrors.IsNotFound"), "migration should not be created in a dry run mode") | ||
}) | ||
}) | ||
|
||
|
@@ -1004,10 +1004,10 @@ var _ = Describe("[rfe_id:1177][crit:medium][vendor:[email protected]][level:com | |
}, 10)).To(Succeed()) | ||
|
||
By("Waiting for the VMI to disappear") | ||
Eventually(func() bool { | ||
Eventually(func() error { | ||
_, err := virtClient.VirtualMachineInstance(vm.Namespace).Get(context.Background(), vm.Name, &k8smetav1.GetOptions{}) | ||
return errors.IsNotFound(err) | ||
}, time.Minute, time.Second).Should(BeTrue()) | ||
return err | ||
}, time.Minute, time.Second).Should(MatchError(errors.IsNotFound, "k8serrors.IsNotFound")) | ||
}) | ||
|
||
It("should restart a failed VMI", func() { | ||
|
@@ -1863,10 +1863,10 @@ status: | |
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("Ensure the vm has disappeared") | ||
Eventually(func() bool { | ||
Eventually(func() error { | ||
vm, err = virtClient.VirtualMachine(vm.Namespace).Get(context.Background(), vm.Name, &k8smetav1.GetOptions{}) | ||
return errors.IsNotFound(err) | ||
}, 2*time.Minute, 1*time.Second).Should(BeTrue(), fmt.Sprintf("vm %s is not deleted", vm.Name)) | ||
return err | ||
}, 2*time.Minute, 1*time.Second).Should(MatchError(errors.IsNotFound, "k8serrors.IsNotFound"), fmt.Sprintf("vm %s is not deleted", vm.Name)) | ||
}) | ||
|
||
It("should be added when the vm is created and removed when the vm is being deleted", func() { | ||
|
Oops, something went wrong.