99
1010if 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,17 +24,31 @@ 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 )
3338 vm .destroy (verify = True )
3439 sr .destroy (verify = True )
3540
36- @pytest .mark .usefixtures ("largeblock_sr" )
41+ # We want to skip class tests for qcow2 if the SM does not support qcow2
42+ @pytest .fixture (scope = "class" )
43+ def for_qcow2_vdi_image_format (vdi_on_largeblock_sr : VDI , image_format : str ):
44+ # only check qcow2-specific behavior
45+ if image_format != "qcow2" :
46+ return
47+ # feature-detect: if the SM doesn't report image-format, skip this check
48+ if not vdi_on_largeblock_sr .get_image_format ():
49+ pytest .skip ("SM does not report sm-config:image-format; skipping qcow2 format check" )
50+
51+ @pytest .mark .usefixtures ("for_qcow2_vdi_image_format" , "largeblock_sr" )
3752class TestLARGEBLOCKSR :
3853 @pytest .mark .quicktest
3954 def test_quicktest (self , largeblock_sr ):
0 commit comments