mirror of https://github.com/ansible/ansible.git
* throttle tests: fix detection of parallel execution
The test wasn't able to detect if too many workers were running.
On my laptop:
- without this change, the 'throttle' target takes ~20 seconds
- with this change, the 'throttle' target takes ~70 seconds
- 1 second isn't long enough to encounter the issue
* Fix throttle test when strategy is 'free' based
'free' strategy allows multiple tasks to be executed in parallel: use
one 'throttledir' per task.
Use 'linear' strategy with a dedicated play for cleanup/setup tasks
* throttle: reset worker idx before queuing a new task
* TestStrategyBase: define task.throttle
otherwise '1' will be used instead of the default value due to the
following expression being equal to '1':
int(templar.template(task_mock.throttle))
Co-authored-by: James Cammarata <jimi@sngx.net>
(cherry picked from commit bbbdc1c25c
)
pull/67297/head
parent
6df09ae41e
commit
783daf9d1b
@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- "throttle: the linear strategy didn't always stuck with the throttle limit"
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
throttledir: '{{ base_throttledir }}/{{ subdir }}'
|
||||||
|
base_throttledir: "{{ lookup('env', 'OUTPUT_DIR') }}/throttle.dir"
|
||||||
|
subdir: "{{ test_id if lookup('env', 'SELECTED_STRATEGY') in ['free', 'host_pinned'] else '' }}"
|
@ -1,59 +1,84 @@
|
|||||||
---
|
---
|
||||||
- hosts: localhosts
|
- hosts: localhosts
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
vars:
|
strategy: linear
|
||||||
throttledir: "{{ lookup('env', 'OUTPUT_DIR') }}/throttle.dir/"
|
run_once: yes
|
||||||
tasks:
|
tasks:
|
||||||
- name: Clean throttledir '{{ throttledir }}'
|
- name: Clean base throttledir '{{ base_throttledir }}'
|
||||||
file:
|
file:
|
||||||
state: absent
|
state: absent
|
||||||
path: '{{ throttledir }}'
|
path: '{{ base_throttledir }}'
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
run_once: yes
|
|
||||||
- name: Create throttledir '{{ throttledir }}'
|
- name: Create throttledir '{{ throttledir }}'
|
||||||
file:
|
file:
|
||||||
state: directory
|
state: directory
|
||||||
path: '{{ throttledir }}'
|
path: '{{ throttledir }}'
|
||||||
run_once: yes
|
loop: "{{ range(1, test_count|int)|list }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_id
|
||||||
|
vars:
|
||||||
|
test_count: "{{ 9 if lookup('env', 'SELECTED_STRATEGY') in ['free', 'host_pinned'] else 2 }}"
|
||||||
|
|
||||||
|
- hosts: localhosts
|
||||||
|
gather_facts: false
|
||||||
|
strategy: "{{ lookup('env', 'SELECTED_STRATEGY') }}"
|
||||||
|
tasks:
|
||||||
- block:
|
- block:
|
||||||
- name: "Test 1 (max throttle: 3)"
|
- name: "Test 1 (max throttle: 3)"
|
||||||
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 3"
|
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 3"
|
||||||
|
vars:
|
||||||
|
test_id: 1
|
||||||
throttle: 3
|
throttle: 3
|
||||||
- block:
|
- block:
|
||||||
- name: "Test 2 (max throttle: 5)"
|
- name: "Test 2 (max throttle: 5)"
|
||||||
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 5"
|
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 5"
|
||||||
throttle: 5
|
throttle: 5
|
||||||
|
vars:
|
||||||
|
test_id: 2
|
||||||
- block:
|
- block:
|
||||||
- name: "Test 3 (max throttle: 8)"
|
- name: "Test 3 (max throttle: 8)"
|
||||||
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 8"
|
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 8"
|
||||||
throttle: 8
|
throttle: 8
|
||||||
throttle: 6
|
throttle: 6
|
||||||
|
vars:
|
||||||
|
test_id: 3
|
||||||
- block:
|
- block:
|
||||||
- block:
|
- block:
|
||||||
- name: "Test 4 (max throttle: 8)"
|
- name: "Test 4 (max throttle: 8)"
|
||||||
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 8"
|
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 8"
|
||||||
throttle: 8
|
throttle: 8
|
||||||
|
vars:
|
||||||
|
test_id: 4
|
||||||
throttle: 6
|
throttle: 6
|
||||||
throttle: 12
|
throttle: 12
|
||||||
throttle: 15
|
throttle: 15
|
||||||
- block:
|
- block:
|
||||||
- name: "Test 1 (max throttle: 3)"
|
- name: "Teat 5 (max throttle: 3)"
|
||||||
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 3"
|
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 3"
|
||||||
|
vars:
|
||||||
|
test_id: 5
|
||||||
throttle: 3
|
throttle: 3
|
||||||
- block:
|
- block:
|
||||||
- name: "Test 2 (max throttle: 5)"
|
- name: "Test 6 (max throttle: 5)"
|
||||||
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 5"
|
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 5"
|
||||||
throttle: 5
|
throttle: 5
|
||||||
|
vars:
|
||||||
|
test_id: 6
|
||||||
- block:
|
- block:
|
||||||
- name: "Test 3 (max throttle: 6)"
|
- name: "Test 7 (max throttle: 6)"
|
||||||
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 6"
|
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 6"
|
||||||
throttle: 6
|
throttle: 6
|
||||||
|
vars:
|
||||||
|
test_id: 7
|
||||||
throttle: 3
|
throttle: 3
|
||||||
- block:
|
- block:
|
||||||
- block:
|
- block:
|
||||||
- name: "Test 4 (max throttle: 8)"
|
- name: "Test 8 (max throttle: 8)"
|
||||||
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 8"
|
script: "test_throttle.py {{throttledir}} {{inventory_hostname}} 8"
|
||||||
throttle: 8
|
throttle: 8
|
||||||
|
vars:
|
||||||
|
test_id: 8
|
||||||
throttle: 6
|
throttle: 6
|
||||||
throttle: 4
|
throttle: 4
|
||||||
throttle: 2
|
throttle: 2
|
||||||
|
Loading…
Reference in New Issue