diff --git a/.zuul.yaml b/.zuul.yaml index 09a58979af..5ff91bec39 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -154,8 +154,11 @@ Base integration test with Neutron networking. It includes all scenarios as it was in the past. This job runs all scenario tests in parallel! + timeout: 9000 vars: tox_envlist: full-parallel + run_tempest_cleanup: true + run_tempest_dry_cleanup: true devstack_localrc: USE_PYTHON3: True diff --git a/playbooks/devstack-tempest.yaml b/playbooks/devstack-tempest.yaml index 5f87abd31a..7ee74110d4 100644 --- a/playbooks/devstack-tempest.yaml +++ b/playbooks/devstack-tempest.yaml @@ -12,8 +12,41 @@ # job provided by the gabbi-tempest plugin. It can be safely ignored # if that plugin is not being used. GABBI_TEMPEST_PATH: "{{ gabbi_tempest_path | default('') }}" - roles: - - setup-tempest-run-dir - - setup-tempest-data-dir - - acl-devstack-files - - run-tempest + tasks: + - name: Setup Tempest Run Directory + include_role: + name: setup-tempest-run-dir + + - name: Setup Tempest Data Directory + include_role: + name: setup-tempest-data-dir + + - name: ACL devstack files + include_role: + name: acl-devstack-files + + - name: Run tempest cleanup init-saved-state + include_role: + name: tempest-cleanup + vars: + init_saved_state: true + when: + - run_tempest_dry_cleanup is defined + - run_tempest_cleanup is defined + + - name: Run Tempest + include_role: + name: run-tempest + + - name: Run tempest cleanup dry-run + include_role: + name: tempest-cleanup + vars: + dry_run: true + when: + - run_tempest_dry_cleanup is defined + + - name: Run tempest cleanup + include_role: + name: tempest-cleanup + when: run_tempest_cleanup is defined diff --git a/roles/tempest-cleanup/README.rst b/roles/tempest-cleanup/README.rst new file mode 100644 index 0000000000..70719ca2cd --- /dev/null +++ b/roles/tempest-cleanup/README.rst @@ -0,0 +1,33 @@ +Tempest cleanup +=============== + +Documentation regarding tempest cleanup can be found at the following +link: +https://docs.openstack.org/tempest/latest/cleanup.html + +When init_saved_state and dry_run variables are set to false, the role +execution will run tempest cleanup which deletes resources not present in the +saved_state.json file. + +**Role Variables** + +.. zuul:rolevar:: devstack_base_dir + :default: /opt/stack + + The devstack base directory. + +.. zuul:rolevar:: init_saved_state + :default: false + + When true, tempest cleanup --init-saved-state will be executed which + initializes the saved state of the OpenStack deployment and will output + a saved_state.json file containing resources from the deployment that will + be preserved from the cleanup command. This should be done prior to running + Tempest tests. + +.. zuul:rolevar:: dry_run + :default: false + + When true, tempest cleanup creates a report (./dry_run.json) of the + resources that would be cleaned up if the role was ran with dry_run option + set to false. diff --git a/roles/tempest-cleanup/defaults/main.yaml b/roles/tempest-cleanup/defaults/main.yaml new file mode 100644 index 0000000000..fc1948a13a --- /dev/null +++ b/roles/tempest-cleanup/defaults/main.yaml @@ -0,0 +1,3 @@ +devstack_base_dir: /opt/stack +init_saved_state: false +dry_run: false diff --git a/roles/tempest-cleanup/tasks/main.yaml b/roles/tempest-cleanup/tasks/main.yaml new file mode 100644 index 0000000000..5494ffff36 --- /dev/null +++ b/roles/tempest-cleanup/tasks/main.yaml @@ -0,0 +1,31 @@ +- when: init_saved_state + block: + - name: Run tempest cleanup init-saved-state + become: yes + become_user: tempest + command: tox -evenv-tempest -- tempest cleanup --init-saved-state + args: + chdir: "{{ devstack_base_dir }}/tempest" + + - name: Cat saved_state.json + command: cat "{{ devstack_base_dir }}/tempest/saved_state.json" + +- when: dry_run + block: + - name: Run tempest cleanup dry-run + become: yes + become_user: tempest + command: tox -evenv-tempest -- tempest cleanup --dry-run + args: + chdir: "{{ devstack_base_dir }}/tempest" + + - name: Cat dry_run.json + command: cat "{{ devstack_base_dir }}/tempest/dry_run.json" + +- name: Run tempest cleanup + become: yes + become_user: tempest + command: tox -evenv-tempest -- tempest cleanup + args: + chdir: "{{ devstack_base_dir }}/tempest" + when: not dry_run and not init_saved_state