From 51cb16c5612968d0f5f865ce13d938f48e21ca99 Mon Sep 17 00:00:00 2001 From: Rob Holland Date: Tue, 10 Dec 2024 17:22:59 +0000 Subject: [PATCH] Unit tests for PR 450 (#611) * Add unit tests for #450. --- .../templates/admintools-deployment.yaml | 2 +- charts/temporal/templates/server-job.yaml | 21 ++++++------- .../tests/admintools_deployment_test.yaml | 31 +++++++++++++++++++ .../tests/server_deployment_test.yaml | 14 +++++++++ charts/temporal/tests/server_job_test.yaml | 31 +++++++++++++++++++ 5 files changed, 87 insertions(+), 12 deletions(-) create mode 100644 charts/temporal/tests/admintools_deployment_test.yaml create mode 100644 charts/temporal/tests/server_job_test.yaml diff --git a/charts/temporal/templates/admintools-deployment.yaml b/charts/temporal/templates/admintools-deployment.yaml index 1082986c..5dfcbea7 100644 --- a/charts/temporal/templates/admintools-deployment.yaml +++ b/charts/temporal/templates/admintools-deployment.yaml @@ -24,7 +24,7 @@ spec: {{ include "temporal.serviceAccount" $ }} {{- if $.Values.admintools.additionalInitContainers }} initContainers: - {{- toYaml $.Values.admintools.additionalInitContainers | nindent 8}} + {{- toYaml $.Values.admintools.additionalInitContainers | nindent 8 }} {{- end }} containers: - name: admin-tools diff --git a/charts/temporal/templates/server-job.yaml b/charts/temporal/templates/server-job.yaml index e1aec9c1..3894bc0a 100644 --- a/charts/temporal/templates/server-job.yaml +++ b/charts/temporal/templates/server-job.yaml @@ -24,6 +24,9 @@ spec: {{ include "temporal.serviceAccount" $ }} restartPolicy: OnFailure initContainers: + {{- if $.Values.admintools.additionalInitContainers }} + {{- toYaml $.Values.admintools.additionalInitContainers | nindent 8 }} + {{- end }} {{- if $.Values.cassandra.enabled }} - name: check-cassandra-service image: busybox @@ -56,7 +59,7 @@ spec: {{- end }} env: {{- include "temporal.admintools-env" (list $ $store) | nindent 12 }} - {{- with $.Values.server.additionalVolumeMounts }} + {{- with $.Values.admintools.additionalVolumeMounts }} volumeMounts: {{- toYaml . | nindent 12 }} {{- end }} @@ -83,7 +86,7 @@ spec: {{- end }} env: {{- include "temporal.admintools-env" (list $ $store) | nindent 12 }} - {{- with $.Values.server.additionalVolumeMounts }} + {{- with $.Values.admintools.additionalVolumeMounts }} volumeMounts: {{- toYaml . | nindent 12 }} {{- end }} @@ -118,7 +121,7 @@ spec: {{- end }} env: {{- include "temporal.admintools-env" (list $ $store) | nindent 12 }} - {{- with $.Values.server.additionalVolumeMounts }} + {{- with $.Values.admintools.additionalVolumeMounts }} volumeMounts: {{- toYaml . | nindent 12 }} {{- end }} @@ -143,7 +146,7 @@ spec: env: - name: TEMPORAL_ADDRESS value: "{{ include "temporal.fullname" $ }}-frontend.{{ $.Release.Namespace }}.svc:{{ $.Values.server.frontend.service.port }}" - {{- with $.Values.server.additionalVolumeMounts }} + {{- with $.Values.admintools.additionalVolumeMounts }} volumeMounts: {{- toYaml . | nindent 12 }} {{- end }} @@ -178,19 +181,15 @@ spec: imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} - {{- with $.Values.server.nodeSelector }} + {{- with $.Values.admintools.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} - {{- with $.Values.server.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with $.Values.server.tolerations }} + {{- with $.Values.admintools.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} - {{- with $.Values.server.additionalVolumes }} + {{- with $.Values.admintools.additionalVolumes }} volumes: {{- toYaml . | nindent 8 }} {{- end }} diff --git a/charts/temporal/tests/admintools_deployment_test.yaml b/charts/temporal/tests/admintools_deployment_test.yaml new file mode 100644 index 00000000..2c3336e3 --- /dev/null +++ b/charts/temporal/tests/admintools_deployment_test.yaml @@ -0,0 +1,31 @@ +suite: test admintools deployment +templates: + - admintools-deployment.yaml +tests: + - it: includes additional init containers + set: + admintools: + additionalInitContainers: + - name: my-init-container + asserts: + - equal: + path: spec.template.spec.initContainers[0].name + value: my-init-container + - it: includes additional volumes + set: + admintools: + additionalVolumes: + - name: my-volume + asserts: + - equal: + path: spec.template.spec.volumes[0].name + value: my-volume + - it: includes additional volume mounts + set: + admintools: + additionalVolumeMounts: + - name: my-volume + asserts: + - equal: + path: spec.template.spec.containers[0].volumeMounts[0].name + value: my-volume \ No newline at end of file diff --git a/charts/temporal/tests/server_deployment_test.yaml b/charts/temporal/tests/server_deployment_test.yaml index 3c4d5557..51e7b0cf 100644 --- a/charts/temporal/tests/server_deployment_test.yaml +++ b/charts/temporal/tests/server_deployment_test.yaml @@ -52,3 +52,17 @@ tests: - equal: path: spec.template.spec.containers[0].resources.requests.cpu value: 200m + - it: includes additional init containers + template: templates/server-deployment.yaml + documentSelector: + path: .kind + value: Deployment + matchMany: true + set: + server: + additionalInitContainers: + - name: my-init-container + asserts: + - equal: + path: spec.template.spec.initContainers[0].name + value: my-init-container \ No newline at end of file diff --git a/charts/temporal/tests/server_job_test.yaml b/charts/temporal/tests/server_job_test.yaml new file mode 100644 index 00000000..abf0f57f --- /dev/null +++ b/charts/temporal/tests/server_job_test.yaml @@ -0,0 +1,31 @@ +suite: test server job +templates: + - server-job.yaml +tests: + - it: includes additional init containers + set: + admintools: + additionalInitContainers: + - name: my-init-container + asserts: + - equal: + path: spec.template.spec.initContainers[0].name + value: my-init-container + - it: includes additional volumes + set: + admintools: + additionalVolumes: + - name: my-volume + asserts: + - equal: + path: spec.template.spec.volumes[0].name + value: my-volume + - it: includes additional volume mounts + set: + admintools: + additionalVolumeMounts: + - name: my-volume + asserts: + - equal: + path: spec.template.spec.initContainers[*].volumeMounts[0].name + value: my-volume \ No newline at end of file