tripleo-quickstart-extras/playbooks/tasks/tempest.yml

234 lines
8.8 KiB
YAML

---
# Load the skipp list
- name: Install and run tempest-skip tool
block:
- name: Load tests to be skipped
vars:
list_skipped_release: "{{ release }}"
list_skipped_job: "{{ zuul.job | default(omit) }}"
list_skipped_deployment: "{{ (tempest_cloud_name in ['undercloud']) | ternary('undercloud', 'overcloud') }}"
include_role:
name: list_skipped
- name: Add skiplist tests to tempest_test_blacklist - skip them
set_fact:
tempest_test_blacklist: "{{ tempest_skip_register.skipped_tests }}"
when: not tempest_run_skipped | default(false) | bool
- name: Add skiplist tests to tempest_test_whitelist - run them
set_fact:
tempest_test_whitelist: "{{ tempest_skip_register.skipped_tests }}"
tempest_test_blacklist: []
when: tempest_run_skipped | default(false) | bool
vars:
# when ansible.cfg have the option interpreter_python set to auto, ansible
# executes with the system python instead of virtualenv even though you are
# inside the virtualenv. Setting ansible_python_interpreter here ensures
# that this playbook will be executed the virtualenv python, which have the
# openstac-tempest-skiplist module
ansible_python_interpreter: "{{ local_working_dir }}/bin/python"
list_skipped_yaml_file: "{{ local_working_dir }}/usr/local/share/ansible/roles/validate-tempest/vars/tempest_skip.yml"
when: tempest_use_skiplist | default(true)
delegate_to: localhost
- name: set python_cmd
set_fact:
python_cmd: "python{{ ansible_python.version.major }}"
cacheable: true
when: python_cmd is not defined
- name: Check if virtualenv is in the system
command: "{{ python_cmd }} -m virtualenv --version"
register: virtualenv_exist
failed_when: false
changed_when: false
- when: virtualenv_exist.rc != 0
name: Install virtualenv
become: true
package:
state: present
name: >
{% if ansible_python.version.major == 3 %}
python3-virtualenv
{% else %}
python-virtualenv
{% endif %}
- name: Set the rc file
set_fact:
rc_file: "{{ (tempest_cloud_name in ['undercloud']) | ternary('stackrc', 'overcloudrc') }}"
when: release in ['queens', 'stein']
- name: Create clouds.yaml if it doesn't exist
shell: |
# queens is returning //v3 so we replace with /v3
sed -i 's/\/\/v3/\/v3/g' {{ ansible_user_dir }}/{{ rc_file }}
source {{ ansible_user_dir }}/{{ rc_file }}
mkdir -p {{ ansible_user_dir }}/.config/openstack
cat <<EOF>>{{ ansible_user_dir }}/.config/openstack/clouds.yaml
clouds:
{{ tempest_cloud_name }}:
identity_api_version: $OS_IDENTITY_API_VERSION
region_name: regionOne
auth:
auth_url: $OS_AUTH_URL
password: $OS_PASSWORD
username: $OS_USERNAME
user_domain_name: Default
project_domain_name: Default
project_name: $OS_PROJECT_NAME
EOF
when:
- release in ['queens', 'stein']
- not tempest_cloud_name in ['standalone']
# Ansible requires openstacksdk>=0.12 do the resource setup, however
# queens upper-constraint has openstacksdk==0.11.36, so we need to
# implement a custom venv with the right openstacksdk to make it work
- name: Queens specific settings and tasks
when: release in ['queens']
vars:
sdk_venv_path: "{{ ansible_user_dir }}/.sdk"
block:
- name: Set tempest_service_setup_host_python_interpreter
set_fact:
tempest_service_setup_host_python_interpreter: "{{ sdk_venv_path }}/bin/python"
- name: Prepare openstacksdk venv
import_role:
name: "python_venv_build"
vars:
venv_python_executable: "{{ python_cmd }}"
venv_build_constraints:
- "--constraint https://releases.openstack.org/constraints/upper/rocky"
venv_install_destination_path: "{{ sdk_venv_path }}"
venv_pip_packages:
- 'openstacksdk'
venv_wheel_build_enable: false
# This will execute os_tempest
- name: Execute os_tempest
when: use_os_tempest | default(true)
block:
- name: Fail the tempest playbook on undefined cloud name and install method
fail:
msg: |
The variable tempest_install_method and tempest_cloud_name is required and
has not been set.
when:
- tempest_install_method is not defined
- tempest_cloud_name is not defined
# If tempest is running on undercloud, do not set this variable to true
- name: Initialize neutron service for network creation
set_fact:
tempest_service_available_neutron: true
when: tempest_cloud_name in ['overcloud', 'standalone']
- name: Create /root/.config/openstack directory
file:
state: directory
path: "/root/.config/openstack"
mode: 0700
become: true
- name: Copy clouds.yaml file to /root directory
block:
- name: Copy clouds.yaml file from user's home to /root directory
copy:
src: '{{ ansible_user_dir }}/.config/openstack/clouds.yaml'
remote_src: true
dest: '/root/.config/openstack/clouds.yaml'
mode: 0600
become: true
rescue:
- name: Copy clouds.yaml file /etc/openstack to /root directory
copy:
src: '/etc/openstack/clouds.yaml'
remote_src: true
dest: '/root/.config/openstack/clouds.yaml'
mode: 0600
become: true
- name: Set network vars
set_fact:
tempest_public_net_physical_type: 'datacentre'
tempest_public_subnet_cidr: '{{ tempest_cidr }}'
tempest_public_subnet_gateway_ip: '{{ tempest_cidr|nthhost(1) }}'
tempest_public_subnet_allocation_pools: '{{ tempest_cidr|nthhost(100) ~ "-" ~ tempest_cidr|nthhost(150) }}'
tempest_private_net_seg_id: "{{ (release in ['queens']) | ternary('', omit) }}"
tempest_network_ping_gateway: true
tempest_private_net_provider_type: "{{ (release in ['queens']) | ternary('vlan', 'geneve') }}"
when: tempest_cidr is defined
- name: Handle migration of br-ex network
block:
- name: Check if standalone parameters exists
stat:
path: "{{ working_dir }}/standalone_parameters.yaml"
register: parameter_file
- name: Read content of standalone parameters file if exists
slurp:
src: "{{ working_dir }}/standalone_parameters.yaml"
register: standalone_parameters
when: parameter_file.stat.exists
- name: Parse contents
set_fact:
standalone_parameters_yaml: "{{ standalone_parameters['content'] | b64decode | from_yaml }}"
when: parameter_file.stat.exists
- name: set tempest facts for br-ex network migration
set_fact:
tempest_public_subnet_cidr: '172.16.1.0/24'
tempest_public_subnet_gateway_ip: '172.16.1.2'
tempest_public_subnet_allocation_pools: '172.16.1.100-172.16.1.150'
when:
- parameter_file.stat.exists
- "'NeutronPhysicalBridge' not in (standalone_parameters_yaml | from_yaml)['parameter_defaults']"
when:
- job.environment_type is defined and job.environment_type == "standalone"
- job.bridge_address_prefix is defined and job.bridge_address_prefix == "172.16.1"
- name: Set tempest workspace related vars
set_fact:
tempest_use_tempestconf: true
tempest_service_setup_host: '{{ inventory_hostname }}'
tempest_workspace: "{{ ansible_user_dir }}/tempest"
stackviz_venv_bin: "{{ ansible_user_dir }}/stackviz_venv/bin"
- name: set facts while running tempest from source
set_fact:
tempest_git_repo: https://opendev.org/openstack/tempest
tempest_tempestconf_git_repo: https://opendev.org/osf/python-tempestconf
tempest_tempestconf_venv_bin: "{{ ansible_user_dir }}/tempestconf_venv/bin"
tempest_venv_bin: "{{ ansible_user_dir }}/tempest_venv/bin"
when: tempest_install_method == 'source'
- name: set cirros image facts for periodic
vars:
default_cirros_image: /opt/cache/files/cirros-0.5.2-x86_64-disk.img
set_fact:
tempest_tempestconf_profile_extras:
image: "{{ featureset_override['cirros_image'] | default(default_cirros_image) }}"
retry_image: true
# stackviz in venv pulls oslo.db due upstream constraints,
# but it dropped py2 support so on such system we need to skip it
# https://bugs.launchpad.net/tripleo/+bug/1862134
- name: disable stackviz in python2 environment
set_fact:
tempest_run_stackviz: false
when:
- ansible_distribution_major_version is version('8', '<')
- name: Run os_tempest role
vars:
ansible_become: true
debug: true
tempest_run: 'yes'
include_role:
name: os_tempest