Skip to content

Commit

Permalink
Improve ovm tests again
Browse files Browse the repository at this point in the history
The last "fix" introduced a new issue which led to never updated ovms,
in case the ovm was modified in the meantime.
  • Loading branch information
rmohr committed May 23, 2018
1 parent b1402b7 commit 2fdc0e7
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions tests/ovm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,18 @@ var _ = Describe("OfflineVirtualMachine", func() {

startOVM := func(ovm *v1.OfflineVirtualMachine) *v1.OfflineVirtualMachine {
By("Starting the VM")
var err error

updatedOVM, err := virtClient.OfflineVirtualMachine(ovm.Namespace).Get(ovm.Name, &v12.GetOptions{})
Expect(err).ToNot(HaveOccurred())

updatedOVM = updatedOVM.DeepCopy()
updatedOVM.Spec.Running = true
Eventually(func() error {
_, err := virtClient.OfflineVirtualMachine(updatedOVM.Namespace).Update(updatedOVM)
updatedOVM, err := virtClient.OfflineVirtualMachine(ovm.Namespace).Get(ovm.Name, &v12.GetOptions{})
Expect(err).ToNot(HaveOccurred())
updatedOVM.Spec.Running = true
_, err = virtClient.OfflineVirtualMachine(updatedOVM.Namespace).Update(updatedOVM)
return err
}, 300*time.Second, 1*time.Second).ShouldNot(HaveOccurred())

updatedOVM, err := virtClient.OfflineVirtualMachine(ovm.Namespace).Get(ovm.Name, &v12.GetOptions{})
Expect(err).ToNot(HaveOccurred())

// Observe the VM created
Eventually(func() error {
_, err := virtClient.VM(updatedOVM.Namespace).Get(updatedOVM.Name, v12.GetOptions{})
Expand All @@ -161,18 +161,18 @@ var _ = Describe("OfflineVirtualMachine", func() {

stopOVM := func(ovm *v1.OfflineVirtualMachine) *v1.OfflineVirtualMachine {
By("Stopping the VM")
var err error

updatedOVM, err := virtClient.OfflineVirtualMachine(ovm.Namespace).Get(ovm.Name, &v12.GetOptions{})
Expect(err).ToNot(HaveOccurred())

updatedOVM = updatedOVM.DeepCopy()
updatedOVM.Spec.Running = false
Eventually(func() error {
_, err := virtClient.OfflineVirtualMachine(updatedOVM.Namespace).Update(updatedOVM)
updatedOVM, err := virtClient.OfflineVirtualMachine(ovm.Namespace).Get(ovm.Name, &v12.GetOptions{})
Expect(err).ToNot(HaveOccurred())
updatedOVM.Spec.Running = false
_, err = virtClient.OfflineVirtualMachine(updatedOVM.Namespace).Update(updatedOVM)
return err
}, 300*time.Second, 1*time.Second).ShouldNot(HaveOccurred())

updatedOVM, err := virtClient.OfflineVirtualMachine(ovm.Namespace).Get(ovm.Name, &v12.GetOptions{})
Expect(err).ToNot(HaveOccurred())

// Observe the VM deleted
Eventually(func() bool {
_, err = virtClient.VM(updatedOVM.Namespace).Get(updatedOVM.Name, v12.GetOptions{})
Expand Down

0 comments on commit 2fdc0e7

Please sign in to comment.