Skip to content

Commit 910db93

Browse files
committed
Refactor workers extraInitContainers-related tests
1 parent f4f48b9 commit 910db93

2 files changed

Lines changed: 26 additions & 15 deletions

File tree

helm-tests/tests/helm_tests/airflow_aux/test_pod_template_file.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,10 +1080,12 @@ def test_should_add_extra_init_containers(self):
10801080
chart_dir=self.temp_chart_dir,
10811081
)
10821082

1083-
assert jmespath.search("spec.initContainers[-1]", docs[0]) == {
1084-
"name": "test-init-container",
1085-
"image": "test-registry/test-repo:test-tag",
1086-
}
1083+
assert jmespath.search("spec.initContainers", docs[0]) == [
1084+
{
1085+
"name": "test-init-container",
1086+
"image": "test-registry/test-repo:test-tag",
1087+
}
1088+
]
10871089

10881090
def test_should_template_extra_init_containers(self):
10891091
docs = render_chart(
@@ -1096,9 +1098,11 @@ def test_should_template_extra_init_containers(self):
10961098
chart_dir=self.temp_chart_dir,
10971099
)
10981100

1099-
assert jmespath.search("spec.initContainers[-1]", docs[0]) == {
1100-
"name": "release-name-test-init-container",
1101-
}
1101+
assert jmespath.search("spec.initContainers", docs[0]) == [
1102+
{
1103+
"name": "release-name-test-init-container",
1104+
}
1105+
]
11021106

11031107
@pytest.mark.parametrize(
11041108
"workers_values",

helm-tests/tests/helm_tests/airflow_core/test_worker.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,13 @@ def test_should_add_extra_init_containers(self):
291291
show_only=["templates/workers/worker-deployment.yaml"],
292292
)
293293

294-
assert jmespath.search("spec.template.spec.initContainers[-1]", docs[0]) == {
295-
"name": "test-init-container",
296-
"image": "test-registry/test-repo:test-tag",
297-
}
294+
# [1:] -> Skipping wait-for-airflow-migrations init container
295+
assert jmespath.search("spec.template.spec.initContainers[1:]", docs[0]) == [
296+
{
297+
"name": "test-init-container",
298+
"image": "test-registry/test-repo:test-tag",
299+
}
300+
]
298301

299302
def test_should_template_extra_init_containers(self):
300303
docs = render_chart(
@@ -306,9 +309,10 @@ def test_should_template_extra_init_containers(self):
306309
show_only=["templates/workers/worker-deployment.yaml"],
307310
)
308311

309-
assert jmespath.search("spec.template.spec.initContainers[-1]", docs[0]) == {
310-
"name": "release-name-test-init-container"
311-
}
312+
# [1:] -> Skipping wait-for-airflow-migrations init container
313+
assert jmespath.search("spec.template.spec.initContainers[1:]", docs[0]) == [
314+
{"name": "release-name-test-init-container"}
315+
]
312316

313317
def test_should_add_extra_volume_and_extra_volume_mount(self):
314318
docs = render_chart(
@@ -952,7 +956,10 @@ def test_extra_init_container_restart_policy_is_configurable(self):
952956
show_only=["templates/workers/worker-deployment.yaml"],
953957
)
954958

955-
assert jmespath.search("spec.template.spec.initContainers[1].restartPolicy", docs[0]) == "Always"
959+
# [1:] -> Skipping wait-for-airflow-migrations init container
960+
assert jmespath.search("spec.template.spec.initContainers[1:] | [*].restartPolicy", docs[0]) == [
961+
"Always"
962+
]
956963

957964
@pytest.mark.parametrize(
958965
("log_values", "expected_volume"),

0 commit comments

Comments
 (0)