Skip to content

Commit 55a2e7a

Browse files
committed
Add integrity check in live migration tests
Signed-off-by: Gaëtan Lehmann <[email protected]>
1 parent 140158c commit 55a2e7a

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

tests/storage/storage.py

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1+
from __future__ import annotations
2+
13
import logging
24

35
from lib.commands import SSHCommandFailed
4-
from lib.common import strtobool, wait_for, wait_for_not
6+
from lib.common import GiB, strtobool, wait_for, wait_for_not
7+
from lib.host import Host
58
from lib.sr import SR
69
from lib.vdi import VDI
10+
from lib.vm import VM
711

8-
from typing import TYPE_CHECKING, Literal
9-
10-
if TYPE_CHECKING:
11-
from lib.host import Host
12-
from lib.vm import VM
13-
12+
from typing import Literal
1413

1514
def try_to_create_sr_with_missing_device(sr_type, label, host):
1615
try:
@@ -42,21 +41,51 @@ def cold_migration_then_come_back(vm, prov_host, dest_host, dest_sr):
4241
vm.wait_for_os_booted()
4342
vm.shutdown(verify=True)
4443

45-
def live_storage_migration_then_come_back(vm, prov_host, dest_host, dest_sr):
44+
if vdi_name is not None:
45+
vm.destroy_vdi_by_name(vdi_name)
46+
47+
def live_storage_migration_then_come_back(vm: VM, prov_host: Host, dest_host: Host, dest_sr: SR):
4648
prov_sr = vm.get_sr()
49+
vdi_name = None
50+
51+
if not vm.is_windows:
52+
vdi = prov_sr.create_vdi(virtual_size=1 * GiB)
53+
vdi_name = vdi.name()
54+
vm.connect_vdi(vdi, 'xvdb')
55+
4756
# start VM
4857
vm.start(on=prov_host.uuid)
49-
vm.wait_for_os_booted()
58+
if vm.is_windows:
59+
vm.wait_for_os_booted()
60+
else:
61+
vm.wait_for_vm_running_and_ssh_up()
62+
install_randstream(vm)
63+
logging.info("Generate /dev/xvdb content")
64+
vm.ssh("randstream generate -v /dev/xvdb")
65+
logging.info("Validate /dev/xvdb")
66+
vm.ssh("randstream validate -v --expected-checksum 65280014 /dev/xvdb")
67+
5068
# Move the VM to another host of the pool
5169
vm.migrate(dest_host, dest_sr)
5270
wait_for(lambda: vm.all_vdis_on_sr(dest_sr), "Wait for all VDIs on destination SR")
5371
wait_for(lambda: vm.is_running_on_host(dest_host), "Wait for VM to be running on destination host")
72+
if not vm.is_windows:
73+
logging.info("Validate /dev/xvdb")
74+
vm.ssh("randstream validate -v --expected-checksum 65280014 /dev/xvdb")
75+
5476
# Migrate it back to the provenance SR
5577
vm.migrate(prov_host, prov_sr)
5678
wait_for(lambda: vm.all_vdis_on_sr(prov_sr), "Wait for all VDIs back on provenance SR")
5779
wait_for(lambda: vm.is_running_on_host(prov_host), "Wait for VM to be running on provenance host")
80+
if not vm.is_windows:
81+
logging.info("Validate /dev/xvdb")
82+
vm.ssh("randstream validate -v --expected-checksum 65280014 /dev/xvdb")
83+
5884
vm.shutdown(verify=True)
5985

86+
if vdi_name is not None:
87+
vm.destroy_vdi_by_name(vdi_name)
88+
6089
def vdi_is_open(vdi):
6190
sr = vdi.sr
6291

0 commit comments

Comments
 (0)