Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uses k8s_test_harness utils #6

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 18 additions & 53 deletions tests/integration/test_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pathlib import Path

from k8s_test_harness import harness
from k8s_test_harness.util import exec_util
from k8s_test_harness.util import exec_util, k8s_util

pytest_plugins = ["k8s_test_harness.plugin"]

Expand All @@ -28,66 +28,31 @@ def test_integration_contour(module_instance: harness.Instance):

image_uri = os.getenv(image_name_env_variable)
assert image_uri is not None, f"{image_name_env_variable} is not set"
image_split = image_uri.split(":")
image = image_split[0].rsplit("/", 1)

helm_command = [
"k8s",
"helm",
"install",
"contour",
"--repo",
"https://charts.bitnami.com/bitnami",
# This helm chart requires the registry to be separated from the image.
registry = "docker.io"
parts = image_uri.split("/")
if len(parts) > 1:
registry = parts[0]
image_uri = "/".join(parts[1:])

helm_command = k8s_util.get_helm_install_command(
"contour",
"--namespace",
"contour",
"--create-namespace",
"--version",
"17.0.4", # chart version with 1.28.2 app
"--set",
"installCRDs=true",
"--set",
f"contour.image.repository={image[1]}",
"--set",
f"contour.image.registry={image[0]}",
"--set",
f"contour.image.tag={image_split[1]}",
"--set",
"securityContext.runAsUser=584792",
]
namespace="contour",
repository="https://charts.bitnami.com/bitnami",
images=[k8s_util.HelmImage(image_uri)],
chart_version="17.0.4", # chart version with 1.28.2 app
set_configs=[f"image.registry={registry}"],
)

module_instance.exec(helm_command)

# wait for envoy
exec_util.stubbornly(retries=5, delay_s=5).on(module_instance).exec(
[
"k8s",
"kubectl",
"rollout",
"status",
"daemonset",
"contour-envoy",
"--namespace",
"contour",
"--timeout",
"180s",
]
)
k8s_util.wait_for_daemonset(module_instance, "contour-envoy", "contour")

# wait for contour
exec_util.stubbornly(retries=5, delay_s=1).on(module_instance).exec(
[
"k8s",
"kubectl",
"rollout",
"status",
"deployment",
"contour-contour",
"--namespace",
"contour",
"--timeout",
"180s",
]
)
k8s_util.wait_for_deployment(module_instance, "contour-contour", "contour")

# deploy for httpbin
manifest = os.path.join("templates", "httpbin.yaml")
Expand Down
11 changes: 4 additions & 7 deletions tests/sanity/test_rock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# See LICENSE file for licensing details
#
import os
import subprocess

from k8s_test_harness.util import docker_util


def test_sanity():
Expand All @@ -12,9 +13,5 @@ def test_sanity():
image = os.getenv(image_variable)
assert image is not None, f"${image_variable} is not set"

docker_run = subprocess.run(
["docker", "run", "--rm", "--entrypoint", entrypoint, image, "--help"],
capture_output=True,
text=True,
)
assert "Contour Kubernetes ingress controller." in docker_run.stderr
process = docker_util.run_in_docker(image, [entrypoint, "--help"], False)
assert "Contour Kubernetes ingress controller." in process.stderr
Loading