commit f6df57d25c9c62d3f23eac0e2d13a0f8aeb85631 Author: David Moreau Simard Date: Wed Oct 14 20:29:53 2020 -0400 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 diff --git a/tests/integration/benchmark.yaml b/tests/integration/benchmark.yaml new file mode 100644 index 0000000..74ac38d --- /dev/null +++ b/tests/integration/benchmark.yaml @@ -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 }} diff --git a/tests/integration/benchmark_tasks.yaml b/tests/integration/benchmark_tasks.yaml new file mode 100644 index 0000000..d6df989 --- /dev/null +++ b/tests/integration/benchmark_tasks.yaml @@ -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 }}"