Skip to content

Commit

Permalink
Add minimal tests for git, helm and nginx containers
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkmueller committed Jul 31, 2023
1 parent 1105535 commit 5622516
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 1 deletion.
23 changes: 23 additions & 0 deletions bci_tester/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,25 @@ def create_BCI(
volume_mounts=[ContainerVolume(container_path="/var/lib/docker-registry")],
)

GIT_CONTAINER = create_BCI(
build_tag=f"{APP_CONTAINER_PREFIX}/git:latest",
bci_type=ImageType.APPLICATION,
image_type="kiwi",
)

HELM_CONTAINER = create_BCI(
build_tag=f"{APP_CONTAINER_PREFIX}/helm:latest",
bci_type=ImageType.APPLICATION,
custom_entry_point="/bin/sh",
image_type="kiwi",
)

NGINX_CONTAINER = create_BCI(
build_tag=f"{APP_CONTAINER_PREFIX}/nginx:latest",
bci_type=ImageType.APPLICATION,
forwarded_ports=[PortForwarding(container_port=80)],
)

DOTNET_CONTAINERS = [
DOTNET_SDK_6_0_CONTAINER,
DOTNET_SDK_7_0_CONTAINER,
Expand All @@ -502,6 +521,7 @@ def create_BCI(
OPENJDK_DEVEL_11_CONTAINER,
OPENJDK_17_CONTAINER,
OPENJDK_DEVEL_17_CONTAINER,
NGINX_CONTAINER,
NODEJS_16_CONTAINER,
NODEJS_18_CONTAINER,
NODEJS_20_CONTAINER,
Expand All @@ -524,6 +544,8 @@ def create_BCI(
MINIMAL_CONTAINER,
MICRO_CONTAINER,
BUSYBOX_CONTAINER,
HELM_CONTAINER,
GIT_CONTAINER,
DISTRIBUTION_CONTAINER,
]

Expand All @@ -533,6 +555,7 @@ def create_BCI(
BASE_CONTAINER,
MINIMAL_CONTAINER,
MICRO_CONTAINER,
GIT_CONTAINER,
INIT_CONTAINER,
BUSYBOX_CONTAINER,
OPENJDK_11_CONTAINER,
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ markers = [
'dotnet-sdk_5.0',
'dotnet-sdk_6.0',
'dotnet-sdk_7.0',
'git_latest',
'helm_latest',
'nginx_latest',
'golang_1.19',
'golang_1.20',
'golang_oldstable',
Expand Down
3 changes: 2 additions & 1 deletion tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
RUN go build main.go
FROM $runner
ENTRYPOINT []
WORKDIR /fetcher/
COPY --from=builder /src/main .
CMD ["/fetcher/main"]
Expand Down Expand Up @@ -195,7 +196,7 @@ def test_certificates_are_present(
"""This is a multistage container build, verifying that the certificates are
correctly set up in the containers.
In the first step, we build a very simple go binary from
In the first step, we build a go binary from
:py:const:`FETCH_SUSE_DOT_COM` in the golang container. We copy the
resulting binary into the container under test and execute it in that
container.
Expand Down
15 changes: 15 additions & 0 deletions tests/test_git.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pytest_container.runtime import LOCALHOST

from bci_tester.data import GIT_CONTAINER


CONTAINER_IMAGES = (GIT_CONTAINER,)


def test_git_version(auto_container, host):
assert (
"git version 2."
in auto_container.connection.run_expect(
[0], "git --version"
).stdout.strip()
)
16 changes: 16 additions & 0 deletions tests/test_helm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pytest_container.runtime import LOCALHOST

from bci_tester.data import HELM_CONTAINER


CONTAINER_IMAGES = (HELM_CONTAINER,)


def test_helm_version(auto_container, host, container_runtime):
assert (
"GitTreeState"
in host.run_expect(
[0],
f"{container_runtime.runner_binary} run --rm {auto_container.image_url_or_id} version",
).stdout.strip()
)
6 changes: 6 additions & 0 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@
from bci_tester.data import DOTNET_RUNTIME_7_0_CONTAINER
from bci_tester.data import DOTNET_SDK_6_0_CONTAINER
from bci_tester.data import DOTNET_SDK_7_0_CONTAINER
from bci_tester.data import GIT_CONTAINER
from bci_tester.data import GOLANG_CONTAINERS
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 L3_CONTAINERS
from bci_tester.data import MICRO_CONTAINER
from bci_tester.data import MINIMAL_CONTAINER
from bci_tester.data import NGINX_CONTAINER
from bci_tester.data import NODEJS_16_CONTAINER
from bci_tester.data import NODEJS_18_CONTAINER
from bci_tester.data import NODEJS_20_CONTAINER
Expand Down Expand Up @@ -125,6 +128,9 @@ def _get_container_label_prefix(
(PHP_8_APACHE, "php-apache", ImageType.LANGUAGE_STACK),
(PHP_8_CLI, "php", ImageType.LANGUAGE_STACK),
(PHP_8_FPM, "php-fpm", ImageType.LANGUAGE_STACK),
(GIT_CONTAINER, "git", ImageType.APPLICATION),
(HELM_CONTAINER, "helm", ImageType.APPLICATION),
(NGINX_CONTAINER, "nginx", ImageType.APPLICATION),
]
+ [
(container_389ds, "389-ds", ImageType.APPLICATION)
Expand Down
14 changes: 14 additions & 0 deletions tests/test_nginx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from pytest_container.runtime import LOCALHOST

from bci_tester.data import NGINX_CONTAINER


CONTAINER_IMAGES = (NGINX_CONTAINER,)


def test_nginx_welcome_page(auto_container, host):
host_port = auto_container.forwarded_ports[0].host_port

assert "Welcome to nginx" in host.check_output(
f"curl -sf --retry 5 --retry-connrefused http://localhost:{host_port}/"
)

0 comments on commit 5622516

Please sign in to comment.