Updating workflow job template collection test (#12468)

Adding additional use case

Fixing error with workflow calling itslef

Adding better cleanup of assets created as part of the test
This commit is contained in:
John Westcott IV
2022-07-11 16:07:07 -04:00
committed by GitHub
parent de17cff39c
commit 6279295541

View File

@@ -14,30 +14,38 @@
approval_node_name: "AWX-Collection-tests-workflow_approval_node-{{ test_id }}" approval_node_name: "AWX-Collection-tests-workflow_approval_node-{{ test_id }}"
lab1: "AWX-Collection-tests-job_template-lab1-{{ test_id }}" lab1: "AWX-Collection-tests-job_template-lab1-{{ test_id }}"
wfjt_name: "AWX-Collection-tests-workflow_job_template-wfjt-{{ test_id }}" wfjt_name: "AWX-Collection-tests-workflow_job_template-wfjt-{{ test_id }}"
webhook_wfjt_name: "AWX-Collection-tests-workflow_job_template-webhook-wfjt-{{ test_id }}"
email_not: "AWX-Collection-tests-job_template-email-not-{{ test_id }}" email_not: "AWX-Collection-tests-job_template-email-not-{{ test_id }}"
webhook_not: "AWX-Collection-tests-notification_template-wehbook-not-{{ test_id }}" webhook_notification: "AWX-Collection-tests-notification_template-wehbook-not-{{ test_id }}"
project_inv: "AWX-Collection-tests-inventory_source-inv-project-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" project_inv: "AWX-Collection-tests-inventory_source-inv-project-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
project_inv_source: "AWX-Collection-tests-inventory_source-inv-source-project-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" project_inv_source: "AWX-Collection-tests-inventory_source-inv-source-project-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
github_webhook_credential_name: "AWX-Collection-tests-credential-webhook-{{ test_id }}_github"
- name: "Create a new organization" - block:
- name: "Create a new organization"
organization: organization:
name: "{{ org_name }}" name: "{{ org_name }}"
galaxy_credentials: galaxy_credentials:
- Ansible Galaxy - Ansible Galaxy
register: result register: result
- name: Create an SCM Credential - name: Create Credentials
credential: credential:
name: "{{ scm_cred_name }}" name: "{{ item.name }}"
organization: Default organization: Default
credential_type: Source Control credential_type: "{{ item.type }}"
register: result register: result
loop:
- name: "{{ scm_cred_name }}"
type: Source Control
- name: "{{ github_webhook_credential_name }}"
type: GitHub Personal Access Token
- assert: - assert:
that: that:
- "result is changed" - "result is changed"
- name: Add email notification - name: Add email notification
notification_template: notification_template:
name: "{{ email_not }}" name: "{{ email_not }}"
organization: Default organization: Default
@@ -54,9 +62,9 @@
use_ssl: false use_ssl: false
state: present state: present
- name: Add webhook notification - name: Add webhook notification
notification_template: notification_template:
name: "{{ webhook_not }}" name: "{{ webhook_notification }}"
organization: Default organization: Default
notification_type: webhook notification_type: webhook
notification_configuration: notification_configuration:
@@ -66,7 +74,7 @@
state: present state: present
register: result register: result
- name: Create Labels - name: Create Labels
label: label:
name: "{{ lab1 }}" name: "{{ lab1 }}"
organization: "{{ item }}" organization: "{{ item }}"
@@ -74,7 +82,7 @@
- Default - Default
- "{{ org_name }}" - "{{ org_name }}"
- name: Create a Demo Project - name: Create a Demo Project
project: project:
name: "{{ demo_project_name }}" name: "{{ demo_project_name }}"
organization: Default organization: Default
@@ -84,11 +92,11 @@
scm_credential: "{{ scm_cred_name }}" scm_credential: "{{ scm_cred_name }}"
register: result register: result
- assert: - assert:
that: that:
- "result is changed" - "result is changed"
- name: Create a 2nd Demo Project in another org - name: Create a 2nd Demo Project in another org
project: project:
name: "{{ demo_project_name_2 }}" name: "{{ demo_project_name_2 }}"
organization: "{{ org_name }}" organization: "{{ org_name }}"
@@ -98,17 +106,17 @@
scm_credential: "{{ scm_cred_name }}" scm_credential: "{{ scm_cred_name }}"
register: result register: result
- assert: - assert:
that: that:
- "result is changed" - "result is changed"
- name: Add an inventory - name: Add an inventory
inventory: inventory:
description: Test inventory description: Test inventory
organization: Default organization: Default
name: "{{ project_inv }}" name: "{{ project_inv }}"
- name: Create a source inventory - name: Create a source inventory
inventory_source: inventory_source:
name: "{{ project_inv_source }}" name: "{{ project_inv_source }}"
description: Source for Test inventory description: Source for Test inventory
@@ -119,11 +127,11 @@
source: scm source: scm
register: project_inv_source_result register: project_inv_source_result
- assert: - assert:
that: that:
- "project_inv_source_result is changed" - "project_inv_source_result is changed"
- name: Create a Job Template - name: Create a Job Template
job_template: job_template:
name: "{{ jt1_name }}" name: "{{ jt1_name }}"
project: "{{ demo_project_name }}" project: "{{ demo_project_name }}"
@@ -133,11 +141,11 @@
state: present state: present
register: result register: result
- assert: - assert:
that: that:
- "result is changed" - "result is changed"
- name: Create a second Job Template - name: Create a second Job Template
job_template: job_template:
name: "{{ jt2_name }}" name: "{{ jt2_name }}"
project: "{{ demo_project_name }}" project: "{{ demo_project_name }}"
@@ -147,11 +155,11 @@
state: present state: present
register: result register: result
- assert: - assert:
that: that:
- "result is changed" - "result is changed"
- name: Create a second Job Template in new org - name: Create a second Job Template in new org
job_template: job_template:
name: "{{ jt2_name }}" name: "{{ jt2_name }}"
project: "{{ demo_project_name_2 }}" project: "{{ demo_project_name_2 }}"
@@ -161,11 +169,11 @@
state: present state: present
register: jt2_name_result register: jt2_name_result
- assert: - assert:
that: that:
- "jt2_name_result is changed" - "jt2_name_result is changed"
- name: Add a Survey to second Job Template - name: Add a Survey to second Job Template
job_template: job_template:
name: "{{ jt2_name }}" name: "{{ jt2_name }}"
organization: Default organization: Default
@@ -178,11 +186,11 @@
survey_spec: '{"spec": [{"index": 0, "question_name": "my question?", "default": "mydef", "variable": "myvar", "type": "text", "required": false}], "description": "test", "name": "test"}' survey_spec: '{"spec": [{"index": 0, "question_name": "my question?", "default": "mydef", "variable": "myvar", "type": "text", "required": false}], "description": "test", "name": "test"}'
register: result register: result
- assert: - assert:
that: that:
- "result is changed" - "result is changed"
- name: Create a workflow job template - name: Create a workflow job template
workflow_job_template: workflow_job_template:
name: "{{ wfjt_name }}" name: "{{ wfjt_name }}"
organization: Default organization: Default
@@ -196,11 +204,11 @@
ask_variables_on_launch: true ask_variables_on_launch: true
register: result register: result
- assert: - assert:
that: that:
- "result is changed" - "result is changed"
- name: Create a workflow job template with bad label - name: Create a workflow job template with bad label
workflow_job_template: workflow_job_template:
name: "{{ wfjt_name }}" name: "{{ wfjt_name }}"
organization: Default organization: Default
@@ -215,12 +223,12 @@
register: bad_label_results register: bad_label_results
ignore_errors: true ignore_errors: true
- assert: - assert:
that: that:
- "bad_label_results.msg == 'Could not find label entry with name label_bad'" - "bad_label_results.msg == 'Could not find label entry with name label_bad'"
# Turn off ask_ * settings to test that the issue/10057 has been fixed # Turn off ask_ * settings to test that the issue/10057 has been fixed
- name: Turn ask_* settings OFF - name: Turn ask_* settings OFF
tower_workflow_job_template: tower_workflow_job_template:
name: "{{ wfjt_name }}" name: "{{ wfjt_name }}"
ask_inventory_on_launch: false ask_inventory_on_launch: false
@@ -229,25 +237,25 @@
ask_variables_on_launch: false ask_variables_on_launch: false
state: present state: present
- assert: - assert:
that: that:
- "result is changed" - "result is changed"
# Node actions do what the schema command used to do # Node actions do what the schema command used to do
- name: Create leaf node - name: Create leaf node
workflow_job_template_node: workflow_job_template_node:
identifier: leaf identifier: leaf
unified_job_template: "{{ jt2_name }}" unified_job_template: "{{ jt2_name }}"
lookup_organization: "{{ org_name }}" lookup_organization: "{{ org_name }}"
workflow: "{{ wfjt_name }}" workflow: "{{ wfjt_name }}"
- name: Create root node - name: Create root node
workflow_job_template_node: workflow_job_template_node:
identifier: root identifier: root
unified_job_template: "{{ jt1_name }}" unified_job_template: "{{ jt1_name }}"
workflow: "{{ wfjt_name }}" workflow: "{{ wfjt_name }}"
- name: Fail if no name is set for approval - name: Fail if no name is set for approval
workflow_job_template_node: workflow_job_template_node:
identifier: approval_test identifier: approval_test
approval_node: approval_node:
@@ -256,11 +264,11 @@
register: no_name_results register: no_name_results
ignore_errors: true ignore_errors: true
- assert: - assert:
that: that:
- "no_name_results.msg == 'Approval node name is required to create approval node.'" - "no_name_results.msg == 'Approval node name is required to create approval node.'"
- name: Fail if absent and no identifier set - name: Fail if absent and no identifier set
workflow_job_template_node: workflow_job_template_node:
approval_node: approval_node:
description: "{{ approval_node_name }}" description: "{{ approval_node_name }}"
@@ -269,22 +277,22 @@
register: no_identifier_results register: no_identifier_results
ignore_errors: true ignore_errors: true
- assert: - assert:
that: that:
- "no_identifier_results.msg == 'missing required arguments: identifier'" - "no_identifier_results.msg == 'missing required arguments: identifier'"
- name: Fail if present and no unified job template set - name: Fail if present and no unified job template set
workflow_job_template_node: workflow_job_template_node:
identifier: approval_test identifier: approval_test
workflow: "{{ wfjt_name }}" workflow: "{{ wfjt_name }}"
register: no_unified_results register: no_unified_results
ignore_errors: true ignore_errors: true
- assert: - assert:
that: that:
- "no_unified_results.msg == 'state is present but any of the following are missing: unified_job_template, approval_node, success_nodes, always_nodes, failure_nodes'" - "no_unified_results.msg == 'state is present but any of the following are missing: unified_job_template, approval_node, success_nodes, always_nodes, failure_nodes'"
- name: Create approval node - name: Create approval node
workflow_job_template_node: workflow_job_template_node:
identifier: approval_test identifier: approval_test
approval_node: approval_node:
@@ -292,7 +300,7 @@
timeout: 900 timeout: 900
workflow: "{{ wfjt_name }}" workflow: "{{ wfjt_name }}"
- name: Create link for root node - name: Create link for root node
workflow_job_template_node: workflow_job_template_node:
identifier: root identifier: root
workflow: "{{ wfjt_name }}" workflow: "{{ wfjt_name }}"
@@ -301,7 +309,7 @@
always_nodes: always_nodes:
- leaf - leaf
- name: Delete approval node - name: Delete approval node
workflow_job_template_node: workflow_job_template_node:
identifier: approval_test identifier: approval_test
approval_node: approval_node:
@@ -309,54 +317,54 @@
state: absent state: absent
workflow: "{{ wfjt_name }}" workflow: "{{ wfjt_name }}"
- name: Add started notifications to workflow job template - name: Add started notifications to workflow job template
workflow_job_template: workflow_job_template:
name: "{{ wfjt_name }}" name: "{{ wfjt_name }}"
notification_templates_started: notification_templates_started:
- "{{ email_not }}" - "{{ email_not }}"
- "{{ webhook_not }}" - "{{ webhook_notification }}"
register: result register: result
- assert: - assert:
that: that:
- "result is changed" - "result is changed"
- name: Re Add started notifications to workflow job template - name: Re Add started notifications to workflow job template
workflow_job_template: workflow_job_template:
name: "{{ wfjt_name }}" name: "{{ wfjt_name }}"
notification_templates_started: notification_templates_started:
- "{{ email_not }}" - "{{ email_not }}"
- "{{ webhook_not }}" - "{{ webhook_notification }}"
register: result register: result
- assert: - assert:
that: that:
- "result is not changed" - "result is not changed"
- name: Add success notifications to workflow job template - name: Add success notifications to workflow job template
workflow_job_template: workflow_job_template:
name: "{{ wfjt_name }}" name: "{{ wfjt_name }}"
notification_templates_success: notification_templates_success:
- "{{ email_not }}" - "{{ email_not }}"
- "{{ webhook_not }}" - "{{ webhook_notification }}"
register: result register: result
- assert: - assert:
that: that:
- "result is changed" - "result is changed"
- name: Copy a workflow job template - name: Copy a workflow job template
workflow_job_template: workflow_job_template:
name: "copy_{{ wfjt_name }}" name: "copy_{{ wfjt_name }}"
copy_from: "{{ wfjt_name }}" copy_from: "{{ wfjt_name }}"
organization: Default organization: Default
register: result register: result
- assert: - assert:
that: that:
- result.copied - result.copied
- name: Fail Remove "on start" webhook notification from copied workflow job template - name: Fail Remove "on start" webhook notification from copied workflow job template
workflow_job_template: workflow_job_template:
name: "copy_{{ wfjt_name }}" name: "copy_{{ wfjt_name }}"
notification_templates_started: notification_templates_started:
@@ -364,24 +372,24 @@
register: remove_copied_workflow_node register: remove_copied_workflow_node
ignore_errors: true ignore_errors: true
- assert: - assert:
that: that:
- "remove_copied_workflow_node is failed" - "remove_copied_workflow_node is failed"
- "remove_copied_workflow_node is not changed" - "remove_copied_workflow_node is not changed"
- "'returned 0 items' in remove_copied_workflow_node.msg" - "'returned 0 items' in remove_copied_workflow_node.msg"
- name: Remove "on start" webhook notification from copied workflow job template - name: Remove "on start" webhook notification from copied workflow job template
workflow_job_template: workflow_job_template:
name: "copy_{{ wfjt_name }}" name: "copy_{{ wfjt_name }}"
notification_templates_started: notification_templates_started:
- "{{ email_not }}" - "{{ email_not }}"
register: result register: result
- assert: - assert:
that: that:
- "result is changed" - "result is changed"
- name: Add Survey to Copied workflow job template - name: Add Survey to Copied workflow job template
workflow_job_template: workflow_job_template:
name: "copy_{{ wfjt_name }}" name: "copy_{{ wfjt_name }}"
organization: Default organization: Default
@@ -436,11 +444,11 @@
new_question: true new_question: true
register: result register: result
- assert: - assert:
that: that:
- "result is changed" - "result is changed"
- name: Re add survey to workflow job template expected not changed. - name: Re add survey to workflow job template expected not changed.
workflow_job_template: workflow_job_template:
name: "copy_{{ wfjt_name }}" name: "copy_{{ wfjt_name }}"
organization: Default organization: Default
@@ -495,32 +503,22 @@
new_question: true new_question: true
register: result register: result
- assert: - assert:
that: that:
- "result is not changed" - "result is not changed"
- name: Delete copied workflow job template - name: Remove "on start" webhook notification from workflow job template
workflow_job_template:
name: "copy_{{ wfjt_name }}"
state: absent
register: result
- assert:
that:
- "result is changed"
- name: Remove "on start" webhook notification from workflow job template
workflow_job_template: workflow_job_template:
name: "{{ wfjt_name }}" name: "{{ wfjt_name }}"
notification_templates_started: notification_templates_started:
- "{{ email_not }}" - "{{ email_not }}"
register: result register: result
- assert: - assert:
that: that:
- "result is changed" - "result is changed"
- name: Delete a workflow job template with an invalid inventory and webook_credential - name: Delete a workflow job template with an invalid inventory and webook_credential
workflow_job_template: workflow_job_template:
name: "{{ wfjt_name }}" name: "{{ wfjt_name }}"
inventory: "Does Not Exist" inventory: "Does Not Exist"
@@ -528,25 +526,25 @@
state: absent state: absent
register: result register: result
- assert: - assert:
that: that:
- "result is changed" - "result is changed"
- name: Check module fails with correct msg - name: Check module fails with correct msg
workflow_job_template: workflow_job_template:
name: "{{ wfjt_name }}" name: "{{ wfjt_name }}"
organization: Non_Existing_Organization organization: Non_Existing_Organization
register: result register: result
ignore_errors: true ignore_errors: true
- assert: - assert:
that: that:
- "result is failed" - "result is failed"
- "result is not changed" - "result is not changed"
- "'Non_Existing_Organization' in result.msg" - "'Non_Existing_Organization' in result.msg"
- "result.total_results == 0" - "result.total_results == 0"
- name: Create a workflow job template with workflow nodes in template - name: Create a workflow job template with workflow nodes in template
awx.awx.workflow_job_template: awx.awx.workflow_job_template:
name: "{{ wfjt_name }}" name: "{{ wfjt_name }}"
inventory: Demo Inventory inventory: Demo Inventory
@@ -591,22 +589,22 @@
type: system_job type: system_job
register: result register: result
- assert: - assert:
that: that:
- "result is changed" - "result is changed"
- name: Kick off a workflow and wait for it - name: Kick off a workflow and wait for it
workflow_launch: workflow_launch:
workflow_template: "{{ wfjt_name }}" workflow_template: "{{ wfjt_name }}"
ignore_errors: true ignore_errors: true
register: result register: result
- assert: - assert:
that: that:
- result is not failed - result is not failed
- "'id' in result['job_info']" - "'id' in result['job_info']"
- name: Destroy previous workflow nodes for one that fails - name: Destroy previous workflow nodes for one that fails
awx.awx.workflow_job_template: awx.awx.workflow_job_template:
name: "{{ wfjt_name }}" name: "{{ wfjt_name }}"
destroy_current_nodes: true destroy_current_nodes: true
@@ -630,33 +628,72 @@
type: inventory_source type: inventory_source
- identifier: Workflow inception - identifier: Workflow inception
unified_job_template: unified_job_template:
name: "{{ wfjt_name }}" name: "copy_{{ wfjt_name }}"
organization: organization:
name: Default name: Default
type: workflow_job_template type: workflow_job_template
register: result register: result
- name: Kick off a workflow and wait for it - name: Delete copied workflow job template
workflow_job_template:
name: "copy_{{ wfjt_name }}"
state: absent
register: result
- assert:
that:
- "result is changed"
- name: Kick off a workflow and wait for it
workflow_launch: workflow_launch:
workflow_template: "{{ wfjt_name }}" workflow_template: "{{ wfjt_name }}"
ignore_errors: true ignore_errors: true
register: result register: result
- assert: - assert:
that: that:
- result is failed - result is failed
- name: Delete a workflow job template - name: Create a workflow job template with a GitLab webhook but a GitHub credential
awx.awx.workflow_job_template: workflow_job_template:
name: "{{ wfjt_name }}" name: "{{ webhook_wfjt_name }}"
state: absent organization: Default
inventory: Demo Inventory
webhook_service: gitlab
webhook_credential: "{{ github_webhook_credential_name }}"
ignore_errors: true
register: result register: result
- assert: - assert:
that: that:
- "result is changed" - result is failed
- "'Must match the selected webhook service' in result['msg']"
- name: Delete the Job Template - name: Create a workflow job template with a GitHub webhook and a GitHub credential
workflow_job_template:
name: "{{ webhook_wfjt_name }}"
organization: Default
inventory: Demo Inventory
webhook_service: github
webhook_credential: "{{ github_webhook_credential_name }}"
register: result
- assert:
that:
- result is not failed
always:
- name: Delete the workflow job template
awx.awx.workflow_job_template:
name: "{{ item }}"
state: absent
ignore_errors: True
loop:
- "copy_{{ wfjt_name }}"
- "{{ wfjt_name }}"
- "{{ webhook_wfjt_name }}"
- name: Delete the Job Template
job_template: job_template:
name: "{{ jt1_name }}" name: "{{ jt1_name }}"
project: "{{ demo_project_name }}" project: "{{ demo_project_name }}"
@@ -664,13 +701,9 @@
playbook: hello_world.yml playbook: hello_world.yml
job_type: run job_type: run
state: absent state: absent
register: result ignore_errors: True
- assert: - name: Delete the second Job Template
that:
- "result is changed"
- name: Delete the second Job Template
job_template: job_template:
name: "{{ jt2_name }}" name: "{{ jt2_name }}"
project: "{{ demo_project_name }}" project: "{{ demo_project_name }}"
@@ -679,13 +712,9 @@
playbook: hello_world.yml playbook: hello_world.yml
job_type: run job_type: run
state: absent state: absent
register: result ignore_errors: True
- assert: - name: Delete the second Job Template
that:
- "result is changed"
- name: Delete the second Job Template
job_template: job_template:
name: "{{ jt2_name }}" name: "{{ jt2_name }}"
project: "{{ demo_project_name_2 }}" project: "{{ demo_project_name_2 }}"
@@ -694,35 +723,25 @@
playbook: hello_world.yml playbook: hello_world.yml
job_type: run job_type: run
state: absent state: absent
register: result ignore_errors: True
- assert: - name: Delete the inventory source
that:
- "result is changed"
- name: Delete the inventory source
inventory_source: inventory_source:
name: "{{ project_inv_source }}" name: "{{ project_inv_source }}"
inventory: "{{ project_inv }}" inventory: "{{ project_inv }}"
source: scm source: scm
state: absent state: absent
ignore_errors: True
- assert: - name: Delete the inventory
that:
- "result is changed"
- name: Delete the inventory
inventory: inventory:
description: Test inventory description: Test inventory
organization: Default organization: Default
name: "{{ project_inv }}" name: "{{ project_inv }}"
state: absent state: absent
ignore_errors: True
- assert: - name: Delete the Demo Project
that:
- "result is changed"
- name: Delete the Demo Project
project: project:
name: "{{ demo_project_name }}" name: "{{ demo_project_name }}"
organization: Default organization: Default
@@ -730,9 +749,9 @@
scm_url: https://github.com/ansible/ansible-tower-samples.git scm_url: https://github.com/ansible/ansible-tower-samples.git
scm_credential: "{{ scm_cred_name }}" scm_credential: "{{ scm_cred_name }}"
state: absent state: absent
register: result ignore_errors: True
- name: Delete the 2nd Demo Project - name: Delete the 2nd Demo Project
project: project:
name: "{{ demo_project_name_2 }}" name: "{{ demo_project_name_2 }}"
organization: "{{ org_name }}" organization: "{{ org_name }}"
@@ -740,38 +759,40 @@
scm_url: https://github.com/ansible/ansible-tower-samples.git scm_url: https://github.com/ansible/ansible-tower-samples.git
scm_credential: "{{ scm_cred_name }}" scm_credential: "{{ scm_cred_name }}"
state: absent state: absent
register: result ignore_errors: True
- assert: - name: Delete the SCM Credential
that:
- "result is changed"
- name: Delete the SCM Credential
credential: credential:
name: "{{ scm_cred_name }}" name: "{{ scm_cred_name }}"
organization: Default organization: Default
credential_type: Source Control credential_type: Source Control
state: absent state: absent
register: result ignore_errors: True
- assert: - name: Delete the GitHub Webhook Credential
that: credential:
- "result is changed" name: "{{ github_webhook_credential_name }}"
organization: Default
credential_type: GitHub Personal Access Token
state: absent
ignore_errors: True
- name: Delete email notification - name: Delete email notification
notification_template: notification_template:
name: "{{ email_not }}" name: "{{ email_not }}"
organization: Default organization: Default
state: absent state: absent
ignore_errors: True
- name: Delete webhook notification - name: Delete webhook notification
notification_template: notification_template:
name: "{{ webhook_not }}" name: "{{ webhook_notification }}"
organization: Default organization: Default
state: absent state: absent
ignore_errors: True
- name: "Remove the organization" - name: "Remove the organization"
organization: organization:
name: "{{ org_name }}" name: "{{ org_name }}"
state: absent state: absent
register: result ignore_errors: True