Skip to content

Commit addf191

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

File tree

1 file changed

+39
-8
lines changed

1 file changed

+39
-8
lines changed

tests/storage/storage.py

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
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
12+
from typing import Literal
1313

14+
RANDSTREAM_1GIB_CHECKSUM = '65280014'
1415

1516
def try_to_create_sr_with_missing_device(sr_type, label, host):
1617
try:
@@ -42,21 +43,51 @@ def cold_migration_then_come_back(vm, prov_host, dest_host, dest_sr):
4243
vm.wait_for_os_booted()
4344
vm.shutdown(verify=True)
4445

45-
def live_storage_migration_then_come_back(vm, prov_host, dest_host, dest_sr):
46+
if vdi_name is not None:
47+
vm.destroy_vdi_by_name(vdi_name)
48+
49+
def live_storage_migration_then_come_back(vm: VM, prov_host: Host, dest_host: Host, dest_sr: SR):
4650
prov_sr = vm.get_sr()
51+
vdi_name = None
52+
53+
if not vm.is_windows:
54+
vdi = prov_sr.create_vdi(virtual_size=1 * GiB)
55+
vdi_name = vdi.name()
56+
vm.connect_vdi(vdi, 'xvdb')
57+
4758
# start VM
4859
vm.start(on=prov_host.uuid)
49-
vm.wait_for_os_booted()
60+
if vm.is_windows:
61+
vm.wait_for_os_booted()
62+
else:
63+
vm.wait_for_vm_running_and_ssh_up()
64+
install_randstream(vm)
65+
logging.info("Generate /dev/xvdb content")
66+
vm.ssh("randstream generate -v /dev/xvdb")
67+
logging.info("Validate /dev/xvdb")
68+
vm.ssh(f"randstream validate -v --expected-checksum {RANDSTREAM_1GIB_CHECKSUM} /dev/xvdb")
69+
5070
# Move the VM to another host of the pool
5171
vm.migrate(dest_host, dest_sr)
5272
wait_for(lambda: vm.all_vdis_on_sr(dest_sr), "Wait for all VDIs on destination SR")
5373
wait_for(lambda: vm.is_running_on_host(dest_host), "Wait for VM to be running on destination host")
74+
if not vm.is_windows:
75+
logging.info("Validate /dev/xvdb")
76+
vm.ssh(f"randstream validate -v --expected-checksum {RANDSTREAM_1GIB_CHECKSUM} /dev/xvdb")
77+
5478
# Migrate it back to the provenance SR
5579
vm.migrate(prov_host, prov_sr)
5680
wait_for(lambda: vm.all_vdis_on_sr(prov_sr), "Wait for all VDIs back on provenance SR")
5781
wait_for(lambda: vm.is_running_on_host(prov_host), "Wait for VM to be running on provenance host")
82+
if not vm.is_windows:
83+
logging.info("Validate /dev/xvdb")
84+
vm.ssh(f"randstream validate -v --expected-checksum {RANDSTREAM_1GIB_CHECKSUM} /dev/xvdb")
85+
5886
vm.shutdown(verify=True)
5987

88+
if vdi_name is not None:
89+
vm.destroy_vdi_by_name(vdi_name)
90+
6091
def vdi_is_open(vdi):
6192
sr = vdi.sr
6293

0 commit comments

Comments
 (0)