From 44be415dcadf602ff3c33aa2fa897b8f7d87acb4 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 13 Apr 2022 13:15:07 -0400 Subject: [PATCH] add long-running-job-test.yml; tasks/long_running_tasks.yml; and dev testing scripts --- long-running-job-test.yml | 15 ++++++++------ tasks/long_running_tasks.yml | 40 ++++++++++++++++++++++++++++++++++++ utils/dev_tower_test.sh | 6 +++--- utils/dev_tower_test_2.sh | 24 ++++++++++++++++++++++ 4 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 tasks/long_running_tasks.yml create mode 100644 utils/dev_tower_test_2.sh diff --git a/long-running-job-test.yml b/long-running-job-test.yml index 867b283..2de57fa 100644 --- a/long-running-job-test.yml +++ b/long-running-job-test.yml @@ -6,16 +6,19 @@ vars: - time_to_sleep : 300 - run_cmd : "find /" + pause_time : 60 + num_retries : 1440 poll_interval : 3 + check_commands: + - uname -a + - uptime + - ping -c 1 127.0.0.1 + tasks: - - name: Simulate a long running job - command : "{{ run_cmd }}" - async : "{{ time_to_sleep + 10 }}" # give +10s leeway - poll : "{{ poll_interval }}" + - name: Include long_running_tasks.yml + include_tasks: tasks/long_running_tasks.yml ... diff --git a/tasks/long_running_tasks.yml b/tasks/long_running_tasks.yml new file mode 100644 index 0000000..ab0cab0 --- /dev/null +++ b/tasks/long_running_tasks.yml @@ -0,0 +1,40 @@ +--- +- name: Run a series of test commands + command : "{{ item }}" + until : t_cmd.rc == 0 + retries : "{{ num_retries }}" + delay : "{{ poll_interval }}" + loop : "{{ check_commands }}" + register : t_cmd + + +- name: Increment counter + set_fact: + rcount: "{{ 1 if rcount is undefined else rcount | int + 1 }}" + + +- name: End condition met. Aborting... + fail: + msg: "Bye" + when: rcount|int >= num_retries + + +- name: Current status + debug: + msg: "Currently on run {{ rcount }} of {{ num_retries }}." + run_once: yes + + +- name: Pause for {{ pause_time }} seconds + pause: + seconds: "{{ pause_time }}" + + +- name: Include ourself for recursion + include_tasks: tasks/long_running_tasks.yml + + + + + +... diff --git a/utils/dev_tower_test.sh b/utils/dev_tower_test.sh index 8ec0126..86ba4da 100644 --- a/utils/dev_tower_test.sh +++ b/utils/dev_tower_test.sh @@ -1,9 +1,9 @@ #!/bin/bash -CONC="50" -REQU="100" +CONC="5" +REQU="50" -BASE_URL="10.1.1.51" +BASE_URL="10.1.1.98" AAP_JOB_ID="10" POST_PAYLOAD_PATH="empty.post" #POST_PAYLOAD_PATH="provision.post" diff --git a/utils/dev_tower_test_2.sh b/utils/dev_tower_test_2.sh new file mode 100644 index 0000000..e5e5dec --- /dev/null +++ b/utils/dev_tower_test_2.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +CONC="50" +REQU="50" + +BASE_URL="10.1.1.98" +AAP_JOB_ID="12" +POST_PAYLOAD_PATH="empty.post" +#POST_PAYLOAD_PATH="provision.post" +POST_PAYLOAD_TYPE="application/json" + +TOWER_USER="admin" +TOWER_PASS="redhat" + + +printf "\n%s\n" \ + "# Running test - ${REQU} requests / ${CONC} concurrency" + ab -c "${CONC}" \ + -n ${REQU} \ + -A ${TOWER_USER}:${TOWER_PASS} \ + -T "${POST_PAYLOAD_TYPE}" \ + -v1 \ + -p ${POST_PAYLOAD_PATH} "https://${BASE_URL}/api/v2/job_templates/${AAP_JOB_ID}/launch/" | \ + grep "Failed requests\|Time taken for tests"