Skip to content

Commit 1624439

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 0b80377 commit 1624439

3 files changed

Lines changed: 11 additions & 32 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:

tests/storage/linstor/conftest.py

Lines changed: 3 additions & 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,9 @@ 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+
# Always install from the stable repo. Upgrade tests pull newer packages
135+
# from xcp-ng-linstor-testing themselves via yum_update(enablerepos=...).
136+
host.yum_install([LINSTOR_PACKAGE])
153137
# Needed because the linstor driver is not in the xapi sm-plugins list
154138
# before installing the LINSTOR packages.
155139
host.ssh('systemctl restart multipathd')

tests/storage/linstor/test_linstor_sr.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,17 +274,18 @@ def test_linstor_sr_pool_update(self, linstor_sr: SR, vm_on_linstor_sr: VM) -> N
274274

275275
# RPU is disabled for pools with XOSTOR SRs.
276276
# 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")
277+
def update_host(host: Host) -> None:
278+
logging.info("Updating host %s", host.hostname_or_ip)
279+
host.yum_clean_metadata()
280+
output = host.yum_update(enablerepos=["xcp-ng-linstor-testing"])
281+
if "No packages marked for update" not in output:
281282
with updates_lock:
282283
updates_applied.append(host)
283284
else:
284285
logging.info("No updates available for host %s", host.hostname_or_ip)
285286

286287
with concurrent.futures.ThreadPoolExecutor() as executor:
287-
executor.map(install_updates_on, hosts)
288+
executor.map(update_host, hosts)
288289

289290
# Reboot updated hosts
290291
def reboot_updated(host: Host) -> None:

0 commit comments

Comments
 (0)