Validate that workload selectors match the labels in the template.

This commit is contained in:
Ben Banfield-Zanin committed 2025-05-28 14:39:13 +01:00
1 parent fba881b11b
commit 64df3fc65e
2 files changed
+13

No files matched your search

+1
View File
@@ -0,0 +1 @@
Validate that workload selectors match the labels in the template.
+12
View File
@@ -128,3 +128,15 @@ async def test_our_labels_are_named_consistently(templates):
assert has_match, (
f"{template_id(template)} has label {our_label} that does not match one of {acceptable_matches=}"
)
@pytest.mark.parametrize("values_file", values_files_to_test)
@pytest.mark.asyncio_cooperative
async def test_workloads_selector_matches_labels(templates):
for template in templates:
if template["kind"] in ("Deployment", "StatefulSet"):
for label in template["spec"]["selector"]["matchLabels"]:
assert (
template["spec"]["template"]["metadata"]["labels"][label]
== template["spec"]["selector"]["matchLabels"][label]
)