Skip to content

Commit

Permalink
For loop to delete resources and store tempest configs more persisten…
Browse files Browse the repository at this point in the history
…tly (#25)

* Cleanup of openstack resources after a rally run

 - snapshots
 - volumes
 - images
 - projects
 - domains

Did not add more (instances, security groups, networks) because we don't
see those being left behind now in one environment.

 - #CCCP-2222

* Set the for loop per environment

* Store tempest configs persistently

If we store tempest.configs in /tmp then they might get cleaned up by
reboots or perhaps services that clean that place up. Put them in rally
user's home directory instead.

And the dictionary with the cloud settings can be accessed by {{
item.value.keyname }} from inside the jinja2 template for tempest_run.sh
  • Loading branch information
martbhell authored and junousi committed Oct 3, 2018
1 parent e2d9330 commit 161a883
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ clouds: {}
# network_name: network_name_for_tempest
# tempest_extra_settings: []
# tempest_skip_tests: {}
# tempest_manual_forloop_cleanup: True
# Which tempest tests to skip
# Moving this under the clouds dictionary so you can have a skip test
# per env, as Dev and Test may not have the same amount of hardware to
Expand All @@ -45,6 +46,7 @@ clouds: {}
# network_name: netowork_name_for_tempest
# tempest_extra_settings: "{{ rally_tempest_extra_settings }}"
# tempest_skip_tests: {}
# tempest_manual_forloop_cleanup: False
# Which tempest tests to skip
# Moving this under the clouds dictionary so you can have a skip test
# per env, as Dev and Test may not have the same amount of hardware to
Expand Down Expand Up @@ -97,4 +99,3 @@ tempest_must_be_run_in_screen: False
# - "mysetting = False"
# - "[section1]"
# - "setting2 = True"

12 changes: 10 additions & 2 deletions tasks/tempest_verifiers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,20 @@
tempest_second_flavor_uuid: "{{ second_flavor_id.stdout }}"
tempest_network_name: "{{ item.value.network_name }}"

- name: store tempest configs in a persistent place
file:
state: directory
path: /home/rally/tempest_configs
mode: 0700
owner: rally
group: rally

- name: Template in tempest config
template: src=tempest.j2 dest=/tmp/{{ item.key }}.tempest owner=rally group=rally mode=0700
template: src=tempest.j2 dest=/home/rally/tempest_configs/{{ item.key }}.tempest owner=rally group=rally mode=0700
register: reg_tempest_config

- name: Configure rally verifier if templating in the templest config file task changed
shell: "source /home/rally/rally/bin/activate && rally deployment use {{ item.key }} &>/dev/null && rally verify use-verifier --id {{ item.key }} && rally verify configure-verifier --extend /tmp/{{ item.key }}.tempest && deactivate"
shell: "source /home/rally/rally/bin/activate && rally deployment use {{ item.key }} &>/dev/null && rally verify use-verifier --id {{ item.key }} && rally verify configure-verifier --extend /home/rally/tempest_configs/{{ item.key }}.tempest && deactivate"
args:
executable: /bin/bash
when: reg_tempest_config.changed
Expand Down
9 changes: 9 additions & 0 deletions templates/tempest_run.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ if [[ "$TERM" =~ "screen" ]]; then
rally deployment use {{ item.key }}
rally verify use-verifier --id {{ item.key }}
rally verify start --skip-list {{ item.key }}-skip-list.yml --detailed $*
{% if item.value.tempest_manual_forloop_cleanup %}
# Remove any resources with tempest in their names. Perhaps acceptable in a devel/test environment.
source /home/rally/.rally/openrc
for snapshot in $(openstack volume snapshot list --all-projects -f csv -c ID -c Name |grep -i tempest-|tr -d '"'|cut -d "," -f1); do echo \#Deleting Tempest volume snapshot $snapshot; openstack volume snapshot delete $snapshot; done
for volume in $(openstack volume list --all-projects -f csv -c ID -c Name |grep -i tempest-|tr -d '"'|cut -d "," -f1); do echo \#Deleting Tempest volume $volume; openstack volume delete $volume; done
for image in $(openstack image list -f csv -c ID -c Name |grep -i tempest-|tr -d '"'|cut -d "," -f1); do echo \#Deleting Tempest image $image; openstack image delete $image; done
for project in $(openstack project list -f csv -c ID -c Name |grep -i tempest-|tr -d '"'|cut -d "," -f1); do echo \#Deleting Tempest project $project; openstack project delete $project;done
for domain in $(openstack domain list -f csv -c ID -c Name|tr -d '"'|grep tempest-test_domain|cut -d "," -f1); do echo \#Disabling and deleting Tempest domain $domain; openstack domain set --disable $domain; openstack domain delete $domain; done
{% endif %}
{% if tempest_must_be_run_in_screen %}
else
echo "You are not in a screen: $TERM"
Expand Down
1 change: 1 addition & 0 deletions tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- "[section1]"
- "setting2 = True"
- rally_install_version: 'stable/0.12'
- tempest_manual_forloop_cleanup: True
- clouds:
testcloud:
region: region1
Expand Down

0 comments on commit 161a883

Please sign in to comment.