Skip to content

Commit 2180869

Browse files
Merge pull request #598 from element-hq/gaelg/fix-tests
service/pods labels matching tests: also skip succeeded
2 parents 67b39cf + 4d5345b commit 2180869

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

newsfragments/598.internal.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Tests: don't check services matching labels against terminating pods.

tests/integration/test_networking.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async def test_services_have_matching_labels(
4040
label_selectors = {label: value for label, value in service.spec.selector.items()}
4141

4242
async for pod in kube_client.list(Pod, namespace=generated_data.ess_namespace, labels=label_selectors):
43-
if pod.status and pod.status.phase == "Terminating":
43+
if pod.status and pod.status.phase not in ("Terminating", "Succeeded"):
4444
continue # Skip terminating pods
4545
assert service.metadata, f"Encountered a service without metadata : {service}"
4646
assert pod.metadata, f"Encountered a pod without metadata : {pod}"
@@ -58,7 +58,10 @@ async def test_services_have_matching_labels(
5858
assert value.startswith(
5959
pod.metadata.labels[label.replace("k8s.element.io/target-", "app.kubernetes.io/")]
6060
), (
61-
f"{pod.metadata.name} does not have the correct label {label}={value} "
61+
f"Service/{service.metadata.name} has {label=}={value=} "
62+
f"which does not start with the value from the Pod/{pod.metadata.name} "
63+
f"{label.replace('k8s.element.io/target-', 'app.kubernetes.io/')}="
64+
f"{pod.metadata.labels[label.replace('k8s.element.io/target-', 'app.kubernetes.io/')]} "
6265
f"(pod status phase : {pod.status.phase if pod.status else 'N/A'}"
6366
)
6467

0 commit comments

Comments
 (0)