Skip to content

Commit fd8fa37

Browse files
tests/storage/largeblock: Updated largeblock to handle both vhd and qcow2 vdi image format
Signed-off-by: Rushikesh Jadhav <[email protected]>
1 parent 6965c05 commit fd8fa37

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

tests/storage/largeblock/conftest.py

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

1313
@pytest.fixture(scope='package')
14-
def largeblock_sr(host: Host, unused_4k_disks: dict[Host, list[Host.BlockDeviceInfo]]) -> Generator[SR]:
14+
def largeblock_sr(host: Host,
15+
unused_4k_disks: dict[Host, list[Host.BlockDeviceInfo]],
16+
image_format: str) -> Generator[SR]:
1517
""" A LARGEBLOCK SR on first host. """
1618
sr_disk = unused_4k_disks[host][0]["name"]
17-
sr = host.sr_create('largeblock', "LARGEBLOCK-local-SR-test", {'device': '/dev/' + sr_disk})
19+
sr = host.sr_create('largeblock', "LARGEBLOCK-local-SR-test",
20+
{'device': '/dev/' + sr_disk,
21+
'preferred-image-formats': image_format})
1822
yield sr
1923
# teardown
2024
sr.destroy()

tests/storage/largeblock/test_largeblock_sr.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
if TYPE_CHECKING:
1111
from lib.host import Host
12+
from lib.vdi import VDI
1213

1314
# Requirements:
1415
# - one XCP-ng host with an additional unused 4KiB disk for the SR
@@ -23,10 +24,14 @@ class TestLARGEBLOCKSRCreateDestroy:
2324
def test_create_sr_with_missing_device(self, host):
2425
try_to_create_sr_with_missing_device('largeblock', 'LARGEBLOCK-local-SR-test', host)
2526

26-
def test_create_and_destroy_sr(self, host: Host, unused_4k_disks: dict[Host, list[Host.BlockDeviceInfo]]) -> None:
27+
def test_create_and_destroy_sr(self, host: Host,
28+
unused_4k_disks: dict[Host, list[Host.BlockDeviceInfo]],
29+
image_format: str) -> None:
2730
# Create and destroy tested in the same test to leave the host as unchanged as possible
2831
sr_disk = unused_4k_disks[host][0]["name"]
29-
sr = host.sr_create('largeblock', "LARGEBLOCK-local-SR-test", {'device': '/dev/' + sr_disk}, verify=True)
32+
sr = host.sr_create('largeblock', "LARGEBLOCK-local-SR-test",
33+
{'device': '/dev/' + sr_disk,
34+
'preferred-image-formats': image_format}, verify=True)
3035
# import a VM in order to detect vm import issues here rather than in the vm_on_xfs_fixture used in
3136
# the next tests, because errors in fixtures break teardown
3237
vm = host.import_vm(vm_image('mini-linux-x86_64-bios'), sr_uuid=sr.uuid)
@@ -42,6 +47,9 @@ def test_quicktest(self, largeblock_sr):
4247
def test_vdi_is_not_open(self, vdi_on_largeblock_sr):
4348
assert not vdi_is_open(vdi_on_largeblock_sr)
4449

50+
def test_vdi_image_format(self, vdi_on_largeblock_sr: VDI, image_format: str):
51+
assert vdi_on_largeblock_sr.get_image_format() == image_format
52+
4553
@pytest.mark.small_vm # run with a small VM to test the features
4654
@pytest.mark.big_vm # and ideally with a big VM to test it scales
4755
def test_start_and_shutdown_VM(self, vm_on_largeblock_sr):

0 commit comments

Comments
 (0)