diff --git a/bci_tester/data.py b/bci_tester/data.py index 92a955c4..42c263f1 100755 --- a/bci_tester/data.py +++ b/bci_tester/data.py @@ -837,6 +837,25 @@ def create_BCI( forwarded_ports=[PortForwarding(container_port=80)], ) +_KUBECTL_VERSION_OS_MATRIX: Tuple[Tuple[str, Tuple[str, ...]], ...] = ( + ("1.28", ("15.6", "15.7")), + ("1.30", ("15.7",)), + ("1.29", ("tumbleweed",)), + ("1.30", ("tumbleweed",)), + ("1.31", ("tumbleweed",)), + ("1.32", ("tumbleweed",)), +) + +KUBECTL_CONTAINERS = [ + create_BCI( + build_tag=f"{APP_CONTAINER_PREFIX}/kubectl:{kubectl_ver}", + bci_type=ImageType.APPLICATION, + available_versions=os_versions, + custom_entry_point="/bin/sh", + ) + for kubectl_ver, os_versions in _KUBECTL_VERSION_OS_MATRIX +] + if OS_VERSION in ("16.0",): KERNEL_MODULE_CONTAINER = create_BCI( build_tag=f"{BCI_CONTAINER_PREFIX}/bci-sle16-kernel-module-devel:{OS_CONTAINER_TAG}", @@ -1074,6 +1093,7 @@ def create_BCI( *MARIADB_CLIENT_CONTAINERS, *MARIADB_CONTAINERS, STUNNEL_CONTAINER, + *KUBECTL_CONTAINERS, ] @@ -1129,6 +1149,7 @@ def create_BCI( + RUBY_CONTAINERS + RUST_CONTAINERS + SPACK_CONTAINERS + + KUBECTL_CONTAINERS ) ACC_CONTAINERS = POSTGRESQL_CONTAINERS diff --git a/pyproject.toml b/pyproject.toml index 34b056e2..c167ee23 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,6 +100,11 @@ markers = [ 'kiwi_9.24', 'kiwi_10.1', 'kiwi_latest', + 'kubectl_1.28', + 'kubectl_1.29', + 'kubectl_1.30', + 'kubectl_1.31', + 'kubectl_1.32', 'mariadb_10.11', 'mariadb_11.6', 'mariadb-client_10.11', diff --git a/tests/test_kubectl.py b/tests/test_kubectl.py new file mode 100644 index 00000000..533206f4 --- /dev/null +++ b/tests/test_kubectl.py @@ -0,0 +1,56 @@ +import json + +import pytest + +from bci_tester.data import KUBECTL_CONTAINERS + + +@pytest.mark.parametrize( + "container_per_test", + KUBECTL_CONTAINERS, + indirect=["container_per_test"], +) +def test_kubectl_binary(container_per_test) -> None: + expected_json = json.loads("""{ + "kind": "Deployment", + "apiVersion": "apps/v1", + "metadata": { + "name": "nginx", + "creationTimestamp": null, + "labels": { + "app": "nginx" + } + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app": "nginx" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app": "nginx" + } + }, + "spec": { + "containers": [ + { + "name": "nginx", + "image": "nginx", + "resources": {} + } + ] + } + }, + "strategy": {} + }, + "status": {} +}""") + output = container_per_test.connection.check_output( + "kubectl create deployment nginx --image=nginx --dry-run=client -o json" + ).strip() + json_out = json.loads(output) + assert json_out == expected_json diff --git a/tests/test_metadata.py b/tests/test_metadata.py index 7baa6dec..ec55d705 100644 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -50,6 +50,7 @@ from bci_tester.data import INIT_CONTAINER from bci_tester.data import KERNEL_MODULE_CONTAINER from bci_tester.data import KIWI_CONTAINERS +from bci_tester.data import KUBECTL_CONTAINERS from bci_tester.data import L3_CONTAINERS from bci_tester.data import LTSS_BASE_CONTAINERS from bci_tester.data import LTSS_BASE_FIPS_CONTAINERS @@ -288,6 +289,10 @@ def _get_container_label_prefix( (MILVUS_CONTAINER, "milvus", ImageType.SAC_APPLICATION), ] + [(STUNNEL_CONTAINER, "stunnel", ImageType.APPLICATION)] + + [ + (kubectl_container, "kubectl", ImageType.APPLICATION) + for kubectl_container in KUBECTL_CONTAINERS + ] ] diff --git a/tox.ini b/tox.ini index b1753c9e..8d57dda4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = {py36,py39,py310,py311,py312,py313}-unit, all, base, cosign, fips, init, dotnet, python, ruby, node, go, openjdk, openjdk_devel, rust, php, busybox, 389ds, metadata, minimal, multistage, repository, doc, lint, check_marks, pcp, distribution, postgres, git, helm, nginx, kernel_module, mariadb, tomcat, spack, gcc, prometheus, grafana, kiwi, postfix, ai, stunnel +envlist = {py36,py39,py310,py311,py312,py313}-unit, all, base, cosign, fips, init, dotnet, python, ruby, node, go, openjdk, openjdk_devel, rust, php, busybox, 389ds, metadata, minimal, multistage, repository, doc, lint, check_marks, pcp, distribution, postgres, git, helm, nginx, kernel_module, mariadb, tomcat, spack, gcc, prometheus, grafana, kiwi, postfix, ai, stunnel, kubectl skip_missing_interpreters = True [common]