Skip to content

Commit 0610307

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 b4e1f53 commit 0610307

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
@@ -13,11 +13,14 @@ def host_without_zfs(host):
1313
"zfs must not be installed on the host at the beginning of the tests"
1414

1515
@pytest.fixture(scope='package')
16-
def host_with_zfs(host_without_zfs, host_with_saved_yum_state):
16+
def host_with_zfs(host_without_zfs, host_with_saved_yum_state, image_format):
1717
host = host_with_saved_yum_state
1818
host.yum_install(['zfs'])
1919
host.ssh(['modprobe', 'zfs'])
2020
yield host
21+
host.ssh(["systemctl", "stop", "zfs-zed"])
22+
host.ssh(['rmmod', 'zfs'])
23+
host.yum_remove(['zfs'])
2124

2225
@pytest.fixture(scope='package')
2326
def zpool_vol0(sr_disk_wiped, host_with_zfs):
@@ -27,9 +30,12 @@ def zpool_vol0(sr_disk_wiped, host_with_zfs):
2730
host_with_zfs.ssh(['zpool', 'destroy', POOL_NAME])
2831

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

tests/storage/zfs/test_zfs_sr.py

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

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

3538
@pytest.mark.usefixtures("zpool_vol0")
36-
def test_create_and_destroy_sr(self, host):
39+
def test_create_and_destroy_sr(self, host, image_format):
3740
# Create and destroy tested in the same test to leave the host as unchanged as possible
38-
sr = host.sr_create('zfs', "ZFS-local-SR-test", {'location': POOL_PATH}, verify=True)
41+
sr = host.sr_create('zfs', "ZFS-local-SR-test", {
42+
'location': POOL_PATH,
43+
'preferred-image-formats': image_format
44+
}, verify=True)
3945
# import a VM in order to detect vm import issues here rather than in the vm_on_xfs_fixture used in
4046
# the next tests, because errors in fixtures break teardown
4147
vm = host.import_vm(vm_image('mini-linux-x86_64-bios'), sr_uuid=sr.uuid)

0 commit comments

Comments
 (0)