Add tempest cleanup support

If a user sets tempest_cleanup variable to true, tempest cleanup will be
executed prior tempest tests (to generate saved_state.json) and after the
tests in order to delete leaked resources if any.

Change-Id: Ief00b43237cb634ee25a18264461bfda8464bbc7
changes/05/762405/1
Martin Kopec 2 years ago
parent b4f236f5d2
commit 18f796ad6a
  1. 5
      defaults/main.yml
  2. 6
      tasks/main.yml
  3. 33
      tasks/tempest_cleanup.yml
  4. 31
      tasks/tempest_cleanup_init.yml

@ -39,6 +39,11 @@ tempest_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_
# Toggle whether tempest actually executes
tempest_run: no
# Toggle whether tempest cleanup executes prior and after regular tempest run
tempest_cleanup: no
# if tempest_cleanup_dry_run is set to true, tempest cleanup will log all found
# leftover resources to a dry_run.json file, none resources will be deleted
#tempest_cleanup_dry_run: no
# Toggle whether default resources are implemented
tempest_default_role_resources: yes

@ -64,8 +64,14 @@
- name: Flush handlers
meta: flush_handlers
- import_tasks: tempest_cleanup_init.yml
when: tempest_cleanup | bool
- import_tasks: tempest_run.yml
when: tempest_run | bool
tags:
- tempest-config
- tempest-run
- import_tasks: tempest_cleanup.yml
when: tempest_cleanup | bool

@ -0,0 +1,33 @@
---
# Copyright 2020, Red Hat, Inc.
#
# 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.
- block:
- name: Cleanup leftover resources
shell: >
set -e;
if [ -d {{ tempest_venv_bin }} ];
then
. {{ tempest_venv_bin }}/activate;
fi;
tempest cleanup
{% if tempest_cleanup_dry_run | bool %}
--dry-run
{% endif %}
{% if debug | bool %}
--debug
{% endif %}
args:
chdir: "{{ tempest_workspace }}"
executable: /bin/bash

@ -0,0 +1,31 @@
---
# Copyright 2020, Red Hat, Inc.
#
# 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.
- block:
- name: Generate saved_state.json for tempest cleanup
shell: |
set -e
if [ -d {{ tempest_venv_bin }} ];
then
. {{ tempest_venv_bin }}/activate
fi
tempest cleanup \
{% if debug | bool %}
--debug \
{% endif %}
--init-saved-state
args:
chdir: "{{ tempest_workspace }}"
executable: /bin/bash
Loading…
Cancel
Save