Skip to content

Commit

Permalink
Switch BASE_CONTAINER to a BASE_CONTAINERS list
Browse files Browse the repository at this point in the history
Thereby we can keep it as an empty list in the DSO case and
just assign a FIPS container.
  • Loading branch information
dirkmueller committed Sep 24, 2024
1 parent fdea58c commit 8aa32e5
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 60 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The base container
^^^^^^^^^^^^^^^^^^

We are basing most of our tests on _the_ base container (available via the
``BASE_CONTAINER`` variable in :file:`bci_tester/data.py`). This container is pulled
``BASE_CONTAINERS`` variable in :file:`bci_tester/data.py`). This container is pulled
directly from ``registry.suse.de`` and is being build from the
`SUSE:SLE-15-SP3:Update:CR:ToTest/sles15-image
<https://build.suse.de/package/show/SUSE:SLE-15-SP3:Update:CR:ToTest/sles15-image>`_
Expand All @@ -66,7 +66,7 @@ http://dist.nue.suse.com/ibs/SUSE:/SLE-15-SP3:/Update:/BCI/images/repo/. Unfortu
you have to hand pick the correct folder (use the one ending with ``-Media1`` and
for the correct arch) because the build number is put into the folder name.

The ``BASE_CONTAINER`` will then be rebuild with the ``SLE_BCI`` repository
The ``BASE_CONTAINERS`` will then be rebuild with the ``SLE_BCI`` repository
replaced with the one from the ``BCI_DEVEL_REPO`` and all tests will thus use
the new repository.

