Skip to content

Commit e77a02f

Browse files
committed
Add integrity test in live migration tests
Signed-off-by: Gaëtan Lehmann <[email protected]>
1 parent 7ccb611 commit e77a02f

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

tests/storage/storage.py

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

35
from lib.commands import SSHCommandFailed
46
from lib.common import strtobool, wait_for, wait_for_not
7+
from lib.host import Host
58
from lib.sr import SR
69
from lib.vdi import VDI
7-
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-
10+
from lib.vm import VM
1411

1512
def try_to_create_sr_with_missing_device(sr_type, label, host):
1613
try:
@@ -42,19 +39,42 @@ def cold_migration_then_come_back(vm, prov_host, dest_host, dest_sr):
4239
vm.wait_for_os_booted()
4340
vm.shutdown(verify=True)
4441

45-
def live_storage_migration_then_come_back(vm, prov_host, dest_host, dest_sr):
42+
def live_storage_migration_then_come_back(vm: VM, prov_host: Host, dest_host: Host, dest_sr: SR):
4643
prov_sr = vm.get_sr()
44+
45+
if not vm.is_windows:
46+
# the vdi will be destroyed with the vm
47+
vdi = prov_sr.create_vdi(virtual_size='1GiB')
48+
vm.connect_vdi(vdi, 'xvdb')
49+
4750
# start VM
4851
vm.start(on=prov_host.uuid)
49-
vm.wait_for_os_booted()
52+
if vm.is_windows:
53+
vm.wait_for_os_booted()
54+
else:
55+
vm.wait_for_vm_running_and_ssh_up()
56+
install_randstream(vm)
57+
logging.info("Generate /dev/xvdb content")
58+
vm.ssh("randstream generate -v /dev/xvdb")
59+
logging.info("Validate /dev/xvdb")
60+
vm.ssh("randstream validate -v --expected-checksum 65280014 /dev/xvdb")
61+
5062
# Move the VM to another host of the pool
5163
vm.migrate(dest_host, dest_sr)
5264
wait_for(lambda: vm.all_vdis_on_sr(dest_sr), "Wait for all VDIs on destination SR")
5365
wait_for(lambda: vm.is_running_on_host(dest_host), "Wait for VM to be running on destination host")
66+
if not vm.is_windows:
67+
logging.info("Validate /dev/xvdb")
68+
vm.ssh("randstream validate -v --expected-checksum 65280014 /dev/xvdb")
69+
5470
# Migrate it back to the provenance SR
5571
vm.migrate(prov_host, prov_sr)
5672
wait_for(lambda: vm.all_vdis_on_sr(prov_sr), "Wait for all VDIs back on provenance SR")
5773
wait_for(lambda: vm.is_running_on_host(prov_host), "Wait for VM to be running on provenance host")
74+
if not vm.is_windows:
75+
logging.info("Validate /dev/xvdb")
76+
vm.ssh("randstream validate -v --expected-checksum 65280014 /dev/xvdb")
77+
5878
vm.shutdown(verify=True)
5979

6080
def vdi_is_open(vdi):

0 commit comments

Comments
 (0)