From 8eacbf2500ca85dd4386883b500bd4a60a1283ee Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Wed, 2 Aug 2023 14:22:31 +0200 Subject: [PATCH] fix failing helm unit tests (#2727) --- .github/workflows/linting-and-tests.yml | 9 ++++--- .../topology_deployments_test.yaml.snap | 15 +++++++++++ .../tests/affinity_deployments_test.yaml | 2 +- .../tests/extra_containers_celery_test.yaml | 2 +- .../tests/extra_containers_engine_test.yaml | 2 +- helm/oncall/tests/image_deployments_test.yaml | 1 - .../oncall/tests/image_pull_secrets_test.yaml | 1 - .../tests/migrate_extra_containers_test.yaml | 2 +- .../tests/nodeselector_deployments_test.yaml | 2 +- .../priority_class_deployments_test.yaml | 2 +- helm/oncall/tests/redis_env_test.yaml | 2 +- .../service_account_deployments_test.yaml | 1 - helm/oncall/tests/telegram_env_test.yaml | 1 - .../tests/tolerations_deployments_test.yaml | 2 +- .../tests/topology_deployments_test.yaml | 26 +++++++++---------- helm/oncall/tests/uwsgi_env_test.yaml | 3 --- helm/oncall/tests/wait_for_db_test.yaml | 9 +++---- 17 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 helm/oncall/tests/__snapshot__/topology_deployments_test.yaml.snap diff --git a/.github/workflows/linting-and-tests.yml b/.github/workflows/linting-and-tests.yml index d20ac605..0a49a4ff 100644 --- a/.github/workflows/linting-and-tests.yml +++ b/.github/workflows/linting-and-tests.yml @@ -129,10 +129,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: d3adb5/helm-unittest-action@v2 + - uses: azure/setup-helm@v3 with: - helm-version: v3.8.0 - charts: ./helm/oncall + version: v3.8.0 + - name: Install helm unittest plugin + run: helm plugin install https://github.com/helm-unittest/helm-unittest.git --version=v0.3.3 + - name: Run tests + run: helm unittest ./helm/oncall unit-test-backend-mysql-rabbitmq: name: "Backend Tests: MySQL + RabbitMQ (RBAC enabled: ${{ matrix.rbac_enabled }})" diff --git a/helm/oncall/tests/__snapshot__/topology_deployments_test.yaml.snap b/helm/oncall/tests/__snapshot__/topology_deployments_test.yaml.snap new file mode 100644 index 00000000..606d41c6 --- /dev/null +++ b/helm/oncall/tests/__snapshot__/topology_deployments_test.yaml.snap @@ -0,0 +1,15 @@ +topologySpreadConstraints -> should use custom topologySpreadConstraints: + 1: | + - labelSelector: + matchLabels: + app.kubernetes.io/component: engine + maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: DoNotSchedule + 2: | + - labelSelector: + matchLabels: + app.kubernetes.io/component: engine + maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: DoNotSchedule diff --git a/helm/oncall/tests/affinity_deployments_test.yaml b/helm/oncall/tests/affinity_deployments_test.yaml index 0ce93307..76526a68 100644 --- a/helm/oncall/tests/affinity_deployments_test.yaml +++ b/helm/oncall/tests/affinity_deployments_test.yaml @@ -9,7 +9,7 @@ tests: - it: affinity={} -> should set afffinity null asserts: - notExists: - path: spec.template.spec.affinity + path: spec.template.spec.affinity - it: affinity -> should use custom affinity set: diff --git a/helm/oncall/tests/extra_containers_celery_test.yaml b/helm/oncall/tests/extra_containers_celery_test.yaml index 6f782537..2a805a50 100644 --- a/helm/oncall/tests/extra_containers_celery_test.yaml +++ b/helm/oncall/tests/extra_containers_celery_test.yaml @@ -10,7 +10,7 @@ tests: asserts: - lengthEqual: path: spec.template.spec.containers - count : 1 + count: 1 - it: celery.extraContainers -> should add sidecar containers set: diff --git a/helm/oncall/tests/extra_containers_engine_test.yaml b/helm/oncall/tests/extra_containers_engine_test.yaml index 70fde9ca..4f16ae50 100644 --- a/helm/oncall/tests/extra_containers_engine_test.yaml +++ b/helm/oncall/tests/extra_containers_engine_test.yaml @@ -10,7 +10,7 @@ tests: asserts: - lengthEqual: path: spec.template.spec.containers - count : 1 + count: 1 - it: engine.extraContainers -> should add sidecar containers set: diff --git a/helm/oncall/tests/image_deployments_test.yaml b/helm/oncall/tests/image_deployments_test.yaml index 1418ae7c..535053ec 100644 --- a/helm/oncall/tests/image_deployments_test.yaml +++ b/helm/oncall/tests/image_deployments_test.yaml @@ -30,4 +30,3 @@ tests: - equal: path: spec.template.spec.containers[0].imagePullPolicy value: IfNotPresent - diff --git a/helm/oncall/tests/image_pull_secrets_test.yaml b/helm/oncall/tests/image_pull_secrets_test.yaml index e4ffd7cb..67318aa5 100644 --- a/helm/oncall/tests/image_pull_secrets_test.yaml +++ b/helm/oncall/tests/image_pull_secrets_test.yaml @@ -22,4 +22,3 @@ tests: path: spec.template.spec.imagePullSecrets content: name: regcred - diff --git a/helm/oncall/tests/migrate_extra_containers_test.yaml b/helm/oncall/tests/migrate_extra_containers_test.yaml index 9653a285..83fe7f23 100644 --- a/helm/oncall/tests/migrate_extra_containers_test.yaml +++ b/helm/oncall/tests/migrate_extra_containers_test.yaml @@ -10,7 +10,7 @@ tests: asserts: - lengthEqual: path: spec.template.spec.containers - count : 1 + count: 1 - it: migrate.extraContainers -> should add sidecar containers set: diff --git a/helm/oncall/tests/nodeselector_deployments_test.yaml b/helm/oncall/tests/nodeselector_deployments_test.yaml index 50bfb422..2b937d3a 100644 --- a/helm/oncall/tests/nodeselector_deployments_test.yaml +++ b/helm/oncall/tests/nodeselector_deployments_test.yaml @@ -9,7 +9,7 @@ tests: - it: nodeSelector={} -> should set nodeSelector null asserts: - notExists: - path: spec.template.spec.nodeSelector + path: spec.template.spec.nodeSelector - it: nodeSelector -> should use custom nodeSelector set: diff --git a/helm/oncall/tests/priority_class_deployments_test.yaml b/helm/oncall/tests/priority_class_deployments_test.yaml index 89db7501..ddcbeffd 100644 --- a/helm/oncall/tests/priority_class_deployments_test.yaml +++ b/helm/oncall/tests/priority_class_deployments_test.yaml @@ -8,7 +8,7 @@ tests: - it: priorityClassName="" -> should exclude priorityClassName asserts: - notExists: - path: spec.template.spec.priorityClassName + path: spec.template.spec.priorityClassName - it: priorityClassName -> should use the custom priorityClassName set: diff --git a/helm/oncall/tests/redis_env_test.yaml b/helm/oncall/tests/redis_env_test.yaml index 5fc3739f..dd4cfc0c 100644 --- a/helm/oncall/tests/redis_env_test.yaml +++ b/helm/oncall/tests/redis_env_test.yaml @@ -76,7 +76,7 @@ tests: secretKeyRef: key: redis-password name: oncall-redis - + - it: redis.enabled=false -> should fail if host not set set: redis.enabled: false diff --git a/helm/oncall/tests/service_account_deployments_test.yaml b/helm/oncall/tests/service_account_deployments_test.yaml index 9fbe9303..180880d5 100644 --- a/helm/oncall/tests/service_account_deployments_test.yaml +++ b/helm/oncall/tests/service_account_deployments_test.yaml @@ -27,4 +27,3 @@ tests: - equal: path: spec.template.spec.serviceAccountName value: custom - diff --git a/helm/oncall/tests/telegram_env_test.yaml b/helm/oncall/tests/telegram_env_test.yaml index 7f954568..4c7c7101 100644 --- a/helm/oncall/tests/telegram_env_test.yaml +++ b/helm/oncall/tests/telegram_env_test.yaml @@ -52,4 +52,3 @@ tests: secretKeyRef: name: some-secret key: token - diff --git a/helm/oncall/tests/tolerations_deployments_test.yaml b/helm/oncall/tests/tolerations_deployments_test.yaml index a3eb3381..54e5af36 100644 --- a/helm/oncall/tests/tolerations_deployments_test.yaml +++ b/helm/oncall/tests/tolerations_deployments_test.yaml @@ -9,7 +9,7 @@ tests: - it: tolerations={} -> should set tolerations null asserts: - notExists: - path: spec.template.spec.tolerations + path: spec.template.spec.tolerations - it: tolerations -> should use custom tolerations set: diff --git a/helm/oncall/tests/topology_deployments_test.yaml b/helm/oncall/tests/topology_deployments_test.yaml index a19f4159..3c04d279 100644 --- a/helm/oncall/tests/topology_deployments_test.yaml +++ b/helm/oncall/tests/topology_deployments_test.yaml @@ -8,26 +8,26 @@ tests: - it: topologySpreadConstraints=[] -> should exclude topologySpreadConstraints asserts: - notExists: - path: spec.template.spec.topologySpreadConstraints + path: spec.template.spec.topologySpreadConstraints - it: topologySpreadConstraints -> should use custom topologySpreadConstraints set: engine: topologySpreadConstraints: - - labelSelector: - matchLabels: - app.kubernetes.io/component: engine - maxSkew: 1 - topologyKey: topology.kubernetes.io/zone - whenUnsatisfiable: DoNotSchedule + - labelSelector: + matchLabels: + app.kubernetes.io/component: engine + maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: DoNotSchedule celery: topologySpreadConstraints: - - labelSelector: - matchLabels: - app.kubernetes.io/component: engine - maxSkew: 1 - topologyKey: topology.kubernetes.io/zone - whenUnsatisfiable: DoNotSchedule + - labelSelector: + matchLabels: + app.kubernetes.io/component: engine + maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: DoNotSchedule asserts: - matchSnapshot: path: spec.template.spec.topologySpreadConstraints diff --git a/helm/oncall/tests/uwsgi_env_test.yaml b/helm/oncall/tests/uwsgi_env_test.yaml index 3ed3bbb0..24c9a5e7 100644 --- a/helm/oncall/tests/uwsgi_env_test.yaml +++ b/helm/oncall/tests/uwsgi_env_test.yaml @@ -45,6 +45,3 @@ tests: path: spec.template.spec.containers[0].env content: name: UWSGI_LISTEN - - - diff --git a/helm/oncall/tests/wait_for_db_test.yaml b/helm/oncall/tests/wait_for_db_test.yaml index 9a8bdf8e..5f725e1c 100644 --- a/helm/oncall/tests/wait_for_db_test.yaml +++ b/helm/oncall/tests/wait_for_db_test.yaml @@ -14,8 +14,8 @@ tests: cpu: 100m memory: 128Mi requests: - cpu: 100m - memory: 128Mi + cpu: 100m + memory: 128Mi asserts: - contains: path: spec.template.spec.initContainers @@ -39,8 +39,8 @@ tests: cpu: 100m memory: 128Mi requests: - cpu: 100m - memory: 128Mi + cpu: 100m + memory: 128Mi asserts: - contains: path: spec.template.spec.initContainers @@ -54,4 +54,3 @@ tests: value: postgresql - matchSnapshot: path: spec.template.spec.initContainers -