Enable tempest cleanup with record_resources in jobs

This enables tempest cleanup with record_resources in the tempest-all job
to create a list of all the resources created during the tempest run.
Then the list will be used to run 'tempest cleanup' to clean only
the resources in the list.

Also, enable the dry cleanup with record_resources in tempest-extra-tests
job.

Change-Id: Ia64a1c09d4b5e9815ff5926161d550b56433ec64
This commit is contained in:
Martin Kopec 2024-05-09 13:30:43 +02:00
parent f999b15bd4
commit 1a9c40d469
5 changed files with 52 additions and 3 deletions

View File

@ -47,6 +47,15 @@ saved_state.json file.
only resources with names that match the prefix. This option can be used
together with dry_run.
.. zuul:rolevar:: run_tempest_cleanup_resource_list
:default: false
When true, tempest cleanup will be called with '--resource-list' to delete
only resources listed in ./resource_list.json that is created if
record_resources config option in the default section of tempest.conf file
is enabled (set to True). The resource_list.json contains all resources
created by Tempest during a Tempest run.
Role usage
----------

View File

@ -3,3 +3,4 @@ init_saved_state: false
dry_run: false
run_tempest_fail_if_leaked_resources: false
run_tempest_cleanup_prefix: false
run_tempest_cleanup_resource_list: false

View File

@ -5,7 +5,9 @@
command: tox -evenv-tempest -- tempest cleanup --dry-run --debug
args:
chdir: "{{ devstack_base_dir }}/tempest"
when: not run_tempest_cleanup_prefix
when:
- not run_tempest_cleanup_prefix
- run_tempest_cleanup_resource_list is not defined or not run_tempest_cleanup_resource_list
- name: Run tempest cleanup dry-run with tempest prefix
become: yes
@ -14,3 +16,11 @@
args:
chdir: "{{ devstack_base_dir }}/tempest"
when: run_tempest_cleanup_prefix
- name: Run tempest cleanup with tempest resource list
become: yes
become_user: tempest
command: tox -evenv-tempest -- tempest cleanup --dry-run --debug --resource-list
args:
chdir: "{{ devstack_base_dir }}/tempest"
when: run_tempest_cleanup_resource_list

View File

@ -27,7 +27,9 @@
command: tox -evenv-tempest -- tempest cleanup --debug
args:
chdir: "{{ devstack_base_dir }}/tempest"
when: not run_tempest_cleanup_prefix
when:
- not run_tempest_cleanup_prefix
- run_tempest_cleanup_resource_list is not defined or not run_tempest_cleanup_resource_list
- name: Run tempest cleanup with tempest prefix
become: yes
@ -37,6 +39,18 @@
chdir: "{{ devstack_base_dir }}/tempest"
when: run_tempest_cleanup_prefix
- name: Cat resource_list.json
command: cat "{{ devstack_base_dir }}/tempest/resource_list.json"
when: run_tempest_cleanup_resource_list
- name: Run tempest cleanup with tempest resource list
become: yes
become_user: tempest
command: tox -evenv-tempest -- tempest cleanup --debug --resource-list
args:
chdir: "{{ devstack_base_dir }}/tempest"
when: run_tempest_cleanup_resource_list
- when:
- run_tempest_fail_if_leaked_resources
- not init_saved_state

View File

@ -17,6 +17,13 @@
# TODO(gmann): Enable File injection tests once nova bug is fixed
# https://bugs.launchpad.net/nova/+bug/1882421
# ENABLE_FILE_INJECTION: true
run_tempest_cleanup: true
run_tempest_cleanup_resource_list: true
devstack_local_conf:
test-config:
$TEMPEST_CONFIG:
DEFAULT:
record_resources: true
- job:
name: tempest-ipv6-only
@ -37,6 +44,14 @@
tools/tempest-extra-tests-list.txt.
vars:
tox_envlist: extra-tests
run_tempest_cleanup: true
run_tempest_cleanup_resource_list: true
run_tempest_dry_cleanup: true
devstack_local_conf:
test-config:
$TEMPEST_CONFIG:
DEFAULT:
record_resources: true
- job:
name: tempest-full-py3