Skip to content

Commit d5946aa

Browse files
committed
storage/linstor: fix linstor upgrade test
Use new function `yum_update` instead of redundant function added previously, also fix name of function to be more accurate on what's it does Signed-off-by: Erwan Croze <erwan.croze@vates.tech>
1 parent f3cb69e commit d5946aa

4 files changed

Lines changed: 10 additions & 37 deletions

File tree

lib/host.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -480,11 +480,6 @@ def pool_has_vm(self, vm_uuid: str, vm_type: str = 'vm') -> bool:
480480
else:
481481
return self.xe('vm-list', {'uuid': vm_uuid}, minimal=True) == vm_uuid
482482

483-
def install_updates(self, enablerepo: str | None = None) -> str:
484-
logging.info("Install updates on host %s" % self)
485-
enablerepo_arg = f" --enablerepo={enablerepo}" if enablerepo is not None else ""
486-
return self.ssh(f"yum update -y{enablerepo_arg}")
487-
488483
def get_system_uuid(self) -> str:
489484
"""Get system uuid of current host.
490485
@@ -611,11 +606,10 @@ def is_enabled(self) -> bool:
611606
# If XAPI is not ready yet, or the host is down, this will throw. We return False in that case.
612607
return False
613608

614-
def has_updates(self, enablerepo: str | None = None) -> bool:
615-
enablerepo_arg = f" --enablerepo={enablerepo}" if enablerepo is not None else ""
609+
def has_updates(self) -> bool:
616610
try:
617611
# yum check-update returns 100 if there are updates, 1 if there's an error, 0 if no updates
618-
self.ssh(f"yum check-update{enablerepo_arg}")
612+
self.ssh('yum check-update')
619613
# returned 0, else there would have been a SSHCommandFailed
620614
return False
621615
except commands.SSHCommandFailed as e:

pytest.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ markers =
55
default_vm: mark a test with a default VM in case no --vm parameter was given.
66

77
# *** Markers used to select tests at collect stage ***
8-
upgrade_test: mark a test which will upgrade packages from testing repo
98

109
# * Host-related markers, automatically set based on fixtures
1110
hostA2: a second member in the first pool.

tests/storage/linstor/conftest.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,6 @@ def storage_pool_name(provisioning_type: str) -> str:
108108
def provisioning_type(request: pytest.FixtureRequest) -> str:
109109
return request.param
110110

111-
_linstor_upgrade_test = False
112-
113-
# pytest hook: called once at startup, before test collection.
114-
def pytest_configure(config):
115-
global _linstor_upgrade_test
116-
_linstor_upgrade_test = False
117-
118-
# pytest hook: called after all tests are collected, before any test runs.
119-
def pytest_collection_modifyitems(config, items):
120-
global _linstor_upgrade_test
121-
for item in items:
122-
if item.get_closest_marker("upgrade_test"):
123-
_linstor_upgrade_test = True
124-
break
125-
126111
@pytest.fixture(scope='package')
127112
def pool_with_linstor(
128113
hostA2: Host,
@@ -146,10 +131,7 @@ def ensure_linstor_not_installed(host: Host) -> None:
146131
def install_linstor(host: Host) -> None:
147132
logging.info(f"Installing {LINSTOR_PACKAGE} on host {host}...")
148133
host.yum_install([LINSTOR_RELEASE_PACKAGE])
149-
if _linstor_upgrade_test:
150-
host.yum_install([LINSTOR_PACKAGE], enablerepo="xcp-ng-linstor-testing")
151-
else:
152-
host.yum_install([LINSTOR_PACKAGE])
134+
host.yum_install([LINSTOR_PACKAGE], enablerepo="xcp-ng-linstor-testing")
153135
# Needed because the linstor driver is not in the xapi sm-plugins list
154136
# before installing the LINSTOR packages.
155137
host.ssh('systemctl restart multipathd')

tests/storage/linstor/test_linstor_sr.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,11 @@ def test_linstor_missing(self, linstor_sr: SR, host: Host) -> None:
255255

256256
@pytest.mark.reboot
257257
@pytest.mark.small_vm
258-
@pytest.mark.upgrade_test
259258
def test_linstor_sr_pool_update(self, linstor_sr: SR, vm_on_linstor_sr: VM) -> None:
260259
"""
261260
Perform update on the Linstor SR pool hosts while ensuring VM availability.
262261
1. Identify all hosts in the SR pool and order them with the master first.
263-
2. Update all hosts if updates are available.
262+
2. Update all hosts if updates are available from xcp-ng-linstor-testing.
264263
3. Reboot updated hosts.
265264
4. Sequentially ensure that the VM can start on all hosts.
266265
"""
@@ -274,17 +273,18 @@ def test_linstor_sr_pool_update(self, linstor_sr: SR, vm_on_linstor_sr: VM) -> N
274273

275274
# RPU is disabled for pools with XOSTOR SRs.
276275
# LINSTOR expects that we always use satellites and controllers with the same version on all hosts.
277-
def install_updates_on(host: Host) -> None:
278-
logging.info("Checking on host %s", host.hostname_or_ip)
279-
if host.has_updates(enablerepo="xcp-ng-linstor-testing"):
280-
host.install_updates(enablerepo="xcp-ng-linstor-testing")
276+
def update_host(host: Host) -> None:
277+
logging.info("Updating host %s", host.hostname_or_ip)
278+
host.yum_clean_metadata()
279+
output = host.yum_update(enablerepos=["xcp-ng-linstor-testing"])
280+
if "No packages marked for update" not in output:
281281
with updates_lock:
282282
updates_applied.append(host)
283283
else:
284284
logging.info("No updates available for host %s", host.hostname_or_ip)
285285

286286
with concurrent.futures.ThreadPoolExecutor() as executor:
287-
executor.map(install_updates_on, hosts)
287+
executor.map(update_host, hosts)
288288

289289
# Reboot updated hosts
290290
def reboot_updated(host: Host) -> None:
@@ -301,8 +301,6 @@ def reboot_updated(host: Host) -> None:
301301
vm.wait_for_os_booted()
302302
vm.shutdown(verify=True)
303303

304-
sr.scan()
305-
306304
# *** End of tests with reboots
307305

308306
# --- Test diskless resources --------------------------------------------------

0 commit comments

Comments
 (0)