From 8ba43880149c30d55414aa026b08cc2ff06000d7 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Mon, 23 Mar 2020 22:47:30 -0400 Subject: [PATCH] Rewrite tests to use the new modules --- Makefile | 3 +- .../tasks/main.yml | 34 +++++++++++++------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index dbf278f30d..c804ff43bf 100644 --- a/Makefile +++ b/Makefile @@ -371,6 +371,7 @@ prepare_collection_venv: $(VENV_BASE)/awx/bin/pip install --target=$(COLLECTION_VENV) git+https://github.com/ansible/tower-cli.git COLLECTION_TEST_DIRS ?= awx_collection/test/awx +COLLECTION_TEST_TARGET ?= COLLECTION_PACKAGE ?= awx COLLECTION_NAMESPACE ?= awx COLLECTION_INSTALL = ~/.ansible/collections/ansible_collections/$(COLLECTION_NAMESPACE)/$(COLLECTION_PACKAGE) @@ -405,7 +406,7 @@ test_collection_sanity: install_collection cd $(COLLECTION_INSTALL) && ansible-test sanity test_collection_integration: install_collection - cd $(COLLECTION_INSTALL) && ansible-test integration + cd $(COLLECTION_INSTALL) && ansible-test integration $(COLLECTION_TEST_TARGET) test_unit: @if [ "$(VENV_BASE)" ]; then \ diff --git a/awx_collection/tests/integration/targets/tower_workflow_job_template/tasks/main.yml b/awx_collection/tests/integration/targets/tower_workflow_job_template/tasks/main.yml index 12b33aefdc..6ac1a84e51 100644 --- a/awx_collection/tests/integration/targets/tower_workflow_job_template/tasks/main.yml +++ b/awx_collection/tests/integration/targets/tower_workflow_job_template/tasks/main.yml @@ -1,11 +1,11 @@ --- - name: Generate names set_fact: - scm_cred_name: "AWX-Collection-tests-tower_workflow_template-scm-cred-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" - demo_project_name: "AWX-Collection-tests-tower_workflow_template-proj-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" - jt1_name: "AWX-Collection-tests-tower_workflow_template-jt1-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" - jt2_name: "AWX-Collection-tests-tower_workflow_template-jt2-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" - wfjt_name: "AWX-Collection-tests-tower_workflow_template-wfjt-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" + scm_cred_name: "AWX-Collection-tests-tower_workflow_job_template-scm-cred-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" + demo_project_name: "AWX-Collection-tests-tower_workflow_job_template-proj-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" + jt1_name: "AWX-Collection-tests-tower_workflow_job_template-jt1-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" + jt2_name: "AWX-Collection-tests-tower_workflow_job_template-jt2-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" + wfjt_name: "AWX-Collection-tests-tower_workflow_job_template-wfjt-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" - name: Create an SCM Credential tower_credential: @@ -80,9 +80,8 @@ - "result is changed" - name: Create a workflow job template - tower_workflow_template: + tower_workflow_job_template: name: "{{ wfjt_name }}" - schema: [{"success": [{"job_template": "{{ jt1_name }}"}], "job_template": "{{ jt2_name }}"}] extra_vars: {'foo': 'bar', 'another-foo': {'barz': 'bar2'}} register: result @@ -90,8 +89,22 @@ that: - "result is changed" +# Node actions do what this schema command used to do +# schema: [{"success": [{"job_template": "{{ jt1_name }}"}], "job_template": "{{ jt2_name }}"}] +- name: Create leaf node + tower_workflow_job_template_node: + identifier: leaf + unified_job_template: "{{ jt2_name }}" + workflow: "{{ wfjt_name }}" + +- name: Create root node + tower_workflow_job_template_node: + identifier: root + unified_job_template: "{{ jt1_name }}" + workflow: "{{ wfjt_name }}" + - name: Delete a workflow job template - tower_workflow_template: + tower_workflow_job_template: name: "{{ wfjt_name }}" state: absent register: result @@ -101,16 +114,15 @@ - "result is changed" - name: Check module fails with correct msg - tower_workflow_template: + tower_workflow_job_template: name: "{{ wfjt_name }}" organization: Non Existing Organization - schema: [{"success": [{"job_template": "{{ jt1_name }}"}], "job_template": "{{ jt2_name }}"}] register: result ignore_errors: true - assert: that: - - "result.msg =='Failed to update organization source,organization not found: The requested object could not be found.'" + - "'The organizations Non Existing Organization was not found' in result.msg" - name: Delete the Job Template tower_job_template: