Skip to content

Commit 0198448

Browse files
test: fix e2e VirtualMachineMigration (#2208)
Description Fixes and improvements to VirtualMachineMigration e2e tests. Changes: - Removed commented-out disk verification code - Refactored By blocks for better readability - Added informative checks with VM name display - Moved disk verification after migration into a separate loop with SSH accessibility check - Fix vm CVI for vmBIOS to alpine --------- Signed-off-by: Nikita Korolev <nikita.korolev@flant.com> Co-authored-by: Roman Sysoev <36233932+hardcoretime@users.noreply.github.com>
1 parent 539b1dd commit 0198448

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

test/e2e/vm/migration.go

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ var _ = Describe("VirtualMachineMigration", func() {
7676

7777
It("verifies that migrations are successful", func() {
7878
By("Environment preparation", func() {
79-
vdRootBIOS = object.NewVDFromCVI("vd-root-bios", f.Namespace().Name, object.PrecreatedCVIUbuntu,
79+
vdRootBIOS = object.NewVDFromCVI("vd-root-bios", f.Namespace().Name, object.PrecreatedCVIAlpineBIOS,
8080
vd.WithSize(ptr.To(resource.MustParse("10Gi"))),
8181
)
8282
vdBlankBIOS = vd.New(
@@ -105,7 +105,7 @@ var _ = Describe("VirtualMachineMigration", func() {
105105
},
106106
),
107107
vm.WithBootloader(v1alpha2.BIOS),
108-
vm.WithProvisioningUserData(object.UbuntuCloudInit),
108+
vm.WithProvisioningUserData(object.AlpineCloudInit),
109109
vm.WithLiveMigrationPolicy(v1alpha2.PreferSafeMigrationPolicy),
110110
vm.WithName("vm-bios"),
111111
)
@@ -260,17 +260,30 @@ var _ = Describe("VirtualMachineMigration", func() {
260260
err = f.GenericClient().Get(context.Background(), crclient.ObjectKeyFromObject(vmopMigrateUEFI), vmopMigrateUEFI)
261261
Expect(err).NotTo(HaveOccurred()) // Intentionally fail the test on a single error, so g.Expect is not needed
262262

263-
biosDiskCount, err := f.SSHCommand(vmBIOS.Name, f.Namespace().Name, lsblkCommand)
264-
Expect(err).NotTo(HaveOccurred())
265-
Expect(biosDiskCount).To(Equal(biosDiskCountOriginal))
266-
uefiDiskCount, err := f.SSHCommand(vmUEFI.Name, f.Namespace().Name, lsblkCommand)
267-
Expect(err).NotTo(HaveOccurred())
268-
Expect(uefiDiskCount).To(Equal(uefiDiskCountOriginal))
269-
270263
g.Expect(vmopMigrateBIOS.Status.Phase).To(Equal(v1alpha2.VMOPPhaseCompleted))
271264
g.Expect(vmopMigrateUEFI.Status.Phase).To(Equal(v1alpha2.VMOPPhaseCompleted))
272265
}).WithPolling(time.Second).WithTimeout(framework.LongTimeout).To(Succeed())
273266

267+
vmOriginalDiskCount := map[*v1alpha2.VirtualMachine]string{
268+
vmBIOS: biosDiskCountOriginal,
269+
vmUEFI: uefiDiskCountOriginal,
270+
}
271+
272+
By("Wait until the virtual machine is accessible via SSH after migration.")
273+
for vm := range vmOriginalDiskCount {
274+
util.UntilSSHReady(f, vm, framework.MiddleTimeout)
275+
}
276+
277+
By("Check that the disk count of the virtual machine is equal to the disk count before migration.")
278+
for vm, originalDiskCount := range vmOriginalDiskCount {
279+
diskCount, err := f.SSHCommand(vm.Name, f.Namespace().Name, lsblkCommand)
280+
Expect(err).NotTo(HaveOccurred())
281+
Expect(diskCount).To(Equal(originalDiskCount),
282+
"disk count mismatch on VM %s after migration: got %s, expected %s",
283+
vm.Name, diskCount, originalDiskCount,
284+
)
285+
}
286+
274287
cancelVMBDA()
275288
Expect(<-vmbdaWatchErrCh).NotTo(HaveOccurred(), "VMBDAs should stay in Attached phase during migration")
276289
})

0 commit comments

Comments
 (0)