diff --git a/shaker/Chart.yaml b/shaker/Chart.yaml new file mode 100644 index 00000000..720ca306 --- /dev/null +++ b/shaker/Chart.yaml @@ -0,0 +1,25 @@ +# Copyright 2018 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. + +apiVersion: v1 +description: OpenStack-Helm Shaker +name: shaker +version: 0.1.0 +home: https://pyshaker.readthedocs.io/en/latest/index.html +icon: https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTlnnEExfz6H9bBFFDxsDm5mVTdKWOt6Hw2_3aJ7hVkNdDdTCrimQ +sources: + - https://git.openstack.org/cgit/openstack/shaker + - https://git.openstack.org/cgit/openstack/openstack-helm +maintainers: + - name: OpenStack-Helm Authors diff --git a/shaker/requirements.yaml b/shaker/requirements.yaml new file mode 100644 index 00000000..53782e69 --- /dev/null +++ b/shaker/requirements.yaml @@ -0,0 +1,18 @@ +# 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. + +dependencies: + - name: helm-toolkit + repository: http://localhost:8879/charts + version: 0.1.0 diff --git a/shaker/templates/bin/_run-tests.sh.tpl b/shaker/templates/bin/_run-tests.sh.tpl new file mode 100644 index 00000000..ba6881e1 --- /dev/null +++ b/shaker/templates/bin/_run-tests.sh.tpl @@ -0,0 +1,21 @@ +#!/bin/bash + +{{/* +Copyright 2018 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 + +{{ .Values.conf.script }} diff --git a/shaker/templates/configmap-bin.yaml b/shaker/templates/configmap-bin.yaml new file mode 100644 index 00000000..35773be2 --- /dev/null +++ b/shaker/templates/configmap-bin.yaml @@ -0,0 +1,33 @@ +{{/* +Copyright 2018 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.configmap_bin }} +{{- $envAll := . }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: shaker-bin +data: +{{- if .Values.images.local_registry.active }} + image-repo-sync.sh: | +{{- include "helm-toolkit.scripts.image_repo_sync" . | indent 4 }} +{{- end }} + ks-user.sh: | +{{- include "helm-toolkit.scripts.keystone_user" . | indent 4 }} + run-tests.sh: | +{{ tuple "bin/_run-tests.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} +{{- end }} diff --git a/shaker/templates/configmap-etc.yaml b/shaker/templates/configmap-etc.yaml new file mode 100644 index 00000000..49acc348 --- /dev/null +++ b/shaker/templates/configmap-etc.yaml @@ -0,0 +1,58 @@ +{{/* +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.configmap_etc }} +{{- $envAll := . }} + +{{- if empty .Values.conf.shaker.auth.admin_username -}} +{{- $_ := set .Values.conf.shaker.auth "admin_username" .Values.endpoints.identity.auth.admin.username -}} +{{- end -}} +{{- if empty .Values.conf.shaker.auth.admin_password -}} +{{- $_ := set .Values.conf.shaker.auth "admin_password" .Values.endpoints.identity.auth.admin.password -}} +{{- end -}} +{{- if empty .Values.conf.shaker.auth.admin_project_name -}} +{{- $_ := set .Values.conf.shaker.auth "admin_project_name" .Values.endpoints.identity.auth.admin.project_name -}} +{{- end -}} +{{- if empty .Values.conf.shaker.auth.admin_domain_name -}} +{{- $_ := set .Values.conf.shaker.auth "admin_domain_name" .Values.endpoints.identity.auth.admin.user_domain_name -}} +{{- end -}} +{{- if empty .Values.conf.shaker.auth.admin_domain_scope -}} +{{- $_ := set .Values.conf.shaker.auth "admin_domain_scope" .Values.endpoints.identity.auth.admin.user_domain_name -}} +{{- end -}} + +{{- if empty .Values.conf.shaker.identity.uri_v3 -}} +{{- $_ := tuple "identity" "internal" "api" . | include "helm-toolkit.endpoints.keystone_endpoint_uri_lookup"| set .Values.conf.shaker.identity "uri_v3" -}} +{{- end -}} + +{{- if empty .Values.conf.shaker.identity.region -}} +{{- $_ := set .Values.conf.shaker.identity "region" .Values.endpoints.identity.auth.admin.region_name -}} +{{- end -}} + +--- +apiVersion: v1 +kind: Secret +metadata: + name: shaker-etc +type: Opaque +data: + shaker.conf: {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.shaker.shaker | b64enc }} +{{ if not (empty .Values.conf.basic) }} + test-basic: {{ include "shaker.utils.to_regex_file" .Values.conf.basic | b64enc }} +{{ end }} +{{ if not (empty .Values.conf.sriov) }} + test-sriov: {{ include "shaker.utils.to_regex_file" .Values.conf.sriov | b64enc }} +{{ end }} +{{- end }} diff --git a/shaker/templates/job-image-repo-sync.yaml b/shaker/templates/job-image-repo-sync.yaml new file mode 100644 index 00000000..8bfc3579 --- /dev/null +++ b/shaker/templates/job-image-repo-sync.yaml @@ -0,0 +1,20 @@ +{{/* +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 and .Values.manifests.job_image_repo_sync .Values.images.local_registry.active }} +{{- $imageRepoSyncJob := dict "envAll" . "serviceName" "shaker" -}} +{{ $imageRepoSyncJob | include "helm-toolkit.manifests.job_image_repo_sync" }} +{{- end }} diff --git a/shaker/templates/job-ks-user.yaml b/shaker/templates/job-ks-user.yaml new file mode 100644 index 00000000..172ac367 --- /dev/null +++ b/shaker/templates/job-ks-user.yaml @@ -0,0 +1,20 @@ +{{/* +Copyright 2018 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.job_ks_user }} +{{- $ksUserJob := dict "envAll" . "serviceName" "shaker" -}} +{{ $ksUserJob | include "helm-toolkit.manifests.job_ks_user" }} +{{- end }} diff --git a/shaker/templates/pod-shaker-test.yaml b/shaker/templates/pod-shaker-test.yaml new file mode 100644 index 00000000..d2a7d8d5 --- /dev/null +++ b/shaker/templates/pod-shaker-test.yaml @@ -0,0 +1,142 @@ +{{/* +Copyright 2018 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_shaker_test }} +{{- $envAll := . }} + +{{- $mounts_tests := .Values.pod.mounts.shaker_tests.shaker_tests }} +{{- $mounts_tests_init := .Values.pod.mounts.shaker_tests.init_container }} + +{{- $serviceAccountName := print $envAll.Release.Name "-test" }} +{{ tuple $envAll "run_tests" $serviceAccountName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} +--- +apiVersion: v1 +kind: Pod +metadata: + name: {{ print $envAll.Release.Name "-run-tests" }} + labels: +{{ tuple $envAll "shaker" "run-tests" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} + annotations: + "helm.sh/hook": test-success +spec: + nodeSelector: + {{ .Values.labels.pod.node_selector_key }}: {{ .Values.labels.pod.node_selector_value }} + serviceAccountName: {{ $serviceAccountName }} + restartPolicy: OnFailure + initContainers: +{{ tuple $envAll "run_tests" $mounts_tests_init | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 4 }} + - name: {{ .Release.Name }}-test-ks-user +{{ tuple $envAll "ks_user" | include "helm-toolkit.snippets.image" | indent 6 }} +{{ tuple $envAll $envAll.Values.pod.resources.jobs.ks_user | include "helm-toolkit.snippets.kubernetes_resources" | indent 6 }} + command: + - /tmp/ks-user.sh + volumeMounts: + - name: shaker-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: "shaker" +{{- with $env := dict "ksUserSecret" .Values.secrets.identity.shaker }} +{{- include "helm-toolkit.snippets.keystone_user_create_env_vars" $env | indent 8 }} +{{- end }} + - name: SERVICE_OS_ROLE + value: {{ .Values.endpoints.identity.auth.shaker.role | quote }} + - name: {{ .Release.Name }}-perms +{{ tuple $envAll "shaker_run_tests" | include "helm-toolkit.snippets.image" | indent 6 }} + securityContext: + runAsUser: 0 + privileged: true +{{ tuple $envAll $envAll.Values.pod.resources.jobs.run_tests | include "helm-toolkit.snippets.kubernetes_resources" | indent 6 }} + command: ["/bin/sh", "-c"] + args: + - set -xe; + chmod 0777 /opt/shaker/data/; + chmod 0777 /opt/shaker-data/; + volumeMounts: + - name: shaker-reports + mountPath: /opt/shaker/data/ + - name: shaker-data-host + mountPath: /opt/shaker-data/ + containers: + - name: {{ .Release.Name }}-run-tests +{{ tuple $envAll "shaker_run_tests" | include "helm-toolkit.snippets.image" | indent 6 }} +{{ tuple $envAll $envAll.Values.pod.resources.jobs.run_tests | include "helm-toolkit.snippets.kubernetes_resources" | indent 6 }} + securityContext: + runAsUser: {{ .Values.pod.user.shaker.uid }} + privileged: false + 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.shaker }} +{{- include "helm-toolkit.snippets.keystone_user_create_env_vars" $env | indent 8 }} +{{- end }} + - name: SHAKER_ENV_NAME + value: {{.Release.Name}} + - name: SHAKER_SCENARIO + value: {{ .Values.conf.shaker.shaker.DEFAULT.scenario }} + - name: SHAKER_SERVER_ENDPOINT + value: {{ .Values.conf.shaker.shaker.DEFAULT.server_endpoint }} + command: + - /tmp/run-tests.sh + volumeMounts: + - name: shaker-etc + mountPath: /etc/shaker/shaker_tests.yaml + subPath: shaker_tests.yaml + readOnly: true + - name: shaker-bin + mountPath: /tmp/run-tests.sh + subPath: run-tests.sh + readOnly: true + - name: shaker-db + mountPath: /opt/shaker/db/ + - name: shaker-reports + mountPath: /opt/shaker/data/ + - name: shaker-data-host + mountPath: /opt/shaker-data/ + - name: shaker-etc + mountPath: /opt/shaker/shaker.conf + subPath: shaker.conf + readOnly: true +{{ if $mounts_tests.volumeMounts }}{{ toYaml $mounts_tests.volumeMounts | indent 8 }}{{ end }} + volumes: + - name: shaker-etc + secret: + secretName: shaker-etc + defaultMode: 0444 + - name: shaker-bin + configMap: + name: shaker-bin + defaultMode: 0555 + - name: shaker-db + emptyDir: {} + - name: shaker-reports + {{- if not .Values.pvc.enabled }} + emptyDir: {} + {{- else }} + persistentVolumeClaim: + claimName: {{ .Values.pvc.name }} + {{- end }} + - name: shaker-data-host + hostPath: + path: /tmp/shaker-data +{{ if $mounts_tests.volumes }}{{ toYaml $mounts_tests.volumes | indent 4 }}{{ end }} +{{- end }} diff --git a/shaker/templates/pvc-shaker.yaml b/shaker/templates/pvc-shaker.yaml new file mode 100644 index 00000000..a7f25b7a --- /dev/null +++ b/shaker/templates/pvc-shaker.yaml @@ -0,0 +1,30 @@ +# {{/* +# 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.pvc.enabled }} + +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ .Values.pvc.name }} +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.pvc.requests.storage }} + storageClassName: {{ .Values.pvc.storage_class }} +{{- end }} diff --git a/shaker/templates/secret-keystone.yaml b/shaker/templates/secret-keystone.yaml new file mode 100644 index 00000000..63ec633c --- /dev/null +++ b/shaker/templates/secret-keystone.yaml @@ -0,0 +1,30 @@ +{{/* +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.secret_keystone }} +{{- $envAll := . }} +{{- range $key1, $userClass := tuple "admin" "shaker" }} +{{- $secretName := index $envAll.Values.secrets.identity $userClass }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ $secretName }} +type: Opaque +data: +{{- tuple $userClass "internal" $envAll | include "helm-toolkit.snippets.keystone_secret_openrc" | indent 2 -}} +{{- end }} +{{- end }} diff --git a/shaker/templates/service-shaker.yaml b/shaker/templates/service-shaker.yaml new file mode 100644 index 00000000..a01a1d4b --- /dev/null +++ b/shaker/templates/service-shaker.yaml @@ -0,0 +1,43 @@ +{{/* +Copyright 2018 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.service_shaker }} +{{- $envAll := . }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ tuple "shaker" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} +spec: + ports: + - name: shaker-api + protocol: TCP + port: {{ tuple "shaker" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} + {{ if .Values.shaker.controller.node_port.enabled }} + nodePort: {{ .Values.shaker.controller.node_port.port }} + {{ end }} + targetPort: {{ tuple "shaker" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} + selector: +{{ tuple $envAll "shaker" "run-tests" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} + {{ if .Values.shaker.controller.node_port.enabled }} + type: NodePort + {{ if .Values.shaker.controller.external_policy_local }} + externalTrafficPolicy: Local + {{ end }} + {{ end }} + externalIPs: + - {{ .Values.shaker.controller.external_ip }} +{{- end }} \ No newline at end of file diff --git a/shaker/values.yaml b/shaker/values.yaml new file mode 100644 index 00000000..2e711509 --- /dev/null +++ b/shaker/values.yaml @@ -0,0 +1,251 @@ +# Copyright 2018 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. + +# Default values for shaker. +# This is a YAML-formatted file. +# Declare name/value pairs to be passed into your templates. +# name: value + +labels: + job: + node_selector_key: openstack-control-plane + node_selector_value: enabled + pod: + node_selector_key: openstack-control-plane + node_selector_value: enabled + +images: + tags: + dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.3.1 + shaker_run_tests: docker.io/performa/shaker:latest + ks_user: docker.io/openstackhelm/heat:newton + image_repo_sync: docker.io/docker:17.07.0 + pull_policy: "IfNotPresent" + local_registry: + active: false + exclude: + - dep_check + - image_repo_sync + +pod: + user: + shaker: + uid: 1000 + resources: + enabled: false + jobs: + ks_user: + requests: + memory: "128Mi" + cpu: "100m" + limits: + memory: "1024Mi" + cpu: "2000m" + run_tests: + requests: + memory: "128Mi" + cpu: "100m" + limits: + memory: "1024Mi" + cpu: "2000m" + image_repo_sync: + requests: + memory: "128Mi" + cpu: "100m" + limits: + memory: "1024Mi" + cpu: "2000m" + mounts: + shaker_tests: + init_container: null + shaker_tests: + +shaker: + controller: + ingress: + public: true + classes: + namespace: "nginx" + cluster: "nginx-cluster" + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / + external_policy_local: false + node_port: + enabled: true + port: 31999 + external_ip: 9.9.9.9 + +dependencies: + dynamic: + common: + local_image_registry: + jobs: + - shaker-image-repo-sync + services: + - endpoint: node + service: local_image_registry + static: + ks_user: + services: + - service: identity + endpoint: internal + run_tests: + jobs: + - shaker-ks-user + services: + - service: identity + endpoint: internal + image_repo_sync: + services: + - endpoint: internal + service: local_image_registry + +conf: + script: | + sed -i -E "s/(accommodation\: \[.+)(.+\])/accommodation\: \[pair, compute_nodes: 1\]/" /opt/shaker/shaker/scenarios/openstack/full_l2.yaml + export server_endpoint=\`ip a | grep "global eth0" | cut -f6 -d' ' | cut -f1 -d'/'\` + + echo ========== SHAKER CONF PARAMETERS ================= + cat /opt/shaker/shaker.conf + echo ===================================================== + + env -i HOME="$HOME" bash -l -c "printenv; shaker --server-endpoint \$server_endpoint:31999 --config-file /opt/shaker/shaker.conf" + + shaker: + auth: + use_dynamic_credentials: true + admin_domain_scope: true + shaker_roles: admin, member + min_compute_nodes: 1 + identity: + auth_version: v3 + identity-feature-enabled: + api_v2: false + api_v3: true + shaker: + DEFAULT: + debug: true + cleanup_on_error: true + scenario_compute_nodes: 1 + report: /opt/shaker/data/shaker-result.html + output: /opt/shaker/data/shaker-result.json + scenario: /opt/shaker/shaker/scenarios/openstack/full_l2.yaml + flavor_name: m1.small + external_net: public + image_name: shaker-image + scenario_availability_zone: nova + os_username: admin + os_password: password + os_auth_url: "http://keystone.openstack.svc.cluster.local/v3" + os_project_name: admin + os_region_name: RegionOne + os_identity_api_version: 3 + os_interface: public + validation: + connect_method: floating + volume: + disk_formats: raw + backend_name: rbd1 + storage_protocol: rbd + volume-feature-enabled: + api_v1: False + api_v3: True + +pvc: + enabled: true + name: pvc-shaker + requests: + storage: 2Gi + storage_class: general + +secrets: + identity: + admin: shaker-keystone-admin + shaker: shaker-keystone-user + +endpoints: + cluster_domain_suffix: cluster.local + local_image_registry: + name: docker-registry + namespace: docker-registry + hosts: + default: localhost + internal: docker-registry + node: localhost + host_fqdn_override: + default: null + port: + registry: + node: 5000 + identity: + name: keystone + auth: + admin: + region_name: RegionOne + username: admin + password: password + project_name: admin + user_domain_name: default + project_domain_name: default + shaker: + role: admin + region_name: RegionOne + username: shaker + password: password + project_name: service + user_domain_name: service + project_domain_name: service + hosts: + default: keystone + internal: keystone-api + host_fqdn_override: + default: null + path: + default: /v3 + scheme: + default: http + port: + api: + default: 80 + internal: 5000 + shaker: + name: shaker + hosts: + default: shaker + public: shaker + host_fqdn_override: + default: null + # NOTE(portdirect): this chart supports TLS for fqdn over-ridden public + # endpoints using the following format: + # public: + # host: null + # tls: + # crt: null + # key: null + path: + default: null + scheme: + default: 'http' + port: + api: + default: 31999 + public: 80 +manifests: + configmap_bin: true + configmap_etc: true + job_image_repo_sync: true + job_ks_user: true + pod_shaker_test: true + service_shaker: true + secret_keystone: true diff --git a/tools/gate/scripts/090-deploy-shaker.sh b/tools/gate/scripts/090-deploy-shaker.sh new file mode 100755 index 00000000..1d604c7f --- /dev/null +++ b/tools/gate/scripts/090-deploy-shaker.sh @@ -0,0 +1,288 @@ +#!/bin/bash + +# Copyright 2018 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. + +#----------------------------------------------------------------------- +# Two ways to invoke this script +#----------------------------------------------------------------------- +# 1. Provide a shaker.conf file listing the shaker configuration params +# which should go as input to shaker +# 2. Provide the parameters explicitly +#---------------------------------------------------------------------- + +# (1): +# sudo -H -E su -c 'export SHAKER_CONF_HOST="/tmp/shaker.conf"; \ +# export CLONE_SHAKER_SCENARIOS="false"; \ +# export SHAKER_SCENARIOS_REPO="https://git.openstack.org/openstack/shaker"; \ +# export COPY_SHAKER_REPORTS_ON_HOST="false"; \ +# cd $CURR_WORK/openstack-helm-addons; ./tools/gate/scripts/090-shaker.sh ${OSH_EXTRA_HELM_ARGS}' ${username} + +# (2): +# sudo -H -E su -c 'export OSH_EXT_NET_NAME="public"; \ +# export OSH_EXT_SUBNET_NAME="public-subnet"; \ +# export OS_USERNAME="admin"; \ +# export OS_PASSWORD="password"; \ +# export OS_AUTH_URL="http://keystone.openstack.svc.cluster.local/v3"; \ +# export OS_PROJECT_NAME="admin"; \ +# export OS_REGION_NAME="RegionOne"; \ +# export OS_PROJECT_ID=""; \ +# export OS_PROJECT_DOMAIN_NAME="Default"; \ +# export OS_USER_DOMAIN_NAME="Default"; \ +# export OS_IDENTITY_API_VERSION=3; \ +# export EXTERNAL_NETWORK_NAME="public"; \ +# export SCENARIO="/opt/shaker/shaker/scenarios/openstack/full_l2.yaml"; \ +# export AVAILABILITY_ZONE="nova"; \ +# export FLAVOR_ID="shaker-flavor"; \ +# export IMAGE_NAME="shaker-image"; \ +# export SERVER_ENDPOINT_IP=""; \ +# export CLONE_SHAKER_SCENARIOS="false"; \ +# export SHAKER_SCENARIOS_REPO="https://git.openstack.org/openstack/shaker"; \ +# export COPY_SHAKER_REPORTS_ON_HOST="false"; \ +# cd $CURR_WORK/openstack-helm-addons; ./tools/gate/scripts/090-shaker.sh ${OSH_EXTRA_HELM_ARGS}' ${username} + +set -xe + +: ${OSH_EXT_NET_NAME:="public"} +: ${OSH_EXT_SUBNET_NAME:="public-subnet"} +: ${OSH_EXT_SUBNET:="172.24.4.0/24"} +: ${OSH_BR_EX_ADDR:="172.24.4.1/24"} +: ${OSH_PRIVATE_SUBNET_POOL:="11.0.0.0/8"} +: ${OSH_PRIVATE_SUBNET_POOL_NAME:="shared-default-subnetpool"} +: ${OSH_PRIVATE_SUBNET_POOL_DEF_PREFIX:="24"} +: ${OSH_VM_KEY_STACK:="heat-vm-key"} +: ${OSH_PRIVATE_SUBNET:="11.0.0.0/24"} + +# Shaker conf params +: ${OS_USERNAME:="admin"} +: ${OS_PASSWORD:="password"} +: ${OS_AUTH_URL:="http://keystone.openstack.svc.cluster.local/v3"} +: ${OS_PROJECT_NAME:="admin"} +: ${OS_REGION_NAME:="RegionOne"} +: ${OS_USER_DOMAIN_NAME:="Default"} +: ${OS_PROJECT_DOMAIN_NAME:="Default"} +: ${OS_PROJECT_ID:=""} +: ${EXTERNAL_NETWORK_NAME:=$OSH_EXT_NET_NAME} +: ${SCENARIO:="shaker/shaker/scenarios/openstack/full_l2.yaml"} +: ${AVAILABILITY_ZONE:="nova"} +: ${OS_IDENTITY_API_VERSION:="3"} +: ${OS_INTERFACE:="public"} + +: ${REPORT_FILE:="shaker-result.html"} +: ${OUTPUT_FILE:="shaker-result.json"} +: ${FLAVOR_ID:="shaker-flavor"} +: ${IMAGE_NAME:="shaker-image"} +: ${SERVER_ENDPOINT_IP:=""} +: ${SERVER_ENDPOINT_INTF:="eth0"} +: ${SHAKER_PORT:=31999} +: ${COMPUTE_NODES:=1} + +: ${EXECUTE_TEST:="true"} +: ${DEBUG:="true"} +: ${CLEANUP_ON_ERROR:="true"} +: ${CLONE_SHAKER_SCENARIOS:="false"} +: ${SHAKER_SCENARIOS_REPO:="https://git.openstack.org/openstack/shaker"} +: ${COPY_SHAKER_REPORTS_ON_HOST:="false"} +: ${SHAKER_CONF_HOST:=""} + +# DO NOT CHANGE: Change requires update in shaker charts +: ${SHAKER_CONF:="/opt/shaker/shaker.conf"} +: ${SHAKER_DATA:="/opt/shaker/data"} +: ${SHAKER_DATA_HOSTPATH_MOUNT:="/opt/shaker-data"} +: ${SHAKER_DATA_HOSTPATH:="/tmp/shaker-data"} + +#NOTE: Pull images and lint chart +: ${OSH_PATH:="../openstack-helm"} +make -C ${OSH_PATH} pull-images shaker + +#NOTE: Deploy command +if [ ! -z ${SHAKER_CONF_HOST} ] && [ -f ${SHAKER_CONF_HOST} ]; then + SERVER_ENDPOINT_IP=`cat ${SHAKER_CONF_HOST} | awk '/server_endpoint/ {print $2}' | cut -f1 -d':'` + SHAKER_PORT=`cat ${SHAKER_CONF_HOST} | awk '/server_endpoint/ {print $2}' | cut -f2 -d':'` +else + # Export AUTH variables required by shaker-image-builder utility + export OS_USERNAME=${OS_USERNAME} + export OS_PASSWORD=${OS_PASSWORD} + export OS_AUTH_URL=${OS_AUTH_URL} + export OS_PROJECT_NAME=${OS_PROJECT_NAME} + export OS_REGION_NAME=${OS_REGION_NAME} + export EXTERNAL_NETWORK_NAME=${EXTERNAL_NETWORK_NAME} + export OS_PROJECT_ID=${OS_PROJECT_ID} + + if [ $OS_IDENTITY_API_VERSION = "3" ]; then + export OS_PROJECT_DOMAIN_NAME=${OS_PROJECT_DOMAIN_NAME} + export OS_USER_DOMAIN_NAME=${OS_USER_DOMAIN_NAME} + else + export OS_PROJECT_DOMAIN_NAME= + export OS_USER_DOMAIN_NAME= + fi + + export stack_exists=`openstack network list | grep ${OSH_EXT_NET_NAME} | awk '{print $4}'` + + if [ -z $stack_exists ]; then + openstack stack create --wait \ + --parameter network_name=${OSH_EXT_NET_NAME} \ + --parameter physical_network_name=${OSH_EXT_NET_NAME} \ + --parameter subnet_name=${OSH_EXT_SUBNET_NAME} \ + --parameter subnet_cidr=${OSH_EXT_SUBNET} \ + --parameter subnet_gateway=${OSH_BR_EX_ADDR%/*} \ + -t ${OSH_PATH}/tools/gate/files/heat-public-net-deployment.yaml \ + heat-public-net-deployment + fi + + default_sec_grp_id=`openstack security group list --project ${OS_PROJECT_NAME} | grep default | awk '{split(\$0,a,"|"); print a[2]}'` + for sg in $default_sec_grp_id + do + icmp=`openstack security group rule list $sg | grep icmp | awk '{split(\$0,a,"|"); print a[2]}'` + if [ "${icmp}" = "" ]; then openstack security group rule create --proto icmp $sg; fi + shaker=`openstack security group rule list $sg | grep tcp | grep ${SHAKER_PORT} | awk '{split(\$0,a,"|"); print a[2]}'` + if [ "${shaker}" = "" ]; then openstack security group rule create --proto tcp --dst-port ${SHAKER_PORT} $sg; fi + done + + IMAGE_NAME=$(openstack image show -f value -c name \ + $(openstack image list -f csv | awk -F ',' '{ print $2 "," $1 }' | \ + grep "${IMAGE_NAME}" | head -1 | awk -F ',' '{ print $2 }' | tr -d '"')) + + if [ -z $IMAGE_NAME ]; then + # Install shaker to use shaker-image-builder utility + sudo apt-add-repository "deb http://nova.clouds.archive.ubuntu.com/ubuntu/ trusty multiverse" + sudo apt-get update + sudo apt-get -y install python-dev libzmq-dev + sudo pip install pbr pyshaker + + # Run shaker-image-builder utility to build shaker image + # For debug mode + # shaker-image-builder --nocleanup-on-error --debug + # For debug mode - with disk-image-builder mode + # shaker-image-builder --nocleanup-on-error --debug --image-builder-mode dib + shaker-image-builder + + IMAGE_NAME=$(openstack image show -f value -c name \ + $(openstack image list -f csv | awk -F ',' '{ print $2 "," $1 }' | \ + grep "^\"shaker" | head -1 | awk -F ',' '{ print $2 }' | tr -d '"')) + fi + + if [ $CLONE_SHAKER_SCENARIOS = "true" ]; then + SHAKER_SCENARIO="${SHAKER_DATA}/${SCENARIO}" + else + SHAKER_SCENARIO="/opt/${SCENARIO}" + fi +fi + +#NOTE: Deploy shaker pods +tee /tmp/shaker.yaml << EOF +shaker: + controller: + external_ip: ${SERVER_ENDPOINT_IP} +conf: + script: | + #!/bin/bash + set -xe + + # Clone the shaker test-cases + if [ ${CLONE_SHAKER_SCENARIOS} = "true" ]; then + cd ${SHAKER_DATA}; git clone $SHAKER_SCENARIOS_REPO; cd -; + fi + + if [ -z ${SERVER_ENDPOINT_IP} ]; then + export server_endpoint=\`ip a | grep "global ${SERVER_ENDPOINT_INTF}" | cut -f6 -d' ' | cut -f1 -d'/'\` + else + export server_endpoint=${SERVER_ENDPOINT_IP} + fi + + echo =========================== + printenv | grep -i os_ + + echo ========== SHAKER CONF PARAMETERS ================= + cat ${SHAKER_CONF} + echo ===================================================== + + env -i HOME="$HOME" bash -l -c "printenv; shaker --server-endpoint \$server_endpoint:${SHAKER_PORT} --config-file ${SHAKER_CONF}" + + if [ $COPY_SHAKER_REPORTS_ON_HOST = "true" ]; then + export DATA_FOLDER_NAME=`date +%Y%m%d_%H%M%S` + mkdir ${SHAKER_DATA_HOSTPATH_MOUNT}/\$DATA_FOLDER_NAME + echo \$DATA_FOLDER_NAME > ${SHAKER_DATA_HOSTPATH_MOUNT}/latest-shaker-data-name.txt + declare -a file_extns_arr_to_copy=(html json subunit conf yaml stream) + for i in "\${file_extns_arr_to_copy[@]}" + do + if [ -e ${SHAKER_DATA}/*.\$i ]; then cp -avb ${SHAKER_DATA}/*.\$i ${SHAKER_DATA_HOSTPATH_MOUNT}/\$DATA_FOLDER_NAME/; fi + done + cp -avb ${SHAKER_CONF} ${SHAKER_DATA_HOSTPATH_MOUNT}/\$DATA_FOLDER_NAME/ + fi +EOF + +if [ -z ${SHAKER_CONF_HOST} ] || [ ! -f ${SHAKER_CONF_HOST} ]; then +tee -a /tmp/shaker.yaml << EOF + shaker: + shaker: + DEFAULT: + debug: ${DEBUG} + cleanup_on_error: ${CLEANUP_ON_ERROR} + scenario_compute_nodes: ${COMPUTE_NODES} + report: ${SHAKER_DATA}/${REPORT_FILE} + output: ${SHAKER_DATA}/${OUTPUT_FILE} + scenario: ${SHAKER_SCENARIO} + flavor_name: ${FLAVOR_ID} + external_net: ${EXTERNAL_NETWORK_NAME} + image_name: ${IMAGE_NAME} + scenario_availability_zone: ${AVAILABILITY_ZONE} + os_username: ${OS_USERNAME} + os_password: ${OS_PASSWORD} + os_auth_url: ${OS_AUTH_URL} + os_project_name: ${OS_PROJECT_NAME} + os_region_name: ${OS_REGION_NAME} + os_identity_api_version: ${OS_IDENTITY_API_VERSION} + os_interface: ${OS_INTERFACE} +EOF + +if [ $OS_IDENTITY_API_VERSION = "3" ]; then +tee -a /tmp/shaker.yaml << EOF + os_project_domain_name: ${OS_PROJECT_DOMAIN_NAME} + os_user_domain_name: ${OS_USER_DOMAIN_NAME} +EOF +fi + +else + +echo " shaker:" >> /tmp/shaker.yaml +echo " shaker:" >> /tmp/shaker.yaml +cp ${SHAKER_CONF_HOST} ${SHAKER_CONF_HOST}.tmp +sed -i -e 's/^/ /' ${SHAKER_CONF_HOST}.tmp +cat ${SHAKER_CONF_HOST}.tmp >> /tmp/shaker.yaml +rm -rf ${SHAKER_CONF_HOST}.tmp + +fi + +helm upgrade --install shaker ./shaker \ + --namespace=openstack \ + --values=/tmp/shaker.yaml \ + ${OSH_EXTRA_HELM_ARGS} \ + ${OSH_EXTRA_HELM_ARGS_SHAKER} + +#NOTE: Wait for deploy +./tools/gate/scripts/wait-for-pods.sh openstack 2400 + +#NOTE: Validate Deployment info +kubectl get -n openstack jobs --show-all + +if [ -n $EXECUTE_TEST ]; then + helm test shaker --timeout 2700 + + if [ $COPY_SHAKER_REPORTS_ON_HOST = "true" ]; then + shaker_pod_name=`kubectl -n openstack get pods | grep shaker-run-tests | cut -f1 -d' '` + latest_data_folder=`cat ${SHAKER_DATA_HOSTPATH}/latest-shaker-data-name.txt` + kubectl -n openstack logs ${shaker_pod_name} > ${SHAKER_DATA_HOSTPATH}/${latest_data_folder}/${shaker_pod_name}.logs + fi +fi