Skip to content

Commit ff0987b

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

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

tests/storage/ext/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 ext_sr(host: Host, unused_512B_disks: dict[Host, list[Host.BlockDeviceInfo]]) -> Generator[SR]:
14+
def ext_sr(host: Host,
15+
unused_512B_disks: dict[Host, list[Host.BlockDeviceInfo]],
16+
image_format: str
17+
) -> Generator[SR]:
1518
""" An EXT SR on first host. """
1619
sr_disk = unused_512B_disks[host][0]["name"]
17-
sr = host.sr_create('ext', "EXT-local-SR-test", {'device': '/dev/' + sr_disk})
20+
sr = host.sr_create('ext', "EXT-local-SR-test",
21+
{'device': '/dev/' + sr_disk,
22+
'preferred-image-formats': image_format})
1823
yield sr
1924
# teardown
2025
sr.destroy()

tests/storage/ext/test_ext_sr.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,32 @@ class TestEXTSRCreateDestroy:
2828
def test_create_sr_with_missing_device(self, host):
2929
try_to_create_sr_with_missing_device('ext', 'EXT-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
# Create and destroy tested in the same test to leave the host as unchanged as possible
3336
sr_disk = unused_512B_disks[host][0]["name"]
34-
sr = host.sr_create('ext', "EXT-local-SR-test", {'device': '/dev/' + sr_disk}, verify=True)
37+
sr = host.sr_create('ext', "EXT-local-SR-test",
38+
{'device': '/dev/' + sr_disk,
39+
'preferred-image-formats': image_format}, verify=True)
3540
# import a VM in order to detect vm import issues here rather than in the vm_on_xfs_fixture used in
3641
# the next tests, because errors in fixtures break teardown
3742
vm = host.import_vm(vm_image('mini-linux-x86_64-bios'), sr_uuid=sr.uuid)
3843
vm.destroy(verify=True)
3944
sr.destroy(verify=True)
4045

41-
@pytest.mark.usefixtures("ext_sr")
46+
# We want to skip class tests for qcow2 if the SM does not support qcow2
47+
@pytest.fixture(scope="class")
48+
def for_qcow2_vdi_image_format(vdi_on_ext_sr: VDI, image_format: str):
49+
# only check qcow2-specific behavior
50+
if image_format != "qcow2":
51+
return
52+
# feature-detect: if the SM doesn't report image-format, skip this check
53+
if not vdi_on_ext_sr.get_image_format():
54+
pytest.skip("SM does not report sm-config:image-format; skipping qcow2 format check")
55+
56+
@pytest.mark.usefixtures("for_qcow2_vdi_image_format", "ext_sr")
4257
class TestEXTSR:
4358
@pytest.mark.quicktest
4459
def test_quicktest(self, ext_sr):

0 commit comments

Comments
 (0)