Merge pull request #13903 from john-westcott-iv/collection_intergration_tests

Enhance collection intergration tests
This commit is contained in:
John Westcott IV 2023-04-26 09:08:00 -04:00 committed by GitHub
commit 7fda4b0675
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 145 additions and 159 deletions

View File

@ -46,27 +46,24 @@
that:
- "command is changed"
- name: Timeout waiting for the command to cancel
- name: Cancel the command
ad_hoc_command_cancel:
command_id: "{{ command.id }}"
timeout: -1
register: results
ignore_errors: true
- assert:
that:
- results is failed
- "results['msg'] == 'Monitoring of ad hoc command aborted due to timeout'"
- results is changed
- block:
- name: "Wait for up to a minute until the job enters the can_cancel: False state"
debug:
msg: "The job can_cancel status has transitioned into False, we can proceed with testing"
until: not job_status
retries: 6
delay: 10
vars:
job_status: "{{ lookup('awx.awx.controller_api', 'ad_hoc_commands/'+ command.id | string +'/cancel')['can_cancel'] }}"
- name: "Wait for up to a minute until the job enters the can_cancel: False state"
debug:
msg: "The job can_cancel status has transitioned into False, we can proceed with testing"
until: not job_status
retries: 6
delay: 10
vars:
job_status: "{{ lookup('awx.awx.controller_api', 'ad_hoc_commands/'+ command.id | string +'/cancel')['can_cancel'] }}"
- name: Cancel the command with hard error if it's not running
ad_hoc_command_cancel:

View File

@ -108,9 +108,8 @@
- assert:
that:
- wait_results is failed
- 'wait_results.status == "canceled"'
- "wait_results.msg == 'The ad hoc command - {{ command.id }}, failed'"
- wait_results is successful
- 'wait_results.status == "successful"'
- name: Delete the Credential
credential:

View File

@ -2,6 +2,7 @@
- name: Generate a test id
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:

View File

@ -1,7 +1,12 @@
---
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
cred_type_name: "AWX-Collection-tests-credential_type-cred-type-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
cred_type_name: "AWX-Collection-tests-credential_type-cred-type-{{ test_id }}"
- block:
- name: Add Tower credential type

View File

@ -1,13 +1,18 @@
---
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
group_name1: "AWX-Collection-tests-group-group-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
group_name2: "AWX-Collection-tests-group-group-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
group_name3: "AWX-Collection-tests-group-group-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
inv_name: "AWX-Collection-tests-group-inv-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
host_name1: "AWX-Collection-tests-group-host-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
host_name2: "AWX-Collection-tests-group-host-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
host_name3: "AWX-Collection-tests-group-host-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
group_name1: "AWX-Collection-tests-group-group1-{{ test_id }}"
group_name2: "AWX-Collection-tests-group-group2-{{ test_id }}"
group_name3: "AWX-Collection-tests-group-group3-{{ test_id }}"
inv_name: "AWX-Collection-tests-group-inv-{{ test_id }}"
host_name1: "AWX-Collection-tests-group-host1-{{ test_id }}"
host_name2: "AWX-Collection-tests-group-host2-{{ test_id }}"
host_name3: "AWX-Collection-tests-group-host3-{{ test_id }}"
- name: Create an Inventory
inventory:
@ -117,9 +122,10 @@
state: absent
register: result
# In this case, group 2 was last a child of group1 so deleting group1 deleted group2
- assert:
that:
- "result is changed"
- "result is not changed"
- name: Delete a Group
group:

View File

@ -1,8 +1,13 @@
---
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
host_name: "AWX-Collection-tests-host-host-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
inv_name: "AWX-Collection-tests-host-inv-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
host_name: "AWX-Collection-tests-host-host-{{ test_id }}"
inv_name: "AWX-Collection-tests-host-inv-{{ test_id }}"
- name: Create an Inventory
inventory:

View File

@ -1,14 +1,25 @@
---
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate hostnames
set_fact:
hostname1: "AWX-Collection-tests-instance1.{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}.example.com"
hostname2: "AWX-Collection-tests-instance2.{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}.example.com"
hostname3: "AWX-Collection-tests-instance3.{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}.example.com"
hostname1: "AWX-Collection-tests-instance1.{{ test_id }}.example.com"
hostname2: "AWX-Collection-tests-instance2.{{ test_id }}.example.com"
hostname3: "AWX-Collection-tests-instance3.{{ test_id }}.example.com"
register: facts
- name: Show hostnames
debug:
var: facts
- name: Get the k8s setting
set_fact:
IS_K8S: "{{ controller_settings['IS_K8S'] | default(False) }}"
vars:
controller_settings: "{{ lookup('awx.awx.controller_api', 'settings/all') }}"
- debug:
msg: "Skipping instance test since this is instance is not running on a K8s platform"
when: not IS_K8S
- block:
- name: Create an instance
@ -57,3 +68,5 @@
- "{{ hostname1 }}"
- "{{ hostname2 }}"
- "{{ hostname3 }}"
when: IS_K8S

