diff --git a/src/test/helm/configmap_bindings_type_test.yaml b/src/test/helm/configmap_bindings_type_test.yaml index c9f2232b3ebfcfdddfcd0c4ff4d38190dd56da60..3848f75f77083e4560045d942ffe7ee9b1f27ae3 100644 --- a/src/test/helm/configmap_bindings_type_test.yaml +++ b/src/test/helm/configmap_bindings_type_test.yaml @@ -22,13 +22,23 @@ suite: configmap_bindings_type release: name: administration + namespace: sh-helm-test templates: - templates/configmap_bindings_type.yaml -set: - Release.Namespace: "administration" + tests: - it: validate configmap values asserts: + - isKind: + of: ConfigMap + - isAPIVersion: + of: v1 + - equal: + path: metadata.name + value: administration-bindings-type + - equal: + path: metadata.namespace + value: sh-helm-test - equal: path: data.type value: "ca-certificates" \ 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 new file mode 100644 index 0000000000000000000000000000000000000000..b01cb297e470542fe1c8603c5eb4826776c78cd7 --- /dev/null +++ b/src/test/helm/deployment_defaults_labels_test.yaml @@ -0,0 +1,68 @@ +# +# Copyright (C) 2024 Das Land Schleswig-Holstein vertreten durch den +# Ministerpräsidenten des Landes Schleswig-Holstein +# Staatskanzlei +# Abteilung Digitalisierung und zentrales IT-Management der Landesregierung +# +# Lizenziert unter der EUPL, Version 1.2 oder - sobald +# diese von der Europäischen Kommission genehmigt wurden - +# Folgeversionen der EUPL ("Lizenz"); +# Sie dürfen dieses Werk ausschließlich gemäß +# dieser Lizenz nutzen. +# Eine Kopie der Lizenz finden Sie hier: +# +# https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 +# +# Sofern nicht durch anwendbare Rechtsvorschriften +# gefordert oder in schriftlicher Form vereinbart, wird +# die unter der Lizenz verbreitete Software "so wie sie +# ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN - +# ausdrücklich oder stillschweigend - verbreitet. +# Die sprachspezifischen Genehmigungen und Beschränkungen +# unter der Lizenz sind dem Lizenztext zu entnehmen. +# + +suite: test deployment default labels +release: + name: administration + namespace: sh-helm-test +templates: + - templates/deployment.yaml +set: + ozgcloud: + bundesland: sh + bezeichner: helm + sso: + serverUrl: https://sso.company.local + +tests: + - it: check metadata.labels + asserts: + - equal: + path: metadata.labels + value: + app.kubernetes.io/instance: administration + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: administration + app.kubernetes.io/namespace: sh-helm-test + helm.sh/chart: administration-0.0.0-MANAGED-BY-JENKINS + - it: should set spec.selector.matchLabels + asserts: + - equal: + path: spec.selector.matchLabels + value: + app.kubernetes.io/name: administration + app.kubernetes.io/namespace: sh-helm-test + + + - it: should have correct deyploment spec.template.metadata.labels + asserts: + - equal: + path: spec.template.metadata.labels + value: + app.kubernetes.io/instance: administration + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: administration + app.kubernetes.io/namespace: sh-helm-test + component: administration + helm.sh/chart: administration-0.0.0-MANAGED-BY-JENKINS \ No newline at end of file diff --git a/src/test/helm/deployment_defaults_sso_test.yaml b/src/test/helm/deployment_defaults_sso_test.yaml index 3af4ab3385e69bae001433ba9cf8b0df3795ce9b..907a5923d7abfc578daa3fe7f424cb8ca402e6b9 100644 --- a/src/test/helm/deployment_defaults_sso_test.yaml +++ b/src/test/helm/deployment_defaults_sso_test.yaml @@ -22,7 +22,7 @@ # unter der Lizenz sind dem Lizenztext zu entnehmen. # -suite: test deployment +suite: test deployment sso release: name: administration namespace: sh-helm-test @@ -57,29 +57,12 @@ tests: name: ozgcloud_oauth2_auth-server-url value: https://sso.company.local - - it: check realm with long namespace - set: - ozgcloud: - bezeichner: eins-zwei-drei - environment: dev - bundesland: sh - asserts: - - isKind: - of: Deployment - - contains: - path: spec.template.spec.containers[0].env - content: - name: ozgcloud_oauth2_realm - value: sh-eins-zwei-drei-dev - - it: check different client name set: sso: keycloak_client: client_name: different-client asserts: - - isKind: - of: Deployment - contains: path: spec.template.spec.containers[0].env content: diff --git a/src/test/helm/deployment_resources_test.yaml b/src/test/helm/deployment_resources_test.yaml index d37443f22191266721ac95118b716692cebfeeb0..888f63ff2751f0b9b4e0fa731cd840ebd200f234 100644 --- a/src/test/helm/deployment_resources_test.yaml +++ b/src/test/helm/deployment_resources_test.yaml @@ -41,3 +41,7 @@ tests: - equal: path: spec.template.spec.containers[0].resources value: { "test": 1 } + - it: should not generate resources when values not set + asserts: + - isEmpty: + path: spec.template.spec.containers[0].resources \ No newline at end of file diff --git a/src/test/helm/deployment_spring_profile_test.yaml b/src/test/helm/deployment_spring_profile_test.yaml index f99d9b9893a31a013693ccf7b6402603f8bc390f..1a9326cb74e56a9bb55aa6049f40f02f3aeddb75 100644 --- a/src/test/helm/deployment_spring_profile_test.yaml +++ b/src/test/helm/deployment_spring_profile_test.yaml @@ -39,8 +39,6 @@ tests: set: env.overrideSpringProfiles: oc,dev,ea asserts: - - isKind: - of: Deployment - contains: path: spec.template.spec.containers[0].env content: @@ -48,8 +46,6 @@ tests: value: oc,dev,ea - it: should generate the spring profiles asserts: - - isKind: - of: Deployment - contains: path: spec.template.spec.containers[0].env content: diff --git a/src/test/helm/deployment_test.yaml b/src/test/helm/deployment_test.yaml index 6bd31db1bcadaa990cef70e13f04845e42e6f9e7..5d6ec1cf5e89b6cdad40cfdaed15fc1b1186834a 100644 --- a/src/test/helm/deployment_test.yaml +++ b/src/test/helm/deployment_test.yaml @@ -39,6 +39,8 @@ tests: asserts: - isKind: of: Deployment + - isAPIVersion: + of: apps/v1 - equal: path: metadata.name value: "administration" @@ -77,12 +79,6 @@ tests: value: "RollingUpdate" - it: should have correct template configuration asserts: - - equal: - path: spec.template.metadata.labels["app.kubernetes.io/instance"] - value: "administration" - - equal: - path: spec.template.metadata.labels.component - value: "administration" - equal: path: spec.template.spec.topologySpreadConstraints[0].maxSkew value: 1 diff --git a/src/test/helm/network_policy_test.yaml b/src/test/helm/network_policy_test.yaml index 48a5811fb8c081d3c32fbf9389e6a23fce3e80d7..5ce2a529903425d837453e884304f612e9e24c0b 100644 --- a/src/test/helm/network_policy_test.yaml +++ b/src/test/helm/network_policy_test.yaml @@ -126,4 +126,4 @@ tests: dnsServerNamespace: test-dns-server-namespace asserts: - hasDocuments: - count: 1 + count: 1 \ No newline at end of file diff --git a/src/test/helm/service_test.yaml b/src/test/helm/service_test.yaml index da7cbbbdb325a212fbe9149549d3672867efdb46..c4c6ef1568f96617828dd144a523299e1269a4d2 100644 --- a/src/test/helm/service_test.yaml +++ b/src/test/helm/service_test.yaml @@ -37,14 +37,6 @@ tests: apiVersion: v1 name: administration namespace: helm-test - - it: should have valid metadata values - asserts: - - equal: - path: metadata.labels["helm.sh/chart"] - value: administration-0.0.0-helm-test-version - - equal: - path: metadata.labels.component - value: administration-service - it: should be of type ClusterIP asserts: - equal: @@ -79,4 +71,15 @@ tests: asserts: - equal: path: spec.selector.component - value: administration \ No newline at end of file + value: administration + - it: should contain default lables and component lables + asserts: + - equal: + path: metadata.labels + value: + app.kubernetes.io/instance: administration + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: administration + app.kubernetes.io/namespace: helm-test + component: administration-service + helm.sh/chart: administration-0.0.0-helm-test-version \ No newline at end of file