diff --git a/.github/workflows/unit.yaml b/.github/workflows/unit.yaml index a513583f..9d678667 100644 --- a/.github/workflows/unit.yaml +++ b/.github/workflows/unit.yaml @@ -35,7 +35,7 @@ jobs: # We should periodically check to see if another fork has taken over maintenance, # as the de-facto "best" fork has changed several times over the years. run: | - helm plugin install https://github.com/quintush/helm-unittest --version v0.2.11 + helm plugin install https://github.com/helm-unittest/helm-unittest.git --version v0.4.4 - name: Install chart dependencies run: | @@ -44,4 +44,4 @@ jobs: - name: Run helm-unittest # by default looks for tests/*_test.yaml run: | - helm unittest --color --helm3 -f 'tests/unit/*_test.yaml' . + helm unittest --color -f 'tests/unit/*_test.yaml' . diff --git a/CHANGELOG.md b/CHANGELOG.md index 919af036..c73a35e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## Development +* Updated our tests/unit to support newer versions of `unittests` - for now bumping to `v0.4.4` as `v0.5.0` has a bug that impacts us (see helm-unittest/helm-unittest#329), but testing around the bug shows `v0.5.x` should also "just work" (#414) (by @jk464) ## v1.1.0 * Fix syntax with ensure-packs-volumes-are-writable job (#403, #411) (by @skiedude) diff --git a/templates/deployments.yaml b/templates/deployments.yaml index 7cbceded..b5ea91c3 100644 --- a/templates/deployments.yaml +++ b/templates/deployments.yaml @@ -38,8 +38,8 @@ spec: {{- toYaml .Values.st2auth.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} initContainers: @@ -177,8 +177,8 @@ spec: {{- toYaml .Values.st2api.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} {{- if .Values.st2.packs.images }} @@ -316,8 +316,8 @@ spec: {{- toYaml .Values.st2stream.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} initContainers: @@ -426,8 +426,8 @@ spec: {{- toYaml .Values.st2web.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} terminationGracePeriodSeconds: {{ .Values.st2web.terminationGracePeriodSeconds | default 30 }} @@ -565,8 +565,8 @@ spec: {{- toYaml .Values.st2rulesengine.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} initContainers: @@ -683,8 +683,8 @@ spec: {{- toYaml .Values.st2timersengine.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} initContainers: @@ -791,8 +791,8 @@ spec: {{- end }} spec: terminationGracePeriodSeconds: {{ .Values.st2workflowengine.terminationGracePeriodSeconds | default 300 }} - imagePullSecrets: {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} initContainers: @@ -910,8 +910,8 @@ spec: {{- toYaml .Values.st2scheduler.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} initContainers: @@ -1027,8 +1027,8 @@ spec: {{- toYaml .Values.st2notifier.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} initContainers: @@ -1173,8 +1173,8 @@ spec: {{- toYaml $sensor.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if $.Values.image.pullSecret }} + imagePullSecrets: - name: {{ $.Values.image.pullSecret }} {{- end }} {{- if $.Values.st2.packs.images }} @@ -1354,8 +1354,8 @@ spec: hostAliases: {{- toYaml .Values.st2actionrunner.hostAliases | nindent 8 }} {{- end }} - imagePullSecrets: {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} {{- if .Values.st2.packs.images }} @@ -1501,8 +1501,8 @@ spec: {{- toYaml .Values.st2garbagecollector.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} initContainers: @@ -1615,11 +1615,11 @@ spec: {{- toYaml .Values.st2client.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if .Values.st2.packs.images }} {{- include "stackstorm-ha.packs-pullSecrets" . | nindent 6 }} {{- end }} {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} initContainers: diff --git a/templates/jobs.yaml b/templates/jobs.yaml index 592936fb..dfbca877 100644 --- a/templates/jobs.yaml +++ b/templates/jobs.yaml @@ -25,8 +25,8 @@ spec: {{- toYaml .Values.jobs.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} containers: @@ -127,8 +127,8 @@ spec: {{- toYaml .Values.jobs.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} initContainers: @@ -266,8 +266,8 @@ spec: {{- toYaml .Values.jobs.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} initContainers: @@ -398,8 +398,8 @@ spec: {{- toYaml .Values.jobs.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if .Values.image.pullSecret }} + imagePullSecrets: - name: {{ .Values.image.pullSecret }} {{- end }} {{- if $.Values.st2.packs.images -}} @@ -512,8 +512,8 @@ spec: {{- toYaml $.Values.jobs.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if $.Values.image.pullSecret }} + imagePullSecrets: - name: {{ $.Values.image.pullSecret }} {{- end }} initContainers: [] @@ -633,8 +633,8 @@ spec: {{- toYaml $.Values.jobs.annotations | nindent 8 }} {{- end }} spec: - imagePullSecrets: {{- if $.Values.image.pullSecret }} + imagePullSecrets: - name: {{ $.Values.image.pullSecret }} {{- end }} {{- if $.Values.st2.packs.images -}} diff --git a/tests/README.md b/tests/README.md index cf0a78cc..b4366533 100644 --- a/tests/README.md +++ b/tests/README.md @@ -4,14 +4,14 @@ This directory contains Helm chart unit and integration tests (under `tests/unit ## Unit tests -Unit tests (`tests/unit/*_test.yaml`) use [`helm-unittest`](https://github.com/quintush/helm-unittest). +Unit tests (`tests/unit/*_test.yaml`) use [`helm-unittest`](https://github.com/helm-unittest/helm-unittest). `helm-unittest` uses a yaml-based test file to ensure that the templates generate expected features. For example, they can ensure that custom annotations are applied consistently to all of the deployments. Unit tests do not require a running kubernetes cluster. Before running unit tests, install the `helm-unittest` plugin and ensure you have sub-charts installed: ``` -helm plugin install https://github.com/quintush/helm-unittest +$ helm plugin install https://github.com/helm-unittest/helm-unittest.git helm dependency update ``` @@ -22,7 +22,7 @@ helm unittest --helm3 -f 'tests/unit/*_test.yaml' . > Note! If you need to add unit tests, file names should follow this pattern: `tests/unit/name_your_test.yaml` -See https://github.com/quintush/helm-unittest/blob/master/DOCUMENT.md for details on writing unit tests. +See https://github.com/helm-unittest/helm-unittest/blob/master/DOCUMENT.md for details on writing unit tests. ## Integration tests diff --git a/tests/unit/custom_annotations_test.yaml b/tests/unit/custom_annotations_test.yaml index 33724347..81147051 100644 --- a/tests/unit/custom_annotations_test.yaml +++ b/tests/unit/custom_annotations_test.yaml @@ -31,7 +31,7 @@ tests: foo: bar answer: "42" asserts: &annotations_asserts - - isNotNull: + - exists: path: metadata.annotations - equal: path: metadata.annotations.foo @@ -125,7 +125,7 @@ tests: # st2client, st2chatops # deployment annotations - - isNotNull: + - exists: path: metadata.annotations - equal: path: metadata.annotations.foo @@ -135,7 +135,7 @@ tests: value: "42" # pod annotations - - isNotNull: + - exists: path: spec.template.metadata.annotations - equal: path: spec.template.metadata.annotations.foo @@ -188,7 +188,7 @@ tests: # extra_hooks job # job annotations - - isNotNull: + - exists: path: metadata.annotations - equal: path: metadata.annotations.foo @@ -198,7 +198,7 @@ tests: value: "42" # pod annotations - - isNotNull: + - exists: path: spec.template.metadata.annotations - equal: path: spec.template.metadata.annotations.foo diff --git a/tests/unit/dns_test.yaml b/tests/unit/dns_test.yaml index 3d831ff5..d5e379e6 100644 --- a/tests/unit/dns_test.yaml +++ b/tests/unit/dns_test.yaml @@ -51,9 +51,9 @@ tests: hook_weight: -5 command: ["st2", "run", "--tail", "custom_pack.warn_about_upgrade"] asserts: - - isNull: + - notExists: path: spec.template.spec.dnsPolicy - - isNull: + - notExists: path: spec.template.spec.dnsConfig - it: Deployments and Jobs accept custom dnsPolicy or dnsConfig diff --git a/tests/unit/env_test.yaml b/tests/unit/env_test.yaml index 9cc7badf..72297390 100644 --- a/tests/unit/env_test.yaml +++ b/tests/unit/env_test.yaml @@ -34,32 +34,32 @@ tests: - name: ST2CLIENT value: "1" documentIndex: 12 - - isNull: &is_null_env + - notExists: &is_null_env path: spec.template.spec.containers[0].env documentIndex: 0 - - isNull: *is_null_env + - notExists: *is_null_env documentIndex: 1 - - isNull: *is_null_env + - notExists: *is_null_env documentIndex: 2 - - isNull: *is_null_env + - notExists: *is_null_env documentIndex: 3 - - isNull: *is_null_env + - notExists: *is_null_env documentIndex: 4 - - isNull: *is_null_env + - notExists: *is_null_env documentIndex: 5 - - isNull: *is_null_env + - notExists: *is_null_env documentIndex: 6 - - isNull: *is_null_env + - notExists: *is_null_env documentIndex: 7 - - isNull: *is_null_env + - notExists: *is_null_env documentIndex: 8 - - isNull: *is_null_env + - notExists: *is_null_env documentIndex: 9 - - isNull: *is_null_env + - notExists: *is_null_env documentIndex: 10 - - isNull: *is_null_env + - notExists: *is_null_env documentIndex: 11 - - isNull: *is_null_env + - notExists: *is_null_env documentIndex: 13 - it: Jobs default to no env @@ -76,7 +76,7 @@ tests: asserts: - hasDocuments: count: 5 - - isNull: *is_null_env + - notExists: *is_null_env - it: Deployments accept custom env template: deployments.yaml @@ -177,10 +177,10 @@ tests: - contains: *contains_st2_urls documentIndex: 2 - - isNull: &is_null_envFrom + - notExists: &is_null_envFrom path: spec.template.spec.containers[0].envFrom documentIndex: 0 - - isNull: *is_null_envFrom + - notExists: *is_null_envFrom documentIndex: 3 - it: Deployments support envFromSecrets (st2actionrunner, st2sensorcontainer, and st2client) diff --git a/tests/unit/image_entrypoint_test.yaml b/tests/unit/image_entrypoint_test.yaml index 496b2b4e..e3c6d871 100644 --- a/tests/unit/image_entrypoint_test.yaml +++ b/tests/unit/image_entrypoint_test.yaml @@ -46,10 +46,10 @@ tests: # document indexes: 3, 13 # all remaining deployments do use image.entrypoint - - isNull: &exists_command + - notExists: &exists_command path: spec.template.spec.containers[0].command documentIndex: 3 # st2web - - isNull: *exists_command + - notExists: *exists_command documentIndex: 13 # st2chatops - equal: &eq_custom_entrypoint_0 @@ -119,9 +119,9 @@ tests: - hasDocuments: count: 14 - - isNull: *exists_command + - notExists: *exists_command documentIndex: 3 # st2web - - isNull: *exists_command + - notExists: *exists_command documentIndex: 13 # st2chatops - notEqual: *eq_custom_entrypoint_0 @@ -187,9 +187,9 @@ tests: - hasDocuments: count: 14 - - isNull: *exists_command + - notExists: *exists_command documentIndex: 3 # st2web - - isNull: *exists_command + - notExists: *exists_command documentIndex: 13 # st2chatops - notEqual: *eq_custom_entrypoint_0 diff --git a/tests/unit/image_pull_test.yaml b/tests/unit/image_pull_test.yaml index e739be59..1ee0aec0 100644 --- a/tests/unit/image_pull_test.yaml +++ b/tests/unit/image_pull_test.yaml @@ -67,7 +67,7 @@ tests: hook_weight: -5 command: ["st2", "run", "--tail", "custom_pack.warn_about_upgrade"] asserts: - - isNull: + - notExists: path: spec.template.spec.imagePullSecrets - equal: path: spec.template.spec.containers[0].imagePullPolicy @@ -202,7 +202,7 @@ tests: serviceAccount: create: true asserts: - - isNull: + - notExists: path: imagePullSecrets - it: ServiceAccount accepts custom imagePullSecret diff --git a/tests/unit/labels_test.yaml b/tests/unit/labels_test.yaml index e8857917..57afd975 100644 --- a/tests/unit/labels_test.yaml +++ b/tests/unit/labels_test.yaml @@ -54,58 +54,58 @@ tests: # metdata.labels.[app.kubernetes.io/name] # spec.selector.matchLabels.[app.kubernetes.io/name] # spec.template.metadata.labels.[app.kubernetes.io/name] - # So, we use isNotNull instead. + # So, we use exists instead. # see: https://github.com/quintush/helm-unittest/issues/122 - - isNotNull: - path: metadata.labels.[app.kubernetes.io/name] - - isNotNull: - path: spec.selector.matchLabels.[app.kubernetes.io/name] - - isNotNull: - path: spec.template.metadata.labels.[app.kubernetes.io/name] + - exists: + path: metadata.labels["app.kubernetes.io/name"] + - exists: + path: spec.selector.matchLabels["app.kubernetes.io/name"] + - exists: + path: spec.template.metadata.labels["app.kubernetes.io/name"] - equal: &metadata_labels_instance - path: metadata.labels.[app.kubernetes.io/instance] + path: metadata.labels["app.kubernetes.io/instance"] value: some-release-name - equal: - path: spec.selector.matchLabels.[app.kubernetes.io/instance] + path: spec.selector.matchLabels["app.kubernetes.io/instance"] value: some-release-name - equal: &spec_template_metadata_labels_instance - path: spec.template.metadata.labels.[app.kubernetes.io/instance] + path: spec.template.metadata.labels["app.kubernetes.io/instance"] value: some-release-name - matchRegex: ®ex_metadata_labels_component_backend_or_frontend - path: metadata.labels.[app.kubernetes.io/component] + path: metadata.labels["app.kubernetes.io/component"] pattern: ^(backend|frontend)$ - matchRegex: ®ex_spec_template_metadata_labels_component_backend_or_frontend - path: spec.template.metadata.labels.[app.kubernetes.io/component] + path: spec.template.metadata.labels["app.kubernetes.io/component"] pattern: ^(backend|frontend)$ - equal: &metadata_labels_part_of - path: metadata.labels.[app.kubernetes.io/part-of] + path: metadata.labels["app.kubernetes.io/part-of"] value: stackstorm - equal: &spec_template_metadata_labels_part_of - path: spec.template.metadata.labels.[app.kubernetes.io/part-of] + path: spec.template.metadata.labels["app.kubernetes.io/part-of"] value: stackstorm - equal: &metadata_labels_app_version - path: metadata.labels.[app.kubernetes.io/version] + path: metadata.labels["app.kubernetes.io/version"] value: *appVersion - equal: &spec_template_metadata_labels_app_version - path: spec.template.metadata.labels.[app.kubernetes.io/version] + path: spec.template.metadata.labels["app.kubernetes.io/version"] value: *appVersion - equal: &metadata_labels_chart - path: metadata.labels.[helm.sh/chart] + path: metadata.labels["helm.sh/chart"] value: stackstorm-ha-1.0.999 - equal: &spec_template_metadata_labels_chart - path: spec.template.metadata.labels.[helm.sh/chart] + path: spec.template.metadata.labels["helm.sh/chart"] value: stackstorm-ha-1.0.999 - equal: &metadata_labels_managed_by - path: metadata.labels.[app.kubernetes.io/managed-by] + path: metadata.labels["app.kubernetes.io/managed-by"] value: Helm - equal: &spec_template_metadata_labels_managed_by - path: spec.template.metadata.labels.[app.kubernetes.io/managed-by] + path: spec.template.metadata.labels["app.kubernetes.io/managed-by"] value: Helm - it: Jobs+Pods have requried labels @@ -154,19 +154,19 @@ tests: # like deployments each of these should be the same: # metdata.labels.[app.kubernetes.io/name] # spec.template.metadata.labels.[app.kubernetes.io/name] - - isNotNull: - path: metadata.labels.[app.kubernetes.io/name] - - isNotNull: - path: spec.template.metadata.labels.[app.kubernetes.io/name] + - exists: + path: metadata.labels["app.kubernetes.io/name"] + - exists: + path: spec.template.metadata.labels["app.kubernetes.io/name"] - equal: *metadata_labels_instance - equal: *spec_template_metadata_labels_instance - matchRegex: - path: metadata.labels.[app.kubernetes.io/component] + path: metadata.labels["app.kubernetes.io/component"] pattern: ^(backend|tests)$ - matchRegex: - path: spec.template.metadata.labels.[app.kubernetes.io/component] + path: spec.template.metadata.labels["app.kubernetes.io/component"] pattern: ^(backend|tests)$ - equal: *metadata_labels_part_of @@ -192,8 +192,8 @@ tests: count: 5 # st2auth, st2api, st2stream, st2web, st2chatops - - isNotNull: - path: metadata.labels.[app.kubernetes.io/name] + - exists: + path: metadata.labels["app.kubernetes.io/name"] - equal: *metadata_labels_instance - matchRegex: *regex_metadata_labels_component_backend_or_frontend - equal: *metadata_labels_part_of @@ -211,11 +211,11 @@ tests: - hasDocuments: count: 1 - equal: - path: metadata.labels.[app.kubernetes.io/name] + path: metadata.labels["app.kubernetes.io/name"] value: stackstorm-ha - equal: *metadata_labels_instance - equal: &metadata_labels_component_backend - path: metadata.labels.[app.kubernetes.io/component] + path: metadata.labels["app.kubernetes.io/component"] value: backend - equal: *metadata_labels_part_of - equal: *metadata_labels_app_version @@ -231,7 +231,7 @@ tests: foo: bar answer: "42" asserts: - - isNotNull: + - exists: path: metadata.labels - equal: path: metadata.labels.foo @@ -253,11 +253,11 @@ tests: - hasDocuments: count: 1 - equal: - path: metadata.labels.[app.kubernetes.io/name] + path: metadata.labels["app.kubernetes.io/name"] value: ingress - equal: *metadata_labels_instance - equal: - path: metadata.labels.[app.kubernetes.io/component] + path: metadata.labels["app.kubernetes.io/component"] value: frontend - equal: *metadata_labels_part_of - equal: *metadata_labels_app_version @@ -284,7 +284,7 @@ tests: - hasDocuments: count: 1 - equal: &metadata_labels_app_eq_st2 - path: metadata.labels.[app.kubernetes.io/name] + path: metadata.labels["app.kubernetes.io/name"] value: st2 - equal: *metadata_labels_instance - equal: *metadata_labels_component_backend @@ -323,7 +323,7 @@ tests: - hasDocuments: count: 1 - equal: - path: metadata.labels.[app.kubernetes.io/name] + path: metadata.labels["app.kubernetes.io/name"] value: st2chatops - equal: *metadata_labels_instance - equal: *metadata_labels_component_backend @@ -347,11 +347,11 @@ tests: - hasDocuments: count: 1 - equal: - path: metadata.labels.[app.kubernetes.io/name] + path: metadata.labels["app.kubernetes.io/name"] value: st2 # should this be st2web? - equal: *metadata_labels_instance - equal: - path: metadata.labels.[app.kubernetes.io/component] + path: metadata.labels["app.kubernetes.io/component"] value: backend # should this be frontend? - equal: *metadata_labels_part_of - equal: *metadata_labels_app_version diff --git a/tests/unit/placement_test.yaml b/tests/unit/placement_test.yaml index 76ee7d63..6d7726d7 100644 --- a/tests/unit/placement_test.yaml +++ b/tests/unit/placement_test.yaml @@ -65,11 +65,11 @@ tests: hook_weight: -5 command: ["st2", "run", "--tail", "custom_pack.warn_about_upgrade"] asserts: - - isNull: + - notExists: path: spec.template.spec.nodeSelector - - isNull: + - notExists: path: spec.template.spec.tolerations - - isNull: + - notExists: path: spec.template.spec.affinity - it: Deployments and Jobs accept custom placement diff --git a/tests/unit/post_start_script_test.yaml b/tests/unit/post_start_script_test.yaml index 65f51bfd..916fd22c 100644 --- a/tests/unit/post_start_script_test.yaml +++ b/tests/unit/post_start_script_test.yaml @@ -31,10 +31,10 @@ tests: of: ConfigMap - isAPIVersion: of: v1 - - isNotEmpty: - path: data.[post-start.sh] + - isNotNullOrEmpty: + path: data["post-start.sh"] - equal: - path: data.[post-start.sh] + path: data["post-start.sh"] value: | #!/bin/bash mkdir -p /home/yelnats/.ssh @@ -84,10 +84,10 @@ tests: of: ConfigMap - isAPIVersion: of: v1 - - isNotEmpty: - path: data.[post-start.sh] + - isNotNullOrEmpty: + path: data["post-start.sh"] - matchRegex: - path: data.[post-start.sh] + path: data["post-start.sh"] # (?m) = multi-line mode: ^ and $ match begin/end line in addition to begin/end text # (?s) = let . match \n # .*? = any character zero or more times, prefer fewer @@ -106,8 +106,8 @@ tests: # st2actionrunner and st2client do not have checksum annotations # (even though they probably should) - - isNull: &assert_checksum - path: spec.template.metadata.annotations.[checksum/post-start-script] + - notExists: &assert_checksum + path: spec.template.metadata.annotations["checksum/post-start-script"] # only st2actionrunner and st2client have default postStart scripts - equal: &assert_lifecycle @@ -119,30 +119,30 @@ tests: - equal: *assert_lifecycle documentIndex: 12 - - isNull: &assert_null_lifecycle + - notExists: &assert_null_lifecycle path: spec.template.spec.containers[0].lifecycle documentIndex: 0 - - isNull: *assert_null_lifecycle + - notExists: *assert_null_lifecycle documentIndex: 1 - - isNull: *assert_null_lifecycle + - notExists: *assert_null_lifecycle documentIndex: 2 - - isNull: *assert_null_lifecycle + - notExists: *assert_null_lifecycle documentIndex: 3 - - isNull: *assert_null_lifecycle + - notExists: *assert_null_lifecycle documentIndex: 4 - - isNull: *assert_null_lifecycle + - notExists: *assert_null_lifecycle documentIndex: 5 - - isNull: *assert_null_lifecycle + - notExists: *assert_null_lifecycle documentIndex: 6 - - isNull: *assert_null_lifecycle + - notExists: *assert_null_lifecycle documentIndex: 7 - - isNull: *assert_null_lifecycle + - notExists: *assert_null_lifecycle documentIndex: 8 - - isNull: *assert_null_lifecycle + - notExists: *assert_null_lifecycle documentIndex: 9 - - isNull: *assert_null_lifecycle + - notExists: *assert_null_lifecycle documentIndex: 11 - - isNull: *assert_null_lifecycle + - notExists: *assert_null_lifecycle documentIndex: 13 - contains: &assert_volume_mount @@ -177,10 +177,10 @@ tests: documentIndex: 11 # st2web and st2chatops have no volumes (and can be null) - - isEmpty: + - isNullOrEmpty: path: spec.template.spec.containers[0].volumeMounts documentIndex: 3 - - isEmpty: + - isNullOrEmpty: path: spec.template.spec.containers[0].volumeMounts documentIndex: 13 @@ -217,10 +217,10 @@ tests: - notContains: *assert_volume documentIndex: 11 - - isEmpty: + - isNullOrEmpty: path: spec.template.spec.volumes documentIndex: 3 - - isEmpty: + - isNullOrEmpty: path: spec.template.spec.volumes documentIndex: 13 @@ -263,7 +263,7 @@ tests: - hasDocuments: count: 14 - - isNotEmpty: *assert_checksum + - isNotNullOrEmpty: *assert_checksum - equal: *assert_lifecycle - contains: *assert_volume_mount - contains: *assert_volume diff --git a/tests/unit/resources_test.yaml b/tests/unit/resources_test.yaml index 698897a7..55bd1116 100644 --- a/tests/unit/resources_test.yaml +++ b/tests/unit/resources_test.yaml @@ -30,13 +30,13 @@ tests: count: 14 # only st2web defines limits for now - - isNotEmpty: + - isNotNullOrEmpty: path: spec.template.spec.containers[0].resources.limits.memory documentIndex: 3 - - isNotEmpty: + - isNotNullOrEmpty: path: spec.template.spec.containers[0].resources.requests.memory - - isNotEmpty: + - isNotNullOrEmpty: path: spec.template.spec.containers[0].resources.requests.cpu - it: Deployments accept custom resources (except st2client) diff --git a/tests/unit/secrets_test.yaml b/tests/unit/secrets_test.yaml index 9827e01c..04c259e9 100644 --- a/tests/unit/secrets_test.yaml +++ b/tests/unit/secrets_test.yaml @@ -30,7 +30,7 @@ tests: asserts: - hasDocuments: count: 1 - - isNotEmpty: + - isNotNullOrEmpty: path: data.ST2_AUTH_PASSWORD documentIndex: 0 - equal: @@ -124,7 +124,7 @@ tests: asserts: - hasDocuments: count: 1 - - isNotEmpty: + - isNotNullOrEmpty: path: data.datastore_crypto_key documentIndex: 0 diff --git a/tests/unit/security_context_test.yaml b/tests/unit/security_context_test.yaml index 0468d362..4cc83f3b 100644 --- a/tests/unit/security_context_test.yaml +++ b/tests/unit/security_context_test.yaml @@ -74,13 +74,13 @@ tests: asserts: # pod - - isNull: + - notExists: path: spec.template.spec.securityContext # container - - isNull: + - notExists: path: "spec.template.spec.containers[0].securityContext" # path can only select one element, not all initContainers (if present). - #- isNull: + #- notExists: # path: 'spec.template.spec.initContainers[].securityContext' - it: Deployment and Job Pods+Containers use same SecurityContext when defined diff --git a/tests/unit/service_account_test.yaml b/tests/unit/service_account_test.yaml index e2edd984..dcc208a0 100644 --- a/tests/unit/service_account_test.yaml +++ b/tests/unit/service_account_test.yaml @@ -52,7 +52,7 @@ tests: asserts: - hasDocuments: count: 14 - - isNull: + - notExists: path: spec.template.spec.serviceAccountName - it: Deployments can attach ServiceAccount with default name (except st2client) @@ -92,7 +92,7 @@ tests: - hasDocuments: count: 14 # st2client does not allow attaching serviceAccount - - isNull: + - notExists: path: spec.template.spec.serviceAccountName documentIndex: 12 @@ -165,7 +165,7 @@ tests: - hasDocuments: count: 14 # st2client does not allow attaching serviceAccount - - isNull: + - notExists: path: spec.template.spec.serviceAccountName documentIndex: 12 diff --git a/tests/unit/services_test.yaml b/tests/unit/services_test.yaml index cff4a058..f62160c3 100644 --- a/tests/unit/services_test.yaml +++ b/tests/unit/services_test.yaml @@ -12,7 +12,7 @@ tests: asserts: - hasDocuments: count: 4 - - isNull: + - notExists: path: spec.externalName - it: st2web, st2auth, st2api, st2stream should work with externalName if type is ExternalName diff --git a/tests/unit/st2sensors_test.yaml b/tests/unit/st2sensors_test.yaml index 6564be18..f976b6f8 100644 --- a/tests/unit/st2sensors_test.yaml +++ b/tests/unit/st2sensors_test.yaml @@ -37,17 +37,17 @@ tests: documentIndex: *first_sensor_doc - equal: - path: metadata.labels.[app.kubernetes.io/name] + path: metadata.labels["app.kubernetes.io/name"] value: st2sensorcontainer documentIndex: *first_sensor_doc - equal: - path: spec.template.metadata.labels.[app.kubernetes.io/name] + path: spec.template.metadata.labels["app.kubernetes.io/name"] value: st2sensorcontainer documentIndex: *first_sensor_doc - equal: - path: spec.selector.matchLabels.[app.kubernetes.io/name] + path: spec.selector.matchLabels["app.kubernetes.io/name"] value: st2sensorcontainer documentIndex: *first_sensor_doc @@ -129,41 +129,41 @@ tests: documentIndex: *third_sensor_doc - equal: - path: metadata.labels.[app.kubernetes.io/name] + path: metadata.labels["app.kubernetes.io/name"] value: st2sensorcontainer-foo documentIndex: *first_sensor_doc - equal: - path: metadata.labels.[app.kubernetes.io/name] + path: metadata.labels["app.kubernetes.io/name"] value: st2sensorcontainer-bar documentIndex: *second_sensor_doc - equal: - path: metadata.labels.[app.kubernetes.io/name] + path: metadata.labels["app.kubernetes.io/name"] value: st2sensorcontainer-baz documentIndex: *third_sensor_doc - equal: - path: spec.template.metadata.labels.[app.kubernetes.io/name] + path: spec.template.metadata.labels["app.kubernetes.io/name"] value: st2sensorcontainer-foo documentIndex: *first_sensor_doc - equal: - path: spec.template.metadata.labels.[app.kubernetes.io/name] + path: spec.template.metadata.labels["app.kubernetes.io/name"] value: st2sensorcontainer-bar documentIndex: *second_sensor_doc - equal: - path: spec.template.metadata.labels.[app.kubernetes.io/name] + path: spec.template.metadata.labels["app.kubernetes.io/name"] value: st2sensorcontainer-baz documentIndex: *third_sensor_doc - equal: - path: spec.selector.matchLabels.[app.kubernetes.io/name] + path: spec.selector.matchLabels["app.kubernetes.io/name"] value: st2sensorcontainer-foo documentIndex: *first_sensor_doc - equal: - path: spec.selector.matchLabels.[app.kubernetes.io/name] + path: spec.selector.matchLabels["app.kubernetes.io/name"] value: st2sensorcontainer-bar documentIndex: *second_sensor_doc - equal: - path: spec.selector.matchLabels.[app.kubernetes.io/name] + path: spec.selector.matchLabels["app.kubernetes.io/name"] value: st2sensorcontainer-baz documentIndex: *third_sensor_doc @@ -293,41 +293,41 @@ tests: documentIndex: *third_sensor_doc - equal: - path: metadata.labels.[app.kubernetes.io/name] + path: metadata.labels["app.kubernetes.io/name"] value: st2sensorcontainer-0 documentIndex: *first_sensor_doc - equal: - path: metadata.labels.[app.kubernetes.io/name] + path: metadata.labels["app.kubernetes.io/name"] value: st2sensorcontainer-1 documentIndex: *second_sensor_doc - equal: - path: metadata.labels.[app.kubernetes.io/name] + path: metadata.labels["app.kubernetes.io/name"] value: st2sensorcontainer-2 documentIndex: *third_sensor_doc - equal: - path: spec.template.metadata.labels.[app.kubernetes.io/name] + path: spec.template.metadata.labels["app.kubernetes.io/name"] value: st2sensorcontainer-0 documentIndex: *first_sensor_doc - equal: - path: spec.template.metadata.labels.[app.kubernetes.io/name] + path: spec.template.metadata.labels["app.kubernetes.io/name"] value: st2sensorcontainer-1 documentIndex: *second_sensor_doc - equal: - path: spec.template.metadata.labels.[app.kubernetes.io/name] + path: spec.template.metadata.labels["app.kubernetes.io/name"] value: st2sensorcontainer-2 documentIndex: *third_sensor_doc - equal: - path: spec.selector.matchLabels.[app.kubernetes.io/name] + path: spec.selector.matchLabels["app.kubernetes.io/name"] value: st2sensorcontainer-0 documentIndex: *first_sensor_doc - equal: - path: spec.selector.matchLabels.[app.kubernetes.io/name] + path: spec.selector.matchLabels["app.kubernetes.io/name"] value: st2sensorcontainer-1 documentIndex: *second_sensor_doc - equal: - path: spec.selector.matchLabels.[app.kubernetes.io/name] + path: spec.selector.matchLabels["app.kubernetes.io/name"] value: st2sensorcontainer-2 documentIndex: *third_sensor_doc