View File

@ -2,6 +2,7 @@
- name: Generate test id
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:

View File

@ -2,6 +2,7 @@
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:

View File

@ -1,9 +1,14 @@
---
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
openstack_cred: "AWX-Collection-tests-inventory_source-cred-openstack-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
openstack_inv: "AWX-Collection-tests-inventory_source-inv-openstack-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
openstack_inv_source: "AWX-Collection-tests-inventory_source-inv-source-openstack-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
openstack_cred: "AWX-Collection-tests-inventory_source-cred-openstack-{{ test_id }}"
openstack_inv: "AWX-Collection-tests-inventory_source-inv-openstack-{{ test_id }}"
openstack_inv_source: "AWX-Collection-tests-inventory_source-inv-source-openstack-{{ test_id }}"
- name: Add a credential
credential:

View File

@ -2,6 +2,7 @@
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:

View File

@ -1,9 +1,14 @@
---
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
jt_name1: "AWX-Collection-tests-job_launch-jt1-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
jt_name2: "AWX-Collection-tests-job_launch-jt2-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
proj_name: "AWX-Collection-tests-job_launch-project-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
jt_name1: "AWX-Collection-tests-job_launch-jt1-{{ test_id }}"
jt_name2: "AWX-Collection-tests-job_launch-jt2-{{ test_id }}"
proj_name: "AWX-Collection-tests-job_launch-project-{{ test_id }}"
- name: Launch a Job Template
job_launch:

View File

@ -2,6 +2,7 @@
- name: Generate a random string for test
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: generate random string for project
set_fact:

View File

@ -1,8 +1,13 @@
---
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate random string for template and project
set_fact:
jt_name: "AWX-Collection-tests-job_wait-long_running-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
proj_name: "AWX-Collection-tests-job_wait-long_running-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
jt_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
project:

View File

@ -1,7 +1,12 @@
---
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
label_name: "AWX-Collection-tests-label-label-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
label_name: "AWX-Collection-tests-label-label-{{ test_id }}"
- name: Create a Label
label:

View File

@ -101,6 +101,9 @@
set_fact:
users: "{{ query(plugin_name, 'users', query_params={ 'username__endswith': test_id, 'page_size': 2 }, return_ids=True ) }}"
- debug:
msg: "{{ users }}"
- name: Assert that user list has 2 ids only and that they are strings, not ints
assert:
that:

View File

@ -1,12 +1,17 @@
---
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
slack_not: "AWX-Collection-tests-notification_template-slack-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
webhook_not: "AWX-Collection-tests-notification_template-wehbook-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
email_not: "AWX-Collection-tests-notification_template-email-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
twillo_not: "AWX-Collection-tests-notification_template-twillo-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
pd_not: "AWX-Collection-tests-notification_template-pd-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
irc_not: "AWX-Collection-tests-notification_template-irc-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
slack_not: "AWX-Collection-tests-notification_template-slack-not-{{ test_id }}"
webhook_not: "AWX-Collection-tests-notification_template-wehbook-not-{{ test_id }}"
email_not: "AWX-Collection-tests-notification_template-email-not-{{ test_id }}"
twillo_not: "AWX-Collection-tests-notification_template-twillo-not-{{ test_id }}"
pd_not: "AWX-Collection-tests-notification_template-pd-not-{{ test_id }}"
irc_not: "AWX-Collection-tests-notification_template-irc-not-{{ test_id }}"
- name: Create Slack notification with custom messages
notification_template:

View File

@ -2,6 +2,7 @@
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate an org name
set_fact:

View File

@ -1,13 +1,18 @@
---
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
project_name1: "AWX-Collection-tests-project-project1-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
project_name2: "AWX-Collection-tests-project-project2-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
project_name3: "AWX-Collection-tests-project-project3-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
jt1: "AWX-Collection-tests-project-jt1-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
scm_cred_name: "AWX-Collection-tests-project-scm-cred-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
org_name: "AWX-Collection-tests-project-org-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
cred_name: "AWX-Collection-tests-project-cred-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
project_name1: "AWX-Collection-tests-project-project1-{{ test_id }}"
project_name2: "AWX-Collection-tests-project-project2-{{ test_id }}"
project_name3: "AWX-Collection-tests-project-project3-{{ test_id }}"
jt1: "AWX-Collection-tests-project-jt1-{{ test_id }}"
scm_cred_name: "AWX-Collection-tests-project-scm-cred-{{ test_id }}"
org_name: "AWX-Collection-tests-project-org-{{ test_id }}"
cred_name: "AWX-Collection-tests-project-cred-{{ test_id }}"
- block:
- name: Create an SCM Credential

View File

@ -1,56 +0,0 @@
---
- name: Load the UI settings
set_fact:
project_base_dir: "{{ controller_settings.project_base_dir }}"
vars:
controller_settings: "{{ lookup('awx.awx.controller_api', 'config/') }}"
- inventory:
name: localhost
organization: Default
- host:
name: localhost
inventory: localhost
variables:
ansible_connection: local
- name: Create an unused SSH / Machine credential
credential:
name: dummy
credential_type: Machine
inputs:
ssh_key_data: |
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIIUl6R1xgzR6siIUArz4XBPtGZ09aetma2eWf1v3uYymoAoGCCqGSM49
AwEHoUQDQgAENJNjgeZDAh/+BY860s0yqrLDprXJflY0GvHIr7lX3ieCtrzOMCVU
QWzw35pc5tvuP34SSi0ZE1E+7cVMDDOF3w==
-----END EC PRIVATE KEY-----
organization: Default
- block:
- name: Add a path to a setting
settings:
name: AWX_ISOLATION_SHOW_PATHS
value: "[{{ project_base_dir }}]"
- name: Create a directory for manual project
ad_hoc_command:
credential: dummy
inventory: localhost
job_type: run
module_args: "mkdir -p {{ project_base_dir }}/{{ project_dir_name }}"
module_name: command
wait: true
always:
- name: Delete path from setting
settings:
name: AWX_ISOLATION_SHOW_PATHS
value: []
- name: Delete dummy credential
credential:
name: dummy
credential_type: Machine
state: absent

View File

@ -1,38 +0,0 @@
---
- name: Generate random string for project
set_fact:
rand_string: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
- name: Generate manual project name
set_fact:
project_name: "Manual_Project_{{ rand_string }}"
- name: Generate manual project dir name
set_fact:
project_dir_name: "proj_{{ rand_string }}"
- name: Create a project directory for manual project
import_tasks: create_project_dir.yml
- name: Create a manual project
project:
name: "{{ project_name }}"
organization: Default
scm_type: manual
local_path: "{{ project_dir_name }}"
register: result
- assert:
that:
- "result is changed"
- name: Delete a manual project
project:
name: "{{ project_name }}"
organization: Default
state: absent
register: result
- assert:
that:
- "result is changed"

View File

@ -2,6 +2,7 @@
- name: Generate a test id
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:

View File

@ -2,6 +2,7 @@
- name: Generate a random string for test
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: generate random string for schedule
set_fact:

View File

@ -1,7 +1,12 @@
---
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
team_name: "AWX-Collection-tests-team-team-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
team_name: "AWX-Collection-tests-team-team-{{ test_id }}"
- name: Attempt to add a team to a non-existant Organization
team:

View File

@ -1,7 +1,12 @@
---
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
token_description: "AWX-Collection-tests-token-description-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
token_description: "AWX-Collection-tests-token-description-{{ test_id }}"
- name: Try to use a token as a dict which is missing the token parameter
job_list:

View File

@ -1,7 +1,12 @@
---
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
username: "AWX-Collection-tests-user-user-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
username: "AWX-Collection-tests-user-user-{{ test_id }}"
- name: Create a User
user:
@ -131,10 +136,6 @@
'Can not verify ssl with non-https protocol' in result.exception"
- block:
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
- name: Generate an org name
set_fact:
org_name: "AWX-Collection-tests-organization-org-{{ test_id }}"

View File

@ -2,13 +2,15 @@
- name: Generate a random string for names
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
test_prefix: AWX-Collection-tests-workflow_approval
when: test_id is not defined
- name: Generate random names for test objects
set_fact:
org_name: "{{ test_prefix }}-org-{{ test_id }}"
approval_node_name: "{{ test_prefix }}-node-{{ test_id }}"
wfjt_name: "{{ test_prefix }}-wfjt-{{ test_id }}"
vars:
test_prefix: AWX-Collection-tests-workflow_approval
- block:
- name: Create a new organization for test isolation

View File

@ -2,6 +2,7 @@
- name: Generate a random string for names
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate random names for test objects
set_fact:
@ -17,8 +18,8 @@
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_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') }}"
project_inv: "AWX-Collection-tests-inventory_source-inv-project-{{ test_id }}"
project_inv_source: "AWX-Collection-tests-inventory_source-inv-source-project-{{ test_id }}"
github_webhook_credential_name: "AWX-Collection-tests-credential-webhook-{{ test_id }}_github"
ee1: "AWX-Collection-tests-workflow_job_template-ee1-{{ test_id }}"
label1: "AWX-Collection-tests-workflow_job_template-l1-{{ test_id }}"