Skip to content

Commit

Permalink
test case add for kubectl container
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmadhankumar committed Feb 7, 2025
1 parent 893aeb9 commit b6fb56a
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 1 deletion.
21 changes: 21 additions & 0 deletions bci_tester/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down Expand Up @@ -1074,6 +1093,7 @@ def create_BCI(
*MARIADB_CLIENT_CONTAINERS,
*MARIADB_CONTAINERS,
STUNNEL_CONTAINER,
KUBECTL_CONTAINERS,
]


Expand Down Expand Up @@ -1129,6 +1149,7 @@ def create_BCI(
+ RUBY_CONTAINERS
+ RUST_CONTAINERS
+ SPACK_CONTAINERS
+ KUBECTL_CONTAINERS
)

ACC_CONTAINERS = POSTGRESQL_CONTAINERS
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
56 changes: 56 additions & 0 deletions tests/test_kubectl.py
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
]
]


Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -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]
Expand Down

0 comments on commit b6fb56a

Please sign in to comment.