Skip to content

Commit

Permalink
make update func test more resilient to timing
Browse files Browse the repository at this point in the history
Signed-off-by: David Vossel <[email protected]>
  • Loading branch information
davidvossel committed Feb 16, 2021
1 parent 3cf2a1f commit 01960e7
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions tests/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,18 +652,26 @@ var _ = Describe("[Serial]Operator", func() {
return nil
}, 320, 1).Should(BeNil(), "All VMIs should update via live migration")

By("Verifying only a single successful migration took place for each vmi")
migrationList, err := virtClient.VirtualMachineInstanceMigration(tests.NamespaceTestDefault).List(&metav1.ListOptions{})
Expect(err).To(BeNil(), "retrieving migrations")
for _, vmi := range vmis {
count := 0
for _, migration := range migrationList.Items {
if migration.Spec.VMIName == vmi.Name && migration.Status.Phase == v1.MigrationSucceeded {
count++
// this is put in an eventually loop because it's possible for the VMI to complete
// migrating and for the migration object to briefly lag behind in reporting
// the results
Eventually(func() error {
By("Verifying only a single successful migration took place for each vmi")
migrationList, err := virtClient.VirtualMachineInstanceMigration(tests.NamespaceTestDefault).List(&metav1.ListOptions{})
Expect(err).To(BeNil(), "retrieving migrations")
for _, vmi := range vmis {
count := 0
for _, migration := range migrationList.Items {
if migration.Spec.VMIName == vmi.Name && migration.Status.Phase == v1.MigrationSucceeded {
count++
}
}
if count != 1 {
return fmt.Errorf("vmi [%s] returned %d successful migrations", vmi.Name, count)
}
}
Expect(count).To(Equal(1), "Expects only a single successful migration per workload update")
}
return nil
}, 10, 1).Should(BeNil(), "Expects only a single successful migration per workload update")
}

getVirtLauncherSha = func() string {
Expand Down

0 comments on commit 01960e7

Please sign in to comment.