Skip to content

Commit cc2d80e

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

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

tests/storage/storage.py

Lines changed: 31 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,19 +41,42 @@ 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+
def live_storage_migration_then_come_back(vm: VM, prov_host: Host, dest_host: Host, dest_sr: SR):
4645
prov_sr = vm.get_sr()
46+
47+
if not vm.is_windows:
48+
# the vdi will be destroyed with the vm
49+
vdi = prov_sr.create_vdi(virtual_size=1 * GiB)
50+
vm.connect_vdi(vdi, 'xvdb')
51+
4752
# start VM
4853
vm.start(on=prov_host.uuid)
49-
vm.wait_for_os_booted()
54+
if vm.is_windows:
55+
vm.wait_for_os_booted()
56+
else:
57+
vm.wait_for_vm_running_and_ssh_up()
58+
install_randstream(vm)
59+
logging.info("Generate /dev/xvdb content")
60+
vm.ssh("randstream generate -v /dev/xvdb")
61+
logging.info("Validate /dev/xvdb")
62+
vm.ssh("randstream validate -v --expected-checksum 65280014 /dev/xvdb")
63+
5064
# Move the VM to another host of the pool
5165
vm.migrate(dest_host, dest_sr)
5266
wait_for(lambda: vm.all_vdis_on_sr(dest_sr), "Wait for all VDIs on destination SR")
5367
wait_for(lambda: vm.is_running_on_host(dest_host), "Wait for VM to be running on destination host")
68+
if not vm.is_windows:
69+
logging.info("Validate /dev/xvdb")
70+
vm.ssh("randstream validate -v --expected-checksum 65280014 /dev/xvdb")
71+
5472
# Migrate it back to the provenance SR
5573
vm.migrate(prov_host, prov_sr)
5674
wait_for(lambda: vm.all_vdis_on_sr(prov_sr), "Wait for all VDIs back on provenance SR")
5775
wait_for(lambda: vm.is_running_on_host(prov_host), "Wait for VM to be running on provenance host")
76+
if not vm.is_windows:
77+
logging.info("Validate /dev/xvdb")
78+
vm.ssh("randstream validate -v --expected-checksum 65280014 /dev/xvdb")
79+
5880
vm.shutdown(verify=True)
5981

6082
def vdi_is_open(vdi):

0 commit comments

Comments
 (0)