blob: 70c275b39d09bedaba1336ac02b713e2397683d1 [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
Ghanshyam Mann7aa3b212022-05-23 20:40:57 -050028- name: Use stable branch upper-constraints till stable/ussuri
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 Mann7aa3b212022-05-23 20:40:57 -050032 when: target_branch in ["stable/ocata", "stable/pike", "stable/queens", "stable/rocky", "stable/stein", "stable/train", "stable/ussuri"]
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
82 # NOTE(gmann): stable/train|ussuri use Tempest 26.1.0 and with stestr 2.5.1/3.0.1
83 # (beacause of upper constraints of stestr 2.5.1/3.0.1 in stable/train|ussuri)
84 # which does not have new args exclude-list so let's fallback to old arg
Ghanshyam Mann5ff5dab2021-12-20 10:07:49 -060085 # if new arg is passed.
86 set_fact:
87 exclude_list_option: "--blacklist-file={{ tempest_test_exclude_list|quote }}"
88 when:
89 - tempest_test_exclude_list is defined
Ghanshyam Mann7aa3b212022-05-23 20:40:57 -050090 - target_branch in ["stable/train", "stable/ussuri"]
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 Mann7aa3b212022-05-23 20:40:57 -0500108 - target_branch not in ["stable/train", "stable/ussuri"]
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
111 # NOTE(gmann): stable/train|ussuri use Tempest 26.1.0 and with stestr 2.5.1/3.0.1
112 # (beacause of upper constraints of stestr 2.5.1/3.0.1 in stable/train|ussuri)
113 # which does not have new args exclude-list so let's fallback to old arg
Ghanshyam Mann5ff5dab2021-12-20 10:07:49 -0600114 # if new arg is passed.
115 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 Mann7aa3b212022-05-23 20:40:57 -0500120 - target_branch in ["stable/train", "stable/ussuri"]
Martin Kopecdc844232020-12-24 15:57:53 +0000121
Andrea Frittoli (andreaf)7d5445d2017-10-03 18:43:05 +0100122- name: Run Tempest
Martin Kopecdc844232020-12-24 15:57:53 +0000123 command: tox -e {{tox_envlist}} {{tox_extra_args}} -- {{tempest_test_regex|quote}} \
124 {{blacklist_option|default('')}} {{exclude_list_option|default('')}} \
Chandan Kumara9445042018-02-26 10:22:29 +0000125 --concurrency={{tempest_concurrency|default(default_concurrency)}} \
Martin Kopec8a8c85d2021-02-10 11:28:38 +0000126 {{tempest_test_exclude_regex|default('')}}
Andrea Frittoli (andreaf)7d5445d2017-10-03 18:43:05 +0100127 args:
128 chdir: "{{devstack_base_dir}}/tempest"
Luigi Toscanob7746662020-04-17 13:31:00 +0200129 register: tempest_run_result
Andrea Frittoli (andreaf)7d5445d2017-10-03 18:43:05 +0100130 become: true
131 become_user: tempest
Ghanshyam56149022020-02-05 15:53:26 -0600132 environment: "{{ tempest_tox_environment }}"