1+ from __future__ import annotations
2+
13import pytest
24
35import logging
79from lib .common import vm_image , wait_for
810from tests .storage import vdi_is_open
911
12+ from typing import TYPE_CHECKING
13+
14+ if TYPE_CHECKING :
15+ from lib .host import Host
16+ from lib .vdi import VDI
17+
1018from .conftest import POOL_NAME , POOL_PATH
1119
1220# Requirements:
@@ -21,23 +29,29 @@ class TestZFSSRCreateDestroy:
2129 and VM import.
2230 """
2331
24- def test_create_zfs_sr_without_zfs (self , host ) :
32+ def test_create_zfs_sr_without_zfs (self , host : Host , image_format : str ) -> None :
2533 # This test must be the first in the series in this module
2634 assert not host .file_exists ('/usr/sbin/zpool' ), \
2735 "zfs must not be installed on the host at the beginning of the tests"
2836 sr = None
2937 try :
30- sr = host .sr_create ('zfs' , "ZFS-local-SR-test" , {'location' : POOL_PATH })
38+ sr = host .sr_create ('zfs' , "ZFS-local-SR-test" , {
39+ 'location' : POOL_PATH ,
40+ 'preferred-image-formats' : image_format
41+ }, verify = True )
3142 except Exception :
3243 logging .info ("SR creation failed, as expected." )
3344 if sr is not None :
3445 sr .destroy ()
3546 assert False , "SR creation should not have succeeded!"
3647
3748 @pytest .mark .usefixtures ("zpool_vol0" )
38- def test_create_and_destroy_sr (self , host ) :
49+ def test_create_and_destroy_sr (self , host : Host , image_format : str ) -> None :
3950 # Create and destroy tested in the same test to leave the host as unchanged as possible
40- sr = host .sr_create ('zfs' , "ZFS-local-SR-test" , {'location' : POOL_PATH }, verify = True )
51+ sr = host .sr_create ('zfs' , "ZFS-local-SR-test" , {
52+ 'location' : POOL_PATH ,
53+ 'preferred-image-formats' : image_format
54+ }, verify = True )
4155 # import a VM in order to detect vm import issues here rather than in the vm_on_xfs_fixture used in
4256 # the next tests, because errors in fixtures break teardown
4357 vm = host .import_vm (vm_image ('mini-linux-x86_64-bios' ), sr_uuid = sr .uuid )
@@ -53,6 +67,9 @@ def test_quicktest(self, zfs_sr):
5367 def test_vdi_is_not_open (self , vdi_on_zfs_sr ):
5468 assert not vdi_is_open (vdi_on_zfs_sr )
5569
70+ def test_vdi_image_format (self , vdi_on_zfs_sr : VDI , image_format : str ):
71+ assert vdi_on_zfs_sr .get_image_format () == image_format
72+
5673 @pytest .mark .small_vm # run with a small VM to test the features
5774 @pytest .mark .big_vm # and ideally with a big VM to test it scales
5875 def test_start_and_shutdown_VM (self , vm_on_zfs_sr ):
0 commit comments