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 }}"
lab1: "AWX-Collection-tests-job_template-lab1-{{ 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 }}"
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_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"
organization:
name: "{{ org_name }}"
@@ -26,12 +29,17 @@
- Ansible Galaxy
register: result
- name: Create an SCM Credential
- name: Create Credentials
credential:
name: "{{ scm_cred_name }}"
name: "{{ item.name }}"
organization: Default
credential_type: Source Control
credential_type: "{{ item.type }}"
register: result
loop:
- name: "{{ scm_cred_name }}"
type: Source Control
- name: "{{ github_webhook_credential_name }}"
type: GitHub Personal Access Token
- assert:
that:
@@ -56,7 +64,7 @@
- name: Add webhook notification
notification_template:
name: "{{ webhook_not }}"
name: "{{ webhook_notification }}"
organization: Default
notification_type: webhook
notification_configuration:
@@ -314,7 +322,7 @@
name: "{{ wfjt_name }}"
notification_templates_started:
- "{{ email_not }}"
- "{{ webhook_not }}"
- "{{ webhook_notification }}"
register: result
- assert:
@@ -326,7 +334,7 @@
name: "{{ wfjt_name }}"
notification_templates_started:
- "{{ email_not }}"
- "{{ webhook_not }}"
- "{{ webhook_notification }}"
register: result
- assert:
@@ -338,7 +346,7 @@
name: "{{ wfjt_name }}"
notification_templates_success:
- "{{ email_not }}"
- "{{ webhook_not }}"
- "{{ webhook_notification }}"
register: result
- assert:
@@ -499,16 +507,6 @@
that:
- "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
workflow_job_template:
name: "{{ wfjt_name }}"
@@ -630,12 +628,22 @@
type: inventory_source
- identifier: Workflow inception
unified_job_template:
name: "{{ wfjt_name }}"
name: "copy_{{ wfjt_name }}"
organization:
name: Default
type: workflow_job_template
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
workflow_launch:
workflow_template: "{{ wfjt_name }}"
@@ -646,15 +654,44 @@
that:
- result is failed
- name: Delete a workflow job template
awx.awx.workflow_job_template:
name: "{{ wfjt_name }}"
state: absent
- name: Create a workflow job template with a GitLab webhook but a GitHub credential
workflow_job_template:
name: "{{ webhook_wfjt_name }}"
organization: Default
inventory: Demo Inventory
webhook_service: gitlab
webhook_credential: "{{ github_webhook_credential_name }}"
ignore_errors: true
register: result
- assert:
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
job_template:
@@ -664,11 +701,7 @@
playbook: hello_world.yml
job_type: run
state: absent
register: result
- assert:
that:
- "result is changed"
ignore_errors: True
- name: Delete the second Job Template
job_template:
@@ -679,11 +712,7 @@
playbook: hello_world.yml
job_type: run
state: absent
register: result
- assert:
that:
- "result is changed"
ignore_errors: True
- name: Delete the second Job Template
job_template:
@@ -694,11 +723,7 @@
playbook: hello_world.yml
job_type: run
state: absent
register: result
- assert:
that:
- "result is changed"
ignore_errors: True
- name: Delete the inventory source
inventory_source:
@@ -706,10 +731,7 @@
inventory: "{{ project_inv }}"
source: scm
state: absent
- assert:
that:
- "result is changed"
ignore_errors: True
- name: Delete the inventory
inventory:
@@ -717,10 +739,7 @@
organization: Default
name: "{{ project_inv }}"
state: absent
- assert:
that:
- "result is changed"
ignore_errors: True
- name: Delete the Demo Project
project:
@@ -730,7 +749,7 @@
scm_url: https://github.com/ansible/ansible-tower-samples.git
scm_credential: "{{ scm_cred_name }}"
state: absent
register: result
ignore_errors: True
- name: Delete the 2nd Demo Project
project:
@@ -740,11 +759,7 @@
scm_url: https://github.com/ansible/ansible-tower-samples.git
scm_credential: "{{ scm_cred_name }}"
state: absent
register: result
- assert:
that:
- "result is changed"
ignore_errors: True
- name: Delete the SCM Credential
credential:
@@ -752,26 +767,32 @@
organization: Default
credential_type: Source Control
state: absent
register: result
ignore_errors: True
- assert:
that:
- "result is changed"
- name: Delete the GitHub Webhook Credential
credential:
name: "{{ github_webhook_credential_name }}"
organization: Default
credential_type: GitHub Personal Access Token
state: absent
ignore_errors: True
- name: Delete email notification
notification_template:
name: "{{ email_not }}"
organization: Default
state: absent
ignore_errors: True
- name: Delete webhook notification
notification_template:
name: "{{ webhook_not }}"
name: "{{ webhook_notification }}"
organization: Default
state: absent
ignore_errors: True
- name: "Remove the organization"
organization:
name: "{{ org_name }}"
state: absent
register: result
ignore_errors: True