From eecf827877d397be57cc02be656af432206496b2 Mon Sep 17 00:00:00 2001 From: Gergely Brautigam <182850+Skarlso@users.noreply.github.com> Date: Tue, 13 Aug 2024 09:30:33 +0200 Subject: [PATCH] adding some helm tests and snapshost Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com> --- .github/workflows/tests.yaml | 2 + Makefile | 6 ++ .../templates/tests/test-connection.yaml | 15 ----- .../__snapshot__/deployment_test.yaml.snap | 60 +++++++++++++++++++ .../tests/deployment_test.yaml | 9 +++ 5 files changed, 77 insertions(+), 15 deletions(-) delete mode 100644 deploy/charts/bitwarden-sdk-server/templates/tests/test-connection.yaml create mode 100644 deploy/charts/bitwarden-sdk-server/tests/__snapshot__/deployment_test.yaml.snap create mode 100644 deploy/charts/bitwarden-sdk-server/tests/deployment_test.yaml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 11401a1..7e0496b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -38,3 +38,5 @@ jobs: run: make lint - name: Run tests run: make test-ci + - name: Run helm test + run: make helm-test diff --git a/Makefile b/Makefile index 4dcac07..2e3427e 100644 --- a/Makefile +++ b/Makefile @@ -68,6 +68,12 @@ test-ci: ## Test the project prime-test-cluster: mkcert ./hack/prime_test_cluster.sh +helm.test: + @helm unittest --file tests/*.yaml --file 'tests/**/*.yaml' deploy/charts/bitwarden-sdk-server/ + +helm.test.update: + @helm unittest -u --file tests/*.yaml --file 'tests/**/*.yaml' deploy/charts/bitwarden-sdk-server/ + ##@ Docker IMG ?= ghcr.io/external-secrets/bitwarden-sdk-server diff --git a/deploy/charts/bitwarden-sdk-server/templates/tests/test-connection.yaml b/deploy/charts/bitwarden-sdk-server/templates/tests/test-connection.yaml deleted file mode 100644 index 9f5ca59..0000000 --- a/deploy/charts/bitwarden-sdk-server/templates/tests/test-connection.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "bitwarden-sdk-server.fullname" . }}-test-connection" - labels: - {{- include "bitwarden-sdk-server.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": test -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "bitwarden-sdk-server.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never diff --git a/deploy/charts/bitwarden-sdk-server/tests/__snapshot__/deployment_test.yaml.snap b/deploy/charts/bitwarden-sdk-server/tests/__snapshot__/deployment_test.yaml.snap new file mode 100644 index 0000000..2fbcdb1 --- /dev/null +++ b/deploy/charts/bitwarden-sdk-server/tests/__snapshot__/deployment_test.yaml.snap @@ -0,0 +1,60 @@ +deployment should match snapshot: + 1: | + apiVersion: apps/v1 + kind: Deployment + metadata: + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: bitwarden-sdk-server + app.kubernetes.io/version: 1.16.0 + helm.sh/chart: bitwarden-sdk-server-0.1.0 + name: bitwarden-sdk-server + spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/name: bitwarden-sdk-server + template: + metadata: + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/name: bitwarden-sdk-server + spec: + containers: + - image: ghcr.io/external-secrets/bitwarden-sdk-server:v0.8.0 + imagePullPolicy: IfNotPresent + livenessProbe: + httpGet: + path: /live + port: http + scheme: HTTPS + name: bitwarden-sdk-server + ports: + - containerPort: 9998 + name: http + protocol: TCP + readinessProbe: + httpGet: + path: /ready + port: http + scheme: HTTPS + resources: {} + securityContext: {} + volumeMounts: + - mountPath: /certs + name: bitwarden-tls-certs + securityContext: {} + serviceAccountName: bitwarden-sdk-server + volumes: + - name: bitwarden-tls-certs + secret: + items: + - key: tls.crt + path: cert.pem + - key: tls.key + path: key.pem + - key: ca.crt + path: ca.pem + secretName: bitwarden-tls-certs diff --git a/deploy/charts/bitwarden-sdk-server/tests/deployment_test.yaml b/deploy/charts/bitwarden-sdk-server/tests/deployment_test.yaml new file mode 100644 index 0000000..bb4e2f4 --- /dev/null +++ b/deploy/charts/bitwarden-sdk-server/tests/deployment_test.yaml @@ -0,0 +1,9 @@ +suite: test deployment +templates: + - deployment.yaml +tests: + - it: deployment should match snapshot + set: + image.tag: v0.8.0 + asserts: + - matchSnapshot: {}