add a functioal test to verify live migration with mixed vloumes
@@ -164,7 +164,7 @@ var _ = Describe("Migrations", func() {
// create a new PV and PVC (PVs can't be reused)
tests.DeletePvAndPvc(pvName)
}, 60)
- It("should reject migration specs with shared and non-shared disks", func() {
+ It("should migrate a VMI with shared and non-shared disks", func() {
// Start the VirtualMachineInstance with PVC and Ephemeral Disks
vmi := tests.NewRandomVMIWithPVC(pvName)
image := tests.ContainerDiskFor(tests.ContainerDiskAlpine)
@@ -178,12 +178,20 @@ var _ = Describe("Migrations", func() {
Expect(err).To(BeNil())
expecter.Close()
- By("Starting a Migration and expecting it to be rejected")
+ By("Starting a Migration")
migration := tests.NewRandomMigration(vmi.Name, vmi.Namespace)
- Eventually(func() error {
- _, err := virtClient.VirtualMachineInstanceMigration(migration.Namespace).Create(migration)
- return err
- }, 120, 1*time.Second).Should(HaveOccurred())
+ migrationUID := runMigrationAndExpectCompletion(migration, 180)
+
+ // check VMI, confirm migration state
+ confirmVMIPostMigration(vmi, migrationUID)
+
+ // delete VMI
+ By("Deleting the VMI")
+ err = virtClient.VirtualMachineInstance(vmi.Namespace).Delete(vmi.Name, &metav1.DeleteOptions{})
+ Expect(err).To(BeNil())
+
+ By("Waiting for VMI to disappear")
+ tests.WaitForVirtualMachineToDisappearWithTimeout(vmi, 120)
})
It("should be successfully migrated multiple times", func() {
// Start the VirtualMachineInstance with the PVC attached
@@ -216,6 +224,34 @@ var _ = Describe("Migrations", func() {
tests.WaitForVirtualMachineToDisappearWithTimeout(vmi, 120)
})
+ It("should be successfully with a cloud init", func() {
+ // Start the VirtualMachineInstance with the PVC attached
+ vmi := tests.NewRandomVMIWithPVC(pvName)
+ tests.AddUserData(vmi, "cloud-init", "#!/bin/bash\necho 'hello'\n")
+
+ vmi = runVMIAndExpectLaunch(vmi, 180)
+
+ By("Checking that the VirtualMachineInstance console has expected output")
+ expecter, err := tests.LoggedInAlpineExpecter(vmi)
+ Expect(err).To(BeNil())
+ expecter.Close()
+
+ // execute a migration, wait for finalized state
+ By("Starting the Migration for iteration")
+ migration := tests.NewRandomMigration(vmi.Name, vmi.Namespace)
+ migrationUID := runMigrationAndExpectCompletion(migration, 180)
+
+ // check VMI, confirm migration state
+ confirmVMIPostMigration(vmi, migrationUID)
+
+ // delete VMI
+ By("Deleting the VMI")
+ err = virtClient.VirtualMachineInstance(vmi.Namespace).Delete(vmi.Name, &metav1.DeleteOptions{})
+ Expect(err).To(BeNil())
+
+ By("Waiting for VMI to disappear")
+ tests.WaitForVirtualMachineToDisappearWithTimeout(vmi, 120)
+ })
})
})
