Skip to content

Commit c9547db

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 86e904b commit c9547db

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
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: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,15 @@ 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)
@@ -47,6 +52,13 @@ def test_quicktest(self, ext_sr):
4752
def test_vdi_is_not_open(self, vdi_on_ext_sr):
4853
assert not vdi_is_open(vdi_on_ext_sr)
4954

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

0 commit comments

Comments
 (0)