diff --git a/bci_tester/data.py b/bci_tester/data.py index b8b19846..e22267f1 100755 --- a/bci_tester/data.py +++ b/bci_tester/data.py @@ -569,6 +569,12 @@ def create_BCI( forwarded_ports=[PortForwarding(container_port=80)], ) +KERNEL_MODULE_CONTAINER = create_BCI( + build_tag=f"{BCI_CONTAINER_PREFIX}/bci-sle15-kernel-module-toolkit:{OS_CONTAINER_TAG}", + available_versions=["15.4", "15.5", "15.6"], + bci_type=ImageType.OS, +) + DOTNET_CONTAINERS = [ DOTNET_SDK_6_0_CONTAINER, DOTNET_SDK_7_0_CONTAINER, @@ -589,6 +595,7 @@ def create_BCI( PHP_8_APACHE, PHP_8_CLI, PHP_8_FPM, + KERNEL_MODULE_CONTAINER, ] + CONTAINER_389DS_CONTAINERS + PYTHON_CONTAINERS diff --git a/pyproject.toml b/pyproject.toml index d5bbb599..d7798b0f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,6 +88,11 @@ markers = [ 'rust_oldstable', 'rust_stable', 'tumbleweed_latest', + # not used, but required: + 'bci-sle15-kernel-module-toolkit_15.3', + 'bci-sle15-kernel-module-toolkit_15.4', + 'bci-sle15-kernel-module-toolkit_15.5', + 'bci-sle15-kernel-module-toolkit_15.6', ] [tool.black] diff --git a/tests/test_all.py b/tests/test_all.py index 4a0de84e..313a276b 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -17,6 +17,7 @@ from bci_tester.data import BUSYBOX_CONTAINER from bci_tester.data import CONTAINERS_WITH_ZYPPER from bci_tester.data import INIT_CONTAINER +from bci_tester.data import KERNEL_MODULE_CONTAINER from bci_tester.data import OS_PRETTY_NAME from bci_tester.data import OS_VERSION from bci_tester.data import OS_VERSION_ID @@ -234,6 +235,12 @@ def test_zypper_dup_works(container_per_test: ContainerData) -> None: "skelcd-EULA-bci", "sles-release", "ALP-dummy-release", + # packages pulled into the kernel-module container: + "kernel-default-devel", + "kernel-devel", + "kernel-macros", + "kernel-syms", + "pesign-obs-integration", } assert not orphaned_packages.difference(known_orphaned_packages) @@ -259,7 +266,13 @@ def test_zypper_verify_passes(container_per_test: ContainerData) -> None: [ c for c in ALL_CONTAINERS - if (c not in [INIT_CONTAINER, PCP_CONTAINER] + POSTGRESQL_CONTAINERS) + if ( + c + not in ( + [INIT_CONTAINER, PCP_CONTAINER, KERNEL_MODULE_CONTAINER] + + POSTGRESQL_CONTAINERS + ) + ) ], indirect=True, ) diff --git a/tests/test_kernel_module.py b/tests/test_kernel_module.py new file mode 100644 index 00000000..3aaee544 --- /dev/null +++ b/tests/test_kernel_module.py @@ -0,0 +1,51 @@ +import pytest +from pytest_container import container_from_pytest_param +from pytest_container import DerivedContainer +from pytest_container.container import ContainerData + +from bci_tester.data import KERNEL_MODULE_CONTAINER + + +_DRBD_VERSION = "9.2.5" + + +DRBD_CONTAINER = DerivedContainer( + base=container_from_pytest_param(KERNEL_MODULE_CONTAINER), + containerfile=rf"""WORKDIR /src/ +RUN zypper -n in coccinelle tar + +RUN set -euxo pipefail; \ + curl -L -o drbd.tar.gz https://pkg.linbit.com//downloads/drbd/9/drbd-{_DRBD_VERSION}.tar.gz; \ + tar xvzf drbd.tar.gz; rm drbd.tar.gz; cd drbd-{_DRBD_VERSION}; \ + make -C /usr/src/linux-obj/x86_64/default modules M="$(pwd)/drbd" SPAAS=false +""", +) + + +_DPDK_VERSION = "23.07" + +DPDK_CONTAINER = DerivedContainer( + base=container_from_pytest_param(KERNEL_MODULE_CONTAINER), + containerfile=rf"""WORKDIR /src/ +RUN zypper -n in meson python3-pip libnuma-devel && pip install pyelftools + +RUN set -euxo pipefail; \ + curl -o dpdk.tar.gz https://fast.dpdk.org/rel/dpdk-{_DPDK_VERSION}.tar.gz; tar xvzf dpdk.tar.gz; rm dpdk.tar.gz; cd dpdk-{_DPDK_VERSION}; \ + meson --prefix=/usr --includedir=/usr/include/ -Ddefault_library=shared -Denable_docs=false -Db_lto=false -Dplatform="$(uname -m)" -Dcpu_instruction_set=generic -Denable_kmods=true -Dkernel_dir="/usr/src/linux-obj/$(uname -m)/default" build; \ + meson compile -C build +""", +) + + +@pytest.mark.parametrize("container", [DRBD_CONTAINER], indirect=True) +def test_drbd_builds(container: ContainerData) -> None: + assert container.connection.file( + f"/src/drbd-{_DRBD_VERSION}/drbd/drbd.ko" + ).exists + + +@pytest.mark.parametrize("container", [DPDK_CONTAINER], indirect=True) +def test_dpdk_builds(container: ContainerData) -> None: + assert container.connection.file( + f"/src/dpdk-{_DPDK_VERSION}/build/kernel/linux/kni/rte_kni.ko" + ).exists diff --git a/tests/test_metadata.py b/tests/test_metadata.py index 0db661ce..757f95de 100644 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -39,6 +39,7 @@ from bci_tester.data import HELM_CONTAINER from bci_tester.data import ImageType from bci_tester.data import INIT_CONTAINER +from bci_tester.data import KERNEL_MODULE_CONTAINER from bci_tester.data import L3_CONTAINERS from bci_tester.data import MICRO_CONTAINER from bci_tester.data import MINIMAL_CONTAINER @@ -107,6 +108,7 @@ def _get_container_label_prefix( (MINIMAL_CONTAINER, "minimal", ImageType.OS), (MICRO_CONTAINER, "micro", ImageType.OS), (BUSYBOX_CONTAINER, "busybox", ImageType.OS), + (KERNEL_MODULE_CONTAINER, "sle15-kernel-module-toolkit", ImageType.OS), (OPENJDK_11_CONTAINER, "openjdk", ImageType.LANGUAGE_STACK), ( OPENJDK_DEVEL_11_CONTAINER, diff --git a/tox.ini b/tox.ini index 3331e91e..fa416641 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = {py36,py39,py310,py311}-unit, build, all, base, fips, init, dotnet, python, ruby, node, go, openjdk, openjdk_devel, rust, php, busybox, 389ds, metadata, minimal, multistage, repository, doc, lint, get_urls, pcp, distribution, postgres, git, helm, nginx +envlist = {py36,py39,py310,py311}-unit, build, all, base, fips, init, dotnet, python, ruby, node, go, openjdk, openjdk_devel, rust, php, busybox, 389ds, metadata, minimal, multistage, repository, doc, lint, get_urls, pcp, distribution, postgres, git, helm, nginx, kernel_module isolated_build = True skip_missing_interpreters = True