From 356fa9e922dbd3380d2b9b92a379a253913b97e1 Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Thu, 3 May 2018 17:28:32 -0500 Subject: [PATCH] Mistral: Add helm test This PS adds helm test functionaility to mistral. Change-Id: I463d16d6e6fcd00afdc23365b58a8c1e1d395388 --- mistral/templates/configmap-bin.yaml | 3 + mistral/templates/configmap-etc.yaml | 6 ++ mistral/templates/pod-rally-test.yaml | 108 ++++++++++++++++++++++ mistral/templates/secret-keystone.yaml | 2 +- mistral/values.yaml | 89 ++++++++++++++++++ tools/deployment/multinode/180-mistral.sh | 3 +- 6 files changed, 209 insertions(+), 2 deletions(-) create mode 100644 mistral/templates/pod-rally-test.yaml diff --git a/mistral/templates/configmap-bin.yaml b/mistral/templates/configmap-bin.yaml index 825a7aabaf..68ce510ef2 100644 --- a/mistral/templates/configmap-bin.yaml +++ b/mistral/templates/configmap-bin.yaml @@ -16,6 +16,7 @@ limitations under the License. {{- if .Values.manifests.configmap_bin }} {{- $envAll := . }} +{{- $rallyTests := .Values.conf.rally_tests }} --- apiVersion: v1 kind: ConfigMap @@ -26,6 +27,8 @@ data: bootstrap.sh: | {{ tuple "bin/_bootstrap.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} {{- end }} + rally-test.sh: | +{{ tuple $rallyTests | include "helm-toolkit.scripts.rally_test" | indent 4 }} db-init.py: | {{- include "helm-toolkit.scripts.db_init" . | indent 4 }} db-sync.sh: | diff --git a/mistral/templates/configmap-etc.yaml b/mistral/templates/configmap-etc.yaml index 8e28303c94..30afc8f284 100644 --- a/mistral/templates/configmap-etc.yaml +++ b/mistral/templates/configmap-etc.yaml @@ -69,8 +69,14 @@ kind: ConfigMap metadata: name: mistral-etc data: + rally_tests.yaml: | +{{ toYaml .Values.conf.rally_tests.tests | indent 4 }} mistral.conf: | {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.mistral | indent 4 }} policy.json: | {{ toJson .Values.conf.policy | indent 4 }} +{{- range $key, $value := $envAll.Values.conf.rally_tests.templates }} + {{ printf "test_template_%d" $key }}: | +{{ $value.template | indent 4 }} +{{- end }} {{- end }} diff --git a/mistral/templates/pod-rally-test.yaml b/mistral/templates/pod-rally-test.yaml new file mode 100644 index 0000000000..7a0085cb44 --- /dev/null +++ b/mistral/templates/pod-rally-test.yaml @@ -0,0 +1,108 @@ +{{/* +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. +*/}} + +{{- if .Values.manifests.pod_rally_test }} +{{- $envAll := . }} +{{- $dependencies := .Values.dependencies.static.tests }} + +{{- $mounts_tests := .Values.pod.mounts.mistral_tests.mistral_tests }} +{{- $mounts_tests_init := .Values.pod.mounts.mistral_tests.init_container }} + +{{- $serviceAccountName := print $envAll.Release.Name "-test" }} +{{ tuple $envAll $dependencies $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} +--- +apiVersion: v1 +kind: Pod +metadata: + name: {{ print $envAll.Release.Name "-test" }} + annotations: + "helm.sh/hook": test-success +spec: + nodeSelector: + {{ .Values.labels.test.node_selector_key }}: {{ .Values.labels.test.node_selector_value }} + restartPolicy: Never + serviceAccountName: {{ $serviceAccountName }} + initContainers: +{{ tuple $envAll $dependencies $mounts_tests_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 4 }} + - name: {{ .Release.Name }}-test-ks-user + image: {{ .Values.images.tags.ks_user }} + imagePullPolicy: {{ .Values.images.pull_policy }} +{{ tuple $envAll $envAll.Values.pod.resources.jobs.ks_user | include "helm-toolkit.snippets.kubernetes_resources" | indent 6 }} + command: + - /tmp/ks-user.sh + volumeMounts: + - name: mistral-bin + mountPath: /tmp/ks-user.sh + subPath: ks-user.sh + readOnly: true + env: +{{- with $env := dict "ksUserSecret" .Values.secrets.identity.admin }} +{{- include "helm-toolkit.snippets.keystone_openrc_env_vars" $env | indent 8 }} +{{- end }} + - name: SERVICE_OS_SERVICE_NAME + value: "test" +{{- with $env := dict "ksUserSecret" .Values.secrets.identity.test }} +{{- include "helm-toolkit.snippets.keystone_user_create_env_vars" $env | indent 8 }} +{{- end }} + - name: SERVICE_OS_ROLE + value: {{ .Values.endpoints.identity.auth.test.role | quote }} + containers: + - name: {{ .Release.Name }}-test + image: {{ .Values.images.tags.test }} + imagePullPolicy: {{ .Values.images.pull_policy }} +{{ tuple $envAll $envAll.Values.pod.resources.jobs.tests | include "helm-toolkit.snippets.kubernetes_resources" | indent 6 }} + env: +{{- with $env := dict "ksUserSecret" .Values.secrets.identity.admin }} +{{- include "helm-toolkit.snippets.keystone_openrc_env_vars" $env | indent 8 }} +{{- end }} +{{- with $env := dict "ksUserSecret" .Values.secrets.identity.test }} +{{- include "helm-toolkit.snippets.keystone_user_create_env_vars" $env | indent 8 }} +{{- end }} + - name: RALLY_ENV_NAME + value: {{.Release.Name}} + command: + - /tmp/rally-test.sh + volumeMounts: + - name: mistral-etc + mountPath: /etc/rally/rally_tests.yaml + subPath: rally_tests.yaml + readOnly: true + - name: mistral-bin + mountPath: /tmp/rally-test.sh + subPath: rally-test.sh + readOnly: true + - name: rally-db + mountPath: /var/lib/rally + {{- range $key, $value := $envAll.Values.conf.rally_tests.templates }} + - name: mistral-etc + mountPath: {{ $value.name }} + subPath: {{ printf "test_template_%d" $key }} + readOnly: true + {{- end }} +{{ if $mounts_tests.volumeMounts }}{{ toYaml $mounts_tests.volumeMounts | indent 8 }}{{ end }} + volumes: + - name: mistral-etc + configMap: + name: mistral-etc + defaultMode: 0444 + - name: mistral-bin + configMap: + name: mistral-bin + defaultMode: 0555 + - name: rally-db + emptyDir: {} +{{ if $mounts_tests.volumes }}{{ toYaml $mounts_tests.volumes | indent 4 }}{{ end }} +{{- end }} diff --git a/mistral/templates/secret-keystone.yaml b/mistral/templates/secret-keystone.yaml index bb37d855cc..e36f743db5 100644 --- a/mistral/templates/secret-keystone.yaml +++ b/mistral/templates/secret-keystone.yaml @@ -16,7 +16,7 @@ limitations under the License. {{- if .Values.manifests.secret_keystone }} {{- $envAll := . }} -{{- range $key1, $userClass := tuple "admin" "mistral" }} +{{- range $key1, $userClass := tuple "admin" "mistral" "test" }} {{- $secretName := index $envAll.Values.secrets.identity $userClass }} --- apiVersion: v1 diff --git a/mistral/values.yaml b/mistral/values.yaml index a3ab7db815..c48f312e67 100644 --- a/mistral/values.yaml +++ b/mistral/values.yaml @@ -33,11 +33,15 @@ labels: job: node_selector_key: openstack-control-plane node_selector_value: enabled + test: + node_selector_key: openstack-control-plane + node_selector_value: enabled release_group: null images: tags: + test: docker.io/kolla/ubuntu-source-rally:4.0.0 bootstrap: docker.io/openstackhelm/heat:newton dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.3.1 db_init: docker.io/openstackhelm/heat:newton @@ -146,12 +150,19 @@ dependencies: services: - service: oslo_messaging endpoint: internal + tests: + services: + - endpoint: internal + service: identity + - endpoint: internal + service: workflowv2 # Names of secrets used by bootstrap and environmental checks secrets: identity: admin: mistral-keystone-admin mistral: mistral-keystone-user + test: mistral-keystone-test oslo_db: admin: mistral-db-admin mistral: mistral-db-user @@ -182,6 +193,14 @@ endpoints: project_name: service user_domain_name: default project_domain_name: default + test: + role: admin + region_name: RegionOne + username: test + password: password + project_name: test + user_domain_name: default + project_domain_name: default hosts: default: keystone-api public: keystone @@ -264,6 +283,72 @@ endpoints: default: 11211 conf: + rally_tests: + run_tempest: false + tests: + MistralWorkbooks.create_workbook: + - args: + definition: /tmp/rally-jobs/mistral_wb.yaml + do_delete: true + runner: + concurrency: 1 + times: 1 + type: constant + sla: + failure_rate: + max: 0 + MistralExecutions.create_execution_from_workbook: + - args: + definition: /tmp/rally-jobs/mistral_wb.yaml + do_delete: true + params: /tmp/rally-jobs/mistral_params.json + wf_input: /tmp/rally-jobs/mistral_input.json + workflow_name: wf1 + runner: + concurrency: 1 + times: 1 + type: constant + sla: + failure_rate: + max: 0 + MistralWorkbooks.list_workbooks: + - runner: + concurrency: 1 + times: 1 + type: constant + sla: + failure_rate: + max: 0 + MistralExecutions.list_executions: + - runner: + concurrency: 1 + times: 1 + type: constant + sla: + failure_rate: + max: 0 + templates: + - name: /tmp/rally-jobs/mistral_wb.yaml + template: | + version: "2.0" + name: wb + workflows: + wf1: + type: direct + input: + - input1: input1 + - some_json_input: {} + tasks: + hello: + action: std.echo output="Hello" + publish: + result: $ + - name: /tmp/rally-jobs/mistral_input.json + template: | + {"input1": "value1", "some_json_input": {"a": "b"}} + - name: /tmp/rally-jobs/mistral_params.json + template: | + {"env": {"env_param": "env_param_value"}} policy: admin_only: is_admin:True admin_or_owner: is_admin:True or project_id:%(project_id)s @@ -359,6 +444,9 @@ pod: mistral_bootstrap: init_container: null mistral_bootstrap: + mistral_tests: + init_container: null + mistral_tests: replicas: api: 1 engine: 1 @@ -488,6 +576,7 @@ manifests: job_ks_user: true job_rabbit_init: true pdb_api: true + pod_rally_test: true secret_db: true secret_keystone: true secret_rabbitmq: true diff --git a/tools/deployment/multinode/180-mistral.sh b/tools/deployment/multinode/180-mistral.sh index 3b203d82bd..2603b61fcc 100755 --- a/tools/deployment/multinode/180-mistral.sh +++ b/tools/deployment/multinode/180-mistral.sh @@ -28,6 +28,7 @@ helm upgrade --install mistral ./mistral \ #NOTE: Wait for deploy ./tools/deployment/common/wait-for-pods.sh openstack -#NOTE: Validate Deployment info +#NOTE: Validate Deployment export OS_CLOUD=openstack_helm openstack service list +helm test mistral