Skip to content

Commit

Permalink
Sort the list of modules based on a hash of their name (#969)
Browse files Browse the repository at this point in the history
Sort the list of modules based on a hash of their name

The AWS modules have a lot of 'slow' tests with related names.  If we hash the list we reduce the chance that they clump together

Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
  • Loading branch information
tremble authored Jun 28, 2021
1 parent f57a9bb commit f8fa3e9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions roles/ansible-test/tasks/split_targets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
- set_fact:
_start_at: "{{ number_entries|int // ansible_test_split_in * (ansible_test_do_number -1)|int }}"
_end_at: "{{ (number_entries|int // ansible_test_split_in * (ansible_test_do_number |int)) }}"
- debug:
msg: "Do roles: {{ ansible_test_targets.stdout_lines[_start_at|int:_end_at|int] }}"
# Slow tests tend to be closely related. Hash the names to produce a repeatable
# list that avoids bringing those tests all into one group
- set_fact:
_hashed_targets: "{{ ( _hashed_targets | default([])) + [ { 'name': item, 'hash': (item | hash('md5')) } ] }}"
loop: '{{ ansible_test_targets.stdout_lines }}'
- set_fact:
_integration_targets: "{{ ansible_test_targets.stdout_lines[_start_at|int:_end_at|int]|join(' ') }}"
sorted_test_targets: "{{ _hashed_targets | sort(attribute='hash') | map(attribute='name') | list }}"
- set_fact:
_integration_targets: "{{ sorted_test_targets[_start_at|int:_end_at|int]|sort|join(' ') }}"
- debug:
msg: "Do roles: {{ _integration_targets }}"

0 comments on commit f8fa3e9

Please sign in to comment.