Skip to content

Commit

Permalink
fix gateway test
Browse files Browse the repository at this point in the history
  • Loading branch information
bschimke95 committed Oct 22, 2024
1 parent 1e27cfb commit 075752d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
34 changes: 31 additions & 3 deletions tests/integration/tests/test_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#
import json
import logging
import subprocess
import time
from pathlib import Path

from test_util import harness, util
Expand Down Expand Up @@ -36,6 +38,34 @@ def get_gateway_service_node_port(p):
return None


def get_external_service_ip(instance: harness.Instance) -> str:
try_count = 0
gateway_ip = None
while gateway_ip is None and try_count < 5:
try_count += 1
try:
gateway_ip = (
instance.exec(
[
"k8s",
"kubectl",
"get",
"gateway",
"my-gateway",
"-o=jsonpath='{.status.addresses[0].value}'",
],
capture_output=True,
)
.stdout.decode()
.replace("'", "")
)
except subprocess.CalledProcessError:
gateway_ip = None
pass
time.sleep(3)
return gateway_ip


def test_gateway(session_instance: harness.Instance):
manifest = MANIFESTS_DIR / "gateway-test.yaml"
session_instance.exec(
Expand Down Expand Up @@ -80,9 +110,7 @@ def test_gateway(session_instance: harness.Instance):
lambda p: "Welcome to nginx!" in p.stdout.decode()
).exec(["curl", f"localhost:{gateway_http_port}"])

gateway_ip = util.get_external_service_ip(
session_instance, ["ck-ingress-contour-envoy", "cilium-ingress"]
)
gateway_ip = get_external_service_ip(session_instance)
assert gateway_ip is not None, "No Gateway IP found."
util.stubbornly(retries=5, delay_s=5).on(session_instance).until(
lambda p: "Welcome to nginx!" in p.stdout.decode()
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/tests/test_util/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ def wait_until_k8s_ready(

def wait_for_dns(instance: harness.Instance):
LOG.info("Waiting for DNS to be ready")
instance.exec(["k8s", "x-wait-for", "dns"])
instance.exec(["k8s", "x-wait-for", "dns", "--timeout", "20m"])


def wait_for_network(instance: harness.Instance):
LOG.info("Waiting for network to be ready")
instance.exec(["k8s", "x-wait-for", "network", "--timeout", "10m"])
instance.exec(["k8s", "x-wait-for", "network", "--timeout", "20m"])


def hostname(instance: harness.Instance) -> str:
Expand Down

0 comments on commit 075752d

Please sign in to comment.