mirror of
https://github.com/ansible/awx.git
synced 2026-04-07 02:59:21 -02:30
Merge pull request #13976 from john-westcott-iv/collection_job_wait_remove_depreciated_field_check
Change the job_wait integration test
This commit is contained in:
@@ -9,168 +9,156 @@
|
|||||||
jt_name: "AWX-Collection-tests-job_wait-long_running-{{ test_id }}"
|
jt_name: "AWX-Collection-tests-job_wait-long_running-{{ test_id }}"
|
||||||
proj_name: "AWX-Collection-tests-job_wait-long_running-{{ test_id }}"
|
proj_name: "AWX-Collection-tests-job_wait-long_running-{{ test_id }}"
|
||||||
|
|
||||||
- name: Assure that the demo project exists
|
- block:
|
||||||
project:
|
- name: Create a project
|
||||||
name: "{{ proj_name }}"
|
project:
|
||||||
scm_type: 'git'
|
name: "{{ proj_name }}"
|
||||||
scm_url: 'https://github.com/ansible/test-playbooks.git'
|
scm_type: 'git'
|
||||||
scm_update_on_launch: true
|
scm_url: 'https://github.com/ansible/test-playbooks.git'
|
||||||
organization: Default
|
scm_update_on_launch: true
|
||||||
|
organization: Default
|
||||||
|
|
||||||
- name: Create a job template
|
- name: Create a job template
|
||||||
job_template:
|
job_template:
|
||||||
name: "{{ jt_name }}"
|
name: "{{ jt_name }}"
|
||||||
playbook: "sleep.yml"
|
playbook: "sleep.yml"
|
||||||
job_type: run
|
job_type: run
|
||||||
project: "{{ proj_name }}"
|
project: "{{ proj_name }}"
|
||||||
inventory: "Demo Inventory"
|
inventory: "Demo Inventory"
|
||||||
extra_vars:
|
extra_vars:
|
||||||
sleep_interval: 300
|
sleep_interval: 600
|
||||||
|
|
||||||
- name: Validate that interval superceeds min/max
|
- name: Check module fails with correct msg
|
||||||
job_wait:
|
job_wait:
|
||||||
min_interval: 10
|
job_id: "99999999"
|
||||||
max_interval: 20
|
register: result
|
||||||
interval: 12
|
ignore_errors: true
|
||||||
job_id: "99999999"
|
|
||||||
register: result
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.msg =='Unable to wait on job 99999999; that ID does not exist.' or
|
- result is failed
|
||||||
'min and max interval have been depricated, please use interval instead, interval will be set to 12'"
|
- "result.msg =='Unable to wait, no job_id 99999999 found: The requested object could not be found.' or
|
||||||
|
'Unable to wait on job 99999999; that ID does not exist.'"
|
||||||
|
|
||||||
- name: Check module fails with correct msg
|
- name: Launch Demo Job Template (take happy path)
|
||||||
job_wait:
|
job_launch:
|
||||||
job_id: "99999999"
|
job_template: "Demo Job Template"
|
||||||
register: result
|
register: job
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- job is changed
|
||||||
- "result.msg =='Unable to wait, no job_id 99999999 found: The requested object could not be found.' or
|
|
||||||
'Unable to wait on job 99999999; that ID does not exist.'"
|
|
||||||
|
|
||||||
- name: Launch Demo Job Template (take happy path)
|
- name: Wait for the Job to finish
|
||||||
job_launch:
|
job_wait:
|
||||||
job_template: "Demo Job Template"
|
job_id: "{{ job.id }}"
|
||||||
register: job
|
register: wait_results
|
||||||
|
|
||||||
- assert:
|
# Make sure it worked and that we have some data in our results
|
||||||
that:
|
- assert:
|
||||||
- job is changed
|
that:
|
||||||
|
- wait_results is successful
|
||||||
|
- "'elapsed' in wait_results"
|
||||||
|
- "'id' in wait_results"
|
||||||
|
|
||||||
- name: Wait for the Job to finish
|
- name: Launch a long running job
|
||||||
job_wait:
|
job_launch:
|
||||||
job_id: "{{ job.id }}"
|
job_template: "{{ jt_name }}"
|
||||||
register: wait_results
|
register: job
|
||||||
|
|
||||||
# Make sure it worked and that we have some data in our results
|
- assert:
|
||||||
- assert:
|
that:
|
||||||
that:
|
- job is changed
|
||||||
- wait_results is successful
|
|
||||||
- "'elapsed' in wait_results"
|
|
||||||
- "'id' in wait_results"
|
|
||||||
|
|
||||||
- name: Launch a long running job
|
- name: Timeout waiting for the job to complete
|
||||||
job_launch:
|
job_wait:
|
||||||
job_template: "{{ jt_name }}"
|
job_id: "{{ job.id }}"
|
||||||
register: job
|
timeout: 5
|
||||||
|
ignore_errors: true
|
||||||
|
register: wait_results
|
||||||
|
|
||||||
- assert:
|
# Make sure that we failed and that we have some data in our results
|
||||||
that:
|
- assert:
|
||||||
- job is changed
|
that:
|
||||||
|
- "wait_results.msg == 'Monitoring aborted due to timeout' or 'Timeout waiting for job to finish.'"
|
||||||
|
- "'id' in wait_results"
|
||||||
|
|
||||||
- name: Timeout waiting for the job to complete
|
- name: Async cancel the long running job
|
||||||
job_wait:
|
job_cancel:
|
||||||
job_id: "{{ job.id }}"
|
job_id: "{{ job.id }}"
|
||||||
timeout: 5
|
async: 3600
|
||||||
ignore_errors: true
|
poll: 0
|
||||||
register: wait_results
|
|
||||||
|
|
||||||
# Make sure that we failed and that we have some data in our results
|
- name: Wait for the job to exit on cancel
|
||||||
- assert:
|
job_wait:
|
||||||
that:
|
job_id: "{{ job.id }}"
|
||||||
- "wait_results.msg == 'Monitoring aborted due to timeout' or 'Timeout waiting for job to finish.'"
|
register: wait_results
|
||||||
- "'id' in wait_results"
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Async cancel the long running job
|
- assert:
|
||||||
job_cancel:
|
that:
|
||||||
job_id: "{{ job.id }}"
|
- wait_results is failed
|
||||||
async: 3600
|
- 'wait_results.status == "canceled"'
|
||||||
poll: 0
|
- "wait_results.msg == 'Job with id {{ job.id }} failed' or 'Job with id={{ job.id }} failed, error: Job failed.'"
|
||||||
|
|
||||||
- name: Wait for the job to exit on cancel
|
# workflow wait test
|
||||||
job_wait:
|
- name: Generate a random string for test
|
||||||
job_id: "{{ job.id }}"
|
set_fact:
|
||||||
register: wait_results
|
test_id1: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
ignore_errors: true
|
when: test_id1 is not defined
|
||||||
|
|
||||||
- assert:
|
- name: Generate names
|
||||||
that:
|
set_fact:
|
||||||
- wait_results is failed
|
wfjt_name2: "AWX-Collection-tests-workflow_launch--wfjt1-{{ test_id1 }}"
|
||||||
- 'wait_results.status == "canceled"'
|
|
||||||
- "wait_results.msg == 'Job with id {{ job.id }} failed' or 'Job with id={{ job.id }} failed, error: Job failed.'"
|
|
||||||
|
|
||||||
- name: Delete the job template
|
- name: Create our workflow
|
||||||
job_template:
|
workflow_job_template:
|
||||||
name: "{{ jt_name }}"
|
name: "{{ wfjt_name2 }}"
|
||||||
playbook: "sleep.yml"
|
state: present
|
||||||
job_type: run
|
|
||||||
project: "{{ proj_name }}"
|
|
||||||
inventory: "Demo Inventory"
|
|
||||||
state: absent
|
|
||||||
|
|
||||||
- name: Delete the project
|
- name: Add a node
|
||||||
project:
|
workflow_job_template_node:
|
||||||
name: "{{ proj_name }}"
|
workflow_job_template: "{{ wfjt_name2 }}"
|
||||||
organization: Default
|
unified_job_template: "Demo Job Template"
|
||||||
state: absent
|
identifier: leaf
|
||||||
|
register: new_node
|
||||||
|
|
||||||
# workflow wait test
|
- name: Kick off a workflow
|
||||||
- name: Generate a random string for test
|
workflow_launch:
|
||||||
set_fact:
|
workflow_template: "{{ wfjt_name2 }}"
|
||||||
test_id1: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
ignore_errors: true
|
||||||
when: test_id1 is not defined
|
register: workflow
|
||||||
|
|
||||||
- name: Generate names
|
- name: Wait for the Workflow Job to finish
|
||||||
set_fact:
|
job_wait:
|
||||||
wfjt_name2: "AWX-Collection-tests-workflow_launch--wfjt1-{{ test_id1 }}"
|
job_id: "{{ workflow.job_info.id }}"
|
||||||
|
job_type: "workflow_jobs"
|
||||||
|
register: wait_workflow_results
|
||||||
|
|
||||||
- name: Create our workflow
|
# Make sure it worked and that we have some data in our results
|
||||||
workflow_job_template:
|
- assert:
|
||||||
name: "{{ wfjt_name2 }}"
|
that:
|
||||||
state: present
|
- wait_workflow_results is successful
|
||||||
|
- "'elapsed' in wait_workflow_results"
|
||||||
|
- "'id' in wait_workflow_results"
|
||||||
|
|
||||||
- name: Add a node
|
always:
|
||||||
workflow_job_template_node:
|
- name: Clean up test workflow
|
||||||
workflow_job_template: "{{ wfjt_name2 }}"
|
workflow_job_template:
|
||||||
unified_job_template: "Demo Job Template"
|
name: "{{ wfjt_name2 }}"
|
||||||
identifier: leaf
|
state: absent
|
||||||
register: new_node
|
|
||||||
|
|
||||||
- name: Kick off a workflow
|
- name: Delete the job template
|
||||||
workflow_launch:
|
job_template:
|
||||||
workflow_template: "{{ wfjt_name2 }}"
|
name: "{{ jt_name }}"
|
||||||
ignore_errors: true
|
playbook: "sleep.yml"
|
||||||
register: workflow
|
job_type: run
|
||||||
|
project: "{{ proj_name }}"
|
||||||
|
inventory: "Demo Inventory"
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Wait for the Workflow Job to finish
|
- name: Delete the project
|
||||||
job_wait:
|
project:
|
||||||
job_id: "{{ workflow.job_info.id }}"
|
name: "{{ proj_name }}"
|
||||||
job_type: "workflow_jobs"
|
organization: Default
|
||||||
register: wait_workflow_results
|
state: absent
|
||||||
|
|
||||||
# Make sure it worked and that we have some data in our results
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- wait_workflow_results is successful
|
|
||||||
- "'elapsed' in wait_workflow_results"
|
|
||||||
- "'id' in wait_workflow_results"
|
|
||||||
|
|
||||||
- name: Clean up test workflow
|
|
||||||
workflow_job_template:
|
|
||||||
name: "{{ wfjt_name2 }}"
|
|
||||||
state: absent
|
|
||||||
|
|||||||
Reference in New Issue
Block a user