blob: e9c8e9260c1255a2af98e1af9360526b40075b71 [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
28- name: Use stable branch upper-constraints till stable/rocky
29 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}) }}"
Ghanshyam56149022020-02-05 15:53:26 -060032 when: target_branch in ["stable/ocata", "stable/pike", "stable/queens", "stable/rocky"]
33
34- name: Set OS_TEST_TIMEOUT if requested
35 set_fact:
36 tempest_tox_environment: "{{ tempest_tox_environment | combine({'OS_TEST_TIMEOUT': tempest_test_timeout}) }}"
37 when: tempest_test_timeout != ''
38
Martin Kopecdc844232020-12-24 15:57:53 +000039# TODO(kopecmartin) remove the following 'when block' after all consumers of
40# the role have switched to tempest_test_exclude_list option, until then it's
41# kept here for backward compatibility
Michel Petersonef1a16d2018-02-23 20:20:22 +020042- when:
43 - tempest_test_blacklist is defined
44 block:
45 - name: Check for test blacklist file
46 stat:
47 path: "{{ tempest_test_blacklist }}"
48 register:
49 blacklist_stat
50
51 - name: Build blacklist option
52 set_fact:
53 blacklist_option: "--blacklist-file={{ tempest_test_blacklist|quote }}"
54 when: blacklist_stat.stat.exists
55
Martin Kopecdc844232020-12-24 15:57:53 +000056- when:
57 - tempest_test_exclude_list is defined
58 block:
59 - name: Check for test exclude list file
60 stat:
61 path: "{{ tempest_test_exclude_list }}"
62 register:
63 exclude_list_stat
64
65 - name: Build exclude list option
66 set_fact:
67 exclude_list_option: "--exclude-list={{ tempest_test_exclude_list|quote }}"
68 when: exclude_list_stat.stat.exists
69
70# TODO(kopecmartin) remove this after all consumers of the role have switched
71# to tempest_exclude_regex option, until then it's kept here for the backward
72# compatibility
73- name: Set tempest_exclude_regex
74 set_fact:
75 tempest_exclude_regex: "{{ tempest_black_regex }}"
76 when:
77 - tempest_black_regex is defined
78 - tempest_exclude_regex is not defined
79
80- name: Build exclude regex (old param)
81 set_fact:
82 tempest_exclude_regex: "--black-regex={{tempest_black_regex|quote}}"
83 when:
84 - tempest_black_regex is defined
85
86- name: Build exclude regex (new param)
87 set_fact:
88 tempest_exclude_regex: "--exclude-regex={{tempest_exclude_regex|quote}}"
89 when:
90 - tempest_black_regex is not defined
91 - tempest_exclude_regex is defined
92
Andrea Frittoli (andreaf)7d5445d2017-10-03 18:43:05 +010093- name: Run Tempest
Martin Kopecdc844232020-12-24 15:57:53 +000094 command: tox -e {{tox_envlist}} {{tox_extra_args}} -- {{tempest_test_regex|quote}} \
95 {{blacklist_option|default('')}} {{exclude_list_option|default('')}} \
Chandan Kumara9445042018-02-26 10:22:29 +000096 --concurrency={{tempest_concurrency|default(default_concurrency)}} \
Martin Kopecdc844232020-12-24 15:57:53 +000097 {{tempest_exclude_regex|default('')}}
Andrea Frittoli (andreaf)7d5445d2017-10-03 18:43:05 +010098 args:
99 chdir: "{{devstack_base_dir}}/tempest"
Luigi Toscanob7746662020-04-17 13:31:00 +0200100 register: tempest_run_result
Andrea Frittoli (andreaf)7d5445d2017-10-03 18:43:05 +0100101 become: true
102 become_user: tempest
Ghanshyam56149022020-02-05 15:53:26 -0600103 environment: "{{ tempest_tox_environment }}"