diff --git a/Jenkinsfile b/Jenkinsfile index 9bb110e4afb5ce6d635a114f7830aa44d82a9536..89a513ae03d2827c8f7802a336d9bb6fce4085fa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -134,11 +134,9 @@ pipeline { FAILED_STAGE=env.STAGE_NAME HELM_CHART_VERSION = generateHelmChartVersion() - dir('src/main/helm') { - sh "helm lint -f ../../test/helm-linter-values.yaml" - - sh "helm unittest --helm3 -f '../../test/helm/*.yaml' -v '../../test/unit-values.yaml' ." + sh "./run_helm_test.sh" + dir('src/main/helm') { sh "helm package --version=${HELM_CHART_VERSION} ." deployHelmChart("Intelliform-Adapter", HELM_CHART_VERSION) @@ -152,12 +150,12 @@ pipeline { script { FAILED_STAGE=env.STAGE_NAME HELM_CHART_VERSION = generateHelmChartVersion() + + dir('xta-adapter') { + sh "./run_helm_test.sh" + } dir('xta-adapter/src/main/helm') { - sh "helm lint -f test-values.yaml" - - sh "helm unittest --helm3 -f '../../test/helm/*.yaml' -v '../../test/helm/values/unit-values.yaml' ." - sh "helm package --version=${HELM_CHART_VERSION} ." deployHelmChart("xta-adapter", HELM_CHART_VERSION) diff --git a/run_helm_test.sh b/run_helm_test.sh index 5c2ac8a359d9b3be43e39c05eddf49e36d5f2a2d..76ae9ac809e2a17d7c58020c0cff75be781f1e48 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 0b91b2423345ae8cb001fb2b602a55bd76703bf9..d6952edf6d1fb42b2ab2dcc11321b73d35c7e2d5 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 c95545170d0e4dd01fce0aab3a1c8953e3e20b5f..71e2149189f71dab73ffe321033ae29dc4bb4f65 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 7561bb305275f8ca3e90dc3a317c762bae8dd995..e5086079b97d4b11763d648d70352412d4e8d7ac 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 e20b931986f88f3d9c21a322109738238ef31b5f..55ebac3068844aafb2c632b1ab528b7cefe9cefe 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 f9680d60e2a5a8b75f9f2ab35274f58d2e0808ca..9004018482d301c6e942d4cc0112de534105a38e 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 diff --git a/xta-adapter/run_helm_test.sh b/xta-adapter/run_helm_test.sh index 9e10b8f0eafbab2eac176bd51e453caedabec7fa..8cfc42013cc858b0d2f5afc2c43b12eb56b68bab 100755 --- a/xta-adapter/run_helm_test.sh +++ b/xta-adapter/run_helm_test.sh @@ -4,4 +4,4 @@ set -e helm template ./src/main/helm/ -f src/main/helm/test-values.yaml helm lint -f src/test/helm/values/unit-values.yaml ./src/main/helm/ -cd src/main/helm && helm unittest --helm3 -f '../../test/helm/*.yaml' -v '../../test/helm/values/unit-values.yaml' . \ No newline at end of file +cd src/main/helm && helm unittest -f '../../test/helm/*.yaml' -v '../../test/helm/values/unit-values.yaml' . \ No newline at end of file diff --git a/xta-adapter/src/test/helm/image_pull_secret_test.yaml b/xta-adapter/src/test/helm/image_pull_secret_test.yaml index 80bffcc068842596343a15aeaa1eff0d52930584..1db60649f5340ec1071f476f0cefb7e8c9344f07 100644 --- a/xta-adapter/src/test/helm/image_pull_secret_test.yaml +++ b/xta-adapter/src/test/helm/image_pull_secret_test.yaml @@ -49,7 +49,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/xta-adapter/src/test/helm/xta-root-ca-secret-test.yaml b/xta-adapter/src/test/helm/xta-root-ca-secret-test.yaml index 3ca7b4a14f4fc1572956d7ad5768c029b486903c..c3861ba54d4cdbf807cfb5780090080d1290371e 100644 --- a/xta-adapter/src/test/helm/xta-root-ca-secret-test.yaml +++ b/xta-adapter/src/test/helm/xta-root-ca-secret-test.yaml @@ -44,6 +44,6 @@ tests: path: metadata.namespace value: helm-test - equal: - path: data.[ca.crt] + path: data["ca.crt"] value: Z2VoZWltCg== diff --git a/xta-adapter/src/test/helm/xta_adapter_cronjob_dummy_probes_test.yaml b/xta-adapter/src/test/helm/xta_adapter_cronjob_dummy_probes_test.yaml index e34455f65790222cf1b174fd0f21b92a4a62418e..0a3ef9a964538609c475ec585b624d12892fc984 100644 --- a/xta-adapter/src/test/helm/xta_adapter_cronjob_dummy_probes_test.yaml +++ b/xta-adapter/src/test/helm/xta_adapter_cronjob_dummy_probes_test.yaml @@ -32,17 +32,17 @@ tests: - it: check dummy livenessProbe default disabled template: xta_adapter_cronjob.yaml asserts: - - isEmpty: + - notExists: path: spec.jobTemplate.spec.template.spec.containers[0].livenessProbe - it: check dummy startupProbe default disabled template: xta_adapter_cronjob.yaml asserts: - - isEmpty: + - notExists: path: spec.jobTemplate.spec.template.spec.containers[0].startupProbe - it: check dummy readynessProbe default disabled template: xta_adapter_cronjob.yaml asserts: - - isEmpty: + - notExists: path: spec.jobTemplate.spec.template.spec.containers[0].readinessProbe - it: check dummy livenessProbe disabled @@ -50,21 +50,21 @@ tests: set: dummyProbesEnabled: false asserts: - - isEmpty: + - notExists: path: spec.jobTemplate.spec.template.spec.containers[0].livenessProbe - it: check dummy startupProbe disabled template: xta_adapter_cronjob.yaml set: dummyProbesEnabled: false asserts: - - isEmpty: + - notExists: path: spec.jobTemplate.spec.template.spec.containers[0].startupProbe - it: check dummy readynessProbe disabled template: xta_adapter_cronjob.yaml set: dummyProbesEnabled: false asserts: - - isEmpty: + - notExists: path: spec.jobTemplate.spec.template.spec.containers[0].readinessProbe