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,11 +14,14 @@
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"
- block:
- name: "Create a new organization" - name: "Create a new organization"
organization: organization:
name: "{{ org_name }}" name: "{{ org_name }}"
@@ -26,12 +29,17 @@
- 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:
@@ -56,7 +64,7 @@
- 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:
@@ -314,7 +322,7 @@
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:
@@ -326,7 +334,7 @@
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:
@@ -338,7 +346,7 @@
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:
@@ -499,16 +507,6 @@
that: that:
- "result is not changed" - "result is not changed"
- name: Delete copied 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 - name: Remove "on start" webhook notification from workflow job template
workflow_job_template: workflow_job_template:
name: "{{ wfjt_name }}" name: "{{ wfjt_name }}"
@@ -630,12 +628,22 @@
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: 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 - name: Kick off a workflow and wait for it
workflow_launch: workflow_launch:
workflow_template: "{{ wfjt_name }}" workflow_template: "{{ wfjt_name }}"
@@ -646,15 +654,44 @@
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: 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 - name: Delete the Job Template
job_template: job_template:
@@ -664,11 +701,7 @@
playbook: hello_world.yml playbook: hello_world.yml
job_type: run job_type: run
state: absent state: absent
register: result ignore_errors: True
- assert:
that:
- "result is changed"
- name: Delete the second Job Template - name: Delete the second Job Template
job_template: job_template:
@@ -679,11 +712,7 @@
playbook: hello_world.yml playbook: hello_world.yml
job_type: run job_type: run
state: absent state: absent
register: result ignore_errors: True
- assert:
that:
- "result is changed"
- name: Delete the second Job Template - name: Delete the second Job Template
job_template: job_template:
@@ -694,11 +723,7 @@
playbook: hello_world.yml playbook: hello_world.yml
job_type: run job_type: run
state: absent state: absent
register: result ignore_errors: True
- assert:
that:
- "result is changed"
- name: Delete the inventory source - name: Delete the inventory source
inventory_source: inventory_source:
@@ -706,10 +731,7 @@
inventory: "{{ project_inv }}" inventory: "{{ project_inv }}"
source: scm source: scm
state: absent state: absent
ignore_errors: True
- assert:
that:
- "result is changed"
- name: Delete the inventory - name: Delete the inventory
inventory: inventory:
@@ -717,10 +739,7 @@
organization: Default organization: Default
name: "{{ project_inv }}" name: "{{ project_inv }}"
state: absent state: absent
ignore_errors: True
- assert:
that:
- "result is changed"
- name: Delete the Demo Project - name: Delete the Demo Project
project: project:
@@ -730,7 +749,7 @@
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:
@@ -740,11 +759,7 @@
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:
that:
- "result is changed"
- name: Delete the SCM Credential - name: Delete the SCM Credential
credential: credential:
@@ -752,26 +767,32 @@
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