From ecbe7e5d9765c7336914801001444905d8f84529 Mon Sep 17 00:00:00 2001 From: Peter Motzko Date: Tue, 4 Jul 2023 13:04:49 +0200 Subject: [PATCH] feat(helm): add tests for dev stage and put tests in subfolder for each stage --- .../deployment_test.yaml} | 11 ++- .../service_account_test.yaml} | 0 .../service_test.yaml} | 0 .../tests/dev/deployment_test.yaml | 34 +++++++++ .../tests/dev/ingress_test.yaml | 73 +++++++++++++++++++ .../tests/dev/secret_test.yaml | 56 ++++++++++++++ 6 files changed, 173 insertions(+), 1 deletion(-) rename charts/managed-identity-wallet/tests/{default_deployment_test.yaml => default/deployment_test.yaml} (92%) rename charts/managed-identity-wallet/tests/{default_service_account_test.yaml => default/service_account_test.yaml} (100%) rename charts/managed-identity-wallet/tests/{default_service_test.yaml => default/service_test.yaml} (100%) create mode 100644 charts/managed-identity-wallet/tests/dev/deployment_test.yaml create mode 100644 charts/managed-identity-wallet/tests/dev/ingress_test.yaml create mode 100644 charts/managed-identity-wallet/tests/dev/secret_test.yaml diff --git a/charts/managed-identity-wallet/tests/default_deployment_test.yaml b/charts/managed-identity-wallet/tests/default/deployment_test.yaml similarity index 92% rename from charts/managed-identity-wallet/tests/default_deployment_test.yaml rename to charts/managed-identity-wallet/tests/default/deployment_test.yaml index b6b8a2efe..3ce741602 100644 --- a/charts/managed-identity-wallet/tests/default_deployment_test.yaml +++ b/charts/managed-identity-wallet/tests/default/deployment_test.yaml @@ -94,4 +94,13 @@ tests: privileged: false runAsGroup: 11111 runAsNonRoot: true - runAsUser: 11111 \ No newline at end of file + runAsUser: 11111 + + - it: should have environment variables set + template: templates/deployment.yaml + asserts: + - isNotEmpty: + path: spec.template.spec.containers[0].env + - lengthEqual: + path: spec.template.spec.containers[0].env + count: 1 \ No newline at end of file diff --git a/charts/managed-identity-wallet/tests/default_service_account_test.yaml b/charts/managed-identity-wallet/tests/default/service_account_test.yaml similarity index 100% rename from charts/managed-identity-wallet/tests/default_service_account_test.yaml rename to charts/managed-identity-wallet/tests/default/service_account_test.yaml diff --git a/charts/managed-identity-wallet/tests/default_service_test.yaml b/charts/managed-identity-wallet/tests/default/service_test.yaml similarity index 100% rename from charts/managed-identity-wallet/tests/default_service_test.yaml rename to charts/managed-identity-wallet/tests/default/service_test.yaml diff --git a/charts/managed-identity-wallet/tests/dev/deployment_test.yaml b/charts/managed-identity-wallet/tests/dev/deployment_test.yaml new file mode 100644 index 000000000..1a6626461 --- /dev/null +++ b/charts/managed-identity-wallet/tests/dev/deployment_test.yaml @@ -0,0 +1,34 @@ +# /******************************************************************************** +# * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation +# * +# * See the NOTICE file(s) distributed with this work for additional +# * information regarding copyright ownership. +# * +# * This program and the accompanying materials are made available under the +# * terms of the Apache License, Version 2.0 which is available at +# * https://www.apache.org/licenses/LICENSE-2.0. +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# * License for the specific language governing permissions and limitations +# * under the License. +# * +# * SPDX-License-Identifier: Apache-2.0 +# ********************************************************************************/ + +suite: test dev deployment +chart: + version: 9.9.9+test + appVersion: 9.9.9 +values: + - ../../values-dev.yaml +tests: + - it: should have environment variables set + template: templates/deployment.yaml + asserts: + - isNotEmpty: + path: spec.template.spec.containers[0].env + - lengthEqual: + path: spec.template.spec.containers[0].env + count: 11 \ No newline at end of file diff --git a/charts/managed-identity-wallet/tests/dev/ingress_test.yaml b/charts/managed-identity-wallet/tests/dev/ingress_test.yaml new file mode 100644 index 000000000..4e8013f8e --- /dev/null +++ b/charts/managed-identity-wallet/tests/dev/ingress_test.yaml @@ -0,0 +1,73 @@ +# /******************************************************************************** +# * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation +# * +# * See the NOTICE file(s) distributed with this work for additional +# * information regarding copyright ownership. +# * +# * This program and the accompanying materials are made available under the +# * terms of the Apache License, Version 2.0 which is available at +# * https://www.apache.org/licenses/LICENSE-2.0. +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# * License for the specific language governing permissions and limitations +# * under the License. +# * +# * SPDX-License-Identifier: Apache-2.0 +# ********************************************************************************/ + +suite: test dev ingress +chart: + version: 9.9.9+test + appVersion: 9.9.9 +values: + - ../../values-dev.yaml +tests: + - it: should have correct metadata + template: templates/ingress.yaml + asserts: + - hasDocuments: + count: 1 + - containsDocument: + kind: Ingress + apiVersion: networking.k8s.io/v1 + name: RELEASE-NAME-managed-identity-wallet + - isSubset: + path: metadata.labels + content: + helm.sh/chart: managed-identity-wallet-9.9.9_test + app.kubernetes.io/name: managed-identity-wallet + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/version: "9.9.9" + app.kubernetes.io/managed-by: Helm + + - it: must have rules set + template: templates/ingress.yaml + asserts: + - isNotEmpty: + path: spec.rules + - lengthEqual: + path: spec.rules + count: 1 + - isNotEmpty: + path: spec.rules[0].host + - lengthEqual: + path: spec.rules[0].http.paths + count: 1 + - isNotEmpty: + path: spec.rules[0].http.paths[0].path + + - it: must have tls set + template: templates/ingress.yaml + asserts: + - isNotEmpty: + path: spec.tls + - lengthEqual: + path: spec.tls + count: 1 + - isNotEmpty: + path: spec.tls[0].hosts + - lengthEqual: + path: spec.tls[0].hosts[0] + count: 1 \ No newline at end of file diff --git a/charts/managed-identity-wallet/tests/dev/secret_test.yaml b/charts/managed-identity-wallet/tests/dev/secret_test.yaml new file mode 100644 index 000000000..63e4aefac --- /dev/null +++ b/charts/managed-identity-wallet/tests/dev/secret_test.yaml @@ -0,0 +1,56 @@ +# /******************************************************************************** +# * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation +# * +# * See the NOTICE file(s) distributed with this work for additional +# * information regarding copyright ownership. +# * +# * This program and the accompanying materials are made available under the +# * terms of the Apache License, Version 2.0 which is available at +# * https://www.apache.org/licenses/LICENSE-2.0. +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# * License for the specific language governing permissions and limitations +# * under the License. +# * +# * SPDX-License-Identifier: Apache-2.0 +# ********************************************************************************/ + +suite: test dev secret +chart: + version: 9.9.9+test + appVersion: 9.9.9 +values: + - ../../values-dev.yaml +tests: + - it: should have correct metadata + template: templates/secret.yaml + asserts: + - hasDocuments: + count: 1 + - containsDocument: + kind: Secret + apiVersion: v1 + name: RELEASE-NAME-managed-identity-wallet + - isSubset: + path: metadata.labels + content: + helm.sh/chart: managed-identity-wallet-9.9.9_test + app.kubernetes.io/name: managed-identity-wallet + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/version: "9.9.9" + app.kubernetes.io/managed-by: Helm + + - it: must have type set to Opaque + template: templates/secret.yaml + asserts: + - equal: + path: type + value: Opaque + + - it: must have data set + template: templates/secret.yaml + asserts: + - isNotEmpty: + path: data \ No newline at end of file