From dfc8a7eda963e48bce4970a7931df69f5a3c622c Mon Sep 17 00:00:00 2001 From: Guillaume Date: Tue, 18 Jul 2023 12:51:38 +0200 Subject: [PATCH 1/2] Don't skip missing name with yum install When installing all packages together if one or more package don't exist there is no error. Some tests are checking that packages can be installed so we need to generate an error. To achieve this we add an option to yum install to stop and generate an error if a package is missing. Error is caught only for the first missing package. Signed-off-by: Guillaume --- lib/host.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/host.py b/lib/host.py index 88f629011..2b3b88dc2 100644 --- a/lib/host.py +++ b/lib/host.py @@ -275,7 +275,8 @@ def get_last_yum_history_tid(self): def yum_install(self, packages, enablerepo=None): logging.info('Install packages: %s on host %s' % (' '.join(packages), self)) enablerepo_cmd = ['--enablerepo=%s' % enablerepo] if enablerepo is not None else [] - return self.ssh(['yum', 'install', '-y'] + enablerepo_cmd + packages) + return self.ssh(['yum', 'install', '--setopt=skip_missing_names_on_install=False', '-y'] + + enablerepo_cmd + packages) def yum_remove(self, packages): logging.info('Remove packages: %s from host %s' % (' '.join(packages), self)) From 7ce24d3d9fa0a1f05ba40cb18cb4e1df7a71e0d9 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Mon, 17 Jul 2023 15:30:18 +0200 Subject: [PATCH 2/2] Add a new test to check that extras pkgs can be installed This test gets a list of extra packages from https://reports.xcp-ng.org//extra_installable.txt and checks that: - the package is available and dependencies resolved using yumdownloader - all packages can be installed. Before installing packages it saves the yum state and restores it after the installation. As tests are taking some time we added them in their onw job. Signed-off-by: Guillaume --- jobs.py | 10 ++++++++++ tests/packages/extra/conftest.py | 12 ++++++++++++ tests/packages/extra/test_extra_group_pkgs.py | 15 +++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 tests/packages/extra/conftest.py create mode 100644 tests/packages/extra/test_extra_group_pkgs.py diff --git a/jobs.py b/jobs.py index 5cbc52c37..d61047a0d 100755 --- a/jobs.py +++ b/jobs.py @@ -45,6 +45,16 @@ "paths": ["tests/misc"], "markers": "multi_vms and not flaky and not reboot", }, + "packages": { + "description": "tests that packages can be installed correctly", + "requirements": [ + "Any pool.", + ], + "nb_pools": 1, + "params": {}, + "paths": ["tests/packages"], + "markers": "", + }, "quicktest": { "description": "XAPI's quicktest, not so quick by the way", "requirements": [ diff --git a/tests/packages/extra/conftest.py b/tests/packages/extra/conftest.py new file mode 100644 index 000000000..b67b56356 --- /dev/null +++ b/tests/packages/extra/conftest.py @@ -0,0 +1,12 @@ +import logging +import pytest +import urllib.request + +@pytest.fixture(scope="session") +def extra_pkgs(host): + version = host.xcp_version + url = f"https://reports.xcp-ng.org/{version}/extra_installable.txt" + + logging.info(f"Getting extra packages from {url}") + response = urllib.request.urlopen(url) + return response.read().decode('utf-8').splitlines() diff --git a/tests/packages/extra/test_extra_group_pkgs.py b/tests/packages/extra/test_extra_group_pkgs.py new file mode 100644 index 000000000..ef6ce952a --- /dev/null +++ b/tests/packages/extra/test_extra_group_pkgs.py @@ -0,0 +1,15 @@ +# Explicitly import package-scoped fixtures (see explanation in pkgfixtures.py) +from pkgfixtures import host_with_saved_yum_state + +# Requirements: +# From --hosts parameter: +# - host(A1): any master host of a pool, with access to XCP-ng RPM repositories and reports.xcp-ng.org. + +def test_extra_group_packages_url_resolved(host, extra_pkgs): + for p in extra_pkgs: + host.ssh(['yumdownloader', '--resolve', '--urls', p]) + +def test_extra_group_packages_can_be_installed(host_with_saved_yum_state, extra_pkgs): + # Just try to install all packages together. Installing them one by one + # takes too much time due to the generation of the initrd. + host_with_saved_yum_state.yum_install(extra_pkgs)