Skip to content

Commit 4ead210

Browse files
committed
storage: unify zfsvol VDI export/import tests
Remove zfsvol-specific VDI export/import test code and use the generic vdi_export_import helper, eliminating the VHD format special case workaround. Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent 8d5454b commit 4ead210

1 file changed

Lines changed: 2 additions & 46 deletions

File tree

tests/storage/zfsvol/test_zfsvol_sr.py

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
ImageFormat,
1616
XVACompression,
1717
coalesce_integrity,
18-
randstream,
18+
vdi_export_import,
1919
xva_export_import,
2020
)
2121

@@ -88,51 +88,7 @@ def test_vdi_export_import(self, storage_test_vm: VM, zfsvol_sr: SR, image_forma
8888
defer: Defer):
8989
vm = storage_test_vm
9090
sr = zfsvol_sr
91-
vdi_src = sr.create_vdi(image_format=image_format, virtual_size=config.volume_size)
92-
defer(lambda: vdi_src.destroy() if vdi_src is not None else None)
93-
94-
vbd = vm.connect_vdi(vdi_src)
95-
defer(lambda: vm.disconnect_vdi(vdi_src) if vdi_src is not None and vdi_src.uuid in vm.vdis else None)
96-
dev = f'/dev/{vbd.param_get("device")}'
97-
98-
# the stream is 1/5 of the full one, truncated to a multiple of 32KiB, in order to
99-
# be validable in a single command
100-
stream_size = (config.volume_size // 5 // (32 * KiB)) * (32 * KiB)
101-
stream_position = (config.volume_size // 2)
102-
103-
checksum1 = randstream(vm, f'generate --size {stream_size} {dev}')
104-
# use a different seed to not write the same data (default seed is 0)
105-
checksum2 = randstream(vm, f'generate --seed 1 --position {stream_position} --size {stream_size} {dev}')
106-
randstream(vm, f'validate --size {stream_size} --expected-checksum {checksum1} {dev}')
107-
randstream(
108-
vm, f'validate --position {stream_position} --size {stream_size} --expected-checksum {checksum2} {dev}'
109-
)
110-
vm.disconnect_vdi(vdi_src)
111-
112-
image_path = f'{temp_large_dir}/{vdi_src.uuid}.{image_format}'
113-
defer(lambda: vm.host.ssh(f'rm -f {image_path}'))
114-
115-
vm.host.xe('vdi-export', {'uuid': vdi_src.uuid, 'filename': image_path, 'format': image_format})
116-
vdi_src = vdi_src.destroy()
117-
118-
# check that the zero blocks are not part of the result
119-
size_mb = int(vm.host.ssh(f'du -sm --apparent-size {image_path}').split()[0])
120-
if image_format == 'vhd':
121-
logging.warning(f"FIXME: this is broken with vhd, skip for now (XCPNG-2631). File size is {size_mb}MB")
122-
else:
123-
assert stream_size // MiB * 2 < size_mb < stream_size // MiB * 2.1, f"unexpected image size: {size_mb}"
124-
vdi_dest = sr.create_vdi(image_format=image_format, virtual_size=config.volume_size)
125-
defer(lambda: vdi_dest.destroy())
126-
127-
vm.host.xe('vdi-import', {'uuid': vdi_dest.uuid, 'filename': image_path, 'format': image_format})
128-
vbd = vm.connect_vdi(vdi_dest)
129-
defer(lambda: vm.disconnect_vdi(vdi_dest))
130-
dev = f'/dev/{vbd.param_get("device")}'
131-
132-
randstream(vm, f'validate --size {stream_size} --expected-checksum {checksum1} {dev}')
133-
randstream(
134-
vm, f'validate --position {stream_position} --size {stream_size} --expected-checksum {checksum2} {dev}'
135-
)
91+
vdi_export_import(vm, sr, image_format, temp_large_dir, defer)
13692

13793
# *** tests with reboots (longer tests).
13894

0 commit comments

Comments
 (0)