From 80829d910b8aa5be15c06b9df34952dee37034ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dirk=20M=C3=BCller?= Date: Wed, 25 Oct 2023 11:31:18 +0200 Subject: [PATCH] Restrict repository checks to the BCI repo In case the host is registered, it would otherwise use the registered channels --- bci_tester/data.py | 26 +++++++++++++++----------- tests/test_all.py | 10 ++++------ tests/test_repository.py | 26 ++++++++++++++++---------- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/bci_tester/data.py b/bci_tester/data.py index 13e9abe0..5ab788ed 100755 --- a/bci_tester/data.py +++ b/bci_tester/data.py @@ -149,6 +149,13 @@ }[TARGET] +BCI_REPO_NAME = "SLE_BCI" +if OS_VERSION == "tumbleweed": + BCI_REPO_NAME = "repo-oss" +if OS_VERSION == "basalt": + BCI_REPO_NAME = "repo-basalt" + + def create_container_version_mark( available_versions: Iterable[str], ) -> MarkDecorator: @@ -181,7 +188,7 @@ def create_container_version_mark( BCI_DEVEL_REPO = f"https://updates.suse.com/SUSE/Products/SLE-BCI/{OS_MAJOR_VERSION}-SP{OS_SP_VERSION}/{LOCALHOST.system_info.arch}/product/" _BCI_CONTAINERFILE = "" else: - _BCI_CONTAINERFILE = f"RUN sed -i 's|baseurl.*|baseurl={BCI_DEVEL_REPO}|' /etc/zypp/repos.d/SLE_BCI.repo" + _BCI_CONTAINERFILE = f"RUN sed -i 's|baseurl.*|baseurl={BCI_DEVEL_REPO}|' /etc/zypp/repos.d/{BCI_REPO_NAME}.repo" _IMAGE_TYPE_T = Literal["dockerfile", "kiwi"] @@ -544,17 +551,14 @@ def create_BCI( REPOCLOSURE_CONTAINER = DerivedContainer( base="registry.fedoraproject.org/fedora:latest", - containerfile=r"""RUN dnf -y install 'dnf-command(repoclosure)' + containerfile=f"""RUN dnf -y install 'dnf-command(repoclosure)' RUN rm -f /etc/yum.repos.d/*repo -RUN echo $'[SLE_BCI] \n\ -enabled=1 \n\ -name="SLE BCI" \n\ -autorefresh=0 \n\ -baseurl=""" - + BCI_DEVEL_REPO - + r""" \n\ -priority=100' > /etc/yum.repos.d/SLE_BCI.repo -""", +RUN printf '[{BCI_REPO_NAME}]\\n\ +enabled=1\\n\ +name="SLE BCI"\\n\ +autorefresh=0\\n\ +baseurl={BCI_DEVEL_REPO}\\n\ +priority=100\\n' > /etc/yum.repos.d/{BCI_REPO_NAME}.repo""", ) diff --git a/tests/test_all.py b/tests/test_all.py index b29e09fb..a45250a3 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -15,6 +15,7 @@ from pytest_container.container import ContainerData from bci_tester.data import ALL_CONTAINERS +from bci_tester.data import BCI_REPO_NAME from bci_tester.data import BUSYBOX_CONTAINER from bci_tester.data import CONTAINERS_WITH_ZYPPER from bci_tester.data import INIT_CONTAINER @@ -207,11 +208,6 @@ def test_no_downgrade_on_install(container_per_test: ContainerData) -> None: Also ensure that there is no package in the container that is not also available in the BCI repository. """ - repo_name = "SLE_BCI" - if OS_VERSION == "tumbleweed": - repo_name = "repo-oss" - if OS_VERSION == "basalt": - repo_name = "repo-basalt" conn = container_per_test.connection @@ -220,7 +216,9 @@ def test_no_downgrade_on_install(container_per_test: ContainerData) -> None: conn.check_output("dumpsolv -j /var/cache/zypp/solv/@System/solv") ) bci_solv = json.loads( - conn.check_output(f"dumpsolv -j /var/cache/zypp/solv/{repo_name}/solv") + conn.check_output( + f"dumpsolv -j /var/cache/zypp/solv/{BCI_REPO_NAME}/solv" + ) ) installed_pkgs = { solvable["solvable:name"]: solvable["solvable:evr"] diff --git a/tests/test_repository.py b/tests/test_repository.py index a04e3726..e679276e 100644 --- a/tests/test_repository.py +++ b/tests/test_repository.py @@ -9,11 +9,16 @@ from pytest_container.runtime import LOCALHOST from bci_tester.data import BASE_CONTAINER +from bci_tester.data import BCI_REPO_NAME from bci_tester.data import OS_SP_VERSION from bci_tester.data import OS_VERSION from bci_tester.data import REPOCLOSURE_CONTAINER +_RM_ZYPPSERVICE = ( + "rm -v /usr/lib/zypp/plugins/services/container-suseconnect-zypp" +) + #: Packages that can be installed, but are reported as having dependency issues #: by :command:`dnf repoclosure`. #: This is caused by these packages having boolean requires on the kernel, which @@ -65,14 +70,10 @@ def get_package_list(con) -> List[str]: given a container connection. """ - package_list = ( - con.run_expect( - [0], - "dnf list --available|grep SLE_BCI|awk '{print $1}'", - ) - .stdout.strip() - .split("\n") - ) + + package_list = con.check_output( + f"dnf list --available|grep -F '{BCI_REPO_NAME}' | cut -d' ' -f1", + ).splitlines() assert len(package_list) > 3000 return package_list @@ -196,7 +197,10 @@ def test_package_installation(container_per_test, pkg): that they are not accidentally not installable. """ - container_per_test.connection.run_expect([0], f"zypper -n in {pkg}") + + container_per_test.connection.check_output( + f"{_RM_ZYPPSERVICE}; zypper -n in -r {BCI_REPO_NAME} {pkg}" + ) @pytest.mark.skipif( @@ -213,4 +217,6 @@ def test_sle15_packages(container_per_test, pkg): """Test that packages that we received reports by users for as missing/broken remain installable and available. """ - container_per_test.connection.run_expect([0], f"zypper -n in {pkg}") + container_per_test.connection.check_output( + f"{_RM_ZYPPSERVICE}; zypper -n in -r {BCI_REPO_NAME} {pkg}" + )