Skip to content
Snippets Groups Projects
Commit c0297900 authored by OZGCloud's avatar OZGCloud
Browse files

Merge pull request 'OZG-3328-new-helm-unittest-framework' (#96) from...

Merge pull request 'OZG-3328-new-helm-unittest-framework' (#96) from OZG-3328-new-helm-unittest-framework into master

Reviewed-on: https://git.ozg-sh.de/ozgcloud-app/user-manager/pulls/96
parents 1e1f205b 5111ac35
No related branches found
No related tags found
No related merge requests found
Showing
with 154 additions and 45 deletions
...@@ -159,10 +159,9 @@ pipeline { ...@@ -159,10 +159,9 @@ pipeline {
FAILED_STAGE=env.STAGE_NAME FAILED_STAGE=env.STAGE_NAME
HELM_CHART_VERSION = generateHelmChartVersion() HELM_CHART_VERSION = generateHelmChartVersion()
dir('src/main/helm') { sh "./run_helm_test.sh"
sh "helm lint -f ../../test/linter-values.yaml"
sh "helm unittest --helm3 -f '../../test/helm/*.yaml' -v '../../test/unit-values.yaml' ." dir('src/main/helm') {
sh "helm package --version=${HELM_CHART_VERSION} ." sh "helm package --version=${HELM_CHART_VERSION} ."
......
...@@ -5,4 +5,4 @@ set -x ...@@ -5,4 +5,4 @@ set -x
helm template ./src/main/helm/ -f src/test/linter-values.yaml helm template ./src/main/helm/ -f src/test/linter-values.yaml
helm lint -f src/test/linter-values.yaml ./src/main/helm/ helm lint -f src/test/linter-values.yaml ./src/main/helm/
cd src/main/helm && helm unittest --helm3 -f '../../test/helm/*.yaml' -v '../../test/unit-values.yaml' . cd src/main/helm && helm unittest -f '../../test/helm/*.yaml' .
\ No newline at end of file \ No newline at end of file
...@@ -57,7 +57,7 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }} ...@@ -57,7 +57,7 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }}
{{- end -}} {{- end -}}
{{- define "app.ssoServerUrl" -}} {{- define "app.ssoServerUrl" -}}
{{- if contains "https://" .Values.sso.serverUrl -}} {{- if contains "https://" (required "sso.serverUrl must be set" (.Values.sso).serverUrl) -}}
{{- .Values.sso.serverUrl -}} {{- .Values.sso.serverUrl -}}
{{- else -}} {{- else -}}
{{- printf "https://%s" .Values.sso.serverUrl -}} {{- printf "https://%s" .Values.sso.serverUrl -}}
...@@ -99,7 +99,7 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }} ...@@ -99,7 +99,7 @@ app.kubernetes.io/namespace: {{ include "app.namespace" . }}
{{- end -}} {{- end -}}
{{- define "app.alfaAddress" -}} {{- define "app.alfaAddress" -}}
{{ printf "https://%s.%s" (include "app.ozgcloudBezeichner" .) .Values.baseUrl }} {{ printf "https://%s.%s" (include "app.ozgcloudBezeichner" .) (required "baseUrl must be set" .Values.baseUrl) }}
{{- end -}} {{- end -}}
{{- define "app.replaceAllNonAlphanumeric" -}} {{- define "app.replaceAllNonAlphanumeric" -}}
......
...@@ -4,6 +4,11 @@ release: ...@@ -4,6 +4,11 @@ release:
namespace: sh-test-test namespace: sh-test-test
templates: templates:
- templates/api-password-secret.yaml - templates/api-password-secret.yaml
set:
ozgcloud:
keycloak:
api:
password: testPassword
tests: tests:
- it: test api secret kind - it: test api secret kind
asserts: asserts:
...@@ -13,7 +18,7 @@ tests: ...@@ -13,7 +18,7 @@ tests:
asserts: asserts:
- equal: - equal:
path: stringData.password path: stringData.password
value: geheim value: testPassword
- it: should use Keycloak User Operator - it: should use Keycloak User Operator
set: set:
sso: sso:
......
...@@ -27,11 +27,16 @@ release: ...@@ -27,11 +27,16 @@ release:
name: user-manager name: user-manager
templates: templates:
- templates/deployment.yaml - templates/deployment.yaml
set:
ozgcloud:
bundesland: by
bezeichner: helm
environment: dev
sso:
serverUrl: https://sso.test.by.ozg-cloud.local
baseUrl: test.company.local
tests: tests:
- it: validate keycloak configuration values - it: validate keycloak configuration values
template: deployment.yaml
release:
namespace: sh-helm-test
asserts: asserts:
- contains: - contains:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
...@@ -51,17 +56,17 @@ tests: ...@@ -51,17 +56,17 @@ tests:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
content: content:
name: OZGCLOUD_KEYCLOAK_API_REALM name: OZGCLOUD_KEYCLOAK_API_REALM
value: sh-helm-test value: by-helm-dev
- contains: - contains:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
content: content:
name: QUARKUS_OIDC_AUTH_SERVER_URL name: QUARKUS_OIDC_AUTH_SERVER_URL
value: https://sso.test.sh.ozg-cloud.de/realms/sh-helm-test value: https://sso.test.by.ozg-cloud.local/realms/by-helm-dev
- contains: - contains:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
content: content:
name: KEYCLOAK_URL name: KEYCLOAK_URL
value: https://sso.test.sh.ozg-cloud.de value: https://sso.test.by.ozg-cloud.local
- contains: - contains:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
content: content:
...@@ -69,12 +74,10 @@ tests: ...@@ -69,12 +74,10 @@ tests:
value: alfa value: alfa
- it: should set keycloak client name - it: should set keycloak client name
template: deployment.yaml
release:
namespace: sh-helm-test
set: set:
sso: sso:
client_name: alfa client_name: alfa
serverUrl: https://sso.company.local
asserts: asserts:
- contains: - contains:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
...@@ -83,9 +86,6 @@ tests: ...@@ -83,9 +86,6 @@ tests:
value: alfa value: alfa
- it: sso.serverurl with https - it: sso.serverurl with https
template: deployment.yaml
release:
namespace: sh-helm-test
set: set:
sso.serverUrl: https://sso.test.by.ozg-cloud.de sso.serverUrl: https://sso.test.by.ozg-cloud.de
asserts: asserts:
...@@ -93,16 +93,13 @@ tests: ...@@ -93,16 +93,13 @@ tests:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
content: content:
name: QUARKUS_OIDC_AUTH_SERVER_URL name: QUARKUS_OIDC_AUTH_SERVER_URL
value: https://sso.test.by.ozg-cloud.de/realms/sh-helm-test value: https://sso.test.by.ozg-cloud.de/realms/by-helm-dev
- contains: - contains:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
content: content:
name: KEYCLOAK_URL name: KEYCLOAK_URL
value: https://sso.test.by.ozg-cloud.de value: https://sso.test.by.ozg-cloud.de
- it: sso.serverurl without https - it: sso.serverurl without https
template: deployment.yaml
release:
namespace: sh-helm-test
set: set:
sso.serverUrl: sso.test.by.ozg-cloud.de sso.serverUrl: sso.test.by.ozg-cloud.de
asserts: asserts:
...@@ -110,20 +107,19 @@ tests: ...@@ -110,20 +107,19 @@ tests:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
content: content:
name: QUARKUS_OIDC_AUTH_SERVER_URL name: QUARKUS_OIDC_AUTH_SERVER_URL
value: https://sso.test.by.ozg-cloud.de/realms/sh-helm-test value: https://sso.test.by.ozg-cloud.de/realms/by-helm-dev
- contains: - contains:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
content: content:
name: KEYCLOAK_URL name: KEYCLOAK_URL
value: https://sso.test.by.ozg-cloud.de value: https://sso.test.by.ozg-cloud.de
- it: should use Keycloak User Operator - it: should use Keycloak User Operator
template: deployment.yaml
release:
namespace: sh-helm-test
set: set:
sso: sso:
api_user: api_user:
name: -userManager-ApiUser name: -userManager-ApiUser
serverUrl: https://sso.company.local
asserts: asserts:
- contains: - contains:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
......
...@@ -27,6 +27,13 @@ release: ...@@ -27,6 +27,13 @@ release:
name: user-manager name: user-manager
templates: templates:
- templates/deployment.yaml - templates/deployment.yaml
set:
ozgcloud:
bundesland: by
bezeichner: helm
environment: dev
sso.serverUrl: https://sso.company.local
baseUrl: test.company.local
tests: tests:
- it: should reference mongodb connectionString for user-manager - it: should reference mongodb connectionString for user-manager
set: set:
......
...@@ -27,6 +27,13 @@ release: ...@@ -27,6 +27,13 @@ release:
name: user-manager name: user-manager
templates: templates:
- templates/deployment.yaml - templates/deployment.yaml
set:
ozgcloud:
bundesland: by
bezeichner: helm
environment: dev
sso.serverUrl: https://sso.company.local
baseUrl: test.company.local
tests: tests:
- it: test resources for prod environment - it: test resources for prod environment
release: release:
......
...@@ -27,6 +27,13 @@ release: ...@@ -27,6 +27,13 @@ release:
name: user-manager name: user-manager
templates: templates:
- templates/deployment.yaml - templates/deployment.yaml
set:
ozgcloud:
bundesland: by
bezeichner: helm
environment: dev
sso.serverUrl: https://sso.company.local
baseUrl: test.company.local
tests: tests:
- it: validate keycloak configuration values - it: validate keycloak configuration values
template: deployment.yaml template: deployment.yaml
...@@ -37,4 +44,4 @@ tests: ...@@ -37,4 +44,4 @@ tests:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
content: content:
name: OZGCLOUD_USER_MANAGER_URL name: OZGCLOUD_USER_MANAGER_URL
value: https://helm-user-manager.test.sh.ozg-cloud.de value: https://helm-user-manager.test.company.local
\ No newline at end of file \ No newline at end of file
...@@ -28,6 +28,13 @@ release: ...@@ -28,6 +28,13 @@ release:
namespace: sh-helm-test namespace: sh-helm-test
templates: templates:
- templates/deployment.yaml - templates/deployment.yaml
set:
ozgcloud:
bundesland: by
bezeichner: helm
environment: dev
sso.serverUrl: https://sso.company.local
baseUrl: test.company.local
tests: tests:
- it: check default values - it: check default values
asserts: asserts:
......
...@@ -30,39 +30,47 @@ templates: ...@@ -30,39 +30,47 @@ templates:
- templates/deployment.yaml - templates/deployment.yaml
- templates/service.yaml - templates/service.yaml
- templates/service_monitor.yaml - templates/service_monitor.yaml
set:
ozgcloud:
bundesland: by
bezeichner: helm
environment: dev
sso:
serverUrl: https://sso.company.local
baseUrl: test.sh.ozg-cloud.local
tests: tests:
- it: check default labels - it: check default labels
asserts: asserts:
- equal: - equal:
path: metadata.labels.[app.kubernetes.io/instance] path: metadata.labels["app.kubernetes.io/instance"]
value: user-manager value: user-manager
- equal: - equal:
path: metadata.labels.[app.kubernetes.io/name] path: metadata.labels["app.kubernetes.io/name"]
value: user-manager value: user-manager
- equal: - equal:
path: metadata.labels.[app.kubernetes.io/part-of] path: metadata.labels["app.kubernetes.io/part-of"]
value: ozgcloud value: ozgcloud
- equal: - equal:
path: metadata.labels.[app.kubernetes.io/namespace] path: metadata.labels["app.kubernetes.io/namespace"]
value: sh-helm-test value: sh-helm-test
- it: check component label for deployment - it: check component label for deployment
templates: templates:
- templates/deployment.yaml - templates/deployment.yaml
asserts: asserts:
- equal: - equal:
path: spec.template.metadata.labels.[component] path: spec.template.metadata.labels["component"]
value: user-manager value: user-manager
- it: check component label for service - it: check component label for service
templates: templates:
- templates/service.yaml - templates/service.yaml
asserts: asserts:
- equal: - equal:
path: metadata.labels.[component] path: metadata.labels["component"]
value: user-manager-service value: user-manager-service
- it: check component label for service monitor - it: check component label for service monitor
templates: templates:
- templates/service_monitor.yaml - templates/service_monitor.yaml
asserts: asserts:
- equal: - equal:
path: metadata.labels.[component] path: metadata.labels["component"]
value: user-manager-service-monitor value: user-manager-service-monitor
...@@ -25,6 +25,14 @@ ...@@ -25,6 +25,14 @@
suite: test environments suite: test environments
templates: templates:
- templates/deployment.yaml - templates/deployment.yaml
set:
ozgcloud:
bundesland: by
bezeichner: helm
environment: dev
sso:
serverUrl: sso.test.sh.ozg-cloud.de
baseUrl: test.sh.ozg-cloud.de
tests: tests:
- it: check customList - it: check customList
template: deployment.yaml template: deployment.yaml
...@@ -71,7 +79,12 @@ tests: ...@@ -71,7 +79,12 @@ tests:
value: test-database value: test-database
- it: check user sync period set - it: check user sync period set
set: set:
ozgcloud.usersync.period: "6h" ozgcloud:
bundesland: by
bezeichner: helm
environment: dev
usersync:
period: "6h"
asserts: asserts:
- contains: - contains:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
......
...@@ -28,6 +28,14 @@ release: ...@@ -28,6 +28,14 @@ release:
namespace: sh-helm-test namespace: sh-helm-test
templates: templates:
- templates/deployment.yaml - templates/deployment.yaml
set:
ozgcloud:
bundesland: by
bezeichner: helm
environment: dev
sso:
serverUrl: sso.test.sh.ozg-cloud.de
baseUrl: test.sh.ozg-cloud.de
tests: tests:
- it: should not set hostAliases - it: should not set hostAliases
asserts: asserts:
......
...@@ -28,6 +28,14 @@ release: ...@@ -28,6 +28,14 @@ release:
namespace: sh-helm-test namespace: sh-helm-test
templates: templates:
- templates/deployment.yaml - templates/deployment.yaml
set:
ozgcloud:
bundesland: by
bezeichner: helm
environment: dev
sso:
serverUrl: sso.test.sh.ozg-cloud.de
baseUrl: test.sh.ozg-cloud.de
tests: tests:
- it: should use default imagePull secret - it: should use default imagePull secret
asserts: asserts:
......
...@@ -25,10 +25,18 @@ ...@@ -25,10 +25,18 @@
suite: test environments suite: test environments
templates: templates:
- templates/deployment.yaml - templates/deployment.yaml
set:
ozgcloud:
bundesland: by
bezeichner: helm
environment: dev
sso:
serverUrl: sso.test.sh.ozg-cloud.de
baseUrl: test.sh.ozg-cloud.de
tests: tests:
- it: check without truststore - it: check without truststore
asserts: asserts:
- isEmpty: - notExists:
path: spec.template.spec.containers[0].args path: spec.template.spec.containers[0].args
- notContains: - notContains:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
......
...@@ -27,6 +27,14 @@ release: ...@@ -27,6 +27,14 @@ release:
name: user-manager name: user-manager
templates: templates:
- templates/deployment.yaml - templates/deployment.yaml
set:
ozgcloud:
bundesland: by
bezeichner: helm
environment: dev
sso:
serverUrl: sso.test.sh.ozg-cloud.de
baseUrl: test.sh.ozg-cloud.de
tests: tests:
- it: test resources - it: test resources
template: deployment.yaml template: deployment.yaml
......
...@@ -29,6 +29,15 @@ release: ...@@ -29,6 +29,15 @@ release:
templates: templates:
- templates/deployment.yaml - templates/deployment.yaml
- templates/secret_database_quarkus.yaml - templates/secret_database_quarkus.yaml
set:
ozgcloud:
bundesland: by
bezeichner: helm
environment: dev
sso:
serverUrl: sso.test.sh.ozg-cloud.de
baseUrl: test.sh.ozg-cloud.de
tests: tests:
- it: should set the metrics port by default - it: should set the metrics port by default
template: deployment.yaml template: deployment.yaml
......
...@@ -28,6 +28,15 @@ release: ...@@ -28,6 +28,15 @@ release:
namespace: sh-helm-test namespace: sh-helm-test
templates: templates:
- templates/deployment.yaml - templates/deployment.yaml
set:
ozgcloud:
bundesland: by
bezeichner: helm
environment: dev
sso:
serverUrl: sso.test.sh.ozg-cloud.de
baseUrl: test.sh.ozg-cloud.de
tests: tests:
- it: should use service account with default name - it: should use service account with default name
set: set:
......
...@@ -28,10 +28,16 @@ release: ...@@ -28,10 +28,16 @@ release:
namespace: user-manager namespace: user-manager
templates: templates:
- templates/deployment.yaml - templates/deployment.yaml
set:
ozgcloud:
bezeichner: helm
bundesland: by
environment: dev
baseUrl: test.sh.ozg-cloud.de
sso:
serverUrl: sso.test.sh.ozg-cloud.de
tests: tests:
- it: should mount volumes for user-manager root ca - it: should mount volumes for user-manager root ca
set:
ozgcloud.environment: dev
asserts: asserts:
- contains: - contains:
path: spec.template.spec.containers[0].volumeMounts path: spec.template.spec.containers[0].volumeMounts
......
...@@ -48,8 +48,8 @@ tests: ...@@ -48,8 +48,8 @@ tests:
- equal: - equal:
path: metadata.namespace path: metadata.namespace
value: helm-test value: helm-test
- isNotEmpty: - isNotNullOrEmpty:
path: data.[.dockerconfigjson] path: data[".dockerconfigjson"]
- it: should not create image pull secret - it: should not create image pull secret
set: set:
......
...@@ -28,6 +28,10 @@ release: ...@@ -28,6 +28,10 @@ release:
namespace: sh-helm-test namespace: sh-helm-test
templates: templates:
- templates/ingress.yaml - templates/ingress.yaml
set:
baseUrl: test.sh.ozg-cloud.de
ozgcloud:
bezeichner: helm
tests: tests:
- it: should create ingress tls - it: should create ingress tls
asserts: asserts:
...@@ -56,19 +60,19 @@ tests: ...@@ -56,19 +60,19 @@ tests:
- it: should use default letsencrypt-prod cluster-issuer - it: should use default letsencrypt-prod cluster-issuer
asserts: asserts:
- equal: - equal:
path: metadata.annotations.[cert-manager.io/cluster-issuer] path: metadata.annotations["cert-manager.io/cluster-issuer"]
value: letsencrypt-prod value: letsencrypt-prod
- it: should use letsencrypt-staging cluster-issuer - it: should use letsencrypt-staging cluster-issuer
set: set:
ingress.use_staging_cert: true ingress.use_staging_cert: true
asserts: asserts:
- equal: - equal:
path: metadata.annotations.[cert-manager.io/cluster-issuer] path: metadata.annotations["cert-manager.io/cluster-issuer"]
value: letsencrypt-staging value: letsencrypt-staging
- it: should use letsencrypt-prod cluster-issuer - it: should use letsencrypt-prod cluster-issuer
set: set:
ingress.use_staging_cert: false ingress.use_staging_cert: false
asserts: asserts:
- equal: - equal:
path: metadata.annotations.[cert-manager.io/cluster-issuer] path: metadata.annotations["cert-manager.io/cluster-issuer"]
value: letsencrypt-prod value: letsencrypt-prod
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment