blob: a8b3edef2aea760e70c46ee4ec80981ad0bdd897 [file] [log] [blame]
Andrea Frittoli (andreaf)7d5445d2017-10-03 18:43:05 +01001# NOTE(andreaf) The number of vcpus is not available on all systems.
2# See https://github.com/ansible/ansible/issues/30688
3# When not available, we fall back to ansible_processor_cores
4- name: Get hw.logicalcpu from sysctl
5 shell: sysctl hw.logicalcpu | cut -d' ' -f2
6 register: sysctl_hw_logicalcpu
7 when: ansible_processor_vcpus is not defined
8
9- name: Number of cores
10 set_fact:
11 num_cores: "{{ansible_processor_vcpus|default(sysctl_hw_logicalcpu.stdout)}}"
12
13- name: Set concurrency for cores == 3 or less
14 set_fact:
15 default_concurrency: "{{ num_cores }}"
16 when: num_cores|int <= 3
17
18- name: Limit max concurrency when more than 3 vcpus are available
19 set_fact:
20 default_concurrency: "{{ num_cores|int // 2 }}"
21 when: num_cores|int > 3
22
Ghanshyam56149022020-02-05 15:53:26 -060023- name: Override target branch
24 set_fact:
25 target_branch: "{{ zuul.override_checkout }}"
26 when: zuul.override_checkout is defined
27
Riccardo Pittaubd2acbf2021-02-04 11:21:29 +010028- name: Use stable branch upper-constraints till stable/stein
Ghanshyam56149022020-02-05 15:53:26 -060029 set_fact:
Andreas Jaeger99b085b2020-04-21 15:00:14 +020030 # TOX_CONSTRAINTS_FILE is new name, UPPER_CONSTRAINTS_FILE is old one, best to set both
31 tempest_tox_environment: "{{ tempest_tox_environment | combine({'UPPER_CONSTRAINTS_FILE': stable_constraints_file}) | combine({'TOX_CONSTRAINTS_FILE': stable_constraints_file}) }}"
Riccardo Pittaubd2acbf2021-02-04 11:21:29 +010032 when: target_branch in ["stable/ocata", "stable/pike", "stable/queens", "stable/rocky", "stable/stein"]
Ghanshyam56149022020-02-05 15:53:26 -060033
Ghanshyam Mann62d11d82021-02-10 11:41:48 -060034- name: Use Configured upper-constraints for non-master Tempest
35 set_fact:
36 # TOX_CONSTRAINTS_FILE is new name, UPPER_CONSTRAINTS_FILE is old one, best to set both
37 tempest_tox_environment: "{{ tempest_tox_environment | combine({'UPPER_CONSTRAINTS_FILE': devstack_localrc['TEMPEST_VENV_UPPER_CONSTRAINTS']}) | combine({'TOX_CONSTRAINTS_FILE': devstack_localrc['TEMPEST_VENV_UPPER_CONSTRAINTS']}) }}"
38 when:
39 - devstack_localrc is defined
40 - "'TEMPEST_BRANCH' in devstack_localrc"
41 - "'TEMPEST_VENV_UPPER_CONSTRAINTS' in devstack_localrc"
42 - devstack_localrc['TEMPEST_BRANCH'] != 'master'
Ghanshyam Mann926f8232021-04-07 16:52:41 -050043 - devstack_localrc['TEMPEST_VENV_UPPER_CONSTRAINTS'] != 'master'
Ghanshyam Mann62d11d82021-02-10 11:41:48 -060044
Ghanshyam56149022020-02-05 15:53:26 -060045- name: Set OS_TEST_TIMEOUT if requested
46 set_fact:
47 tempest_tox_environment: "{{ tempest_tox_environment | combine({'OS_TEST_TIMEOUT': tempest_test_timeout}) }}"
48 when: tempest_test_timeout != ''
49
Martin Kopecdc844232020-12-24 15:57:53 +000050# TODO(kopecmartin) remove the following 'when block' after all consumers of
51# the role have switched to tempest_test_exclude_list option, until then it's
52# kept here for backward compatibility
Michel Petersonef1a16d2018-02-23 20:20:22 +020053- when:
54 - tempest_test_blacklist is defined
55 block:
56 - name: Check for test blacklist file
57 stat:
58 path: "{{ tempest_test_blacklist }}"
59 register:
60 blacklist_stat
61
62 - name: Build blacklist option
63 set_fact:
64 blacklist_option: "--blacklist-file={{ tempest_test_blacklist|quote }}"
65 when: blacklist_stat.stat.exists
66
Martin Kopecdc844232020-12-24 15:57:53 +000067- when:
68 - tempest_test_exclude_list is defined
69 block:
70 - name: Check for test exclude list file
71 stat:
72 path: "{{ tempest_test_exclude_list }}"
73 register:
74 exclude_list_stat
75
76 - name: Build exclude list option
77 set_fact:
78 exclude_list_option: "--exclude-list={{ tempest_test_exclude_list|quote }}"
79 when: exclude_list_stat.stat.exists
80
81# TODO(kopecmartin) remove this after all consumers of the role have switched
82# to tempest_exclude_regex option, until then it's kept here for the backward
83# compatibility
Martin Kopec8a8c85d2021-02-10 11:28:38 +000084- name: Build exclude regex (old param)
Martin Kopecdc844232020-12-24 15:57:53 +000085 set_fact:
Martin Kopec8a8c85d2021-02-10 11:28:38 +000086 tempest_test_exclude_regex: "--black-regex={{tempest_black_regex|quote}}"
Martin Kopecdc844232020-12-24 15:57:53 +000087 when:
88 - tempest_black_regex is defined
89 - tempest_exclude_regex is not defined
90
Martin Kopecdc844232020-12-24 15:57:53 +000091- name: Build exclude regex (new param)
92 set_fact:
Martin Kopec8a8c85d2021-02-10 11:28:38 +000093 tempest_test_exclude_regex: "--exclude-regex={{tempest_exclude_regex|quote}}"
Martin Kopecdc844232020-12-24 15:57:53 +000094 when:
95 - tempest_black_regex is not defined
96 - tempest_exclude_regex is defined
97
Andrea Frittoli (andreaf)7d5445d2017-10-03 18:43:05 +010098- name: Run Tempest
Martin Kopecdc844232020-12-24 15:57:53 +000099 command: tox -e {{tox_envlist}} {{tox_extra_args}} -- {{tempest_test_regex|quote}} \
100 {{blacklist_option|default('')}} {{exclude_list_option|default('')}} \
Chandan Kumara9445042018-02-26 10:22:29 +0000101 --concurrency={{tempest_concurrency|default(default_concurrency)}} \
Martin Kopec8a8c85d2021-02-10 11:28:38 +0000102 {{tempest_test_exclude_regex|default('')}}
Andrea Frittoli (andreaf)7d5445d2017-10-03 18:43:05 +0100103 args:
104 chdir: "{{devstack_base_dir}}/tempest"
Luigi Toscanob7746662020-04-17 13:31:00 +0200105 register: tempest_run_result
Andrea Frittoli (andreaf)7d5445d2017-10-03 18:43:05 +0100106 become: true
107 become_user: tempest
Ghanshyam56149022020-02-05 15:53:26 -0600108 environment: "{{ tempest_tox_environment }}"