From 8e76f324076ca2371453c112d947a4dbb37b5f54 Mon Sep 17 00:00:00 2001 From: Tin Lam Date: Mon, 7 Aug 2017 01:26:28 -0500 Subject: [PATCH] Add barbican helm test This patch set adds basic barbican test using the OpenStack Client. This patch set also addressed an issue where the href contains a duplicate version in the path, e.g. http://URL:xxxx/v1/v1/secrets in secret path. Change-Id: Ie66d00d5a0b02721ba41e6bf4b5e784fb49adce8 --- barbican/templates/bin/_barbican-test.sh.tpl | 37 ++++++++++++++ barbican/templates/configmap-bin.yaml | 2 + barbican/templates/configmap-etc.yaml | 3 +- barbican/templates/pod-test.yaml | 52 ++++++++++++++++++++ barbican/values.yaml | 4 ++ tools/gate/basic_launch.sh | 1 + tools/gate/funcs/helm.sh | 9 +++- 7 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 barbican/templates/bin/_barbican-test.sh.tpl create mode 100644 barbican/templates/pod-test.yaml diff --git a/barbican/templates/bin/_barbican-test.sh.tpl b/barbican/templates/bin/_barbican-test.sh.tpl new file mode 100644 index 0000000000..689bdf385e --- /dev/null +++ b/barbican/templates/bin/_barbican-test.sh.tpl @@ -0,0 +1,37 @@ +#!/bin/bash + +{{/* +Copyright 2017 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://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. +*/}} + +set -ex + +openstack secret list + +# Come up with a random payload +PAYLOAD=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1` +echo $PAYLOAD + +SECRET=`openstack secret store --name mysecret --payload ${PAYLOAD} | awk ' /href/ {print $5}'` + +openstack secret list + +openstack secret get $SECRET + +openstack secret get --payload $SECRET + +openstack secret delete $SECRET + +openstack secret list diff --git a/barbican/templates/configmap-bin.yaml b/barbican/templates/configmap-bin.yaml index ef24c56383..f4f5117dd1 100644 --- a/barbican/templates/configmap-bin.yaml +++ b/barbican/templates/configmap-bin.yaml @@ -26,6 +26,8 @@ data: bootstrap.sh: |+ {{ tuple "bin/_bootstrap.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} {{- end }} + barbican-test.sh: | +{{ tuple "bin/_barbican-test.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} db-init.py: | {{- include "helm-toolkit.scripts.db_init" . | indent 4 }} db-sync.sh: | diff --git a/barbican/templates/configmap-etc.yaml b/barbican/templates/configmap-etc.yaml index 6399ef4d2c..484cdc2af3 100644 --- a/barbican/templates/configmap-etc.yaml +++ b/barbican/templates/configmap-etc.yaml @@ -58,8 +58,9 @@ limitations under the License. {{- tuple "oslo_messaging" "internal" "user" "amqp" . | include "helm-toolkit.endpoints.authenticated_endpoint_uri_lookup" | set .Values.conf.barbican.default.oslo.messaging "transport_url" | quote | trunc 0 -}} {{- end -}} +{{- $barbicanPath := index .Values "endpoints" "key-manager" "path" "default" }} {{- if empty .Values.conf.barbican.default.barbican.common.config.host_href -}} -{{- tuple "key-manager" "public" "api" . | include "helm-toolkit.endpoints.keystone_endpoint_uri_lookup" | set .Values.conf.barbican.default.barbican.common.config "host_href" | quote | trunc 0 -}} +{{- tuple "key-manager" "public" "api" . | include "helm-toolkit.endpoints.keystone_endpoint_uri_lookup" | trimSuffix $barbicanPath | set .Values.conf.barbican.default.barbican.common.config "host_href" | quote | trunc 0 -}} {{- end -}} --- diff --git a/barbican/templates/pod-test.yaml b/barbican/templates/pod-test.yaml new file mode 100644 index 0000000000..64f64b192f --- /dev/null +++ b/barbican/templates/pod-test.yaml @@ -0,0 +1,52 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://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. +*/}} + +{{- $envAll := . }} +{{- $dependencies := .Values.dependencies.tests }} +{{- $mounts_barbican_tests := .Values.pod.mounts.barbican_tests.barbican_tests }} +{{- $mounts_barbican_tests_init := .Values.pod.mounts.barbican_tests.init_container }} +--- +apiVersion: v1 +kind: Pod +metadata: + name: "{{.Release.Name}}-test" + annotations: + "helm.sh/hook": test-success +spec: + restartPolicy: Never + initContainers: +{{ tuple $envAll $dependencies $mounts_barbican_tests_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} + containers: + - name: {{.Release.Name}}-barbican-test + image: {{ .Values.images.test }} + env: +{{- with $env := dict "ksUserSecret" .Values.secrets.identity.admin }} +{{- include "helm-toolkit.snippets.keystone_openrc_env_vars" $env | indent 8 }} +{{- end }} + command: + - /tmp/barbican-test.sh + volumeMounts: + - name: barbican-bin + mountPath: /tmp/barbican-test.sh + subPath: barbican-test.sh + readOnly: true +{{- if $mounts_barbican_tests.volumeMounts }}{{ toYaml $mounts_barbican_tests.volumeMounts | indent 8 }}{{ end }} + volumes: + - name: barbican-bin + configMap: + name: barbican-bin + defaultMode: 0555 +{{- if $mounts_barbican_tests.volumes }}{{ toYaml $mounts_barbican_tests.volumes | indent 4 }}{{ end }} diff --git a/barbican/values.yaml b/barbican/values.yaml index 2f05181c45..9cef050b8a 100644 --- a/barbican/values.yaml +++ b/barbican/values.yaml @@ -19,6 +19,7 @@ release_group: null images: bootstrap: docker.io/kolla/ubuntu-source-barbican-api:3.0.3 dep_check: docker.io/kolla/ubuntu-source-kubernetes-entrypoint:4.0.0 + test: docker.io/kolla/ubuntu-source-barbican-api:3.0.3 db_init: docker.io/kolla/ubuntu-source-barbican-api:3.0.3 db_sync: docker.io/kolla/ubuntu-source-barbican-api:3.0.3 ks_user: docker.io/kolla/ubuntu-source-kolla-toolbox:3.0.3 @@ -41,6 +42,9 @@ pod: barbican_bootstrap: init_container: null barbican_bootstrap: + barbican_tests: + init_container: null + barbican_tests: replicas: api: 1 lifecycle: diff --git a/tools/gate/basic_launch.sh b/tools/gate/basic_launch.sh index dcc18fa080..e151177684 100755 --- a/tools/gate/basic_launch.sh +++ b/tools/gate/basic_launch.sh @@ -126,4 +126,5 @@ if [ "x$INTEGRATION" == "xmulti" ]; then helm_test_deployment cinder ${SERVICE_TEST_TIMEOUT} helm_test_deployment neutron ${SERVICE_TEST_TIMEOUT} helm_test_deployment nova ${SERVICE_TEST_TIMEOUT} + helm_test_deployment barbican ${SERVICE_TEST_TIMEOUT} norally fi diff --git a/tools/gate/funcs/helm.sh b/tools/gate/funcs/helm.sh index 1b67cd7944..411b13c5ba 100755 --- a/tools/gate/funcs/helm.sh +++ b/tools/gate/funcs/helm.sh @@ -84,13 +84,18 @@ function helm_test_deployment { TIMEOUT=$2 fi + NAME="${DEPLOYMENT}-rally-test" + if [ "$#" -gt 2 ]; then + NAME="${DEPLOYMENT}-test" + fi + # Get the namespace of the chart via the Helm release NAMESPACE=$(helm status ${DEPLOYMENT} | awk '/^NAMESPACE/ { print $NF }') helm test --timeout ${TIMEOUT} ${DEPLOYMENT} mkdir -p ${LOGS_DIR}/rally - kubectl logs -n ${NAMESPACE} ${DEPLOYMENT}-rally-test > ${LOGS_DIR}/rally/${DEPLOYMENT} - kubectl delete -n ${NAMESPACE} pod ${DEPLOYMENT}-rally-test + kubectl logs -n ${NAMESPACE} ${NAME} > ${LOGS_DIR}/rally/${DEPLOYMENT} + kubectl delete -n ${NAMESPACE} pod ${NAME} } function helm_plugin_template_install {