Expand Down
40 changes: 27 additions & 13 deletions bci_tester/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,18 +369,32 @@ def create_BCI(
LTSS_BASE_FIPS_CONTAINERS = []

if OS_VERSION == "tumbleweed":
BASE_CONTAINER = create_BCI(
build_tag="tumbleweed:latest",
image_type="kiwi",
bci_type=ImageType.OS,
)
BASE_CONTAINERS = [
create_BCI(
build_tag="tumbleweed:latest",
image_type="kiwi",
bci_type=ImageType.OS,
)
]
else:
BASE_CONTAINER = create_BCI(
build_tag=f"{BCI_CONTAINER_PREFIX}/bci-base:{OS_CONTAINER_TAG}",
image_type="kiwi",
bci_type=ImageType.OS,
)
if TARGET not in ("dso",):
# DSO has the bci-base container as fips version and no non-fips base container
if TARGET in ("dso",):
BASE_CONTAINERS: list[ParameterSet] = []
BASE_FIPS_CONTAINERS: list[ParameterSet] = [
create_BCI(
build_tag=f"{BCI_CONTAINER_PREFIX}/bci-base:{OS_CONTAINER_TAG}",
bci_type=ImageType.OS,
available_versions=("15.6",),
)
]
else:
BASE_CONTAINERS = [
create_BCI(
build_tag=f"{BCI_CONTAINER_PREFIX}/bci-base:{OS_CONTAINER_TAG}",
image_type="kiwi",
bci_type=ImageType.OS,
)
]
BASE_FIPS_CONTAINERS = [
create_BCI(
build_tag=f"{BCI_CONTAINER_PREFIX}/bci-base-fips:{OS_CONTAINER_TAG}",
Expand Down Expand Up @@ -859,7 +873,6 @@ def create_BCI(

CONTAINERS_WITH_ZYPPER = (
[
BASE_CONTAINER,
INIT_CONTAINER,
KERNEL_MODULE_CONTAINER,
NGINX_CONTAINER,
Expand All @@ -868,6 +881,7 @@ def create_BCI(
PHP_8_FPM,
]
+ ALERTMANAGER_CONTAINERS
+ BASE_CONTAINERS
+ BASE_FIPS_CONTAINERS
+ BLACKBOX_CONTAINERS
+ CONTAINER_389DS_CONTAINERS
Expand Down Expand Up @@ -931,7 +945,6 @@ def create_BCI(
else:
L3_CONTAINERS = (
[
BASE_CONTAINER,
BUSYBOX_CONTAINER,
DISTRIBUTION_CONTAINER,
GIT_CONTAINER,
Expand All @@ -944,6 +957,7 @@ def create_BCI(
PHP_8_CLI,
PHP_8_FPM,
]
+ BASE_CONTAINERS
+ BASE_FIPS_CONTAINERS
+ CONTAINER_389DS_CONTAINERS
+ GOLANG_CONTAINERS
Expand Down
42 changes: 22 additions & 20 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pytest_container.container import container_and_marks_from_pytest_param
from pytest_container.runtime import LOCALHOST

from bci_tester.data import BASE_CONTAINER
from bci_tester.data import BASE_CONTAINERS
from bci_tester.data import BASE_FIPS_CONTAINERS
from bci_tester.data import LTSS_BASE_CONTAINERS
from bci_tester.data import LTSS_BASE_FIPS_CONTAINERS
Expand All @@ -26,7 +26,7 @@
from tests.test_fips import openssl_fips_hashes_test_fnct

CONTAINER_IMAGES = [
BASE_CONTAINER,
*BASE_CONTAINERS,
*BASE_FIPS_CONTAINERS,
*LTSS_BASE_CONTAINERS,
*LTSS_BASE_FIPS_CONTAINERS,
Expand Down Expand Up @@ -182,8 +182,7 @@ def test_openssl_hashes(container):

@pytest.mark.parametrize(
"container_per_test",
[*LTSS_BASE_FIPS_CONTAINERS, *BASE_FIPS_CONTAINERS]
+ ([BASE_CONTAINER] if TARGET in ("dso",) else []),
[*LTSS_BASE_FIPS_CONTAINERS, *BASE_FIPS_CONTAINERS],
indirect=True,
)
def test_openssl_fips_hashes(container_per_test):
Expand Down Expand Up @@ -226,24 +225,27 @@ def test_all_openssl_hashes_known(auto_container):

#: This is the base container with additional launch arguments applied to it so
#: that docker can be launched inside the container
DIND_CONTAINER = pytest.param(
DerivedContainer(
base=container_and_marks_from_pytest_param(BASE_CONTAINER)[0],
**{
x: getattr(BASE_CONTAINER.values[0], x)
for x in BASE_CONTAINER.values[0].__dict__
if x not in ("extra_launch_args", "base")
},
extra_launch_args=[
"--privileged=true",
"-v",
"/var/run/docker.sock:/var/run/docker.sock",
],
),
)
DIND_CONTAINERS = [
pytest.param(
DerivedContainer(
base=container_and_marks_from_pytest_param(c)[0],
**{
x: getattr(c.values[0], x)
for x in c.values[0].__dict__
if x not in ("extra_launch_args", "base")
},
extra_launch_args=[
"--privileged=true",
"-v",
"/var/run/docker.sock:/var/run/docker.sock",
],
)
)
for c in BASE_CONTAINERS
]


@pytest.mark.parametrize("container_per_test", [DIND_CONTAINER], indirect=True)
@pytest.mark.parametrize("container_per_test", DIND_CONTAINERS, indirect=True)
@pytest.mark.xfail(
OS_VERSION in ("15.7",), reason="SLE BCI repository not yet available"
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pytest_container.container import ContainerData
from pytest_container.runtime import LOCALHOST

from bci_tester.data import BASE_CONTAINER
from bci_tester.data import BASE_CONTAINERS
from bci_tester.data import GOLANG_CONTAINERS
from bci_tester.runtime_choice import DOCKER_SELECTED

Expand Down Expand Up @@ -102,7 +102,7 @@ def test_go_get_binary_in_path(auto_container_per_test):
)


@pytest.mark.parametrize("container", [BASE_CONTAINER], indirect=True)
@pytest.mark.parametrize("container", BASE_CONTAINERS, indirect=True)
def test_base_PATH_present(auto_container, container):
"""Regression test that we did not accidentally omit parts of ``$PATH`` that are
present in he base container in the golang containers.
Expand Down
19 changes: 5 additions & 14 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from bci_tester.data import ACC_CONTAINERS
from bci_tester.data import ALERTMANAGER_CONTAINERS
from bci_tester.data import ALL_CONTAINERS
from bci_tester.data import BASE_CONTAINER
from bci_tester.data import BASE_CONTAINERS
from bci_tester.data import BASE_FIPS_CONTAINERS
from bci_tester.data import BLACKBOX_CONTAINERS
from bci_tester.data import BUSYBOX_CONTAINER
Expand Down Expand Up @@ -114,7 +114,9 @@ def _get_container_label_prefix(
IMAGES_AND_NAMES: List[ParameterSet] = [
pytest.param(cont, name, img_type, marks=cont.marks)
for cont, name, img_type in [
(BASE_CONTAINER, "base", ImageType.OS),
(c, "base-fips", ImageType.OS) for c in BASE_CONTAINERS
]
+ [
(GIT_CONTAINER, "git", ImageType.APPLICATION),
(HELM_CONTAINER, "helm", ImageType.APPLICATION),
(MINIMAL_CONTAINER, "minimal", ImageType.OS),
Expand Down Expand Up @@ -485,18 +487,7 @@ def test_disturl_can_be_checked_out(
if (
cont not in L3_CONTAINERS
and cont not in ACC_CONTAINERS
and cont != BASE_CONTAINER
)
]
+ [
pytest.param(
BASE_CONTAINER.values,
marks=BASE_CONTAINER.marks
+ [
pytest.mark.xfail(
reason="Base container for SLE 15 SP6 is not using the techpreview label (https://build.suse.de/request/show/325200)"
)
],
and cont not in BASE_CONTAINERS
)
],
indirect=True,
Expand Down
12 changes: 6 additions & 6 deletions tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pytest

from bci_tester.data import ALLOWED_BCI_REPO_OS_VERSIONS
from bci_tester.data import BASE_CONTAINER
from bci_tester.data import BASE_CONTAINERS
from bci_tester.data import BCI_REPO_NAME
from bci_tester.data import OS_VERSION

Expand Down Expand Up @@ -55,7 +55,7 @@ def f(pkg_name: str) -> bool:
@pytest.mark.skipif(
OS_VERSION == "tumbleweed", reason="No testing for openSUSE"
)
@pytest.mark.parametrize("container_per_test", [BASE_CONTAINER], indirect=True)
@pytest.mark.parametrize("container_per_test", BASE_CONTAINERS, indirect=True)
def test_installcheck(container_per_test):
"""Run installcheck against the SLE_BCI repo + locally installed packages."""
# Let zypper fetch the repo data and generate solv files.
Expand All @@ -72,7 +72,7 @@ def test_installcheck(container_per_test):
@pytest.mark.skipif(
OS_VERSION == "tumbleweed", reason="No testing for openSUSE"
)
@pytest.mark.parametrize("container_per_test", [BASE_CONTAINER], indirect=True)
@pytest.mark.parametrize("container_per_test", BASE_CONTAINERS, indirect=True)
def test_sle_bci_forbidden_packages(container_per_test):
"""Regression test that no packages containing the following strings are in the
``SLE_BCI`` repository:
Expand Down Expand Up @@ -143,7 +143,7 @@ def test_sle_bci_forbidden_packages(container_per_test):
reason="no included BCI repository - can't test",
)
@pytest.mark.parametrize("pkg", ("git", "curl", "wget", "unzip"))
@pytest.mark.parametrize("container_per_test", [BASE_CONTAINER], indirect=True)
@pytest.mark.parametrize("container_per_test", BASE_CONTAINERS, indirect=True)
def test_package_installation(container_per_test, pkg):
"""Check that some basic packages (:command:`wget`, :command:`git`,
:command:`curl` and :command:`unzip`) can be installed.
Expand All @@ -164,7 +164,7 @@ def test_package_installation(container_per_test, pkg):
OS_VERSION not in ALLOWED_BCI_REPO_OS_VERSIONS,
reason="no included BCI repository - can't test",
)
@pytest.mark.parametrize("container_per_test", [BASE_CONTAINER], indirect=True)
@pytest.mark.parametrize("container_per_test", BASE_CONTAINERS, indirect=True)
def test_repo_content_licensing(container_per_test) -> None:
conn = container_per_test.connection
conn.check_output("timeout 2m zypper ref && zypper -n in libsolv-tools")
Expand Down Expand Up @@ -195,7 +195,7 @@ def test_repo_content_licensing(container_per_test) -> None:
"libboost_program_options1_66_0", # bsc#1229894
],
)
@pytest.mark.parametrize("container_per_test", [BASE_CONTAINER], indirect=True)
@pytest.mark.parametrize("container_per_test", BASE_CONTAINERS, indirect=True)
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.
Expand Down
6 changes: 3 additions & 3 deletions tests/test_spack.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pytest_container.helpers import get_extra_build_args
from pytest_container.helpers import get_extra_run_args

from bci_tester.data import BASE_CONTAINER
from bci_tester.data import BASE_CONTAINERS
from bci_tester.data import SPACK_CONTAINERS
from bci_tester.runtime_choice import PODMAN_SELECTED

Expand Down Expand Up @@ -55,7 +55,7 @@ def test_spack(
format: docker
images:
build: "{container.image_url_or_id}"
final: "{DerivedContainer.get_base(container_and_marks_from_pytest_param(BASE_CONTAINER)[0]).url}"
final: "{DerivedContainer.get_base(container_and_marks_from_pytest_param(BASE_CONTAINERS[0])[0]).url}"
"""
)
)
Expand All @@ -75,7 +75,7 @@ def test_spack(
multi_stage_build = MultiStageBuild(
containers={
"builder": container.container,
"runner": BASE_CONTAINER,
"runner": BASE_CONTAINERS[0],
},
containerfile_template=containerfile.replace("$", "$$"),
)
Expand Down

0 comments on commit 8aa32e5

Please sign in to comment.