Skip to content

Commit

Permalink
Correct vm test to run on WFFC storage (#28)
Browse files Browse the repository at this point in the history
On Wffc storage the DV will not be populated until VM start is attempted.
So now VM always starts, and only for testsing stopped VM's it is stopped.

Signed-off-by: Bartosz Rybacki <[email protected]>
  • Loading branch information
brybacki authored Mar 2, 2022
1 parent 1b312d0 commit dce6ad9
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions tests/vm_backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,14 @@ var _ = Describe("VM Backup", func() {
vm, err = CreateVirtualMachineFromDefinition(*kvClient, namespace.Name, vmSpec)
Expect(err).ToNot(HaveOccurred())

By("Starting VM")
err = StartVirtualMachine(*kvClient, namespace.Name, vm.Name)
Expect(err).ToNot(HaveOccurred())

err = WaitForDataVolumePhase(cdiClient, namespace.Name, cdiv1.Succeeded, vmSpec.Spec.DataVolumeTemplates[0].Name)
Expect(err).ToNot(HaveOccurred())
err = WaitForVirtualMachineInstancePhase(*kvClient, namespace.Name, vm.Name, kvv1.Running)
Expect(err).ToNot(HaveOccurred())
})

AfterEach(func() {
Expand All @@ -87,8 +93,12 @@ var _ = Describe("VM Backup", func() {
})

It("Backing up stopped VM should succeed", func() {
By("Stoppin a VM")
err := StopVirtualMachine(*kvClient, namespace.Name, vm.Name)
Expect(err).ToNot(HaveOccurred())

By("Creating backup")
err := CreateBackupForNamespace(timeout, "test-backup", namespace.Name, snapshotLocation, r.BackupNamespace, true)
err = CreateBackupForNamespace(timeout, "test-backup", namespace.Name, snapshotLocation, r.BackupNamespace, true)
Expect(err).ToNot(HaveOccurred())

phase, err := GetBackupPhase(timeout, "test-backup", r.BackupNamespace)
Expand All @@ -97,10 +107,7 @@ var _ = Describe("VM Backup", func() {
})

It("Backing up started VM should succeed", func() {
By("Starting VM")
err := StartVirtualMachine(*kvClient, namespace.Name, vm.Name)
Expect(err).ToNot(HaveOccurred())
err = WaitForVirtualMachineInstancePhase(*kvClient, namespace.Name, vm.Name, kvv1.Running)
err := WaitForVirtualMachineInstancePhase(*kvClient, namespace.Name, vm.Name, kvv1.Running)
Expect(err).ToNot(HaveOccurred())
ok, err := WaitForVirtualMachineInstanceCondition(*kvClient, namespace.Name, vm.Name, kvv1.VirtualMachineInstanceAgentConnected)
Expect(err).ToNot(HaveOccurred())
Expand All @@ -116,8 +123,12 @@ var _ = Describe("VM Backup", func() {
})

It("Stoped VM should be restored", func() {
By("Stoppin a VM")
err := StopVirtualMachine(*kvClient, namespace.Name, vm.Name)
Expect(err).ToNot(HaveOccurred())

By("Creating backup")
err := CreateBackupForNamespace(timeout, "test-backup", namespace.Name, snapshotLocation, r.BackupNamespace, true)
err = CreateBackupForNamespace(timeout, "test-backup", namespace.Name, snapshotLocation, r.BackupNamespace, true)
Expect(err).ToNot(HaveOccurred())

phase, err := GetBackupPhase(timeout, "test-backup", r.BackupNamespace)
Expand All @@ -142,10 +153,7 @@ var _ = Describe("VM Backup", func() {
})

It("started VM should be restored", func() {
By("Starting VM")
err := StartVirtualMachine(*kvClient, namespace.Name, vm.Name)
Expect(err).ToNot(HaveOccurred())
err = WaitForVirtualMachineStatus(*kvClient, namespace.Name, vm.Name, kvv1.VirtualMachineStatusRunning)
err := WaitForVirtualMachineStatus(*kvClient, namespace.Name, vm.Name, kvv1.VirtualMachineStatusRunning)
Expect(err).ToNot(HaveOccurred())
ok, err := WaitForVirtualMachineInstanceCondition(*kvClient, namespace.Name, vm.Name, kvv1.VirtualMachineInstanceAgentConnected)
Expect(err).ToNot(HaveOccurred())
Expand Down

0 comments on commit dce6ad9

Please sign in to comment.