Skip to content

Commit 685a040

Browse files
tests/storage/zfs: Updated zfs to handle both vhd and qcow2 vdi image format
Signed-off-by: Rushikesh Jadhav <[email protected]>
1 parent 91f2bb5 commit 685a040

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

tests/storage/zfs/conftest.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ def host_without_zfs(host):
1414
"zfs must not be installed on the host at the beginning of the tests"
1515

1616
@pytest.fixture(scope='package')
17-
def host_with_zfs(host_without_zfs, host_with_saved_yum_state):
17+
def host_with_zfs(host_without_zfs, host_with_saved_yum_state, image_format):
1818
host = host_with_saved_yum_state
1919
host.yum_install(['zfs'])
2020
host.ssh(['modprobe', 'zfs'])
2121
yield host
22+
host.ssh(["systemctl", "stop", "zfs-zed"])
23+
host.ssh(['rmmod', 'zfs'])
24+
host.yum_remove(['zfs'])
2225

2326
@pytest.fixture(scope='package')
2427
def zpool_vol0(sr_disk_wiped, host_with_zfs):
@@ -28,9 +31,12 @@ def zpool_vol0(sr_disk_wiped, host_with_zfs):
2831
host_with_zfs.ssh(['zpool', 'destroy', POOL_NAME])
2932

3033
@pytest.fixture(scope='package')
31-
def zfs_sr(host, zpool_vol0):
34+
def zfs_sr(host, image_format, zpool_vol0):
3235
""" A ZFS SR on first host. """
33-
sr = host.sr_create('zfs', "ZFS-local-SR-test", {'location': POOL_PATH})
36+
sr = host.sr_create('zfs', "ZFS-local-SR-test", {
37+
'location': POOL_PATH,
38+
'preferred-image-formats': image_format
39+
}, verify=True)
3440
yield sr
3541
# teardown
3642
sr.destroy()

tests/storage/zfs/test_zfs_sr.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,29 @@ class TestZFSSRCreateDestroy:
2121
and VM import.
2222
"""
2323

24-
def test_create_zfs_sr_without_zfs(self, host):
24+
def test_create_zfs_sr_without_zfs(self, host, image_format):
2525
# This test must be the first in the series in this module
2626
assert not host.file_exists('/usr/sbin/zpool'), \
2727
"zfs must not be installed on the host at the beginning of the tests"
2828
sr = None
2929
try:
30-
sr = host.sr_create('zfs', "ZFS-local-SR-test", {'location': POOL_PATH})
30+
sr = host.sr_create('zfs', "ZFS-local-SR-test", {
31+
'location': POOL_PATH,
32+
'preferred-image-formats': image_format
33+
}, verify=True)
3134
except Exception:
3235
logging.info("SR creation failed, as expected.")
3336
if sr is not None:
3437
sr.destroy()
3538
assert False, "SR creation should not have succeeded!"
3639

3740
@pytest.mark.usefixtures("zpool_vol0")
38-
def test_create_and_destroy_sr(self, host):
41+
def test_create_and_destroy_sr(self, host, image_format):
3942
# 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)
43+
sr = host.sr_create('zfs', "ZFS-local-SR-test", {
44+
'location': POOL_PATH,
45+
'preferred-image-formats': image_format
46+
}, verify=True)
4147
# import a VM in order to detect vm import issues here rather than in the vm_on_xfs_fixture used in
4248
# the next tests, because errors in fixtures break teardown
4349
vm = host.import_vm(vm_image('mini-linux-x86_64-bios'), sr_uuid=sr.uuid)

0 commit comments

Comments
 (0)