Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
bschimke95 committed Oct 21, 2024
1 parent 6d3af97 commit 119cbe7
Showing 1 changed file with 37 additions and 18 deletions.
55 changes: 37 additions & 18 deletions tests/integration/tests/test_loadbalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Copyright 2024 Canonical, Ltd.
#
import ipaddress
import json
import logging
from pathlib import Path
import subprocess
import time
from pathlib import Path
from typing import List

import pytest
Expand Down Expand Up @@ -118,29 +118,48 @@ def test_loadbalancer(instances: List[harness.Instance]):

# Try to access the service via Ingress
instance.exec(["k8s", "enable", "ingress"])
instance.exec(["k8s", "kubectl", "apply", "-f", "-"], input=Path(MANIFESTS_DIR / "ingress-test.yaml").read_bytes())
instance.exec(["k8s", "kubectl", "wait", "--for=condition=ready", "pod", "-l", "run=my-nginx", "--timeout", "180s"])
instance.exec(
["k8s", "kubectl", "apply", "-f", "-"],
input=Path(MANIFESTS_DIR / "ingress-test.yaml").read_bytes(),
)
instance.exec(
[
"k8s",
"kubectl",
"wait",
"--for=condition=ready",
"pod",
"-l",
"run=my-nginx",
"--timeout",
"180s",
]
)

try_count = 0
ingress_ip = None
while ingress_ip is None and try_count < 5:
try_count += 1
for svc in ["ck-ingress-contour-envoy", "cilium-ingress"]:
try:
ingress_ip = instance.exec(
[
"k8s",
"kubectl",
"--namespace",
"kube-system",
"get",
"service",
svc,
"-o=jsonpath='{.status.loadBalancer.ingress[0].ip}'",
],
capture_output=True,
).stdout.decode().replace("'", "")
except :
ingress_ip = (
instance.exec(
[
"k8s",
"kubectl",
"--namespace",
"kube-system",
"get",
"service",
svc,
"-o=jsonpath='{.status.loadBalancer.ingress[0].ip}'",
],
capture_output=True,
)
.stdout.decode()
.replace("'", "")
)
except subprocess.CalledProcessError:
ingress_ip = None
pass
time.sleep(3)
Expand Down

0 comments on commit 119cbe7

Please sign in to comment.