Federico Ressi 597bd231a8 Limit max default concurrency for tox jobs.
Change-Id: Ib6a4a54391d32a25292562af4d02bbc43b2ff274
2019-01-14 10:29:17 +01:00

35 lines
962 B
YAML

# The number of vcpus is not available on all systems.
# See https://github.com/ansible/ansible/issues/30688
# When not available, we fall back to ansible_processor_cores
- name: Get hw.logicalcpu from sysctl
shell: sysctl hw.logicalcpu | cut -d' ' -f2
register: sysctl_hw_logicalcpu
when: ansible_processor_vcpus is not defined
- name: Get number of cores
set_fact:
num_cores: "{{ansible_processor_vcpus|default(sysctl_hw_logicalcpu.stdout)}}"
- name: Set default concurrency
set_fact:
stestr_concurrency: "{{ num_cores|int // 2 }}"
- name: Limit min concurrency to 1
set_fact:
stestr_concurrency: 1
when:
stestr_concurrency|int < 1
- name: Limit max concurrency to 2
set_fact:
stestr_concurrency: 2
when:
stestr_concurrency|int > 2
- name: Run Tobiko
command: tox -e {{tox_envlist}} {{tox_extra_args}} -- --concurrency={{stestr_concurrency}}
args:
chdir: "{{tox_dir}}"
become: true
become_user: stack