service/pods labels matching tests: also skip succeeded

This commit is contained in:
Gaël Goinvic committed 2025-07-02 10:07:47 +02:00
1 parent 4d8171fefc
commit 4f602d0fba
2 files changed
+4 -2

No files matched your search

+1
View File
@@ -0,0 +1 @@
Tests : Dont check services matching labels against terminating pods.
+3 -2
View File
@@ -40,7 +40,7 @@ async def test_services_have_matching_labels(
label_selectors = {label: value for label, value in service.spec.selector.items()}
async for pod in kube_client.list(Pod, namespace=generated_data.ess_namespace, labels=label_selectors):
if pod.status and pod.status.phase == "Terminating":
if pod.status and pod.status.phase not in ("Terminating", "Succeeded"):
continue # Skip terminating pods
assert service.metadata, f"Encountered a service without metadata : {service}"
assert pod.metadata, f"Encountered a pod without metadata : {pod}"
@@ -58,7 +58,8 @@ async def test_services_have_matching_labels(
assert value.startswith(
pod.metadata.labels[label.replace("k8s.element.io/target-", "app.kubernetes.io/")]
), (
f"{pod.metadata.name} does not have the correct label {label}={value} "
f"{value} does not starts with "
f"{pod.metadata.labels[label.replace('k8s.element.io/target-', 'app.kubernetes.io/')]}"
f"(pod status phase : {pod.status.phase if pod.status else 'N/A'}"
)