Miretpl commented on code in PR #64763:
URL: https://github.com/apache/airflow/pull/64763#discussion_r3053290431
##########
helm-tests/tests/helm_tests/airflow_aux/test_annotations.py:
##########
@@ -264,6 +264,99 @@ def test_annotations_are_added(self, values, show_only,
expected_annotations):
assert k in obj["metadata"]["annotations"]
assert v == obj["metadata"]["annotations"][k]
+ @pytest.mark.parametrize(
+ ("values_key", "show_only"),
+ [
+ ("scheduler", "templates/scheduler/scheduler-serviceaccount.yaml"),
+ ("pgbouncer", "templates/pgbouncer/pgbouncer-serviceaccount.yaml"),
+ ("triggerer", "templates/triggerer/triggerer-serviceaccount.yaml"),
+ ],
+ )
+ def test_tpl_rendered_annotations_airflow_2(self, values_key, show_only):
+ """Test SA annotations support tpl rendering for Airflow 2.x
components."""
+ component_values = {
+ "serviceAccount": {
+ "annotations": {
+ "iam.gke.io/gcp-service-account": "{{ .Release.Name
}}[email protected]",
+ },
+ },
+ }
+ if values_key == "pgbouncer":
+ component_values["enabled"] = True
+ k8s_objects = render_chart(
+ values={
+ "airflowVersion": "2.11.2",
+ values_key: component_values,
+ },
+ show_only=[show_only],
+ )
+ assert len(k8s_objects) == 1
+ annotations = k8s_objects[0]["metadata"]["annotations"]
+ assert annotations["iam.gke.io/gcp-service-account"] ==
"[email protected]"
+
+ @pytest.mark.parametrize(
+ ("values_key", "show_only"),
+ [
+ ("dagProcessor",
"templates/dag-processor/dag-processor-serviceaccount.yaml"),
+ ("apiServer",
"templates/api-server/api-server-serviceaccount.yaml"),
+ ],
+ )
+ def test_tpl_rendered_annotations_airflow_3(self, values_key, show_only):
+ """Test SA annotations support tpl rendering for Airflow 3.x
components."""
+ k8s_objects = render_chart(
+ values={
+ "airflowVersion": "3.0.0",
+ values_key: {
+ "serviceAccount": {
+ "annotations": {
+ "iam.gke.io/gcp-service-account": "{{
.Release.Name }}[email protected]",
+ },
+ },
+ },
+ },
+ show_only=[show_only],
+ )
+ assert len(k8s_objects) == 1
+ annotations = k8s_objects[0]["metadata"]["annotations"]
+ assert annotations["iam.gke.io/gcp-service-account"] ==
"[email protected]"
+
+ def test_tpl_rendered_annotations_worker(self):
+ """Test worker SA annotations support tpl rendering."""
+ k8s_objects = render_chart(
+ values={
+ "workers": {
+ "serviceAccount": {
+ "annotations": {
+ "iam.gke.io/gcp-service-account": "{{
.Release.Name }}[email protected]",
+ },
+ },
+ },
+ },
+ show_only=["templates/workers/worker-serviceaccount.yaml"],
+ )
+ assert len(k8s_objects) == 1
+ annotations = k8s_objects[0]["metadata"]["annotations"]
+ assert annotations["iam.gke.io/gcp-service-account"] ==
"[email protected]"
+
+ def test_tpl_rendered_annotations_webserver(self):
+ """Test webserver SA annotations support tpl rendering (Airflow 2.x
only)."""
+ k8s_objects = render_chart(
+ values={
+ "airflowVersion": "2.11.2",
Review Comment:
```suggestion
"airflowVersion": "2.11.0",
```
We support all 2.11 versions currently, so it is safer to test with the
first 2.11 version.
##########
helm-tests/tests/helm_tests/airflow_aux/test_annotations.py:
##########
@@ -264,6 +264,99 @@ def test_annotations_are_added(self, values, show_only,
expected_annotations):
assert k in obj["metadata"]["annotations"]
assert v == obj["metadata"]["annotations"][k]
+ @pytest.mark.parametrize(
+ ("values_key", "show_only"),
+ [
+ ("scheduler", "templates/scheduler/scheduler-serviceaccount.yaml"),
+ ("pgbouncer", "templates/pgbouncer/pgbouncer-serviceaccount.yaml"),
+ ("triggerer", "templates/triggerer/triggerer-serviceaccount.yaml"),
+ ],
+ )
+ def test_tpl_rendered_annotations_airflow_2(self, values_key, show_only):
+ """Test SA annotations support tpl rendering for Airflow 2.x
components."""
+ component_values = {
+ "serviceAccount": {
+ "annotations": {
+ "iam.gke.io/gcp-service-account": "{{ .Release.Name
}}[email protected]",
+ },
+ },
+ }
+ if values_key == "pgbouncer":
+ component_values["enabled"] = True
+ k8s_objects = render_chart(
+ values={
+ "airflowVersion": "2.11.2",
Review Comment:
```suggestion
"airflowVersion": "2.11.0",
```
##########
helm-tests/tests/helm_tests/airflow_aux/test_annotations.py:
##########
@@ -264,6 +264,99 @@ def test_annotations_are_added(self, values, show_only,
expected_annotations):
assert k in obj["metadata"]["annotations"]
assert v == obj["metadata"]["annotations"][k]
+ @pytest.mark.parametrize(
+ ("values_key", "show_only"),
+ [
+ ("scheduler", "templates/scheduler/scheduler-serviceaccount.yaml"),
+ ("pgbouncer", "templates/pgbouncer/pgbouncer-serviceaccount.yaml"),
+ ("triggerer", "templates/triggerer/triggerer-serviceaccount.yaml"),
+ ],
+ )
+ def test_tpl_rendered_annotations_airflow_2(self, values_key, show_only):
+ """Test SA annotations support tpl rendering for Airflow 2.x
components."""
+ component_values = {
+ "serviceAccount": {
+ "annotations": {
+ "iam.gke.io/gcp-service-account": "{{ .Release.Name
}}[email protected]",
+ },
+ },
+ }
+ if values_key == "pgbouncer":
+ component_values["enabled"] = True
Review Comment:
Could you separate pgbouncer to the dedicated test case to remove the
conditional logic from the test (basically point 2
https://github.com/apache/airflow/pull/64763#discussion_r3046002491)?
##########
helm-tests/tests/helm_tests/airflow_aux/test_annotations.py:
##########
@@ -264,6 +264,99 @@ def test_annotations_are_added(self, values, show_only,
expected_annotations):
assert k in obj["metadata"]["annotations"]
assert v == obj["metadata"]["annotations"][k]
+ @pytest.mark.parametrize(
+ ("values_key", "show_only"),
+ [
+ ("scheduler", "templates/scheduler/scheduler-serviceaccount.yaml"),
+ ("pgbouncer", "templates/pgbouncer/pgbouncer-serviceaccount.yaml"),
+ ("triggerer", "templates/triggerer/triggerer-serviceaccount.yaml"),
+ ],
+ )
+ def test_tpl_rendered_annotations_airflow_2(self, values_key, show_only):
+ """Test SA annotations support tpl rendering for Airflow 2.x
components."""
+ component_values = {
+ "serviceAccount": {
+ "annotations": {
+ "iam.gke.io/gcp-service-account": "{{ .Release.Name
}}[email protected]",
+ },
+ },
+ }
+ if values_key == "pgbouncer":
+ component_values["enabled"] = True
+ k8s_objects = render_chart(
+ values={
+ "airflowVersion": "2.11.2",
+ values_key: component_values,
+ },
+ show_only=[show_only],
+ )
+ assert len(k8s_objects) == 1
+ annotations = k8s_objects[0]["metadata"]["annotations"]
+ assert annotations["iam.gke.io/gcp-service-account"] ==
"[email protected]"
+
+ @pytest.mark.parametrize(
+ ("values_key", "show_only"),
+ [
+ ("dagProcessor",
"templates/dag-processor/dag-processor-serviceaccount.yaml"),
+ ("apiServer",
"templates/api-server/api-server-serviceaccount.yaml"),
+ ],
+ )
+ def test_tpl_rendered_annotations_airflow_3(self, values_key, show_only):
+ """Test SA annotations support tpl rendering for Airflow 3.x
components."""
+ k8s_objects = render_chart(
+ values={
+ "airflowVersion": "3.0.0",
+ values_key: {
+ "serviceAccount": {
+ "annotations": {
+ "iam.gke.io/gcp-service-account": "{{
.Release.Name }}[email protected]",
+ },
+ },
+ },
+ },
+ show_only=[show_only],
+ )
+ assert len(k8s_objects) == 1
+ annotations = k8s_objects[0]["metadata"]["annotations"]
+ assert annotations["iam.gke.io/gcp-service-account"] ==
"[email protected]"
+
+ def test_tpl_rendered_annotations_worker(self):
+ """Test worker SA annotations support tpl rendering."""
+ k8s_objects = render_chart(
+ values={
+ "workers": {
Review Comment:
Currently, the `workers.serviceAccount` is deprecated in favour of
`workers.celery.serviceAccount` (tested here) and
`workers.kubernetes.serviceAccount` (tested in test_pod_template_file.py).
Could you modify this test to test the celery one and add a similar test case
for the Kubernetes one?
##########
helm-tests/tests/helm_tests/airflow_aux/test_annotations.py:
##########
@@ -264,6 +264,99 @@ def test_annotations_are_added(self, values, show_only,
expected_annotations):
assert k in obj["metadata"]["annotations"]
assert v == obj["metadata"]["annotations"][k]
+ @pytest.mark.parametrize(
+ ("values_key", "show_only"),
+ [
+ ("scheduler", "templates/scheduler/scheduler-serviceaccount.yaml"),
+ ("pgbouncer", "templates/pgbouncer/pgbouncer-serviceaccount.yaml"),
+ ("triggerer", "templates/triggerer/triggerer-serviceaccount.yaml"),
+ ],
+ )
+ def test_tpl_rendered_annotations_airflow_2(self, values_key, show_only):
+ """Test SA annotations support tpl rendering for Airflow 2.x
components."""
+ component_values = {
+ "serviceAccount": {
+ "annotations": {
+ "iam.gke.io/gcp-service-account": "{{ .Release.Name
}}[email protected]",
+ },
+ },
+ }
+ if values_key == "pgbouncer":
+ component_values["enabled"] = True
+ k8s_objects = render_chart(
+ values={
+ "airflowVersion": "2.11.2",
+ values_key: component_values,
+ },
+ show_only=[show_only],
+ )
+ assert len(k8s_objects) == 1
+ annotations = k8s_objects[0]["metadata"]["annotations"]
+ assert annotations["iam.gke.io/gcp-service-account"] ==
"[email protected]"
+
+ @pytest.mark.parametrize(
+ ("values_key", "show_only"),
+ [
+ ("dagProcessor",
"templates/dag-processor/dag-processor-serviceaccount.yaml"),
+ ("apiServer",
"templates/api-server/api-server-serviceaccount.yaml"),
+ ],
+ )
+ def test_tpl_rendered_annotations_airflow_3(self, values_key, show_only):
+ """Test SA annotations support tpl rendering for Airflow 3.x
components."""
+ k8s_objects = render_chart(
+ values={
+ "airflowVersion": "3.0.0",
Review Comment:
```suggestion
```
Just for consistency with other test cases, which are testing Airflow 3
renderings.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]