Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/storage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from .storage import (
CoalesceOperation,
ImageFormat,
XVACompression,
coalesce_integrity,
cold_migration_then_come_back,
install_randstream,
live_storage_migration_then_come_back,
try_to_create_sr_with_missing_device,
vdi_export_import,
vdi_is_open,
xva_export_import,
)
7 changes: 7 additions & 0 deletions tests/storage/ext/test_ext_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
from lib.common import vm_image, wait_for
from lib.fistpoint import FistPoint
from lib.host import Host
from lib.sr import SR
from lib.vdi import VDI
from lib.vm import VM
from tests.storage import (
CoalesceOperation,
ImageFormat,
XVACompression,
coalesce_integrity,
try_to_create_sr_with_missing_device,
vdi_export_import,
vdi_is_open,
xva_export_import,
)
Expand Down Expand Up @@ -80,6 +83,10 @@ def test_coalesce(self, storage_test_vm: VM, vdi_on_ext_sr: VDI, vdi_op: Coalesc
def test_xva_export_import(self, vm_on_ext_sr: VM, compression: XVACompression):
xva_export_import(vm_on_ext_sr, compression)

@pytest.mark.small_vm
def test_vdi_export_import(self, storage_test_vm: VM, ext_sr: SR, image_format: ImageFormat):
vdi_export_import(storage_test_vm, ext_sr, image_format)

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

@pytest.mark.small_vm
Expand Down
7 changes: 7 additions & 0 deletions tests/storage/lvm/test_lvm_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
from lib.common import vm_image, wait_for
from lib.fistpoint import FistPoint
from lib.host import Host
from lib.sr import SR
from lib.vdi import VDI
from lib.vm import VM
from tests.storage import (
CoalesceOperation,
ImageFormat,
XVACompression,
coalesce_integrity,
try_to_create_sr_with_missing_device,
vdi_export_import,
vdi_is_open,
xva_export_import,
)
Expand Down Expand Up @@ -132,6 +135,10 @@ def test_coalesce(self, storage_test_vm: VM, vdi_on_lvm_sr: VDI, vdi_op: Coalesc
def test_xva_export_import(self, vm_on_lvm_sr: VM, compression: XVACompression):
xva_export_import(vm_on_lvm_sr, compression)

@pytest.mark.small_vm
def test_vdi_export_import(self, storage_test_vm: VM, lvm_sr: SR, image_format: ImageFormat):
vdi_export_import(storage_test_vm, lvm_sr, image_format)

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

@pytest.mark.reboot
Expand Down
7 changes: 7 additions & 0 deletions tests/storage/lvmoiscsi/test_lvmoiscsi_sr.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import pytest

from lib.common import vm_image, wait_for
from lib.sr import SR
from lib.vdi import VDI
from lib.vm import VM
from tests.storage import (
CoalesceOperation,
ImageFormat,
XVACompression,
coalesce_integrity,
vdi_export_import,
vdi_is_open,
xva_export_import,
)
Expand Down Expand Up @@ -69,6 +72,10 @@ def test_coalesce(self, storage_test_vm: 'VM', vdi_on_lvmoiscsi_sr: 'VDI', vdi_o
def test_xva_export_import(self, vm_on_lvmoiscsi_sr: VM, compression: XVACompression):
xva_export_import(vm_on_lvmoiscsi_sr, compression)

@pytest.mark.small_vm
def test_vdi_export_import(self, storage_test_vm: VM, lvmoiscsi_sr: SR, image_format: ImageFormat):
vdi_export_import(storage_test_vm, lvmoiscsi_sr, image_format)

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

@pytest.mark.reboot
Expand Down
10 changes: 10 additions & 0 deletions tests/storage/nfs/test_nfs_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

from lib.commands import SSHCommandFailed
from lib.common import vm_image, wait_for
from lib.sr import SR
from lib.vdi import VDI
from lib.vm import VM
from tests.storage import (
CoalesceOperation,
ImageFormat,
XVACompression,
coalesce_integrity,
vdi_export_import,
vdi_is_open,
xva_export_import,
)
Expand Down Expand Up @@ -130,6 +133,13 @@ def test_coalesce(self, storage_test_vm: VM, dispatch_nfs: VDI, vdi_op: Coalesce
def test_xva_export_import(self, dispatch_nfs: VM, compression: XVACompression):
xva_export_import(dispatch_nfs, compression)

@pytest.mark.small_vm
# Make sure this fixture is called before the parametrized one
@pytest.mark.usefixtures('image_format')
@pytest.mark.parametrize('dispatch_nfs', ['nfs_sr', 'nfs4_sr'], indirect=True)
def test_vdi_export_import(self, storage_test_vm: VM, dispatch_nfs: SR, image_format: ImageFormat):
vdi_export_import(storage_test_vm, dispatch_nfs, image_format)

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

@pytest.mark.reboot
Expand Down
30 changes: 30 additions & 0 deletions tests/storage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,33 @@ def xva_export_import(vm: VM, compression: XVACompression):
if imported_vm is not None:
imported_vm.destroy()
vm.host.ssh(f'rm -f {xva_path}')

ImageFormat = Literal['vhd', 'qcow2']

def vdi_export_import(vm: VM, sr: SR, image_format: ImageFormat):
vdi = sr.create_vdi(image_format=image_format)
image_path = f'/tmp/{vdi.uuid}.{image_format}'
try:
vm.connect_vdi(vdi, 'xvdb')
# generate 2 blocks of data of 200MiB, at position 0 and at position 500MiB
vm.ssh("randstream generate -v --size 200MiB /dev/xvdb")
# use a different seed to not write the same data (default seed is 0)
vm.ssh("randstream generate -v --seed 1 --position 500MiB --size 200MiB /dev/xvdb")
vm.ssh("randstream validate -v --size 200MiB --expected-checksum c6310c52 /dev/xvdb")
vm.ssh("randstream validate -v --position 500MiB --size 200MiB --expected-checksum 1cb4218e /dev/xvdb")
vm.disconnect_vdi(vdi)
vm.host.xe('vdi-export', {'uuid': vdi.uuid, 'filename': image_path, 'format': image_format})
vdi = vdi.destroy()
# check that the zero blocks are not part of the result
size_mb = int(vm.host.ssh(f'du -sm {image_path}').split()[0])
assert 400 < size_mb < 410, f"unexpected image size: {size_mb}"
vdi = sr.create_vdi(image_format=image_format)
vm.host.xe('vdi-import', {'uuid': vdi.uuid, 'filename': image_path, 'format': image_format})
vm.connect_vdi(vdi, 'xvdb')
vm.ssh("randstream validate -v --size 200MiB --expected-checksum c6310c52 /dev/xvdb")
vm.ssh("randstream validate -v --position 500MiB --size 200MiB --expected-checksum 1cb4218e /dev/xvdb")
finally:
if vdi is not None:
vm.disconnect_vdi(vdi)
vdi.destroy()
vm.host.ssh(f'rm -f {image_path}')
15 changes: 14 additions & 1 deletion tests/storage/xfs/test_xfs_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@
from lib.commands import SSHCommandFailed
from lib.common import vm_image, wait_for
from lib.host import Host
from lib.sr import SR
from lib.vdi import VDI
from lib.vm import VM
from tests.storage import CoalesceOperation, XVACompression, coalesce_integrity, vdi_is_open, xva_export_import
from tests.storage import (
CoalesceOperation,
ImageFormat,
XVACompression,
coalesce_integrity,
vdi_export_import,
vdi_is_open,
xva_export_import,
)

# Requirements:
# - one XCP-ng host >= 8.2 with an additional unused disk for the SR
Expand Down Expand Up @@ -92,6 +101,10 @@ def test_coalesce(self, storage_test_vm: VM, vdi_on_xfs_sr: VDI, vdi_op: Coalesc
def test_xva_export_import(self, vm_on_xfs_sr: VM, compression: XVACompression):
xva_export_import(vm_on_xfs_sr, compression)

@pytest.mark.small_vm
def test_vdi_export_import(self, storage_test_vm: VM, xfs_sr: SR, image_format: ImageFormat):
vdi_export_import(storage_test_vm, xfs_sr, image_format)

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

@pytest.mark.reboot
Expand Down
15 changes: 14 additions & 1 deletion tests/storage/zfs/test_zfs_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@

from lib.commands import SSHCommandFailed
from lib.common import vm_image, wait_for
from lib.sr import SR
from lib.vdi import VDI
from lib.vm import VM
from tests.storage import CoalesceOperation, XVACompression, coalesce_integrity, vdi_is_open, xva_export_import
from tests.storage import (
CoalesceOperation,
ImageFormat,
XVACompression,
coalesce_integrity,
vdi_export_import,
vdi_is_open,
xva_export_import,
)

from .conftest import POOL_NAME, POOL_PATH

Expand Down Expand Up @@ -86,6 +95,10 @@ def test_coalesce(self, storage_test_vm: VM, vdi_on_zfs_sr: VDI, vdi_op: Coalesc
def test_xva_export_import(self, vm_on_zfs_sr: VM, compression: XVACompression):
xva_export_import(vm_on_zfs_sr, compression)

@pytest.mark.small_vm
def test_vdi_export_import(self, storage_test_vm: VM, zfs_sr: SR, image_format: ImageFormat):
vdi_export_import(storage_test_vm, zfs_sr, image_format)

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

@pytest.mark.reboot
Expand Down
33 changes: 33 additions & 0 deletions tests/storage/zfsvol/test_zfsvol_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from lib.common import vm_image, wait_for
from lib.sr import SR
from lib.vdi import VDI
from lib.vm import VM
from tests.storage import CoalesceOperation, XVACompression, coalesce_integrity, xva_export_import
Expand Down Expand Up @@ -68,6 +69,38 @@ def test_coalesce(self, storage_test_vm: VM, vdi_on_zfsvol_sr: VDI, vdi_op: Coal
def test_xva_export_import(self, vm_on_zfsvol_sr: VM, compression: XVACompression):
xva_export_import(vm_on_zfsvol_sr, compression)

@pytest.mark.small_vm
def test_vdi_export_import(self, storage_test_vm: VM, zfsvol_sr: SR, image_format: str):
vm = storage_test_vm
sr = zfsvol_sr
vdi = sr.create_vdi(image_format=image_format)
image_path = f'/tmp/{vdi.uuid}.{image_format}'
try:
vm.connect_vdi(vdi, 'xvdb')
# generate 2 blocks of data of 200MiB, at position 0 and at position 500MiB
vm.ssh("randstream generate -v --size 200MiB /dev/xvdb")
vm.ssh("randstream generate -v --seed 1 --position 500MiB --size 200MiB /dev/xvdb")
vm.ssh("randstream validate -v --size 200MiB --expected-checksum c6310c52 /dev/xvdb")
vm.ssh("randstream validate -v --position 500MiB --size 200MiB --expected-checksum 1cb4218e /dev/xvdb")
vm.disconnect_vdi(vdi)
vm.host.xe('vdi-export', {'uuid': vdi.uuid, 'filename': image_path, 'format': image_format})
vdi = vdi.destroy()
# check that the zero blocks are not part of the result
if image_format != 'vhd':
# FIXME: this is broken with vhd, skip for now (XCPNG-2631)
size_mb = int(vm.host.ssh(f'du -sm {image_path}').split()[0])
assert 400 < size_mb < 410, f"unexpected image size: {size_mb}"
vdi = sr.create_vdi(image_format=image_format)
vm.host.xe('vdi-import', {'uuid': vdi.uuid, 'filename': image_path, 'format': image_format})
vm.connect_vdi(vdi, 'xvdb')
vm.ssh("randstream validate -v --size 200MiB --expected-checksum c6310c52 /dev/xvdb")
vm.ssh("randstream validate -v --position 500MiB --size 200MiB --expected-checksum 1cb4218e /dev/xvdb")
finally:
if vdi is not None:
vm.disconnect_vdi(vdi)
vdi.destroy()
vm.host.ssh(f'rm -f {image_path}')

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

@pytest.mark.reboot
Expand Down