From 6fab29fc40704253b2639f25b52012f3b26cf1e0 Mon Sep 17 00:00:00 2001 From: OZG-Cloud Team <noreply@ozg-sh.de> Date: Thu, 11 Jan 2024 20:30:03 +0100 Subject: [PATCH] OZG-3328 use new helm unittest framework --- run_helm_test.sh | 2 +- .../helm/deployment_defaults_labels_test.yaml | 8 ++++---- src/test/helm/image-pull-secret-test.yaml | 2 +- src/test/helm/ingress_test.yaml | 11 ++++++----- src/test/helm/service_monitor_test.yaml | 8 ++++---- src/test/helm/service_test.yaml | 16 ++++++++-------- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/run_helm_test.sh b/run_helm_test.sh index 5c2ac8a3..76ae9ac8 100755 --- a/run_helm_test.sh +++ b/run_helm_test.sh @@ -4,4 +4,4 @@ set -e helm template ./src/main/helm/ -f src/test/helm-linter-values.yaml helm lint -f src/test/helm-linter-values.yaml ./src/main/helm/ -cd src/main/helm && helm unittest --helm3 -f '../../test/helm/*.yaml' -v '../../test/unit-values.yaml' . \ No newline at end of file +cd src/main/helm && helm unittest -f '../../test/helm/*.yaml' -v '../../test/unit-values.yaml' . \ No newline at end of file diff --git a/src/test/helm/deployment_defaults_labels_test.yaml b/src/test/helm/deployment_defaults_labels_test.yaml index 0b91b242..d6952edf 100644 --- a/src/test/helm/deployment_defaults_labels_test.yaml +++ b/src/test/helm/deployment_defaults_labels_test.yaml @@ -34,14 +34,14 @@ tests: - it: check default labels asserts: - equal: - path: metadata.labels.[app.kubernetes.io/instance] + path: metadata.labels["app.kubernetes.io/instance"] value: afm-adapter - equal: - path: metadata.labels.[app.kubernetes.io/name] + path: metadata.labels["app.kubernetes.io/name"] value: intelliform-adapter - equal: - path: metadata.labels.[app.kubernetes.io/part-of] + path: metadata.labels["app.kubernetes.io/part-of"] value: ozgcloud - equal: - path: metadata.labels.[app.kubernetes.io/namespace] + path: metadata.labels["app.kubernetes.io/namespace"] value: sh-helm-test diff --git a/src/test/helm/image-pull-secret-test.yaml b/src/test/helm/image-pull-secret-test.yaml index 604b71ec..7a218d64 100644 --- a/src/test/helm/image-pull-secret-test.yaml +++ b/src/test/helm/image-pull-secret-test.yaml @@ -47,7 +47,7 @@ tests: path: metadata.namespace value: helm-test - isNotEmpty: - path: data.[.dockerconfigjson] + path: data[".dockerconfigjson"] - it: should not create image pull secret set: diff --git a/src/test/helm/ingress_test.yaml b/src/test/helm/ingress_test.yaml index 7561bb30..e5086079 100644 --- a/src/test/helm/ingress_test.yaml +++ b/src/test/helm/ingress_test.yaml @@ -52,8 +52,9 @@ tests: value: intelliform-adapter - it: should match service path asserts: - - isEmpty: + - equal: path: spec.rules[0].http.paths[0].path + value: '' - it: should match service pathType asserts: - equal: @@ -106,7 +107,7 @@ tests: - it: should use letsencrypt-prod cluster-issuer as default asserts: - equal: - path: metadata.annotations.[cert-manager.io/cluster-issuer] + path: metadata.annotations["cert-manager.io/cluster-issuer"] value: letsencrypt-prod - it: should use letsencrypt-staging cluster-issuer if use_staging_cert is true @@ -114,7 +115,7 @@ tests: ingress.use_staging_cert: true asserts: - equal: - path: metadata.annotations.[cert-manager.io/cluster-issuer] + path: metadata.annotations["cert-manager.io/cluster-issuer"] value: letsencrypt-staging - it: should use letsencrypt-prod cluster-issuer if use_staging_cert is false @@ -122,10 +123,10 @@ tests: ingress.use_staging_cert: false asserts: - equal: - path: metadata.annotations.[cert-manager.io/cluster-issuer] + path: metadata.annotations["cert-manager.io/cluster-issuer"] value: letsencrypt-prod - it: should set proxy body size to 42m asserts: - equal: - path: metadata.annotations.[nginx.ingress.kubernetes.io/proxy-body-size] + path: metadata.annotations["nginx.ingress.kubernetes.io/proxy-body-size"] value: 42m \ No newline at end of file diff --git a/src/test/helm/service_monitor_test.yaml b/src/test/helm/service_monitor_test.yaml index e20b9319..55ebac30 100644 --- a/src/test/helm/service_monitor_test.yaml +++ b/src/test/helm/service_monitor_test.yaml @@ -34,7 +34,7 @@ tests: - isKind: of: ServiceMonitor - equal: - path: metadata.labels.[component] + path: metadata.labels["component"] value: afm-adapter-service-monitor - it: should have the metrics endpoint configured by default set: @@ -64,13 +64,13 @@ tests: - it: selector should contain the component label with the value afm-adapter-service asserts: - equal: - path: spec.selector.matchLabels.[component] + path: spec.selector.matchLabels["component"] value: afm-adapter-service - it: selector should contain helm recommended labels name and namespace asserts: - equal: - path: spec.selector.matchLabels.[app.kubernetes.io/name] + path: spec.selector.matchLabels["app.kubernetes.io/name"] value: afm-adapter - equal: - path: spec.selector.matchLabels.[app.kubernetes.io/namespace] + path: spec.selector.matchLabels["app.kubernetes.io/namespace"] value: sh-helm-test diff --git a/src/test/helm/service_test.yaml b/src/test/helm/service_test.yaml index f9680d60..90040184 100644 --- a/src/test/helm/service_test.yaml +++ b/src/test/helm/service_test.yaml @@ -34,7 +34,7 @@ tests: - isKind: of: Service - equal: - path: metadata.labels.[component] + path: metadata.labels["component"] value: afm-adapter-service - it: should be of type ClusterIP asserts: @@ -50,8 +50,8 @@ tests: port: 8080 protocol: TCP targetPort: 8080 - count: 1 - any: true + count: 1 + any: true - it: ports should contain the metrics port asserts: - contains: @@ -60,19 +60,19 @@ tests: name: metrics port: 8081 protocol: TCP - count: 1 - any: true + count: 1 + any: true - it: selector should contain the component label with the value afm-adapter asserts: - equal: - path: spec.selector.[component] + path: spec.selector["component"] value: afm-adapter - it: selector should contain helm recommended labels name and namespace asserts: - equal: - path: spec.selector.[app.kubernetes.io/name] + path: spec.selector["app.kubernetes.io/name"] value: afm-adapter - equal: - path: spec.selector.[app.kubernetes.io/namespace] + path: spec.selector["app.kubernetes.io/namespace"] value: sh-helm-test \ No newline at end of file -- GitLab