Skip to content

Commit 95f19b1

Browse files
authored
Merge pull request #345 from xcp-ng/mlr/933-restart-toolstack-after-teardown
Add toolstack restart after teardown on tests enabling / disabling SRs
2 parents ef08fbb + 48c812e commit 95f19b1

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed

pkgfixtures.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,36 @@ def formatted_and_mounted_ext4_disk(host: Host, unused_512B_disks: dict[Host, li
3838
yield mountpoint
3939
teardown_formatted_and_mounted_disk(host, mountpoint)
4040

41-
@pytest.fixture(scope='package')
42-
def host_with_saved_yum_state(host: Host) -> Generator[Host]:
41+
def _host_with_saved_yum_state(host: Host, restart_toolstack: bool) -> Generator[Host]:
42+
"""
43+
Saves the yum state and restores the saved state on teardown.
44+
45+
It also optionally restarts the toolstack.
46+
Fixtures using this function should not be used concurrently in the same test run.
47+
"""
4348
host.yum_save_state()
4449
yield host
4550
host.yum_restore_saved_state()
51+
if restart_toolstack:
52+
host.restart_toolstack(verify=True)
53+
54+
@pytest.fixture(scope='package')
55+
def host_with_saved_yum_state(host: Host) -> Generator[Host]:
56+
"""
57+
Saves the yum state and then restore it on teardown.
58+
59+
Should not be used concurrently with another "host_with_saved_yum_state" fixture
60+
"""
61+
yield from _host_with_saved_yum_state(host, False)
62+
63+
@pytest.fixture(scope='package')
64+
def host_with_saved_yum_state_toolstack_restart(host: Host) -> Generator[Host]:
65+
"""
66+
Saves the yum state then restore it and restarts the toolstack on teardown.
67+
68+
Should not be used concurrently with another "host_with_saved_yum_state" fixture
69+
"""
70+
yield from _host_with_saved_yum_state(host, True)
4671

4772
@pytest.fixture(scope='package')
4873
def pool_with_saved_yum_state(host: Host) -> Generator[Pool]:

tests/storage/fsp/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22

33
# Explicitly import package-scoped fixtures (see explanation in pkgfixtures.py)
4-
from pkgfixtures import host_with_saved_yum_state
4+
from pkgfixtures import host_with_saved_yum_state_toolstack_restart
55

66
FSP_REPO_NAME = 'runx'
77

@@ -10,8 +10,8 @@
1010
DIRECTORIES_PATH = 'directories'
1111

1212
@pytest.fixture(scope='package')
13-
def host_with_runx_repo(host_with_saved_yum_state):
14-
host = host_with_saved_yum_state
13+
def host_with_runx_repo(host_with_saved_yum_state_toolstack_restart):
14+
host = host_with_saved_yum_state_toolstack_restart
1515
host.add_xcpng_repo(FSP_REPO_NAME, 'vates')
1616
yield host
1717
# teardown

tests/storage/linstor/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def install_linstor(host):
110110
def remove_linstor(host):
111111
logging.info(f"Cleaning up python-linstor from host {host}...")
112112
host.yum_remove(["python-linstor"])
113+
host.restart_toolstack(verify=True)
113114

114115
with concurrent.futures.ThreadPoolExecutor() as executor:
115116
executor.map(remove_linstor, pool.hosts)

tests/storage/zfsvol/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import logging
44

55
# Explicitly import package-scoped fixtures (see explanation in pkgfixtures.py)
6-
from pkgfixtures import host_with_saved_yum_state, sr_disk_wiped
6+
from pkgfixtures import host_with_saved_yum_state_toolstack_restart, sr_disk_wiped
77

88
@pytest.fixture(scope='package')
9-
def host_with_zfsvol(host_with_saved_yum_state):
10-
host = host_with_saved_yum_state
9+
def host_with_zfsvol(host_with_saved_yum_state_toolstack_restart):
10+
host = host_with_saved_yum_state_toolstack_restart
1111
host.yum_install(['xcp-ng-xapi-storage-volume-zfsvol'])
1212
host.restart_toolstack(verify=True)
1313
yield host

0 commit comments

Comments
 (0)