blob: 3d78557b092412b90bfc0d0adc59c85fe7069600 [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:
Ghanshyam Mann671a9312023-06-28 13:37:17 -050020 default_concurrency: "{{ num_cores|int - 2 }}"
Andrea Frittoli (andreaf)7d5445d2017-10-03 18:43:05 +010021 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
Ghanshyam Mann51a5d4f2023-01-25 14:49:48 -060028- name: Use stable branch upper-constraints till stable/wallaby
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}) }}"
Ghanshyam Mann51a5d4f2023-01-25 14:49:48 -060032 when: target_branch in ["stable/ocata", "stable/pike", "stable/queens", "stable/rocky", "stable/stein", "stable/train", "stable/ussuri", "stable/victoria", "stable/wallaby"]
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
Ghanshyam Mann7aa3b212022-05-23 20:40:57 -050081- name: Tempest 26.1.0 workaround to fallback exclude-list to blacklist
Ghanshyam Mannd9b6d7c2022-05-28 18:57:54 -050082 # NOTE(gmann): stable/train|ussuri|victoria use Tempest 26.1.0 and with
83 # stestr 2.5.1/3.0.1 (beacause of upper constraints of stestr 2.5.1/3.0.1
84 # in stable/train|ussuri|victoria) which does not have new args exclude-list
85 # so let's fallback to old arg if new arg is passed.
Ghanshyam Mann5ff5dab2021-12-20 10:07:49 -060086 set_fact:
87 exclude_list_option: "--blacklist-file={{ tempest_test_exclude_list|quote }}"
88 when:
89 - tempest_test_exclude_list is defined
Ghanshyam Mannd9b6d7c2022-05-28 18:57:54 -050090 - target_branch in ["stable/train", "stable/ussuri", "stable/victoria"]
Ghanshyam Mann5ff5dab2021-12-20 10:07:49 -060091
Martin Kopecdc844232020-12-24 15:57:53 +000092# TODO(kopecmartin) remove this after all consumers of the role have switched
93# to tempest_exclude_regex option, until then it's kept here for the backward
94# compatibility
Martin Kopec8a8c85d2021-02-10 11:28:38 +000095- name: Build exclude regex (old param)
Martin Kopecdc844232020-12-24 15:57:53 +000096 set_fact:
Martin Kopec8a8c85d2021-02-10 11:28:38 +000097 tempest_test_exclude_regex: "--black-regex={{tempest_black_regex|quote}}"
Martin Kopecdc844232020-12-24 15:57:53 +000098 when:
99 - tempest_black_regex is defined
100 - tempest_exclude_regex is not defined
101
Martin Kopecdc844232020-12-24 15:57:53 +0000102- name: Build exclude regex (new param)
103 set_fact:
Martin Kopec8a8c85d2021-02-10 11:28:38 +0000104 tempest_test_exclude_regex: "--exclude-regex={{tempest_exclude_regex|quote}}"
Martin Kopecdc844232020-12-24 15:57:53 +0000105 when:
106 - tempest_black_regex is not defined
107 - tempest_exclude_regex is defined
Ghanshyam Mannd9b6d7c2022-05-28 18:57:54 -0500108 - target_branch not in ["stable/train", "stable/ussuri", "stable/victoria"]
Ghanshyam Mann5ff5dab2021-12-20 10:07:49 -0600109
Ghanshyam Mann7aa3b212022-05-23 20:40:57 -0500110- name: Tempest 26.1.0 workaround to fallback exclude-regex to black-regex
Ghanshyam Mannd9b6d7c2022-05-28 18:57:54 -0500111 # NOTE(gmann): stable/train|ussuri|victoria use Tempest 26.1.0 and with stestr
112 # 2.5.1/3.0.1 (beacause of upper constraints of stestr 2.5.1/3.0.1 in
113 # stable/train|ussuri|victoria) which does not have new args exclude-list so
114 # let's fallback to old arg if new arg is passed.
Ghanshyam Mann5ff5dab2021-12-20 10:07:49 -0600115 set_fact:
116 tempest_test_exclude_regex: "--black-regex={{tempest_exclude_regex|quote}}"
117 when:
118 - tempest_black_regex is not defined
119 - tempest_exclude_regex is defined
Ghanshyam Mannd9b6d7c2022-05-28 18:57:54 -0500120 - target_branch in ["stable/train", "stable/ussuri", "stable/victoria"]
Martin Kopecdc844232020-12-24 15:57:53 +0000121
Andrea Frittoli (andreaf)7d5445d2017-10-03 18:43:05 +0100122- name: Run Tempest
Lukáš Piwowarskibd6481d2023-01-06 09:57:04 +0100123 command: tox -e {{tox_envlist}} {{tox_extra_args}} -- \
124 {{tempest_test_regex|quote if (tempest_test_regex|length>0)|default(None, True)}} \
125 {{blacklist_option|default(None)}} {{exclude_list_option|default(None)}} \
Chandan Kumara9445042018-02-26 10:22:29 +0000126 --concurrency={{tempest_concurrency|default(default_concurrency)}} \
Lukáš Piwowarskibd6481d2023-01-06 09:57:04 +0100127 {{tempest_test_exclude_regex|default(None)}}
Andrea Frittoli (andreaf)7d5445d2017-10-03 18:43:05 +0100128 args:
129 chdir: "{{devstack_base_dir}}/tempest"
Luigi Toscanob7746662020-04-17 13:31:00 +0200130 register: tempest_run_result
Andrea Frittoli (andreaf)7d5445d2017-10-03 18:43:05 +0100131 become: true
132 become_user: tempest
Ghanshyam56149022020-02-05 15:53:26 -0600133 environment: "{{ tempest_tox_environment }}"