mirror of
https://github.com/ansible/awx.git
synced 2026-05-16 13:57:39 -02:30
Initial cut at tower_job_wait conversion
This commit is contained in:
committed by
beeankha
parent
5f62426684
commit
7494ba7b9c
@@ -1,18 +1,24 @@
|
||||
---
|
||||
- name: Launch a Job Template
|
||||
tower_job_launch:
|
||||
job_template: "Demo Job Template"
|
||||
register: job
|
||||
- name: generate random string for template and project
|
||||
set_fact:
|
||||
jt_name: "AWX-Collection-tests-tower_job_wait-long_running-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||
proj_name: "AWX-Collection-tests-tower_job_wait-long_running-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "job is changed"
|
||||
- "job.status == 'pending'"
|
||||
- name: Assure that demo project exists
|
||||
tower_project:
|
||||
name: "{{ proj_name }}"
|
||||
scm_type: 'git'
|
||||
scm_url: 'https://github.com/ansible/test-playbooks.git'
|
||||
scm_update_on_launch: true
|
||||
organization: Default
|
||||
|
||||
- name: Wait for the Job to finish
|
||||
tower_job_wait:
|
||||
job_id: "{{ job.id }}"
|
||||
timeout: 60
|
||||
- name: Create a job template
|
||||
tower_job_template:
|
||||
name: "{{ jt_name }}"
|
||||
playbook: "sleep.yml"
|
||||
job_type: run
|
||||
project: "{{ proj_name }}"
|
||||
inventory: "Demo Inventory"
|
||||
|
||||
- name: Check module fails with correct msg
|
||||
tower_job_wait:
|
||||
@@ -22,4 +28,80 @@
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.msg =='Unable to wait, no job_id 99999999 found: The requested object could not be found.'"
|
||||
- result is failed
|
||||
- "result.msg =='Unable to wait, on job 99999999 that ID does not exist in Tower.'"
|
||||
|
||||
- name: Launch Demo Job Template (take happy path)
|
||||
tower_job_launch:
|
||||
job_template: "Jenkins Export Vars"
|
||||
register: job
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- job is changed
|
||||
- "job.status == 'pending'"
|
||||
|
||||
- name: Wait for the Job to finish
|
||||
tower_job_wait:
|
||||
job_id: "{{ job.id }}"
|
||||
register: wait_results
|
||||
|
||||
# Make sure we worked and that we have some data in our results
|
||||
- assert:
|
||||
that:
|
||||
- wait_results is successful
|
||||
- "'elapsed' in wait_results"
|
||||
- "'id' in wait_results"
|
||||
|
||||
- name: Launch a long running job
|
||||
tower_job_launch:
|
||||
job_template: "{{ jt_name }}"
|
||||
register: job
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- job is changed
|
||||
- "job.status == 'pending'"
|
||||
|
||||
- name: Timeout waiting for the job to complete
|
||||
tower_job_wait:
|
||||
job_id: "{{ job.id }}"
|
||||
timeout: 5
|
||||
ignore_errors: True
|
||||
register: wait_results
|
||||
|
||||
# Make sure that we failed and that we have some data in our results
|
||||
- assert:
|
||||
that:
|
||||
- wait_results is failed
|
||||
- "wait_results.msg == 'Monitoring aborted due to timeout'"
|
||||
- "'id' in wait_results"
|
||||
|
||||
- name: Async cancel the long running job
|
||||
tower_job_cancel:
|
||||
job_id: "{{ job.id }}"
|
||||
async: 3600
|
||||
poll: 0
|
||||
|
||||
- name: Wait for the job to exit on cancel
|
||||
tower_job_wait:
|
||||
job_id: "{{ job.id }}"
|
||||
register: wait_results
|
||||
ignore_errors: True
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- wait_results is failed
|
||||
- 'wait_results.status == "canceled"'
|
||||
- "wait_results.msg == 'Job with id {{ job.id }} failed'"
|
||||
|
||||
- name: Delete the job template
|
||||
tower_job_template:
|
||||
name: "{{ jt_name }}"
|
||||
state: absent
|
||||
|
||||
- name: Delete the project
|
||||
tower_project:
|
||||
name: "{{ proj_name }}"
|
||||
organization: Default
|
||||
state: absent
|
||||
|
||||
Reference in New Issue
Block a user