Skip to content

Commit 04dc842

Browse files
committed
lvmoiscsi: add xva export/import test
Signed-off-by: Gaëtan Lehmann <[email protected]>
1 parent d6cfaba commit 04dc842

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/storage/lvmoiscsi/test_lvmoiscsi_sr.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from lib.vdi import VDI
55
from lib.vm import VM
66
from tests.storage import vdi_is_open
7+
from tests.storage.storage import install_randstream
78

89
# Requirements:
910
# - one XCP-ng host >= 8.2
@@ -78,6 +79,34 @@ def test_coalesce(self, storage_test_vm: 'VM', vdi_on_lvmoiscsi_sr: 'VDI', vdi_o
7879
if new_vdi is not None:
7980
new_vdi.destroy()
8081

82+
@pytest.mark.small_vm
83+
@pytest.mark.parametrize("compression", ["none", "gzip", "zstd"])
84+
def test_xva_export_import(self, vm_on_lvmoiscsi_sr: VM, compression):
85+
vm = vm_on_lvmoiscsi_sr
86+
vm.start()
87+
vm.wait_for_vm_running_and_ssh_up()
88+
install_randstream(vm)
89+
# 500MiB, so we have some data to check and some empty spaces in the exported image
90+
vm.ssh("randstream generate -v --size 500MiB /root/data")
91+
vm.ssh("randstream validate -v --expected-checksum 24e905d6 /root/data")
92+
vm.shutdown(verify=True)
93+
xva_path = f'/tmp/{vm.uuid}.xva'
94+
imported_vm = None
95+
try:
96+
vm.export(xva_path, compression)
97+
# check that the zero blocks are not part of the result. Most of the data is from the random stream, so
98+
# compression has little effect. We just check the result is between 500 and 700 MiB
99+
size_mb = int(vm.host.ssh(f'du -sm {xva_path}').split()[0])
100+
assert 500 < size_mb < 700, f"unexpected xva size: {size_mb}"
101+
imported_vm = vm.host.import_vm(xva_path, vm.vdis[0].sr.uuid)
102+
imported_vm.start()
103+
imported_vm.wait_for_vm_running_and_ssh_up()
104+
imported_vm.ssh("randstream validate -v --expected-checksum 24e905d6 /root/data")
105+
finally:
106+
if imported_vm is not None:
107+
imported_vm.destroy()
108+
vm.host.ssh(f'rm -f {xva_path}')
109+
81110
# *** tests with reboots (longer tests).
82111

83112
@pytest.mark.reboot

0 commit comments

Comments
 (0)