mirror of
https://github.com/ansible/awx.git
synced 2026-04-07 02:59:21 -02:30
Update integration tests
This commit is contained in:
@@ -45,7 +45,7 @@ EXAMPLES = '''
|
|||||||
tower_ad_hoc_command:
|
tower_ad_hoc_command:
|
||||||
inventory: "Demo Inventory"
|
inventory: "Demo Inventory"
|
||||||
credential: "Demo Credential"
|
credential: "Demo Credential"
|
||||||
wait: False
|
wait: false
|
||||||
register: command
|
register: command
|
||||||
|
|
||||||
- name: Wait for ad joc command max 120s
|
- name: Wait for ad joc command max 120s
|
||||||
|
|||||||
@@ -1,19 +1,45 @@
|
|||||||
---
|
---
|
||||||
# - name: Generate a random string for test
|
- name: Generate a random string for test
|
||||||
# set_fact:
|
set_fact:
|
||||||
# test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
# when: test_id is not defined
|
when: test_id is not defined
|
||||||
|
|
||||||
# - name: Generate names
|
- name: Generate names
|
||||||
# set_fact:
|
set_fact:
|
||||||
# proj_name: "AWX-Collection-tests-tower_job_launch-project-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
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
|
- name: Launch an Ad Hoc Command waiting for it to finish
|
||||||
tower_ad_hoc_command:
|
tower_ad_hoc_command:
|
||||||
inventory: "Demo Inventory"
|
inventory: "{{ inv_name }}"
|
||||||
credential: "Demo Credential"
|
credential: "{{ ssh_cred_name }}"
|
||||||
module_name: "command"
|
module_name: "command"
|
||||||
module_args: "echo I<3 Ansible"
|
module_args: "echo I <3 Ansible"
|
||||||
wait: true
|
wait: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
@@ -24,8 +50,8 @@
|
|||||||
|
|
||||||
- name: Check module fails with correct msg
|
- name: Check module fails with correct msg
|
||||||
tower_ad_hoc_command:
|
tower_ad_hoc_command:
|
||||||
inventory: "Demo Inventory"
|
inventory: "{{ inv_name }}"
|
||||||
credential: "Demo Credential"
|
credential: "{{ ssh_cred_name }}"
|
||||||
module_name: "Does not exist"
|
module_name: "Does not exist"
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
@@ -35,3 +61,21 @@
|
|||||||
- "result is failed"
|
- "result is failed"
|
||||||
- "result is not changed"
|
- "result is not changed"
|
||||||
- "'Does not exist' in result.response['json']['module_name'][0]"
|
- "'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
|
- name: Generate a random string for test
|
||||||
# set_fact:
|
set_fact:
|
||||||
# test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
# when: test_id is not defined
|
when: test_id is not defined
|
||||||
|
|
||||||
# - name: Generate names
|
- name: Generate names
|
||||||
# set_fact:
|
set_fact:
|
||||||
# proj_name: "AWX-Collection-tests-tower_job_launch-project-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
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
|
- name: Launch an Ad Hoc Command
|
||||||
tower_ad_hoc_command:
|
tower_ad_hoc_command:
|
||||||
inventory: "Demo Inventory"
|
inventory: "{{ inv_name }}"
|
||||||
credential: "Demo Credential"
|
credential: "{{ ssh_cred_name }}"
|
||||||
module_name: "command"
|
module_name: "command"
|
||||||
module_args: "sleep 10"
|
module_args: "sleep 100"
|
||||||
register: command
|
register: command
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
@@ -32,9 +58,10 @@
|
|||||||
- results is failed
|
- results is failed
|
||||||
- "results['msg'] == 'Monitoring of ad hoc command aborted due to timeout'"
|
- "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:
|
tower_ad_hoc_command_cancel:
|
||||||
command_id: "{{ command.id }}"
|
command_id: "{{ command.id }}"
|
||||||
|
fail_if_not_running: true
|
||||||
register: results
|
register: results
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
@@ -61,3 +88,21 @@
|
|||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result.msg == 'Unable to find command with id 9999999999'"
|
- "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
|
- name: Generate a random string for test
|
||||||
# set_fact:
|
set_fact:
|
||||||
# test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
# when: test_id is not defined
|
when: test_id is not defined
|
||||||
|
|
||||||
# - name: Generate names
|
- name: Generate names
|
||||||
# set_fact:
|
set_fact:
|
||||||
# proj_name: "AWX-Collection-tests-tower_job_launch-project-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
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
|
- name: Check module fails with correct msg
|
||||||
tower_ad_hoc_command_wait:
|
tower_ad_hoc_command_wait:
|
||||||
@@ -21,8 +47,8 @@
|
|||||||
|
|
||||||
- name: Launch command module with sleep 10
|
- name: Launch command module with sleep 10
|
||||||
tower_ad_hoc_command:
|
tower_ad_hoc_command:
|
||||||
inventory: "Demo Inventory"
|
inventory: "{{ inv_name }}"
|
||||||
credential: "Demo Credential"
|
credential: "{{ ssh_cred_name }}"
|
||||||
module_name: "command"
|
module_name: "command"
|
||||||
module_args: "sleep 5"
|
module_args: "sleep 5"
|
||||||
register: command
|
register: command
|
||||||
@@ -45,10 +71,10 @@
|
|||||||
|
|
||||||
- name: Launch a long running command
|
- name: Launch a long running command
|
||||||
tower_ad_hoc_command:
|
tower_ad_hoc_command:
|
||||||
inventory: "Demo Inventory"
|
inventory: "{{ inv_name }}"
|
||||||
credential: "Demo Credential"
|
credential: "{{ ssh_cred_name }}"
|
||||||
module_name: "command"
|
module_name: "command"
|
||||||
module_args: "sleep 100"
|
module_args: "sleep 10000"
|
||||||
register: command
|
register: command
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
@@ -65,10 +91,10 @@
|
|||||||
# Make sure that we failed and that we have some data in our results
|
# Make sure that we failed and that we have some data in our results
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
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"
|
- "'id' in wait_results"
|
||||||
|
|
||||||
- name: Async cancel the long running command
|
- name: Async cancel the long-running command
|
||||||
tower_ad_hoc_command_cancel:
|
tower_ad_hoc_command_cancel:
|
||||||
command_id: "{{ command.id }}"
|
command_id: "{{ command.id }}"
|
||||||
async: 3600
|
async: 3600
|
||||||
@@ -85,3 +111,21 @@
|
|||||||
- wait_results is failed
|
- wait_results is failed
|
||||||
- 'wait_results.status == "canceled"'
|
- 'wait_results.status == "canceled"'
|
||||||
- "wait_results.msg == 'The ad hoc command - {{ command.id }}, failed'"
|
- "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
|
||||||
|
|||||||
Reference in New Issue
Block a user