Add new flag cleanup-heat-stacks to the infrared plugin

When this flag is set, the heat stacks created by tobiko are deleted at
the end of the tobiko infrared execution
Additionally, the images created by tobiko are also removed from glance

Change-Id: I3415a7fd73f02e47cf4a0c3351d90db3f7614fef
This commit is contained in:
Eduardo Olivares 2021-10-06 18:11:19 +02:00
parent 632ce945da
commit 454a63f4e6
5 changed files with 28 additions and 0 deletions

View File

@ -193,6 +193,13 @@ subparsers:
help: Ignore test execution errors
ansible_variable: ignore_test_failures
- title: Cleanup stage
options:
cleanup-heat-stacks:
type: Flag
help: Cleanup heat stacks created by tobiko
ansible_variable: stacks_cleanup
- title: Collect stage
options:
collect-dir:

View File

@ -5,3 +5,4 @@ tobiko_git_refspec: ''
test_git_refspec: ''
tobiko_git_remote: ''
test_git_remote: ''
stacks_cleanup: false

View File

@ -43,6 +43,10 @@
include_role: name=tobiko-run
rescue:
- name: "clean up heat stacks generated during tobiko tests"
include_role: name=tobiko-cleanup
when: stacks_cleanup
- name: "finalize test execution"
include_role: name=tobiko-collect
ignore_errors: yes
@ -51,6 +55,10 @@
msg: 'TEST EXECUTION FAILED'
- name: "clean up heat stacks generated during tobiko tests"
include_role: name=tobiko-cleanup
when: stacks_cleanup
- name: "finalize test execution"
include_role: name=tobiko-collect

View File

@ -0,0 +1,4 @@
---
# OpenStack client credentials
stackrc_file: '{{ ansible_user_dir }}/overcloudrc'

View File

@ -0,0 +1,8 @@
---
- name: "cleanup stacks created by tobiko tests"
shell: |
source {{ stackrc_file }}
openstack stack list -f value -c 'Stack Name' | grep "^tobiko\." | xargs openstack stack delete --wait
openstack image list -f value -c Name | grep "^tobiko\." | xargs openstack image delete
ignore_errors: yes