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