mirror of
https://github.com/ansible/awx.git
synced 2026-02-16 18:50:04 -03:30
ad_hoc_command_cancel really can no longer timeout on a cancel (it happens sub second) and remove unneeded block Modified all test to respect test_id parameter so that all tests can be run togeather as a single ID Fix a check in group since its group2 is deleted from being a sub group of group1 The UI now allows to propage sub groups to the inventory which we may want to support within the collection Only run instance integration test if we are running on k8s and assume we are not by default Fix hard coded names in manual_project
287 lines
7.4 KiB
YAML
287 lines
7.4 KiB
YAML
---
|
|
- 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-{{ 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
|
|
credential:
|
|
name: "{{ scm_cred_name }}"
|
|
organization: Default
|
|
credential_type: Source Control
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Create a git project without credentials and wait
|
|
project:
|
|
name: "{{ project_name1 }}"
|
|
organization: Default
|
|
scm_type: git
|
|
scm_url: https://github.com/ansible/test-playbooks
|
|
wait: true
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Recreate the project to validate not changed
|
|
project:
|
|
name: "{{ project_name1 }}"
|
|
organization: Default
|
|
scm_type: git
|
|
scm_url: https://github.com/ansible/test-playbooks
|
|
wait: false
|
|
register: result
|
|
ignore_errors: true
|
|
|
|
- assert:
|
|
that:
|
|
- result is not changed
|
|
|
|
- name: Create organizations
|
|
organization:
|
|
name: "{{ org_name }}"
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Create credential
|
|
credential:
|
|
credential_type: Source Control
|
|
name: "{{ cred_name }}"
|
|
organization: "{{ org_name }}"
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Create a new test project in check_mode
|
|
project:
|
|
name: "{{ project_name2 }}"
|
|
organization: "{{ org_name }}"
|
|
scm_type: git
|
|
scm_url: https://github.com/ansible/test-playbooks
|
|
scm_credential: "{{ cred_name }}"
|
|
check_mode: true
|
|
|
|
- name: "Copy project from {{ project_name1 }}"
|
|
project:
|
|
name: "{{ project_name2 }}"
|
|
copy_from: "{{ project_name1 }}"
|
|
organization: "{{ org_name }}"
|
|
scm_type: git
|
|
scm_credential: "{{ cred_name }}"
|
|
state: present
|
|
register: result
|
|
|
|
# If this fails it may be because the check_mode task actually already created
|
|
# the project, or it could be because the module actually failed somehow
|
|
- assert:
|
|
that:
|
|
- result.copied
|
|
|
|
- name: Check module fails with correct msg when given non-existing org as param
|
|
project:
|
|
name: "{{ project_name2 }}"
|
|
organization: Non_Existing_Org
|
|
scm_type: git
|
|
scm_url: https://github.com/ansible/test-playbooks
|
|
scm_credential: "{{ cred_name }}"
|
|
register: result
|
|
ignore_errors: true
|
|
|
|
- assert:
|
|
that:
|
|
- "result is failed"
|
|
- "result is not changed"
|
|
- "'Non_Existing_Org' in result.msg"
|
|
- "result.total_results == 0"
|
|
|
|
- name: Check module fails with correct msg when given non-existing credential as param
|
|
project:
|
|
name: "{{ project_name2 }}"
|
|
organization: "{{ org_name }}"
|
|
scm_type: git
|
|
scm_url: https://github.com/ansible/test-playbooks
|
|
scm_credential: Non_Existing_Credential
|
|
register: result
|
|
ignore_errors: true
|
|
|
|
- assert:
|
|
that:
|
|
- "result is failed"
|
|
- "result is not changed"
|
|
- "'Non_Existing_Credential' in result.msg"
|
|
- "result.total_results == 0"
|
|
|
|
- name: Create a git project without credentials without waiting
|
|
project:
|
|
name: "{{ project_name3 }}"
|
|
organization: Default
|
|
scm_type: git
|
|
scm_branch: empty_branch
|
|
scm_url: https://github.com/ansible/test-playbooks
|
|
allow_override: true
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Update the project and wait. Verify not changed as no change made to repo and refspec not changed
|
|
project:
|
|
name: "{{ project_name3 }}"
|
|
organization: Default
|
|
scm_type: git
|
|
scm_branch: empty_branch
|
|
scm_url: https://github.com/ansible/test-playbooks
|
|
allow_override: true
|
|
wait: true
|
|
update_project: true
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is not changed
|
|
|
|
- name: Create a job template that overrides the project scm_branch
|
|
job_template:
|
|
name: "{{ jt1 }}"
|
|
project: "{{ project_name3 }}"
|
|
inventory: "Demo Inventory"
|
|
scm_branch: master
|
|
playbook: debug.yml
|
|
|
|
- name: Launch "{{ jt1 }}"
|
|
job_launch:
|
|
job_template: "{{ jt1 }}"
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: "wait for job {{ result.id }}"
|
|
job_wait:
|
|
job_id: "{{ result.id }}"
|
|
register: job
|
|
|
|
- assert:
|
|
that:
|
|
- job is successful
|
|
|
|
- name: Rename an inventory
|
|
project:
|
|
name: "{{ project_name3 }}"
|
|
new_name: "{{ project_name3 }}a"
|
|
organization: Default
|
|
state: present
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result.changed
|
|
|
|
- name: Set project to remote archive and test that it updates correctly.
|
|
project:
|
|
name: "{{ project_name3 }}"
|
|
organization: Default
|
|
scm_type: archive
|
|
scm_url: https://github.com/ansible/test-playbooks/archive/refs/tags/1.0.0.tar.gz
|
|
wait: true
|
|
update_project: true
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is changed
|
|
|
|
always:
|
|
- name: Delete the test job_template
|
|
job_template:
|
|
name: "{{ jt1 }}"
|
|
project: "{{ project_name3 }}"
|
|
inventory: "Demo Inventory"
|
|
state: absent
|
|
|
|
- name: Delete the test project 3
|
|
project:
|
|
name: "{{ project_name3 }}"
|
|
organization: Default
|
|
state: absent
|
|
|
|
- name: Delete the test project 3a
|
|
project:
|
|
name: "{{ project_name3 }}a"
|
|
organization: Default
|
|
state: absent
|
|
|
|
- name: Delete the test project 2
|
|
project:
|
|
name: "{{ project_name2 }}"
|
|
organization: "{{ org_name }}"
|
|
state: absent
|
|
|
|
- name: Delete the SCM Credential
|
|
credential:
|
|
name: "{{ scm_cred_name }}"
|
|
organization: Default
|
|
credential_type: Source Control
|
|
state: absent
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Delete the test project 1
|
|
project:
|
|
name: "{{ project_name1 }}"
|
|
organization: Default
|
|
state: absent
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Delete credential
|
|
credential:
|
|
credential_type: Source Control
|
|
name: "{{ cred_name }}"
|
|
organization: "{{ org_name }}"
|
|
state: absent
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Delete the organization
|
|
organization:
|
|
name: "{{ org_name }}"
|
|
state: absent
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result is changed
|