mirror of
https://github.com/ansible/awx.git
synced 2026-01-09 23:12:08 -03:30
Update integration tests
This commit is contained in:
parent
842e490ba6
commit
b34c1f4c79
@ -45,7 +45,7 @@ EXAMPLES = '''
|
||||
tower_ad_hoc_command:
|
||||
inventory: "Demo Inventory"
|
||||
credential: "Demo Credential"
|
||||
wait: False
|
||||
wait: false
|
||||
register: command
|
||||
|
||||
- name: Wait for ad joc command max 120s
|
||||
|
||||
@ -1,19 +1,45 @@
|
||||
---
|
||||
# - 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 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 names
|
||||
# set_fact:
|
||||
# proj_name: "AWX-Collection-tests-tower_job_launch-project-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||
- name: Generate names
|
||||
set_fact:
|
||||
inv_name: "AWX-Collection-tests-tower_tower_ad_hoc_command-inventory-{{ test_id }}"
|
||||
ssh_cred_name: "AWX-Collection-tests-tower_tower_ad_hoc_command-ssh-cred-{{ test_id }}"
|
||||
org_name: "AWX-Collection-tests-tower_tower_ad_hoc_command-org-{{ test_id }}"
|
||||
|
||||
- name: Create a New Organization
|
||||
tower_organization:
|
||||
name: "{{ org_name }}"
|
||||
|
||||
- name: Create an Inventory
|
||||
tower_inventory:
|
||||
name: "{{ inv_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
state: present
|
||||
|
||||
- name: Add localhost to the Inventory
|
||||
tower_host:
|
||||
name: localhost
|
||||
inventory: "{{ inv_name }}"
|
||||
variables:
|
||||
ansible_connection: local
|
||||
|
||||
- name: Create a Credential
|
||||
tower_credential:
|
||||
name: "{{ ssh_cred_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
credential_type: 'Machine'
|
||||
state: present
|
||||
|
||||
- name: Launch an Ad Hoc Command waiting for it to finish
|
||||
tower_ad_hoc_command:
|
||||
inventory: "Demo Inventory"
|
||||
credential: "Demo Credential"
|
||||
inventory: "{{ inv_name }}"
|
||||
credential: "{{ ssh_cred_name }}"
|
||||
module_name: "command"
|
||||
module_args: "echo I<3 Ansible"
|
||||
module_args: "echo I <3 Ansible"
|
||||
wait: true
|
||||
register: result
|
||||
|
||||
@ -24,8 +50,8 @@
|
||||
|
||||
- name: Check module fails with correct msg
|
||||
tower_ad_hoc_command:
|
||||
inventory: "Demo Inventory"
|
||||
credential: "Demo Credential"
|
||||
inventory: "{{ inv_name }}"
|
||||
credential: "{{ ssh_cred_name }}"
|
||||
module_name: "Does not exist"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
@ -35,3 +61,21 @@
|
||||
- "result is failed"
|
||||
- "result is not changed"
|
||||
- "'Does not exist' in result.response['json']['module_name'][0]"
|
||||
|
||||
- name: Delete the Credential
|
||||
tower_credential:
|
||||
name: "{{ ssh_cred_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
credential_type: 'Machine'
|
||||
state: absent
|
||||
|
||||
- name: Delete the Inventory
|
||||
tower_inventory:
|
||||
name: "{{ inv_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
state: absent
|
||||
|
||||
- name: Remove the Organization
|
||||
tower_organization:
|
||||
name: "{{ org_name }}"
|
||||
state: absent
|
||||
|
||||
@ -1,19 +1,45 @@
|
||||
---
|
||||
# - 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 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 names
|
||||
# set_fact:
|
||||
# proj_name: "AWX-Collection-tests-tower_job_launch-project-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||
- name: Generate names
|
||||
set_fact:
|
||||
inv_name: "AWX-Collection-tests-tower_tower_ad_hoc_command_cancel-inventory-{{ test_id }}"
|
||||
ssh_cred_name: "AWX-Collection-tests-tower_tower_ad_hoc_command_cancel-ssh-cred-{{ test_id }}"
|
||||
org_name: "AWX-Collection-tests-tower_tower_ad_hoc_command_cancel-org-{{ test_id }}"
|
||||
|
||||
- name: Create a New Organization
|
||||
tower_organization:
|
||||
name: "{{ org_name }}"
|
||||
|
||||
- name: Create an Inventory
|
||||
tower_inventory:
|
||||
name: "{{ inv_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
state: present
|
||||
|
||||
- name: Add localhost to the Inventory
|
||||
tower_host:
|
||||
name: localhost
|
||||
inventory: "{{ inv_name }}"
|
||||
variables:
|
||||
ansible_connection: local
|
||||
|
||||
- name: Create a Credential
|
||||
tower_credential:
|
||||
name: "{{ ssh_cred_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
credential_type: 'Machine'
|
||||
state: present
|
||||
|
||||
- name: Launch an Ad Hoc Command
|
||||
tower_ad_hoc_command:
|
||||
inventory: "Demo Inventory"
|
||||
credential: "Demo Credential"
|
||||
inventory: "{{ inv_name }}"
|
||||
credential: "{{ ssh_cred_name }}"
|
||||
module_name: "command"
|
||||
module_args: "sleep 10"
|
||||
module_args: "sleep 100"
|
||||
register: command
|
||||
|
||||
- assert:
|
||||
@ -32,9 +58,10 @@
|
||||
- results is failed
|
||||
- "results['msg'] == 'Monitoring of ad hoc command aborted due to timeout'"
|
||||
|
||||
- name: Cancel the command
|
||||
- name: Cancel the command with hard error if it's not running
|
||||
tower_ad_hoc_command_cancel:
|
||||
command_id: "{{ command.id }}"
|
||||
fail_if_not_running: true
|
||||
register: results
|
||||
|
||||
- assert:
|
||||
@ -61,3 +88,21 @@
|
||||
- assert:
|
||||
that:
|
||||
- "result.msg == 'Unable to find command with id 9999999999'"
|
||||
|
||||
- name: Delete the Credential
|
||||
tower_credential:
|
||||
name: "{{ ssh_cred_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
credential_type: 'Machine'
|
||||
state: absent
|
||||
|
||||
- name: Delete the Inventory
|
||||
tower_inventory:
|
||||
name: "{{ inv_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
state: absent
|
||||
|
||||
- name: Remove the Organization
|
||||
tower_organization:
|
||||
name: "{{ org_name }}"
|
||||
state: absent
|
||||
|
||||
@ -1,12 +1,38 @@
|
||||
---
|
||||
# - 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 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 names
|
||||
# set_fact:
|
||||
# proj_name: "AWX-Collection-tests-tower_job_launch-project-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||
- name: Generate names
|
||||
set_fact:
|
||||
inv_name: "AWX-Collection-tests-tower_ad_hoc_command_wait-inventory-{{ test_id }}"
|
||||
ssh_cred_name: "AWX-Collection-tests-tower_ad_hoc_command_wait-ssh-cred-{{ test_id }}"
|
||||
org_name: "AWX-Collection-tests-tower_ad_hoc_command_wait-org-{{ test_id }}"
|
||||
|
||||
- name: Create a New Organization
|
||||
tower_organization:
|
||||
name: "{{ org_name }}"
|
||||
|
||||
- name: Create an Inventory
|
||||
tower_inventory:
|
||||
name: "{{ inv_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
state: present
|
||||
|
||||
- name: Add localhost to the Inventory
|
||||
tower_host:
|
||||
name: localhost
|
||||
inventory: "{{ inv_name }}"
|
||||
variables:
|
||||
ansible_connection: local
|
||||
|
||||
- name: Create a Credential
|
||||
tower_credential:
|
||||
name: "{{ ssh_cred_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
credential_type: 'Machine'
|
||||
state: present
|
||||
|
||||
- name: Check module fails with correct msg
|
||||
tower_ad_hoc_command_wait:
|
||||
@ -21,8 +47,8 @@
|
||||
|
||||
- name: Launch command module with sleep 10
|
||||
tower_ad_hoc_command:
|
||||
inventory: "Demo Inventory"
|
||||
credential: "Demo Credential"
|
||||
inventory: "{{ inv_name }}"
|
||||
credential: "{{ ssh_cred_name }}"
|
||||
module_name: "command"
|
||||
module_args: "sleep 5"
|
||||
register: command
|
||||
@ -45,10 +71,10 @@
|
||||
|
||||
- name: Launch a long running command
|
||||
tower_ad_hoc_command:
|
||||
inventory: "Demo Inventory"
|
||||
credential: "Demo Credential"
|
||||
inventory: "{{ inv_name }}"
|
||||
credential: "{{ ssh_cred_name }}"
|
||||
module_name: "command"
|
||||
module_args: "sleep 100"
|
||||
module_args: "sleep 10000"
|
||||
register: command
|
||||
|
||||
- assert:
|
||||
@ -65,10 +91,10 @@
|
||||
# Make sure that we failed and that we have some data in our results
|
||||
- assert:
|
||||
that:
|
||||
- "wait_results.msg == 'Monitoring aborted due to timeout' or 'Timeout waiting for command to finish.'"
|
||||
- "'Monitoring aborted due to timeout' or 'Timeout waiting for command to finish.' in wait_results.msg"
|
||||
- "'id' in wait_results"
|
||||
|
||||
- name: Async cancel the long running command
|
||||
- name: Async cancel the long-running command
|
||||
tower_ad_hoc_command_cancel:
|
||||
command_id: "{{ command.id }}"
|
||||
async: 3600
|
||||
@ -85,3 +111,21 @@
|
||||
- wait_results is failed
|
||||
- 'wait_results.status == "canceled"'
|
||||
- "wait_results.msg == 'The ad hoc command - {{ command.id }}, failed'"
|
||||
|
||||
- name: Delete the Credential
|
||||
tower_credential:
|
||||
name: "{{ ssh_cred_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
credential_type: 'Machine'
|
||||
state: absent
|
||||
|
||||
- name: Delete the Inventory
|
||||
tower_inventory:
|
||||
name: "{{ inv_name }}"
|
||||
organization: "{{ org_name }}"
|
||||
state: absent
|
||||
|
||||
- name: Remove the Organization
|
||||
tower_organization:
|
||||
name: "{{ org_name }}"
|
||||
state: absent
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user