This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v1-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 572387dbeb9d83a2cc4fbdbbbbe5f32a03b1f08f
Author: Kamil BreguĊ‚a <[email protected]>
AuthorDate: Fri Oct 30 15:48:22 2020 +0100

    Migrate from helm-unittest to python unittest (#11827)
    
    * Migrate from helm-unittest to python unittest
    
    * fixup! Migrate from helm-unittest to python unittest
    
    * fixup! fixup! Migrate from helm-unittest to python unittest
    
    (cherry picked from commit 9322f3e46c3a06d2e5b891e399cc054e9b76ae72)
---
 .github/workflows/ci.yml                           |  15 +-
 .pre-commit-config.yaml                            |  17 +-
 airflow/www_rbac/webpack.config.js                 |   2 +-
 chart/tests/conftest.py                            |   6 +-
 chart/tests/dags-persistent-volume-claim_test.yaml |  64 -----
 chart/tests/git-sync-webserver_test.yaml           |  66 -----
 chart/tests/git-sync-worker_test.yaml              |  70 -----
 chart/tests/pod-template-file_test.yaml            | 149 ----------
 chart/tests/test_basic_helm_chart.py               |   2 +-
 chart/tests/test_celery_kubernetes_executor.py     |  47 ++++
 .../test_celery_kubernetes_pod_launcher_role.py    |  23 +-
 chart/tests/test_dags_persistent_volume_claim.py   |  72 +++++
 chart/tests/test_git_sync_scheduler.py             | 311 ++++++++-------------
 chart/tests/test_git_sync_webserver.py             |  62 ++++
 chart/tests/test_git_sync_worker.py                |  75 +++++
 .../tests/test_migrate_database_job.py             |  23 +-
 chart/tests/test_pod_template_file.py              | 185 ++++++++++++
 chart/tests/test_scheduler.py                      |  40 +++
 chart/tests/test_worker.py                         |  40 +++
 docs/static/exampleinclude.css                     |   2 +-
 docs/static/jira-links.js                          |   2 +-
 21 files changed, 686 insertions(+), 587 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2295bd9..596ab3e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -153,19 +153,6 @@ jobs:
             ./scripts/ci/selective_ci_checks.sh
           fi
 
-  helm-tests:
-    timeout-minutes: 5
-    name: "Checks: Helm tests. Will soon be replaced with python tests"
-    runs-on: ubuntu-latest
-    needs: [build-info]
-    if: >
-      needs.build-info.outputs.needs-helm-tests == 'true'
-    steps:
-      - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} : merge commit 
${{ github.merge_commit_sha }} )"
-        uses: actions/checkout@v2
-      - name: "Helm Tests"
-        run: ./scripts/ci/kubernetes/ci_run_helm_testing.sh
-
   ci-images:
     timeout-minutes: 120
     name: "Wait for CI images"
@@ -295,7 +282,7 @@ jobs:
           name: airflow-documentation
           path: "./files/documentation"
 
-  helm-python-tests:
+  tests-helm:
     timeout-minutes: 5
     name: "Python unit tests for helm chart"
     runs-on: ubuntu-latest
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index e4c0a86..1b5c436 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -58,12 +58,12 @@ repos:
           - --fuzzy-match-generates-todo
         files: \.rst$
       - id: insert-license
-        name: Add license for all JS/CSS files
-        files: \.(js|css)$
+        name: Add license for all JS/CSS/PUML files
+        files: \.(js|css|puml)$
         exclude: 
^\.github/.*$|^airflow/www/static/.*|^airflow/www_rbac/static/.*$
         args:
           - --comment-style
-          - "/**| *| */"
+          - "/*!| *| */"
           - --license-filepath
           - license-templates/LICENSE.txt
           - --fuzzy-match-generates-todo
@@ -121,7 +121,7 @@ repos:
       - id: insert-license
         name: Add license for all md files
         files: \.md$
-        exclude: ^\.github/.*$
+        exclude: ^\.github/.*$|PROVIDER_CHANGES.*\.md
         args:
           - --comment-style
           - "<!--|| -->"
@@ -133,7 +133,7 @@ repos:
     hooks:
       - id: doctoc
         name: Add TOC for md files
-        files: ^README\.md$|^CONTRIBUTING\.md$|^UPDATING.md$|^dev/README.md$
+        files: 
^README\.md$|^CONTRIBUTING\.md$|^UPDATING.*.md$|^dev/README\.md$|^dev/PROVIDER_PACKAGES.md$
         args:
           - "--maxlevel"
           - "2"
@@ -141,7 +141,7 @@ repos:
     hooks:
       - id: check-hooks-apply
   - repo: https://github.com/pre-commit/pre-commit-hooks
-    rev: v3.2.0
+    rev: v3.3.0
     hooks:
       - id: check-merge-conflict
       - id: debug-statements
@@ -157,13 +157,14 @@ repos:
       - id: rst-backticks
       - id: python-no-log-warn
   - repo: https://github.com/adrienverge/yamllint
-    rev: v1.24.2
+    rev: v1.25.0
     hooks:
       - id: yamllint
         name: Check yaml files with yamllint
         entry: yamllint -c yamllint-config.yml --strict
         types: [yaml]
-        exclude: 
^.*init_git_sync\.template\.yaml$|^.*airflow\.template\.yaml$|^chart/templates/.*\.yaml$
+        exclude:
+          
^.*init_git_sync\.template\.yaml$|^.*airflow\.template\.yaml$|^chart/(?:templates|files)/.*\.yaml
   ##
   ## Dear committer.
   ##
