|
4 | 4 | from lib.vdi import VDI |
5 | 5 | from lib.vm import VM |
6 | 6 | from tests.storage import vdi_is_open |
| 7 | +from tests.storage.storage import install_randstream |
7 | 8 |
|
8 | 9 | # Requirements: |
9 | 10 | # - 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 |
78 | 79 | if new_vdi is not None: |
79 | 80 | new_vdi.destroy() |
80 | 81 |
|
| 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 | + |
81 | 110 | # *** tests with reboots (longer tests). |
82 | 111 |
|
83 | 112 | @pytest.mark.reboot |
|
0 commit comments