From b1f8446e5b1411fd8579b3e74f5bbef2e00191f0 Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Thu, 26 Sep 2019 12:24:11 -0500 Subject: [PATCH] Neutron: Update force purge of test project to be less aggressive This PS updates the os purge of the test project to be an optional operator driven choice, as they will also need to ensure the project is unique to neutron testing. Additionally this updates the purge image to be driven by the charts values.yaml, as with every other image in OSH. Change-Id: I46807f7c4922a1b411386641eddbd8957ab56f05 Signed-off-by: Pete Birley --- ...h.tpl => _neutron-test-force-cleanup.sh.tpl} | 13 ++++--------- neutron/templates/configmap-bin.yaml | 4 ++-- neutron/templates/pod-rally-test.yaml | 17 ++++++++++------- neutron/values.yaml | 8 ++++++++ 4 files changed, 24 insertions(+), 18 deletions(-) rename neutron/templates/bin/{_neutron-cleanup.sh.tpl => _neutron-test-force-cleanup.sh.tpl} (66%) diff --git a/neutron/templates/bin/_neutron-cleanup.sh.tpl b/neutron/templates/bin/_neutron-test-force-cleanup.sh.tpl similarity index 66% rename from neutron/templates/bin/_neutron-cleanup.sh.tpl rename to neutron/templates/bin/_neutron-test-force-cleanup.sh.tpl index b36d2b4276..12ce3136a7 100644 --- a/neutron/templates/bin/_neutron-cleanup.sh.tpl +++ b/neutron/templates/bin/_neutron-test-force-cleanup.sh.tpl @@ -16,12 +16,7 @@ set -ex -while [ ! -f /tmp/pod-tmp/test_done.log ] -do - sleep 2s -done - -ospurge --purge-project $OS_TEST_PROJECT_NAME - -openstack quota set $OS_TEST_PROJECT_NAME --networks $NETWORK_QUOTA --ports $PORT_QUOTA --routers $ROUTER_QUOTA --subnets $SUBNET_QUOTA --secgroups $SEC_GROUP_QUOTA - +if openstack project show "${OS_TEST_PROJECT_NAME}"; then + ospurge --purge-project "${OS_TEST_PROJECT_NAME}" + openstack quota set "${OS_TEST_PROJECT_NAME}" --networks "${NETWORK_QUOTA}" --ports "${PORT_QUOTA}" --routers "${ROUTER_QUOTA}" --subnets "${SUBNET_QUOTA}" --secgroups "${SEC_GROUP_QUOTA}" +fi diff --git a/neutron/templates/configmap-bin.yaml b/neutron/templates/configmap-bin.yaml index 3786088ff8..0ec16557d0 100644 --- a/neutron/templates/configmap-bin.yaml +++ b/neutron/templates/configmap-bin.yaml @@ -83,6 +83,6 @@ data: {{ tuple "bin/_neutron-ironic-agent.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} rabbit-init.sh: | {{- include "helm-toolkit.scripts.rabbit_init" . | indent 4 }} - neutron-cleanup.sh: | -{{ tuple "bin/_neutron-cleanup.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} + neutron-test-force-cleanup.sh: | +{{ tuple "bin/_neutron-test-force-cleanup.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} {{- end }} diff --git a/neutron/templates/pod-rally-test.yaml b/neutron/templates/pod-rally-test.yaml index d4fad87f5b..362d2aa273 100644 --- a/neutron/templates/pod-rally-test.yaml +++ b/neutron/templates/pod-rally-test.yaml @@ -63,9 +63,9 @@ spec: {{- end }} - name: SERVICE_OS_ROLE value: {{ .Values.endpoints.identity.auth.test.role | quote }} - containers: +{{ if $envAll.Values.conf.rally_tests.force_project_purge }} - name: {{ .Release.Name }}-reset - image: openstackhelm/ospurge +{{ tuple $envAll "purge_test" | include "helm-toolkit.snippets.image" | indent 6 }} env: {{- with $env := dict "ksUserSecret" .Values.secrets.identity.admin }} {{- include "helm-toolkit.snippets.keystone_openrc_env_vars" $env | indent 8 }} @@ -85,14 +85,17 @@ spec: value: {{ (first (index .Values.conf.rally_tests.tests "NeutronNetworks.create_and_delete_subnets")).context.quotas.neutron.subnet | quote }} - name: SEC_GROUP_QUOTA value: {{ (first (index .Values.conf.rally_tests.tests "NeutronSecurityGroup.create_and_list_security_groups")).context.quotas.neutron.security_group | quote }} - command: ["/bin/bash", "-c", "/tmp/neutron-cleanup.sh"] + command: + - /tmp/neutron-test-force-cleanup.sh volumeMounts: - name: neutron-bin - mountPath: /tmp/neutron-cleanup.sh - subPath: neutron-cleanup.sh + mountPath: /tmp/neutron-test-force-cleanup.sh + subPath: neutron-test-force-cleanup.sh readOnly: true - name: pod-tmp mountPath: /tmp/pod-tmp +{{ end }} + containers: - name: {{ .Release.Name }}-test {{ tuple $envAll "test" | include "helm-toolkit.snippets.image" | indent 6 }} {{ tuple $envAll $envAll.Values.pod.resources.jobs.tests | include "helm-toolkit.snippets.kubernetes_resources" | indent 6 }} @@ -105,8 +108,8 @@ spec: {{- end }} - name: RALLY_ENV_NAME value: {{.Release.Name}} - command: ["/bin/bash", "-c"] - args: ["/tmp/rally-test.sh; touch /tmp/test_done.log"] + command: + - /tmp/rally-test.sh volumeMounts: - name: pod-tmp mountPath: /tmp diff --git a/neutron/values.yaml b/neutron/values.yaml index 2b84e43e88..e6c674e488 100644 --- a/neutron/values.yaml +++ b/neutron/values.yaml @@ -23,6 +23,7 @@ images: tags: bootstrap: docker.io/openstackhelm/heat:ocata-ubuntu_xenial test: docker.io/xrally/xrally-openstack:1.3.0 + purge_test: docker.io/openstackhelm/ospurge:latest db_init: docker.io/openstackhelm/heat:ocata-ubuntu_xenial neutron_db_sync: docker.io/openstackhelm/neutron:ocata-ubuntu_xenial db_drop: docker.io/openstackhelm/heat:ocata-ubuntu_xenial @@ -742,6 +743,7 @@ pod: conf: rally_tests: + force_project_purge: false run_tempest: false tests: NeutronNetworks.create_and_delete_networks: @@ -2212,6 +2214,12 @@ endpoints: region_name: RegionOne username: neutron-test password: password + # NOTE: this project will be purged and reset if + # conf.rally_tests.force_project_purge is set to true + # which may be required upon test failure, but be aware that this will + # expunge all openstack objects, so if this is used a seperate project + # should be used for each helm test, and also it should be ensured + # that this project is not in use by other tenants project_name: test user_domain_name: service project_domain_name: service