Skip to content

Commit

Permalink
Restrict repository checks to the BCI repo
Browse files Browse the repository at this point in the history
In case the host is registered, it would otherwise use the registered
channels
  • Loading branch information
dirkmueller committed Oct 25, 2023
1 parent ca9b2fe commit 80829d9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 27 deletions.
26 changes: 15 additions & 11 deletions bci_tester/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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""",
)


Expand Down
10 changes: 4 additions & 6 deletions tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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"]
Expand Down
26 changes: 16 additions & 10 deletions tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand All @@ -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}"
)

0 comments on commit 80829d9

Please sign in to comment.