Files
openstack-ansible-os_tempest/tasks/tempest_post_install.yml
Arx Cruz 4c0fcc91c3 Add tempest_test_extra_test variable
This add a aditional test in the tempest_test_includelist. This is
required right now as a workaround for tripleo jobs, while the
implementation of the includelist in openstack-tempest-skiplist tool.
Tripleo uses os_tempest to setup and run tempest, but it doesn't run all
tempest tests. Sometimes, the list of excluded tests matches the list of
included tests and so tempest fail with no tests to run. This
tempest_test_extra_test will ensure that it will execute at least one
keystone api test to avoid this.
Right now, the tempest_test_whitelist variable is parsed to ansible via
-e command line, and so it's hard to overwrite it on tripleo side, and
it's spreaded in several different jobs with several different set of
tests. So, this is the best/easy way to fix this problem, while we work
on a long term solution.

Change-Id: Ic5f5b44d81ed39b1fa622b5a1d76e482c2aa23aa
2021-06-22 08:48:15 +02:00

189 lines
5.8 KiB
YAML

---
# Copyright 2014, Rackspace US, Inc.
# Copyright 2018, 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.
- name: Create tempest directories
file:
path: "{{ item.path }}"
state: directory
owner: "{{ item.owner | default(omit) }}"
group: "{{ item.group | default(omit) }}"
mode: "{{ item.mode|default('0755') }}"
with_items:
- path: "{{ tempest_log_dir | realpath }}"
owner: root
- path: "{{ tempest_image_dir }}"
- path: "{{ tempest_workspace }}"
- path: "/etc/tempest"
owner: root
group: root
- name: Copy tempest config
config_template:
src: "tempest.conf.j2"
dest: "/etc/tempest/tempest.conf"
owner: "root"
group: "root"
mode: "0644"
config_overrides: "{{ tempest_tempest_conf_overrides }}"
config_type: "ini"
register: copy_tempest_config
when: not tempest_use_tempestconf | bool
- name: Move over workspace when config is updated
shell: |
set -e
if [ -d {{ tempest_venv_bin }} ]; then
. {{ tempest_venv_bin }}/activate
else
exit 0
fi
if tempest workspace list | grep ' workspace '; then
# Get a backup suffix
export CURDATE=$(date +"%d%^b%g_%H%M%S%Z")
# Get the dirname for 'workspace' directly from the tempest workspace list
WSPATH=$(dirname $(tempest workspace list | awk '{if($2 == "workspace"){print $4}}'))
# Rename the workspace
tempest workspace rename --old-name workspace --new-name workspace_${CURDATE}
# A workspace move only changes the config. The move happens manually.
if [ -d "${WSPATH}/workspace" ]
then
mv ${WSPATH}/workspace ${WSPATH}/workspace_${CURDATE}
tempest workspace move --name workspace_${CURDATE} --path ${WSPATH}/workspace_${CURDATE}/
fi
exit 3
fi
args:
executable: /bin/bash
register: tempest_move_workspace
changed_when: tempest_move_workspace.rc == 3
failed_when:
- tempest_move_workspace.rc != 0
- tempest_move_workspace.rc != 3
when:
- not tempest_use_tempestconf | bool
- copy_tempest_config is changed
tags:
# don't trigger ANSIBLE0016
- skip_ansible_lint
- name: Initialise tempest workspace
shell: |
set -e
if [ ! -d {{ tempest_workspace }}/etc ]; then
if [ -d {{ tempest_venv_bin }} ]; then
. {{ tempest_venv_bin }}/activate
fi
# (guilhermesp) We are adding this conditional here to avoid
# breakage when we are upgrade from rocky to stein as the workspace
# path has been change between these two releases
if tempest workspace list | grep ' workspace '; then
# Init not working on existing entry. Renme old workspace instead and init new.
export CURDATE=$(date +"%d%^b%g_%H%M%S%Z")
WSPATH=$(dirname $(tempest workspace list | awk '{if($2 == "workspace"){print $4}}'))
tempest workspace rename --old-name workspace --new-name workspace_${CURDATE}
mv ${WSPATH}/workspace ${WSPATH}/workspace_${CURDATE}
tempest workspace move --name workspace_${CURDATE} --path ${WSPATH}/workspace_${CURDATE}/
tempest init ${CURWORKSPACE}
else
tempest init --name workspace {{ tempest_workspace }}
exit 3
fi
fi
args:
executable: /bin/bash
register: tempest_init_workspace
changed_when: tempest_init_workspace.rc == 3
failed_when:
- tempest_init_workspace.rc != 0
- tempest_init_workspace.rc != 3
tags:
# don't trigger ANSIBLE0013
- skip_ansible_lint
- import_tasks: tempestconf.yml
when: tempest_use_tempestconf | bool
tags:
- tempest-config
- tempestconf
- name: List installed tempest plugins
shell: |
set -e
if [ -d {{ tempest_venv_bin }} ]; then
. {{ tempest_venv_bin }}/activate
fi
tempest list-plugins
args:
executable: /bin/bash
when: "debug | bool"
- name: List tempest tests
shell: |
set -e
if [ -d {{ tempest_venv_bin }} ];
then
. {{ tempest_venv_bin }}/activate
fi
tempest run -l
args:
chdir: "{{ tempest_workspace }}"
executable: /bin/bash
when: "debug | bool"
changed_when: false
# TODO(arxcruz) Right now, we have the tempest_test_whitelist parsed as -e
# argument in ansible in several of our jobs, so it is right now hard to get
# rid of all of it in all the places. Once we implement the include list in the
# openstack-tempest-skiplist side, we can remove the tempest_Test_extra_test.
- name: Generate tempest test include list
copy:
content: |
{% for item in (tempest_test_includelist + tempest_test_extra_test) | unique | sort %}
{% if item %}
{{ item }}
{% endif %}
{% endfor %}
dest: "{{ tempest_test_includelist_file_path }}"
mode: "0644"
when:
- tempest_test_includelist | length > 0
# Tests to NOT execute:
# This sets up a list of tests to skip, which can even include those included in the whitelist.
- name: Generate tempest test exclude list
copy:
content: |
{% for item in tempest_test_excludelist %}
{% if item.test is defined %}
{{ item.test }}
{% else %}
{{ item }}
{% endif %}
{% endfor %}
dest: "{{ tempest_test_excludelist_file_path }}"
mode: "0644"
when:
- tempest_test_excludelist | length > 0