This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new b7fa5ad272 Normalising the helm service account tests (#32874)
b7fa5ad272 is described below
commit b7fa5ad27237928bfe488bac7057319b3f03844e
Author: Amogh Desai <[email protected]>
AuthorDate: Sun Jul 30 03:47:56 2023 +0530
Normalising the helm service account tests (#32874)
---
.../airflow_aux/test_migrate_database_job.py | 48 +++++++++++---------
helm_tests/airflow_core/test_dag_processor.py | 52 ++++++++++++----------
helm_tests/other/test_pgbouncer.py | 52 ++++++++++++----------
helm_tests/other/test_redis.py | 48 +++++++++++---------
helm_tests/other/test_statsd.py | 48 +++++++++++---------
5 files changed, 134 insertions(+), 114 deletions(-)
diff --git a/helm_tests/airflow_aux/test_migrate_database_job.py
b/helm_tests/airflow_aux/test_migrate_database_job.py
index 3f1730f200..6bd52a1100 100644
--- a/helm_tests/airflow_aux/test_migrate_database_job.py
+++ b/helm_tests/airflow_aux/test_migrate_database_job.py
@@ -25,28 +25,6 @@ from tests.charts.helm_template_generator import render_chart
class TestMigrateDatabaseJob:
"""Tests migrate DB job."""
- def test_default_automount_service_account_token(self):
- docs = render_chart(
- values={
- "migrateDatabaseJob": {
- "serviceAccount": {"create": True},
- },
- },
-
show_only=["templates/jobs/migrate-database-job-serviceaccount.yaml"],
- )
- assert jmespath.search("automountServiceAccountToken", docs[0]) is True
-
- def test_overriden_automount_service_account_token(self):
- docs = render_chart(
- values={
- "migrateDatabaseJob": {
- "serviceAccount": {"create": True,
"automountServiceAccountToken": False},
- },
- },
-
show_only=["templates/jobs/migrate-database-job-serviceaccount.yaml"],
- )
- assert jmespath.search("automountServiceAccountToken", docs[0]) is
False
-
def test_should_run_by_default(self):
docs =
render_chart(show_only=["templates/jobs/migrate-database-job.yaml"])
assert "Job" == docs[0]["kind"]
@@ -345,3 +323,29 @@ class TestMigrateDatabaseJob:
"subPath": "airflow_local_settings.py",
"readOnly": True,
} in jmespath.search("spec.template.spec.containers[0].volumeMounts",
docs[0])
+
+
+class TestMigrateDatabaseJobServiceAccount:
+ """Tests migrate database job service account."""
+
+ def test_default_automount_service_account_token(self):
+ docs = render_chart(
+ values={
+ "migrateDatabaseJob": {
+ "serviceAccount": {"create": True},
+ },
+ },
+
show_only=["templates/jobs/migrate-database-job-serviceaccount.yaml"],
+ )
+ assert jmespath.search("automountServiceAccountToken", docs[0]) is True
+
+ def test_overriden_automount_service_account_token(self):
+ docs = render_chart(
+ values={
+ "migrateDatabaseJob": {
+ "serviceAccount": {"create": True,
"automountServiceAccountToken": False},
+ },
+ },
+
show_only=["templates/jobs/migrate-database-job-serviceaccount.yaml"],
+ )
+ assert jmespath.search("automountServiceAccountToken", docs[0]) is
False
diff --git a/helm_tests/airflow_core/test_dag_processor.py
b/helm_tests/airflow_core/test_dag_processor.py
index 544bbf1546..74035222e7 100644
--- a/helm_tests/airflow_core/test_dag_processor.py
+++ b/helm_tests/airflow_core/test_dag_processor.py
@@ -26,30 +26,6 @@ from tests.charts.log_groomer import LogGroomerTestBase
class TestDagProcessor:
"""Tests DAG processor."""
- def test_default_automount_service_account_token(self):
- docs = render_chart(
- values={
- "dagProcessor": {
- "enabled": True,
- "serviceAccount": {"create": True},
- },
- },
-
show_only=["templates/dag-processor/dag-processor-serviceaccount.yaml"],
- )
- assert jmespath.search("automountServiceAccountToken", docs[0]) is True
-
- def test_overriden_automount_service_account_token(self):
- docs = render_chart(
- values={
- "dagProcessor": {
- "enabled": True,
- "serviceAccount": {"create": True,
"automountServiceAccountToken": False},
- },
- },
-
show_only=["templates/dag-processor/dag-processor-serviceaccount.yaml"],
- )
- assert jmespath.search("automountServiceAccountToken", docs[0]) is
False
-
@pytest.mark.parametrize(
"airflow_version, num_docs",
[
@@ -648,3 +624,31 @@ class TestDagProcessorLogGroomer(LogGroomerTestBase):
obj_name = "dag-processor"
folder = "dag-processor"
+
+
+class TestDagProcessorServiceAccount:
+ """Tests DAG processor service account."""
+
+ def test_default_automount_service_account_token(self):
+ docs = render_chart(
+ values={
+ "dagProcessor": {
+ "enabled": True,
+ "serviceAccount": {"create": True},
+ },
+ },
+
show_only=["templates/dag-processor/dag-processor-serviceaccount.yaml"],
+ )
+ assert jmespath.search("automountServiceAccountToken", docs[0]) is True
+
+ def test_overriden_automount_service_account_token(self):
+ docs = render_chart(
+ values={
+ "dagProcessor": {
+ "enabled": True,
+ "serviceAccount": {"create": True,
"automountServiceAccountToken": False},
+ },
+ },
+
show_only=["templates/dag-processor/dag-processor-serviceaccount.yaml"],
+ )
+ assert jmespath.search("automountServiceAccountToken", docs[0]) is
False
diff --git a/helm_tests/other/test_pgbouncer.py
b/helm_tests/other/test_pgbouncer.py
index 1189a2894e..454912b4fb 100644
--- a/helm_tests/other/test_pgbouncer.py
+++ b/helm_tests/other/test_pgbouncer.py
@@ -27,30 +27,6 @@ from tests.charts.helm_template_generator import render_chart
class TestPgbouncer:
"""Tests PgBouncer."""
- def test_default_automount_service_account_token(self):
- docs = render_chart(
- values={
- "pgbouncer": {
- "enabled": True,
- "serviceAccount": {"create": True},
- },
- },
- show_only=["templates/pgbouncer/pgbouncer-serviceaccount.yaml"],
- )
- assert jmespath.search("automountServiceAccountToken", docs[0]) is True
-
- def test_overriden_automount_service_account_token(self):
- docs = render_chart(
- values={
- "pgbouncer": {
- "enabled": True,
- "serviceAccount": {"create": True,
"automountServiceAccountToken": False},
- },
- },
- show_only=["templates/pgbouncer/pgbouncer-serviceaccount.yaml"],
- )
- assert jmespath.search("automountServiceAccountToken", docs[0]) is
False
-
@pytest.mark.parametrize("yaml_filename", ["pgbouncer-deployment",
"pgbouncer-service"])
def test_pgbouncer_resources_not_created_by_default(self, yaml_filename):
docs = render_chart(
@@ -591,3 +567,31 @@ class TestPgbouncerExporter:
"postgresql://username%40123123:password%40%21%40%23$%5E&%2A%28%[email protected]:1111"
"/pgbouncer?sslmode=require" == connection
)
+
+
+class TestPgBouncerServiceAccount:
+ """Tests PgBouncer Service Account."""
+
+ def test_default_automount_service_account_token(self):
+ docs = render_chart(
+ values={
+ "pgbouncer": {
+ "enabled": True,
+ "serviceAccount": {"create": True},
+ },
+ },
+ show_only=["templates/pgbouncer/pgbouncer-serviceaccount.yaml"],
+ )
+ assert jmespath.search("automountServiceAccountToken", docs[0]) is True
+
+ def test_overriden_automount_service_account_token(self):
+ docs = render_chart(
+ values={
+ "pgbouncer": {
+ "enabled": True,
+ "serviceAccount": {"create": True,
"automountServiceAccountToken": False},
+ },
+ },
+ show_only=["templates/pgbouncer/pgbouncer-serviceaccount.yaml"],
+ )
+ assert jmespath.search("automountServiceAccountToken", docs[0]) is
False
diff --git a/helm_tests/other/test_redis.py b/helm_tests/other/test_redis.py
index ee812ca0ed..c99503a4b7 100644
--- a/helm_tests/other/test_redis.py
+++ b/helm_tests/other/test_redis.py
@@ -42,28 +42,6 @@ CELERY_EXECUTORS_PARAMS = ["CeleryExecutor",
"CeleryKubernetesExecutor"]
class TestRedis:
"""Tests redis."""
- def test_default_automount_service_account_token(self):
- docs = render_chart(
- values={
- "redis": {
- "serviceAccount": {"create": True},
- },
- },
- show_only=["templates/redis/redis-serviceaccount.yaml"],
- )
- assert jmespath.search("automountServiceAccountToken", docs[0]) is True
-
- def test_overriden_automount_service_account_token(self):
- docs = render_chart(
- values={
- "redis": {
- "serviceAccount": {"create": True,
"automountServiceAccountToken": False},
- },
- },
- show_only=["templates/redis/redis-serviceaccount.yaml"],
- )
- assert jmespath.search("automountServiceAccountToken", docs[0]) is
False
-
@staticmethod
def get_broker_url_in_broker_url_secret(k8s_obj_by_key):
broker_url_in_obj = b64decode(
@@ -350,3 +328,29 @@ class TestRedis:
show_only=["templates/redis/redis-statefulset.yaml"],
)
assert {"foo": "bar"} ==
jmespath.search("spec.volumeClaimTemplates[0].metadata.annotations", docs[0])
+
+
+class TestRedisServiceAccount:
+ """Tests redis service account."""
+
+ def test_default_automount_service_account_token(self):
+ docs = render_chart(
+ values={
+ "redis": {
+ "serviceAccount": {"create": True},
+ },
+ },
+ show_only=["templates/redis/redis-serviceaccount.yaml"],
+ )
+ assert jmespath.search("automountServiceAccountToken", docs[0]) is True
+
+ def test_overriden_automount_service_account_token(self):
+ docs = render_chart(
+ values={
+ "redis": {
+ "serviceAccount": {"create": True,
"automountServiceAccountToken": False},
+ },
+ },
+ show_only=["templates/redis/redis-serviceaccount.yaml"],
+ )
+ assert jmespath.search("automountServiceAccountToken", docs[0]) is
False
diff --git a/helm_tests/other/test_statsd.py b/helm_tests/other/test_statsd.py
index d26b664514..c383cd99d3 100644
--- a/helm_tests/other/test_statsd.py
+++ b/helm_tests/other/test_statsd.py
@@ -26,28 +26,6 @@ from tests.charts.helm_template_generator import render_chart
class TestStatsd:
"""Tests statsd."""
- def test_default_automount_service_account_token(self):
- docs = render_chart(
- values={
- "statsd": {
- "serviceAccount": {"create": True},
- },
- },
- show_only=["templates/statsd/statsd-serviceaccount.yaml"],
- )
- assert jmespath.search("automountServiceAccountToken", docs[0]) is True
-
- def test_overriden_automount_service_account_token(self):
- docs = render_chart(
- values={
- "statsd": {
- "serviceAccount": {"create": True,
"automountServiceAccountToken": False},
- },
- },
- show_only=["templates/statsd/statsd-serviceaccount.yaml"],
- )
- assert jmespath.search("automountServiceAccountToken", docs[0]) is
False
-
def test_should_create_statsd_default(self):
docs =
render_chart(show_only=["templates/statsd/statsd-deployment.yaml"])
@@ -317,3 +295,29 @@ class TestStatsd:
jmespath.search("spec.template.metadata.annotations",
docs[0])["test_pod_annotation"]
== "test_pod_annotation_value"
)
+
+
+class TestStatsdServiceAccount:
+ """Tests statsd service account."""
+
+ def test_default_automount_service_account_token(self):
+ docs = render_chart(
+ values={
+ "statsd": {
+ "serviceAccount": {"create": True},
+ },
+ },
+ show_only=["templates/statsd/statsd-serviceaccount.yaml"],
+ )
+ assert jmespath.search("automountServiceAccountToken", docs[0]) is True
+
+ def test_overriden_automount_service_account_token(self):
+ docs = render_chart(
+ values={
+ "statsd": {
+ "serviceAccount": {"create": True,
"automountServiceAccountToken": False},
+ },
+ },
+ show_only=["templates/statsd/statsd-serviceaccount.yaml"],
+ )
+ assert jmespath.search("automountServiceAccountToken", docs[0]) is
False