tests: Add a simple benchmarking playbook

The playbook creates a specified number of fake hosts (as localhost)
and runs a task file against them a specified number of times.

By default it will create 25 hosts and run 50 tasks against them,
providing 1250 results.

Change-Id: I88642041d8cee3c11f9d993d6dca245d7eb33f8e
This commit is contained in:
David Moreau Simard 2020-10-14 20:29:53 -04:00
parent 40894c7027
commit f6df57d25c
No known key found for this signature in database
GPG Key ID: 7D4729EC4E64E8B7
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,29 @@
# Copyright (c) 2020 The ARA Records Ansible authors
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Create many hosts
hosts: localhost
gather_facts: no
vars:
benchmark_host_count: 25
tasks:
- name: Add a host to the inventory
add_host:
ansible_connection: local
hostname: "host-{{ item }}"
groups: benchmark
with_sequence: start=1 end={{ benchmark_host_count }}
- name: Run tasks on many hosts
hosts: benchmark
vars:
benchmark_task_file: "{{ playbook_dir }}/benchmark_tasks.yaml"
# Run N tasks per host
benchmark_task_count: 50
# Off by default to prevent accidental load spike on localhost
benchmark_gather_facts: no
gather_facts: "{{ benchmark_gather_facts }}"
tasks:
- name: Include a task file
include_tasks: "{{ benchmark_task_file }}"
with_sequence: start=1 end={{ benchmark_task_count }}

View File

@ -0,0 +1,8 @@
# Copyright (c) 2020 The ARA Records Ansible authors
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# These are tasks meant to be imported by benchmark.yaml
- name: Run a task
debug:
msg: "{{ inventory_hostname }} running task #{{ item }}"