diff --git a/airflow/www_rbac/webpack.config.js 
b/airflow/www_rbac/webpack.config.js
index 2daf628..d58c089 100644
--- a/airflow/www_rbac/webpack.config.js
+++ b/airflow/www_rbac/webpack.config.js
@@ -1,4 +1,4 @@
-/**
+/*!
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
diff --git a/chart/tests/conftest.py b/chart/tests/conftest.py
index c1a06d8..db1f22f 100644
--- a/chart/tests/conftest.py
+++ b/chart/tests/conftest.py
@@ -15,14 +15,10 @@
 # specific language governing permissions and limitations
 # under the License.
 
-import os
 import subprocess
 import sys
-import pytest
 
-# We should set these before loading _any_ of the rest of airflow so that the
-# unit test mode config is set as early as possible.
-tests_directory = os.path.dirname(os.path.realpath(__file__))
+import pytest
 
 
 @pytest.fixture(autouse=True, scope="session")
diff --git a/chart/tests/dags-persistent-volume-claim_test.yaml 
b/chart/tests/dags-persistent-volume-claim_test.yaml
deleted file mode 100644
index 2e24615..0000000
--- a/chart/tests/dags-persistent-volume-claim_test.yaml
+++ /dev/null
@@ -1,64 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
----
-templates:
-  - dags-persistent-volume-claim.yaml
-tests:
-  - it: should  not generate a document if persistence is disabled
-    set:
-      dags:
-        persistence:
-          enabled: false
-    asserts:
-      - hasDocuments:
-          count: 0
-  - it: should  not generate a document when using an existingClaim
-    set:
-      dags:
-        persistence:
-          enabled: true
-          existingClaim: test-claim
-    asserts:
-      - hasDocuments:
-          count: 0
-  - it: should  generate a document if persistence is enabled & not using an 
existingClaim
-    set:
-      dags:
-        persistence:
-          enabled: true
-          existingClaim: ~
-    asserts:
-      - hasDocuments:
-          count: 1
-  - it: should set PVC details correctly
-    set:
-      dags:
-        persistence:
-          enabled: true
-          size: 1G
-          existingClaim: ~
-          storageClass: "MyStorageClass"
-          accessMode: ReadWriteMany
-    asserts:
-      - equal:
-          path: spec
-          value:
-            accessModes: ["ReadWriteMany"]
-            resources:
-              requests:
-                storage: 1G
-            storageClassName: "MyStorageClass"
diff --git a/chart/tests/git-sync-webserver_test.yaml 
b/chart/tests/git-sync-webserver_test.yaml
deleted file mode 100644
index bdbb7c6..0000000
--- a/chart/tests/git-sync-webserver_test.yaml
+++ /dev/null
@@ -1,66 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
----
-templates:
-  - webserver/webserver-deployment.yaml
-tests:
-  - it: should add dags volume to the webserver if git sync & peristence is 
enabled
-    set:
-      dags:
-        gitSync:
-          enabled: true
-        persistence:
-          enabled: true
-    asserts:
-      - equal:
-          path: spec.template.spec.volumes[1].name
-          value: dags
-  - it: should add dags volume to the webserver if git sync is enabled & 
peristence is disabled
-    set:
-      dags:
-        gitSync:
-          enabled: true
-        persistence:
-          enabled: false
-    asserts:
-      - equal:
-          path: spec.template.spec.volumes[1].name
-          value: dags
-  - it: should add git sync container to webserver if persistence is not 
enabled, but git sync is
-    set:
-      dags:
-        gitSync:
-          enabled: true
-          containerName: git-sync
-        persistence:
-          enabled: false
-    asserts:
-      - equal:
-          path: spec.template.spec.containers[0].name
-          value: git-sync
-  - it: should not add sync container to webserver if git sync and persistence 
are enabled
-    set:
-      dags:
-        gitSync:
-          enabled: true
-          container_name: git-sync
-        persistence:
-          enabled: true
-    asserts:
-      - notEqual:
-          path: spec.template.spec.containers[0].name
-          value: git-sync
diff --git a/chart/tests/git-sync-worker_test.yaml 
b/chart/tests/git-sync-worker_test.yaml
deleted file mode 100644
index 847a4dc..0000000
--- a/chart/tests/git-sync-worker_test.yaml
+++ /dev/null
@@ -1,70 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
----
-templates:
-  - workers/worker-deployment.yaml
-tests:
-  - it: should add dags volume to the worker if git sync & peristence is 
enabled
-    set:
-      executor: CeleryExecutor
-      dags:
-        persistence:
-          enabled: true
-        gitSync:
-          enabled: true
-    asserts:
-      - equal:
-          path: spec.template.spec.volumes[1].name
-          value: dags
-  - it: should add dags volume to the worker if git sync is enabled & 
peristence is disabled
-    set:
-      executor: CeleryExecutor
-      dags:
-        gitSync:
-          enabled: true
-        persistence:
-          enabled: false
-    asserts:
-      - equal:
-          path: spec.template.spec.volumes[1].name
-          value: dags
-  - it: should add git sync container to worker if persistence is not enabled, 
but git sync is
-    set:
-      executor: CeleryExecutor
-      dags:
-        gitSync:
-          enabled: true
-          containerName: git-sync
-        persistence:
-          enabled: false
-    asserts:
-      - equal:
-          path: spec.template.spec.containers[0].name
-          value: git-sync
-  - it: should not add sync container to worker if git sync and persistence 
are enabled
-    set:
-      executor: CeleryExecutor
-      dags:
-        gitSync:
-          enabled: true
-          containerName: git-sync
-        persistence:
-          enabled: true
-    asserts:
-      - notEqual:
-          path: spec.template.spec.containers[0].name
-          value: git-sync
diff --git a/chart/tests/pod-template-file_test.yaml 
b/chart/tests/pod-template-file_test.yaml
deleted file mode 100644
index 64e99f8..0000000
--- a/chart/tests/pod-template-file_test.yaml
+++ /dev/null
@@ -1,149 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
----
-templates:
-  - pod-template-file.yaml
-tests:
-  - it: should work
-    asserts:
-      - isKind:
-          of: Pod
-      - equal:
-          path: spec.containers[0].image
-          value: dummy_image
-      - equal:
-          path: spec.containers[0].name
-          value: base
-  - it: should add an initContainer if gitSync is true
-    set:
-      dags:
-        gitSync:
-          enabled: true
-          containerName: git-sync-test
-          containerTag: test-tag
-          containerRepository: test-registry/test-repo
-          wait: 66
-          maxFailures: 70
-          subPath: "path1/path2"
-          dest: "test-dest"
-          root: "/git-root"
-          rev: HEAD
-          depth: 1
-          repo: https://github.com/apache/airflow.git
-          branch: test-branch
-          sshKeySecret: ~
-          credentialsSecret: ~
-          knownHosts: ~
-    asserts:
-      - isKind:
-          of: Pod
-      - equal:
-          path: spec.initContainers[0]
-          value:
-            name: git-sync-test
-            image: test-registry/test-repo:test-tag
-            env:
-              - name: GIT_SYNC_REV
-                value: HEAD
-              - name: GIT_SYNC_BRANCH
-                value: test-branch
-              - name: GIT_SYNC_REPO
-                value: https://github.com/apache/airflow.git
-              - name: GIT_SYNC_DEPTH
-                value: "1"
-              - name: GIT_SYNC_ROOT
-                value: /git-root
-              - name: GIT_SYNC_DEST
-                value: test-dest
-              - name: GIT_SYNC_ADD_USER
-                value: "true"
-              - name: GIT_SYNC_WAIT
-                value: "66"
-              - name: GIT_SYNC_MAX_SYNC_FAILURES
-                value: "70"
-            volumeMounts:
-              - mountPath: /git-root
-                name: dags
-  - it: validate if ssh params are added
-    set:
-      dags:
-        gitSync:
-          enabled: true
-          containerName: git-sync-test
-          sshKeySecret: ssh-secret
-          knownHosts: ~
-          branch: test-branch
-    asserts:
-      - contains:
-          path: spec.initContainers[0].env
-          content:
-            name: GIT_SSH_KEY_FILE
-            value: "/etc/git-secret/ssh"
-      - contains:
-          path: spec.initContainers[0].env
-          content:
-            name: GIT_SYNC_SSH
-            value: "true"
-      - contains:
-          path: spec.initContainers[0].env
-          content:
-            name: GIT_KNOWN_HOSTS
-            value: "false"
-      - contains:
-          path: spec.volumes
-          content:
-            name: git-sync-ssh-key
-            secret:
-              secretName: ssh-secret
-              defaultMode: 288
-  - it: should set username and pass env variables
-    set:
-      dags:
-        gitSync:
-          enabled: true
-          credentialsSecret: user-pass-secret
-          sshKeySecret: ~
-    asserts:
-      - contains:
-          path: spec.initContainers[0].env
-          content:
-            name: GIT_SYNC_USERNAME
-            valueFrom:
-              secretKeyRef:
-                name: user-pass-secret
-                key: GIT_SYNC_USERNAME
-      - contains:
-          path: spec.initContainers[0].env
-          content:
-            name: GIT_SYNC_PASSWORD
-            valueFrom:
-              secretKeyRef:
-                name: user-pass-secret
-                key: GIT_SYNC_PASSWORD
-  - it: should set the volume claim correctly when using an existing claim
-    set:
-      dags:
-        persistence:
-          enabled: true
-          existingClaim: test-claim
-    asserts:
-      - contains:
-          path: spec.volumes
-          content:
-            name: dags
-            persistentVolumeClaim:
-              claimName: test-claim
diff --git a/chart/tests/test_basic_helm_chart.py 
b/chart/tests/test_basic_helm_chart.py
index ea02c91..dcf20cf 100644
--- a/chart/tests/test_basic_helm_chart.py
+++ b/chart/tests/test_basic_helm_chart.py
@@ -17,7 +17,7 @@
 
 import unittest
 
-from .helm_template_generator import render_chart
+from tests.helm_template_generator import render_chart
 
 OBJECT_COUNT_IN_BASIC_DEPLOYMENT = 22
 
diff --git a/chart/tests/test_celery_kubernetes_executor.py 
b/chart/tests/test_celery_kubernetes_executor.py
new file mode 100644
index 0000000..7eae16e
--- /dev/null
+++ b/chart/tests/test_celery_kubernetes_executor.py
@@ -0,0 +1,47 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import unittest
+
+import jmespath
+from tests.helm_template_generator import render_chart
+
+
+class CeleryKubernetesExecutorTest(unittest.TestCase):
+    def test_should_create_a_worker_deployment_with_the_celery_executo(self):
+        docs = render_chart(
+            values={
+                "executor": "CeleryExecutor",
+                "dags": {"persistence": {"enabled": True}, "gitSync": 
{"enabled": True}},
+            },
+            show_only=["templates/workers/worker-deployment.yaml"],
+        )
+
+        self.assertEqual("config", 
jmespath.search("spec.template.spec.volumes[1].name", docs[0]))
+        self.assertEqual("dags", 
jmespath.search("spec.template.spec.volumes[2].name", docs[0]))
+
+    def 
test_should_create_a_worker_deployment_with_the_celery_kubernetes_executor(self):
+        docs = render_chart(
+            values={
+                "executor": "CeleryKubernetesExecutor",
+                "dags": {"gitSync": {"enabled": True}, "persistence": 
{"enabled": False}},
+            },
+            show_only=["templates/workers/worker-deployment.yaml"],
+        )
+
+        self.assertEqual("config", 
jmespath.search("spec.template.spec.volumes[1].name", docs[0]))
+        self.assertEqual("dags", 
jmespath.search("spec.template.spec.volumes[2].name", docs[0]))
diff --git a/scripts/ci/kubernetes/ci_run_helm_testing.sh 
b/chart/tests/test_celery_kubernetes_pod_launcher_role.py
old mode 100755
new mode 100644
similarity index 55%
copy from scripts/ci/kubernetes/ci_run_helm_testing.sh
copy to chart/tests/test_celery_kubernetes_pod_launcher_role.py
index 93d8337..535be11
--- a/scripts/ci/kubernetes/ci_run_helm_testing.sh
+++ b/chart/tests/test_celery_kubernetes_pod_launcher_role.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env bash
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -16,14 +15,20 @@
 # specific language governing permissions and limitations
 # under the License.
 
-echo "Running helm tests"
+import unittest
 
-chart_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd 
)/../../../chart/"
+import jmespath
+from tests.helm_template_generator import render_chart
 
-cat chart/files/pod-template-file.kubernetes-helm-yaml > 
chart/templates/pod-template-file.yaml
 
-docker run -w /airflow-chart -v "$chart_directory":/airflow-chart \
-  --entrypoint /bin/sh \
-  aneeshkj/helm-unittest \
-  -c "helm repo add stable https://kubernetes-charts.storage.googleapis.com; 
helm dependency update ; helm unittest ." \
-  && rm chart/templates/pod-template-file.yaml
+class CeleryKubernetesPodLauncherRole(unittest.TestCase):
+    def 
test_should_allow_both_scheduler_pod_launching_and_worker_pod_launching(self):
+        docs = render_chart(
+            values={"executor": "CeleryKubernetesExecutor"},
+            show_only=[
+                "templates/rbac/pod-launcher-rolebinding.yaml",
+            ],
+        )
+
+        self.assertEqual(jmespath.search("subjects[0].name", docs[0]), 
"RELEASE-NAME-scheduler")
+        self.assertEqual(jmespath.search("subjects[1].name", docs[0]), 
"RELEASE-NAME-worker")
diff --git a/chart/tests/test_dags_persistent_volume_claim.py 
b/chart/tests/test_dags_persistent_volume_claim.py
new file mode 100644
index 0000000..069a0cd
--- /dev/null
+++ b/chart/tests/test_dags_persistent_volume_claim.py
@@ -0,0 +1,72 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import unittest
+
+import jmespath
+from tests.helm_template_generator import render_chart
+
+
+class DagsPersistentVolumeClaimTest(unittest.TestCase):
+    def test_should_not_generate_a_document_if_persistence_is_disabled(self):
+        docs = render_chart(
+            values={"dags": {"persistence": {"enabled": False}}},
+            show_only=["templates/dags-persistent-volume-claim.yaml"],
+        )
+
+        self.assertEqual(0, len(docs))
+
+    def test_should_not_generate_a_document_when_using_an_existing_claim(self):
+        docs = render_chart(
+            values={"dags": {"persistence": {"enabled": True, "existingClaim": 
"test-claim"}}},
+            show_only=["templates/dags-persistent-volume-claim.yaml"],
+        )
+
+        self.assertEqual(0, len(docs))
+
+    def 
test_should_generate_a_document_if_persistence_is_enabled_and_not_using_an_existing_claim(self):
+        docs = render_chart(
+            values={"dags": {"persistence": {"enabled": True, "existingClaim": 
None}}},
+            show_only=["templates/dags-persistent-volume-claim.yaml"],
+        )
+
+        self.assertEqual(1, len(docs))
+
+    def test_should_set_pvc_details_correctly(self):
+        docs = render_chart(
+            values={
+                "dags": {
+                    "persistence": {
+                        "enabled": True,
+                        "size": "1G",
+                        "existingClaim": None,
+                        "storageClassName": "MyStorageClass",
+                        "accessMode": "ReadWriteMany",
+                    }
+                }
+            },
+            show_only=["templates/dags-persistent-volume-claim.yaml"],
+        )
+
+        self.assertEqual(
+            {
+                "accessModes": ["ReadWriteMany"],
+                "resources": {"requests": {"storage": "1G"}},
+                "storageClassName": "MyStorageClass",
+            },
+            jmespath.search("spec", docs[0]),
+        )
diff --git a/chart/tests/test_git_sync_scheduler.py 
b/chart/tests/test_git_sync_scheduler.py
index 116ae10..a01c0f2 100644
--- a/chart/tests/test_git_sync_scheduler.py
+++ b/chart/tests/test_git_sync_scheduler.py
@@ -17,210 +17,143 @@
 
 import unittest
 
-import yaml
-from kubernetes.client import models as k8s
+import jmespath
+from tests.helm_template_generator import render_chart
 
-from .helm_template_generator import render_chart, render_k8s_object
 
-OBJECT_COUNT_IN_BASIC_DEPLOYMENT = 22
-
-git_sync_basic = """
-dags:
-  gitSync:
-    enabled: true
-"""
-
-git_sync_existing_claim = """
-dags:
- persistence:
-  enabled: true
-  existingClaim: test-claim
-"""
-
-git_sync_ssh_params = """
-dags:
- gitSync:
-  enabled: true
-  containerName: git-sync-test
-  sshKeySecret: ssh-secret
-  knownHosts: ~
-  branch: test-branch
-"""
-
-git_sync_username = """
-dags:
- gitSync:
-  enabled: true
-  credentialsSecret: user-pass-secret
-  sshKeySecret: ~
-"""
-
-git_sync_container_spec = """
-images:
-  gitSync:
-    repository: test-registry/test-repo
-    tag: test-tag
-dags:
-  gitSync:
-    enabled: true
-    containerName: git-sync-test
-    wait: 66
-    maxFailures: 70
-    subPath: "path1/path2"
-    dest: "test-dest"
-    root: "/git-root"
-    rev: HEAD
-    depth: 1
-    repo: https://github.com/apache/airflow.git
-    branch: test-branch
-    sshKeySecret: ~
-    credentialsSecret: ~
-    knownHosts: ~
-  persistence:
-    enabled: true
-"""
-
-
-class TestGitSyncScheduler(unittest.TestCase):
-    def test_basic(self):
-        helm_settings = yaml.safe_load(git_sync_basic)
-        res = render_chart(
-            'GIT-SYNC', helm_settings, 
show_only=["templates/scheduler/scheduler-deployment.yaml"]
+class GitSyncSchedulerTest(unittest.TestCase):
+    def test_should_add_dags_volume(self):
+        docs = render_chart(
+            values={"dags": {"gitSync": {"enabled": True}}},
+            show_only=["templates/scheduler/scheduler-deployment.yaml"],
         )
-        dep = render_k8s_object(res[0], k8s.V1Deployment)
-        self.assertEqual("dags", dep.spec.template.spec.volumes[1].name)
 
-    def test_git_container_spec(self):
-        helm_settings = yaml.safe_load(git_sync_container_spec)
-        res = render_chart(
-            'GIT-SYNC', helm_settings, 
show_only=["templates/scheduler/scheduler-deployment.yaml"]
-        )
-        dep = render_k8s_object(res[0], k8s.V1Deployment)
-        git_sync_container = dep.spec.template.spec.containers[1]
-        self.assertEqual(git_sync_container.image, 
"test-registry/test-repo:test-tag")
-        self.assertEqual(git_sync_container.name, "git-sync-test")
-        self.assertEqual(git_sync_container.security_context.run_as_user, 
65533)
-        env_dict = [e.to_dict() for e in git_sync_container.env]
-        self.assertEqual(
-            env_dict,
-            [
-                {'name': 'GIT_SYNC_REV', 'value': 'HEAD', 'value_from': None},
-                {'name': 'GIT_SYNC_BRANCH', 'value': 'test-branch', 
'value_from': None},
-                {
-                    'name': 'GIT_SYNC_REPO',
-                    'value': 'https://github.com/apache/airflow.git',
-                    'value_from': None,
+        self.assertEqual("dags", 
jmespath.search("spec.template.spec.volumes[1].name", docs[0]))
+
+    def test_validate_the_git_sync_container_spec(self):
+        docs = render_chart(
+            values={
+                "images": {
+                    "gitSync": {
+                        "repository": "test-registry/test-repo",
+                        "tag": "test-tag",
+                        "pullPolicy": "Allways",
+                    }
+                },
+                "dags": {
+                    "gitSync": {
+                        "enabled": True,
+                        "containerName": "git-sync-test",
+                        "wait": 66,
+                        "maxFailures": 70,
+                        "subPath": "path1/path2",
+                        "dest": "test-dest",
+                        "root": "/git-root",
+                        "rev": "HEAD",
+                        "depth": 1,
+                        "repo": "https://github.com/apache/airflow.git";,
+                        "branch": "test-branch",
+                        "sshKeySecret": None,
+                        "credentialsSecret": None,
+                        "knownHosts": None,
+                    },
+                    "persistence": {"enabled": True},
                 },
-                {'name': 'GIT_SYNC_DEPTH', 'value': '1', 'value_from': None},
-                {'name': 'GIT_SYNC_ROOT', 'value': '/git-root', 'value_from': 
None},
-                {'name': 'GIT_SYNC_DEST', 'value': 'test-dest', 'value_from': 
None},
-                {'name': 'GIT_SYNC_ADD_USER', 'value': 'true', 'value_from': 
None},
-                {'name': 'GIT_SYNC_WAIT', 'value': '66', 'value_from': None},
-                {'name': 'GIT_SYNC_MAX_SYNC_FAILURES', 'value': '70', 
'value_from': None},
-            ],
+            },
+            show_only=["templates/scheduler/scheduler-deployment.yaml"],
         )
 
         self.assertEqual(
-            git_sync_container.volume_mounts, [k8s.V1VolumeMount(name="dags", 
mount_path="/git-root")]
+            {
+                "name": "git-sync-test",
+                "securityContext": {"runAsUser": 65533},
+                "image": "test-registry/test-repo:test-tag",
+                "imagePullPolicy": "Allways",
+                "env": [
+                    {"name": "GIT_SYNC_REV", "value": "HEAD"},
+                    {"name": "GIT_SYNC_BRANCH", "value": "test-branch"},
+                    {"name": "GIT_SYNC_REPO", "value": 
"https://github.com/apache/airflow.git"},
+                    {"name": "GIT_SYNC_DEPTH", "value": "1"},
+                    {"name": "GIT_SYNC_ROOT", "value": "/git-root"},
+                    {"name": "GIT_SYNC_DEST", "value": "test-dest"},
+                    {"name": "GIT_SYNC_ADD_USER", "value": "true"},
+                    {"name": "GIT_SYNC_WAIT", "value": "66"},
+                    {"name": "GIT_SYNC_MAX_SYNC_FAILURES", "value": "70"},
+                ],
+                "volumeMounts": [{"mountPath": "/git-root", "name": "dags"}],
+            },
+            jmespath.search("spec.template.spec.containers[1]", docs[0]),
         )
 
-    def test_ssh_params_added(self):
-        helm_settings = yaml.safe_load(git_sync_ssh_params)
-        res = render_chart(
-            'GIT-SYNC', helm_settings, 
show_only=["templates/scheduler/scheduler-deployment.yaml"]
+    def test_validate_if_ssh_params_are_added(self):
+        docs = render_chart(
+            values={
+                "dags": {
+                    "gitSync": {
+                        "enabled": True,
+                        "containerName": "git-sync-test",
+                        "sshKeySecret": "ssh-secret",
+                        "knownHosts": None,
+                        "branch": "test-branch",
+                    }
+                }
+            },
+            show_only=["templates/scheduler/scheduler-deployment.yaml"],
         )
-        dep = render_k8s_object(res[0], k8s.V1Deployment)
-        git_sync_container = dep.spec.template.spec.containers[1]
-        env_dict = [e.to_dict() for e in git_sync_container.env]
-        self.assertEqual(
-            env_dict,
-            [
-                {'name': 'GIT_SSH_KEY_FILE', 'value': '/etc/git-secret/ssh', 
'value_from': None},
-                {'name': 'GIT_SYNC_SSH', 'value': 'true', 'value_from': None},
-                {'name': 'GIT_KNOWN_HOSTS', 'value': 'false', 'value_from': 
None},
-                {'name': 'GIT_SYNC_REV', 'value': 'HEAD', 'value_from': None},
-                {'name': 'GIT_SYNC_BRANCH', 'value': 'test-branch', 
'value_from': None},
-                {
-                    'name': 'GIT_SYNC_REPO',
-                    'value': 'https://github.com/apache/airflow.git',
-                    'value_from': None,
-                },
-                {'name': 'GIT_SYNC_DEPTH', 'value': '1', 'value_from': None},
-                {'name': 'GIT_SYNC_ROOT', 'value': '/git', 'value_from': None},
-                {'name': 'GIT_SYNC_DEST', 'value': 'repo', 'value_from': None},
-                {'name': 'GIT_SYNC_ADD_USER', 'value': 'true', 'value_from': 
None},
-                {'name': 'GIT_SYNC_WAIT', 'value': '60', 'value_from': None},
-                {'name': 'GIT_SYNC_MAX_SYNC_FAILURES', 'value': '0', 
'value_from': None},
-            ],
+
+        self.assertIn(
+            {"name": "GIT_SSH_KEY_FILE", "value": "/etc/git-secret/ssh"},
+            jmespath.search("spec.template.spec.containers[1].env", docs[0]),
+        )
+        self.assertIn(
+            {"name": "GIT_SYNC_SSH", "value": "true"},
+            jmespath.search("spec.template.spec.containers[1].env", docs[0]),
+        )
+        self.assertIn(
+            {"name": "GIT_KNOWN_HOSTS", "value": "false"},
+            jmespath.search("spec.template.spec.containers[1].env", docs[0]),
+        )
+        self.assertIn(
+            {"name": "git-sync-ssh-key", "secret": {"secretName": 
"ssh-secret", "defaultMode": 288}},
+            jmespath.search("spec.template.spec.volumes", docs[0]),
         )
 
-    def test_adds_git_username(self):
-        helm_settings = yaml.safe_load(git_sync_username)
-        res = render_chart(
-            'GIT-SYNC', helm_settings, 
show_only=["templates/scheduler/scheduler-deployment.yaml"]
+    def test_should_set_username_and_pass_env_variables(self):
+        docs = render_chart(
+            values={
+                "dags": {
+                    "gitSync": {
+                        "enabled": True,
+                        "credentialsSecret": "user-pass-secret",
+                        "sshKeySecret": None,
+                    }
+                }
+            },
+            show_only=["templates/scheduler/scheduler-deployment.yaml"],
         )
-        dep = render_k8s_object(res[0], k8s.V1Deployment)
-        git_sync_container = dep.spec.template.spec.containers[1]
-        env_dict = [e.to_dict() for e in git_sync_container.env]
-        self.assertEqual(
-            env_dict,
-            [
-                {
-                    'name': 'GIT_SYNC_USERNAME',
-                    'value': None,
-                    'value_from': {
-                        'config_map_key_ref': None,
-                        'field_ref': None,
-                        'resource_field_ref': None,
-                        'secret_key_ref': {
-                            'key': 'GIT_SYNC_USERNAME',
-                            'name': 'user-pass-secret',
-                            'optional': None,
-                        },
-                    },
-                },
-                {
-                    'name': 'GIT_SYNC_PASSWORD',
-                    'value': None,
-                    'value_from': {
-                        'config_map_key_ref': None,
-                        'field_ref': None,
-                        'resource_field_ref': None,
-                        'secret_key_ref': {
-                            'key': 'GIT_SYNC_PASSWORD',
-                            'name': 'user-pass-secret',
-                            'optional': None,
-                        },
-                    },
-                },
-                {'name': 'GIT_SYNC_REV', 'value': 'HEAD', 'value_from': None},
-                {'name': 'GIT_SYNC_BRANCH', 'value': 'v1-10-stable', 
'value_from': None},
-                {
-                    'name': 'GIT_SYNC_REPO',
-                    'value': 'https://github.com/apache/airflow.git',
-                    'value_from': None,
-                },
-                {'name': 'GIT_SYNC_DEPTH', 'value': '1', 'value_from': None},
-                {'name': 'GIT_SYNC_ROOT', 'value': '/git', 'value_from': None},
-                {'name': 'GIT_SYNC_DEST', 'value': 'repo', 'value_from': None},
-                {'name': 'GIT_SYNC_ADD_USER', 'value': 'true', 'value_from': 
None},
-                {'name': 'GIT_SYNC_WAIT', 'value': '60', 'value_from': None},
-                {'name': 'GIT_SYNC_MAX_SYNC_FAILURES', 'value': '0', 
'value_from': None},
-            ],
+
+        self.assertIn(
+            {
+                "name": "GIT_SYNC_USERNAME",
+                "valueFrom": {"secretKeyRef": {"name": "user-pass-secret", 
"key": "GIT_SYNC_USERNAME"}},
+            },
+            jmespath.search("spec.template.spec.containers[1].env", docs[0]),
+        )
+        self.assertIn(
+            {
+                "name": "GIT_SYNC_PASSWORD",
+                "valueFrom": {"secretKeyRef": {"name": "user-pass-secret", 
"key": "GIT_SYNC_PASSWORD"}},
+            },
+            jmespath.search("spec.template.spec.containers[1].env", docs[0]),
         )
 
-    def test_set_volume_claim_to_existing_claim(self):
-        helm_settings = yaml.safe_load(git_sync_existing_claim)
-        res = render_chart(
-            'GIT-SYNC', helm_settings, 
show_only=["templates/scheduler/scheduler-deployment.yaml"]
+    def 
test_should_set_the_volume_claim_correctly_when_using_an_existing_claim(self):
+        docs = render_chart(
+            values={"dags": {"persistence": {"enabled": True, "existingClaim": 
"test-claim"}}},
+            show_only=["templates/scheduler/scheduler-deployment.yaml"],
         )
-        dep = render_k8s_object(res[0], k8s.V1Deployment)
-        volume_map = {vol.name: vol for vol in dep.spec.template.spec.volumes}
-        dag_volume = volume_map['dags']
-        self.assertEqual(
-            dag_volume,
-            k8s.V1Volume(
-                name="dags",
-                
persistent_volume_claim=k8s.V1PersistentVolumeClaimVolumeSource(claim_name='test-claim'),
-            ),
+
+        self.assertIn(
+            {"name": "dags", "persistentVolumeClaim": {"claimName": 
"test-claim"}},
+            jmespath.search("spec.template.spec.volumes", docs[0]),
         )
diff --git a/chart/tests/test_git_sync_webserver.py 
b/chart/tests/test_git_sync_webserver.py
new file mode 100644
index 0000000..30c3f33
--- /dev/null
+++ b/chart/tests/test_git_sync_webserver.py
@@ -0,0 +1,62 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import unittest
+
+import jmespath
+from tests.helm_template_generator import render_chart
+
+
+class GitSyncWebserverTest(unittest.TestCase):
+    def 
test_should_add_dags_volume_to_the_webserver_if_git_sync_and_peristence_is_enabled(self):
+        docs = render_chart(
+            values={"dags": {"gitSync": {"enabled": True}, "persistence": 
{"enabled": True}}},
+            show_only=["templates/webserver/webserver-deployment.yaml"],
+        )
+
+        self.assertEqual("dags", 
jmespath.search("spec.template.spec.volumes[1].name", docs[0]))
+
+    def 
test_should_add_dags_volume_to_the_webserver_if_git_sync_is_enabled_and_peristence_is_disabled(self):
+        docs = render_chart(
+            values={"dags": {"gitSync": {"enabled": True}, "persistence": 
{"enabled": False}}},
+            show_only=["templates/webserver/webserver-deployment.yaml"],
+        )
+
+        self.assertEqual("dags", 
jmespath.search("spec.template.spec.volumes[1].name", docs[0]))
+
+    def 
test_should_add_git_sync_container_to_webserver_if_persistence_is_not_enabled_but_git_sync_is(self):
+        docs = render_chart(
+            values={
+                "dags": {
+                    "gitSync": {"enabled": True, "containerName": "git-sync"},
+                    "persistence": {"enabled": False},
+                }
+            },
+            show_only=["templates/webserver/webserver-deployment.yaml"],
+        )
+
+        self.assertEqual("git-sync", 
jmespath.search("spec.template.spec.containers[0].name", docs[0]))
+
+    def test_should_have_service_account_defined(self):
+        docs = render_chart(
+            values={"dags": {"gitSync": {"enabled": True}, "persistence": 
{"enabled": True}}},
+            show_only=["templates/webserver/webserver-deployment.yaml"],
+        )
+
+        self.assertEqual(
+            "RELEASE-NAME-webserver", 
jmespath.search("spec.template.spec.serviceAccountName", docs[0])
+        )
diff --git a/chart/tests/test_git_sync_worker.py 
b/chart/tests/test_git_sync_worker.py
new file mode 100644
index 0000000..714f385
--- /dev/null
+++ b/chart/tests/test_git_sync_worker.py
@@ -0,0 +1,75 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import unittest
+
+import jmespath
+from tests.helm_template_generator import render_chart
+
+
+class GitSyncWorkerTest(unittest.TestCase):
+    def 
test_should_add_dags_volume_to_the_worker_if_git_sync_and_peristence_is_enabled(self):
+        docs = render_chart(
+            values={
+                "executor": "CeleryExecutor",
+                "dags": {"persistence": {"enabled": True}, "gitSync": 
{"enabled": True}},
+            },
+            show_only=["templates/workers/worker-deployment.yaml"],
+        )
+
+        self.assertEqual("config", 
jmespath.search("spec.template.spec.volumes[1].name", docs[0]))
+        self.assertEqual("dags", 
jmespath.search("spec.template.spec.volumes[2].name", docs[0]))
+
+    def 
test_should_add_dags_volume_to_the_worker_if_git_sync_is_enabled_and_peristence_is_disabled(self):
+        docs = render_chart(
+            values={
+                "executor": "CeleryExecutor",
+                "dags": {"gitSync": {"enabled": True}, "persistence": 
{"enabled": False}},
+            },
+            show_only=["templates/workers/worker-deployment.yaml"],
+        )
+
+        self.assertEqual("config", 
jmespath.search("spec.template.spec.volumes[1].name", docs[0]))
+        self.assertEqual("dags", 
jmespath.search("spec.template.spec.volumes[2].name", docs[0]))
+
+    def 
test_should_add_git_sync_container_to_worker_if_persistence_is_not_enabled_but_git_sync_is(self):
+        docs = render_chart(
+            values={
+                "executor": "CeleryExecutor",
+                "dags": {
+                    "gitSync": {"enabled": True, "containerName": "git-sync"},
+                    "persistence": {"enabled": False},
+                },
+            },
+            show_only=["templates/workers/worker-deployment.yaml"],
+        )
+
+        self.assertEqual("git-sync", 
jmespath.search("spec.template.spec.containers[0].name", docs[0]))
+
+    def 
test_should_not_add_sync_container_to_worker_if_git_sync_and_persistence_are_enabled(self):
+        docs = render_chart(
+            values={
+                "executor": "CeleryExecutor",
+                "dags": {
+                    "gitSync": {"enabled": True, "containerName": "git-sync"},
+                    "persistence": {"enabled": True},
+                },
+            },
+            show_only=["templates/workers/worker-deployment.yaml"],
+        )
+
+        self.assertNotEqual("git-sync", 
jmespath.search("spec.template.spec.containers[0].name", docs[0]))
diff --git a/scripts/ci/kubernetes/ci_run_helm_testing.sh 
b/chart/tests/test_migrate_database_job.py
old mode 100755
new mode 100644
similarity index 60%
rename from scripts/ci/kubernetes/ci_run_helm_testing.sh
rename to chart/tests/test_migrate_database_job.py
index 93d8337..0524315
--- a/scripts/ci/kubernetes/ci_run_helm_testing.sh
+++ b/chart/tests/test_migrate_database_job.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env bash
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -16,14 +15,20 @@
 # specific language governing permissions and limitations
 # under the License.
 
-echo "Running helm tests"
+import unittest
 
-chart_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd 
)/../../../chart/"
+import jmespath
+from tests.helm_template_generator import render_chart
 
-cat chart/files/pod-template-file.kubernetes-helm-yaml > 
chart/templates/pod-template-file.yaml
 
-docker run -w /airflow-chart -v "$chart_directory":/airflow-chart \
-  --entrypoint /bin/sh \
-  aneeshkj/helm-unittest \
-  -c "helm repo add stable https://kubernetes-charts.storage.googleapis.com; 
helm dependency update ; helm unittest ." \
-  && rm chart/templates/pod-template-file.yaml
+class MigrateDatabaseJobTest(unittest.TestCase):
+    def test_should_run_by_default(self):
+        docs = render_chart(
+            values={},
+            show_only=["templates/migrate-database-job.yaml"],
+        )
+
+        self.assertRegex(docs[0]["kind"], "Job")
+        self.assertEqual(
+            "run-airflow-migrations", 
jmespath.search("spec.template.spec.containers[0].name", docs[0])
+        )
diff --git a/chart/tests/test_pod_template_file.py 
b/chart/tests/test_pod_template_file.py
new file mode 100644
index 0000000..0673e08
--- /dev/null
+++ b/chart/tests/test_pod_template_file.py
@@ -0,0 +1,185 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import unittest
+from os import remove
+from os.path import realpath, dirname
+from shutil import copyfile
+
+import jmespath
+from tests.helm_template_generator import render_chart
+
+ROOT_FOLDER = realpath(dirname(realpath(__file__)) + "/..")
+
+
+class PodTemplateFileTest(unittest.TestCase):
+    def setUp(self):
+        copyfile(
+            ROOT_FOLDER + "/files/pod-template-file.kubernetes-helm-yaml",
+            ROOT_FOLDER + "/templates/pod-template-file.yaml",
+        )
+
+    def tearDown(self):
+        remove(ROOT_FOLDER + "/templates/pod-template-file.yaml")
+
+    def test_should_work(self):
+        docs = render_chart(
+            values={},
+            show_only=["templates/pod-template-file.yaml"],
+        )
+
+        self.assertRegex(docs[0]["kind"], "Pod")
+        self.assertIsNotNone(jmespath.search("spec.containers[0].image", 
docs[0]))
+        self.assertEqual("base", jmespath.search("spec.containers[0].name", 
docs[0]))
+
+    def test_should_add_an_init_container_if_git_sync_is_true(self):
+        docs = render_chart(
+            values={
+                "images": {
+                    "gitSync": {
+                        "repository": "test-registry/test-repo",
+                        "tag": "test-tag",
+                        "pullPolicy": "Allways",
+                    }
+                },
+                "dags": {
+                    "gitSync": {
+                        "enabled": True,
+                        "containerName": "git-sync-test",
+                        "wait": 66,
+                        "maxFailures": 70,
+                        "subPath": "path1/path2",
+                        "dest": "test-dest",
+                        "root": "/git-root",
+                        "rev": "HEAD",
+                        "depth": 1,
+                        "repo": "https://github.com/apache/airflow.git";,
+                        "branch": "test-branch",
+                        "sshKeySecret": None,
+                        "credentialsSecret": None,
+                        "knownHosts": None,
+                    }
+                },
+            },
+            show_only=["templates/pod-template-file.yaml"],
+        )
+
+        self.assertRegex(docs[0]["kind"], "Pod")
+        self.assertEqual(
+            {
+                "name": "git-sync-test",
+                "securityContext": {"runAsUser": 65533},
+                "image": "test-registry/test-repo:test-tag",
+                "imagePullPolicy": "Allways",
+                "env": [
+                    {"name": "GIT_SYNC_REV", "value": "HEAD"},
+                    {"name": "GIT_SYNC_BRANCH", "value": "test-branch"},
+                    {"name": "GIT_SYNC_REPO", "value": 
"https://github.com/apache/airflow.git"},
+                    {"name": "GIT_SYNC_DEPTH", "value": "1"},
+                    {"name": "GIT_SYNC_ROOT", "value": "/git-root"},
+                    {"name": "GIT_SYNC_DEST", "value": "test-dest"},
+                    {"name": "GIT_SYNC_ADD_USER", "value": "true"},
+                    {"name": "GIT_SYNC_WAIT", "value": "66"},
+                    {"name": "GIT_SYNC_MAX_SYNC_FAILURES", "value": "70"},
+                    {"name": "GIT_SYNC_ONE_TIME", "value": "true"},
+                ],
+                "volumeMounts": [{"mountPath": "/git-root", "name": "dags"}],
+            },
+            jmespath.search("spec.initContainers[0]", docs[0]),
+        )
+
+    def test_validate_if_ssh_params_are_added(self):
+        docs = render_chart(
+            values={
+                "dags": {
+                    "gitSync": {
+                        "enabled": True,
+                        "containerName": "git-sync-test",
+                        "sshKeySecret": "ssh-secret",
+                        "knownHosts": None,
+                        "branch": "test-branch",
+                    }
+                }
+            },
+            show_only=["templates/pod-template-file.yaml"],
+        )
+
+        self.assertIn(
+            {"name": "GIT_SSH_KEY_FILE", "value": "/etc/git-secret/ssh"},
+            jmespath.search("spec.initContainers[0].env", docs[0]),
+        )
+        self.assertIn(
+            {"name": "GIT_SYNC_SSH", "value": "true"}, 
jmespath.search("spec.initContainers[0].env", docs[0])
+        )
+        self.assertIn(
+            {"name": "GIT_KNOWN_HOSTS", "value": "false"},
+            jmespath.search("spec.initContainers[0].env", docs[0]),
+        )
+        self.assertIn(
+            {"name": "git-sync-ssh-key", "secret": {"secretName": 
"ssh-secret", "defaultMode": 288}},
+            jmespath.search("spec.volumes", docs[0]),
+        )
+
+    def test_should_set_username_and_pass_env_variables(self):
+        docs = render_chart(
+            values={
+                "dags": {
+                    "gitSync": {
+                        "enabled": True,
+                        "credentialsSecret": "user-pass-secret",
+                        "sshKeySecret": None,
+                    }
+                }
+            },
+            show_only=["templates/pod-template-file.yaml"],
+        )
+
+        self.assertIn(
+            {
+                "name": "GIT_SYNC_USERNAME",
+                "valueFrom": {"secretKeyRef": {"name": "user-pass-secret", 
"key": "GIT_SYNC_USERNAME"}},
+            },
+            jmespath.search("spec.initContainers[0].env", docs[0]),
+        )
+        self.assertIn(
+            {
+                "name": "GIT_SYNC_PASSWORD",
+                "valueFrom": {"secretKeyRef": {"name": "user-pass-secret", 
"key": "GIT_SYNC_PASSWORD"}},
+            },
+            jmespath.search("spec.initContainers[0].env", docs[0]),
+        )
+
+    def 
test_should_set_the_volume_claim_correctly_when_using_an_existing_claim(self):
+        docs = render_chart(
+            values={"dags": {"persistence": {"enabled": True, "existingClaim": 
"test-claim"}}},
+            show_only=["templates/pod-template-file.yaml"],
+        )
+
+        self.assertIn(
+            {"name": "dags", "persistentVolumeClaim": {"claimName": 
"test-claim"}},
+            jmespath.search("spec.volumes", docs[0]),
+        )
+
+    def test_should_set_a_custom_image_in_pod_template(self):
+        docs = render_chart(
+            values={"images": {"pod_template": {"repository": "dummy_image", 
"tag": "latest"}}},
+            show_only=["templates/pod-template-file.yaml"],
+        )
+
+        self.assertRegex(docs[0]["kind"], "Pod")
+        self.assertEqual("dummy_image:latest", 
jmespath.search("spec.containers[0].image", docs[0]))
+        self.assertEqual("base", jmespath.search("spec.containers[0].name", 
docs[0]))
diff --git a/chart/tests/test_scheduler.py b/chart/tests/test_scheduler.py
new file mode 100644
index 0000000..9769848
--- /dev/null
+++ b/chart/tests/test_scheduler.py
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import unittest
+
+import jmespath
+from tests.helm_template_generator import render_chart
+
+
+class SchedulerTest(unittest.TestCase):
+    def test_should_add_extra_volume_and_extra_volume_mount(self):
+        docs = render_chart(
+            values={
+                "executor": "CeleryExecutor",
+                "scheduler": {
+                    "extraVolumes": [{"name": "test-volume", "emptyDir": {}}],
+                    "extraVolumeMounts": [{"name": "test-volume", "mountPath": 
"/opt/test"}],
+                },
+            },
+            show_only=["templates/scheduler/scheduler-deployment.yaml"],
+        )
+
+        self.assertEqual("test-volume", 
jmespath.search("spec.template.spec.volumes[1].name", docs[0]))
+        self.assertEqual(
+            "test-volume", 
jmespath.search("spec.template.spec.containers[0].volumeMounts[3].name", 
docs[0])
+        )
diff --git a/chart/tests/test_worker.py b/chart/tests/test_worker.py
new file mode 100644
index 0000000..2fc6d17
--- /dev/null
+++ b/chart/tests/test_worker.py
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import unittest
+
+import jmespath
+from tests.helm_template_generator import render_chart
+
+
+class WorkerTest(unittest.TestCase):
+    def test_should_add_extra_volume_and_extra_volume_mount(self):
+        docs = render_chart(
+            values={
+                "executor": "CeleryExecutor",
+                "workers": {
+                    "extraVolumes": [{"name": "test-volume", "emptyDir": {}}],
+                    "extraVolumeMounts": [{"name": "test-volume", "mountPath": 
"/opt/test"}],
+                },
+            },
+            show_only=["templates/workers/worker-deployment.yaml"],
+        )
+
+        self.assertEqual("test-volume", 
jmespath.search("spec.template.spec.volumes[0].name", docs[0]))
+        self.assertEqual(
+            "test-volume", 
jmespath.search("spec.template.spec.containers[0].volumeMounts[0].name", 
docs[0])
+        )
diff --git a/docs/static/exampleinclude.css b/docs/static/exampleinclude.css
index 722ffec..b4f2a42 100644
--- a/docs/static/exampleinclude.css
+++ b/docs/static/exampleinclude.css
@@ -1,4 +1,4 @@
-/**
+/*!
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
diff --git a/docs/static/jira-links.js b/docs/static/jira-links.js
index 8dc4394..7d6d7f7 100644
--- a/docs/static/jira-links.js
+++ b/docs/static/jira-links.js
@@ -1,4 +1,4 @@
-/**
+/*!
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information

Reply via email to