Skip to content

Commit 7ad889e

Browse files
tests/storage/lvm: Updated lvm to handle both vhd and qcow2 vdi image format
Signed-off-by: Rushikesh Jadhav <rushikesh7@gmail.com>
1 parent c9547db commit 7ad889e

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

tests/storage/lvm/conftest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@
1111
from lib.sr import SR
1212

1313
@pytest.fixture(scope='package')
14-
def lvm_sr(host: Host, unused_512B_disks: dict[Host, list[Host.BlockDeviceInfo]]) -> Generator[SR]:
14+
def lvm_sr(host: Host,
15+
unused_512B_disks: dict[Host, list[Host.BlockDeviceInfo]],
16+
image_format: str
17+
) -> Generator[SR]:
1518
""" An LVM SR on first host. """
1619
sr_disk = unused_512B_disks[host][0]["name"]
17-
sr = host.sr_create('lvm', "LVM-local-SR-test", {'device': '/dev/' + sr_disk})
20+
sr = host.sr_create('lvm', "LVM-local-SR-test",
21+
{'device': '/dev/' + sr_disk,
22+
'preferred-image-formats': image_format})
1823
yield sr
1924
# teardown
2025
sr.destroy()

tests/storage/lvm/test_lvm_sr.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@ class TestLVMSRCreateDestroy:
2828
def test_create_sr_with_missing_device(self, host):
2929
try_to_create_sr_with_missing_device('lvm', 'LVM-local-SR-test', host)
3030

31-
def test_create_and_destroy_sr(self, host: Host, unused_512B_disks: dict[Host, list[Host.BlockDeviceInfo]]) -> None:
31+
def test_create_and_destroy_sr(self, host: Host,
32+
unused_512B_disks: dict[Host, list[Host.BlockDeviceInfo]],
33+
image_format: str
34+
) -> None:
3235
sr_disk = unused_512B_disks[host][0]["name"]
3336
# Create and destroy tested in the same test to leave the host as unchanged as possible
34-
sr = host.sr_create('lvm', "LVM-local-SR-test", {'device': '/dev/' + sr_disk}, verify=True)
37+
sr = host.sr_create('lvm', "LVM-local-SR-test", {
38+
'device': '/dev/' + sr_disk,
39+
'preferred-image-formats': image_format
40+
}, verify=True)
3541
# import a VM in order to detect vm import issues here rather than in the vm_on_xfs_fixture used in
3642
# the next tests, because errors in fixtures break teardown
3743
vm = host.import_vm(vm_image('mini-linux-x86_64-bios'), sr_uuid=sr.uuid)
@@ -47,6 +53,13 @@ def test_quicktest(self, lvm_sr):
4753
def test_vdi_is_not_open(self, vdi_on_lvm_sr):
4854
assert not vdi_is_open(vdi_on_lvm_sr)
4955

56+
def test_vdi_image_format(self, vdi_on_lvm_sr: VDI, image_format: str):
57+
fmt = vdi_on_lvm_sr.get_image_format()
58+
# feature-detect: if the SM doesn't report image-format, skip this check
59+
if not fmt:
60+
pytest.skip("SM does not report sm-config:image-format; skipping format check")
61+
assert fmt == image_format
62+
5063
@pytest.mark.small_vm # run with a small VM to test the features
5164
@pytest.mark.big_vm # and ideally with a big VM to test it scales
5265
def test_start_and_shutdown_VM(self, vm_on_lvm_sr):

0 commit comments

Comments
 (0)