summaryrefslogtreecommitdiffstats
path: root/test/ansible-python-dg
diff options
context:
space:
mode:
authorJozsef Csongvai <jozsef.csongvai@bell.ca>2021-01-19 12:32:04 -0500
committerJozsef Csongvai <jozsef.csongvai@bell.ca>2021-01-20 10:02:39 -0500
commite92fce768cb792f11920f45fdbb38b3af69e212f (patch)
tree650d0bd49b1c98b49535d3f8aa9f98bb97255532 /test/ansible-python-dg
parentbfffa2d982cc506979aaa0b96b6bb352c8dda9a7 (diff)
Update to latest version
Issue-ID: TEST-295 Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca> Change-Id: Ie14e2061c1e0931bf3d555e54c79bb736d140d5c
Diffstat (limited to 'test/ansible-python-dg')
-rw-r--r--test/ansible-python-dg/ansible-python-dg-enrichment-test.sh36
-rw-r--r--test/ansible-python-dg/ansible-python-dg-upload-test.sh36
-rw-r--r--test/ansible-python-dg/dummy-request-payload.json14
-rw-r--r--test/ansible-python-dg/init-mockserver.sh67
-rw-r--r--test/ansible-python-dg/mock-payloads/get_job-template-launch.json46
-rw-r--r--test/ansible-python-dg/mock-payloads/inventory.json110
-rw-r--r--test/ansible-python-dg/mock-payloads/job-execution.json216
-rw-r--r--test/ansible-python-dg/mock-payloads/job-output.json24
-rw-r--r--test/ansible-python-dg/mock-payloads/job-template.json224
-rw-r--r--test/ansible-python-dg/mock-payloads/post_job-template-launch.json144
-rw-r--r--test/ansible-python-dg/success/expected-response.json30
-rw-r--r--test/ansible-python-dg/success/request-payload.json27
-rw-r--r--test/ansible-python-dg/success/test.sh40
13 files changed, 1014 insertions, 0 deletions
diff --git a/test/ansible-python-dg/ansible-python-dg-enrichment-test.sh b/test/ansible-python-dg/ansible-python-dg-enrichment-test.sh
new file mode 100644
index 0000000..ea41c92
--- /dev/null
+++ b/test/ansible-python-dg/ansible-python-dg-enrichment-test.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# Copyright (C) 2020 Bell Canada.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+CBA_NAME="ansible-python-dg"
+TEST_NAME="$CBA_NAME-enrichment"
+TEST_NUMBER=$RANDOM
+RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers"
+
+. ./$TEST_DIRECTORY/utils.sh
+
+export MOCK_SRV="http://cds-regression-mockserver/mock-$CI_PIPELINE_ID/ansible-python-dg/success"
+export CMD_EXEC_SVC=${CMD_EXEC_SVC:-"cds-command-executor"}
+apply_env_to_definition $CBA_NAME
+
+echo "Compressing CBA: $CBA_NAME"
+compress_cba $CBA_NAME
+
+echo "Enriching CBA: $CBA_NAME"
+enrich_cba $CBA_NAME $RESPONSE_HEADERS_FILE
+
+echo 'Assert status 200'
+assert_status_code 200 $RESPONSE_HEADERS_FILE
diff --git a/test/ansible-python-dg/ansible-python-dg-upload-test.sh b/test/ansible-python-dg/ansible-python-dg-upload-test.sh
new file mode 100644
index 0000000..568bb40
--- /dev/null
+++ b/test/ansible-python-dg/ansible-python-dg-upload-test.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# Copyright (C) 2020 Bell Canada.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+CBA_NAME="ansible-python-dg"
+TEST_NAME="$CBA_NAME-upload"
+TEST_NUMBER=$RANDOM
+RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers"
+RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-payload"
+REQUEST_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/dummy-request-payload.json"
+
+. ./$TEST_DIRECTORY/utils.sh
+
+echo "Uploading CBA: $CBA_NAME"
+upload_cba $CBA_NAME $RESPONSE_PAYLOAD_FILE $RESPONSE_HEADERS_FILE
+
+echo 'Assert status 200'
+assert_status_code 200 $RESPONSE_HEADERS_FILE
+
+# This step prevents a race-condition for parallel process requests
+# when cba has not yet been written to filesystem
+echo 'Send process request to force CDS to load CBA to filesystem'
+process_cba $REQUEST_PAYLOAD_FILE '/dev/null' '/dev/null'
diff --git a/test/ansible-python-dg/dummy-request-payload.json b/test/ansible-python-dg/dummy-request-payload.json
new file mode 100644
index 0000000..f04d745
--- /dev/null
+++ b/test/ansible-python-dg/dummy-request-payload.json
@@ -0,0 +1,14 @@
+{
+ "commonHeader": {
+ "originatorId": "System",
+ "requestId": "dummy-request-should-fail",
+ "subRequestId": "1"
+ },
+ "actionIdentifiers": {
+ "blueprintName": "RT-ansible-python-dg",
+ "blueprintVersion": "1.0.0",
+ "actionName": "dummy",
+ "mode": "sync"
+ },
+ "payload": {}
+}
diff --git a/test/ansible-python-dg/init-mockserver.sh b/test/ansible-python-dg/init-mockserver.sh
new file mode 100644
index 0000000..42122d3
--- /dev/null
+++ b/test/ansible-python-dg/init-mockserver.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+#
+# Copyright (C) 2020 Bell Canada.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+. ./$TEST_DIRECTORY/utils.sh
+
+CBA_NAME="ansible-python-dg"
+DIR_PAYLOADS="$TEST_DIRECTORY/$CBA_NAME/mock-payloads"
+
+OP=expectation
+if [[ $1 == rm ]]; then
+ OP=clear
+fi
+
+# JOB TEMPLATE
+echo "Mocking Job Template route..."
+export PATH_JT_PAYLOAD="/mock-$CI_PIPELINE_ID/ansible-python-dg/success/api/v2/job_templates/hello_world_job_template/"
+JT_PAYLOAD="$DIR_PAYLOADS/job-template.json"
+apply_env_to_json_template $JT_PAYLOAD
+curl -vLk -X PUT "http://$CLUSTER_IP:$MOCKSERVER_NODEPORT/mockserver/$OP" -d "@$JT_PAYLOAD"
+
+# JOB TEMPLATE LAUNCH - GET
+echo "Mocking Job Template Launch GET route..."
+export PATH_GET_JT_LAUNCH_PAYLOAD="/mock-$CI_PIPELINE_ID/ansible-python-dg/success/api/v2/job_templates/123/launch/"
+GET_JT_LAUNCH_PAYLOAD="$DIR_PAYLOADS/get_job-template-launch.json"
+apply_env_to_json_template $GET_JT_LAUNCH_PAYLOAD
+curl -vLk -X PUT "http://$CLUSTER_IP:$MOCKSERVER_NODEPORT/mockserver/$OP" -d "@$GET_JT_LAUNCH_PAYLOAD"
+
+# JOB TEMPLATE LAUNCH
+echo "Mocking Inventory route..."
+export PATH_INVENTORY="/mock-$CI_PIPELINE_ID/ansible-python-dg/success/api/v2/inventories/"
+INVENTORY_PAYLOAD="$DIR_PAYLOADS/inventory.json"
+apply_env_to_json_template $INVENTORY_PAYLOAD
+curl -vLk -X PUT "http://$CLUSTER_IP:$MOCKSERVER_NODEPORT/mockserver/$OP" -d "@$INVENTORY_PAYLOAD"
+
+# JOB TEMPLATE LAUNCH - POST
+echo "Mocking Job Template Launch POST route..."
+export PATH_POST_JT_LAUNCH_PAYLOAD="/mock-$CI_PIPELINE_ID/ansible-python-dg/success/api/v2/job_templates/123/launch/"
+POST_JT_LAUNCH_PAYLOAD="$DIR_PAYLOADS/post_job-template-launch.json"
+apply_env_to_json_template $POST_JT_LAUNCH_PAYLOAD
+curl -vLk -X PUT "http://$CLUSTER_IP:$MOCKSERVER_NODEPORT/mockserver/$OP" -d "@$POST_JT_LAUNCH_PAYLOAD"
+
+# JOB EXECUTION
+echo "Mocking Job Execution route..."
+export PATH_JOB_EXECUTION_PAYLOAD="/mock-$CI_PIPELINE_ID/ansible-python-dg/success/api/v2/jobs/456/"
+JOB_EXECUTION_PAYLOAD="$DIR_PAYLOADS/job-execution.json"
+apply_env_to_json_template $JOB_EXECUTION_PAYLOAD
+curl -vLk -X PUT "http://$CLUSTER_IP:$MOCKSERVER_NODEPORT/mockserver/$OP" -d "@$JOB_EXECUTION_PAYLOAD"
+
+# JOB OUTPUT
+echo "Mocking Job Output route..."
+export PATH_JOB_OUTPUT_PAYLOAD="/mock-$CI_PIPELINE_ID/ansible-python-dg/success/api/v2/jobs/456/stdout/"
+JOB_OUTPUT_PAYLOAD="$DIR_PAYLOADS/job-output.json"
+apply_env_to_json_template $JOB_OUTPUT_PAYLOAD
+curl -vLk -X PUT "http://$CLUSTER_IP:$MOCKSERVER_NODEPORT/mockserver/$OP" -d "@$JOB_OUTPUT_PAYLOAD"
diff --git a/test/ansible-python-dg/mock-payloads/get_job-template-launch.json b/test/ansible-python-dg/mock-payloads/get_job-template-launch.json
new file mode 100644
index 0000000..ddc9e17
--- /dev/null
+++ b/test/ansible-python-dg/mock-payloads/get_job-template-launch.json
@@ -0,0 +1,46 @@
+{
+ "httpRequest" : {
+ "method" : "GET",
+ "path" : .PATH_GET_JT_LAUNCH_PAYLOAD
+ },
+ "httpResponse" : {
+ "body" : {
+ "can_start_without_user_input": false,
+ "passwords_needed_to_start": [],
+ "ask_variables_on_launch": true,
+ "ask_tags_on_launch": true,
+ "ask_diff_mode_on_launch": false,
+ "ask_skip_tags_on_launch": true,
+ "ask_job_type_on_launch": false,
+ "ask_limit_on_launch": true,
+ "ask_verbosity_on_launch": false,
+ "ask_inventory_on_launch": true,
+ "ask_credential_on_launch": true,
+ "survey_enabled": true,
+ "variables_needed_to_start": [
+ "tor_group",
+ "site_id"
+ ],
+ "credential_needed_to_start": false,
+ "inventory_needed_to_start": false,
+ "job_template_data": {
+ "name": "hello_world_job_template",
+ "id": "123",
+ "description": "hello_world Runner Job Template"
+ },
+ "defaults": {
+ "extra_vars": "",
+ "diff_mode": false,
+ "limit": "",
+ "job_tags": "",
+ "skip_tags": "",
+ "job_type": "run",
+ "verbosity": 0,
+ "inventory": {
+ "name": "Demo Inventory",
+ "id": 1
+ }
+ }
+ }
+ }
+}
diff --git a/test/ansible-python-dg/mock-payloads/inventory.json b/test/ansible-python-dg/mock-payloads/inventory.json
new file mode 100644
index 0000000..9fd5ba1
--- /dev/null
+++ b/test/ansible-python-dg/mock-payloads/inventory.json
@@ -0,0 +1,110 @@
+{
+ "httpRequest" : {
+ "method" : "GET",
+ "path" : .PATH_INVENTORY
+ },
+ "httpResponse" : {
+ "body" : {
+ "count": 1,
+ "next": null,
+ "previous": null,
+ "results": [
+ {
+ "id": 1,
+ "type": "inventory",
+ "url": "/api/v2/inventories/1/",
+ "related": {
+ "created_by": "/api/v2/users/1/",
+ "modified_by": "/api/v2/users/1/",
+ "hosts": "/api/v2/inventories/1/hosts/",
+ "groups": "/api/v2/inventories/1/groups/",
+ "root_groups": "/api/v2/inventories/1/root_groups/",
+ "variable_data": "/api/v2/inventories/1/variable_data/",
+ "script": "/api/v2/inventories/1/script/",
+ "tree": "/api/v2/inventories/1/tree/",
+ "inventory_sources": "/api/v2/inventories/1/inventory_sources/",
+ "update_inventory_sources": "/api/v2/inventories/1/update_inventory_sources/",
+ "activity_stream": "/api/v2/inventories/1/activity_stream/",
+ "job_templates": "/api/v2/inventories/1/job_templates/",
+ "ad_hoc_commands": "/api/v2/inventories/1/ad_hoc_commands/",
+ "access_list": "/api/v2/inventories/1/access_list/",
+ "object_roles": "/api/v2/inventories/1/object_roles/",
+ "instance_groups": "/api/v2/inventories/1/instance_groups/",
+ "copy": "/api/v2/inventories/1/copy/",
+ "organization": "/api/v2/organizations/1/"
+ },
+ "summary_fields": {
+ "organization": {
+ "id": 1,
+ "name": "Default",
+ "description": ""
+ },
+ "created_by": {
+ "id": 1,
+ "username": "admin",
+ "first_name": "",
+ "last_name": ""
+ },
+ "modified_by": {
+ "id": 1,
+ "username": "admin",
+ "first_name": "",
+ "last_name": ""
+ },
+ "object_roles": {
+ "admin_role": {
+ "description": "Can manage all aspects of the inventory",
+ "name": "Admin",
+ "id": 21
+ },
+ "update_role": {
+ "description": "May update project or inventory or group using the configured source update system",
+ "name": "Update",
+ "id": 22
+ },
+ "adhoc_role": {
+ "description": "May run ad hoc commands on an inventory",
+ "name": "Ad Hoc",
+ "id": 23
+ },
+ "use_role": {
+ "description": "Can use the inventory in a job template",
+ "name": "Use",
+ "id": 24
+ },
+ "read_role": {
+ "description": "May view settings for the inventory",
+ "name": "Read",
+ "id": 25
+ }
+ },
+ "user_capabilities": {
+ "edit": true,
+ "delete": true,
+ "copy": true,
+ "adhoc": true
+ }
+ },
+ "created": "2019-05-21T15:45:31.954359Z",
+ "modified": "2019-05-21T15:45:31.954378Z",
+ "name": "Demo Inventory",
+ "description": "",
+ "organization": 1,
+ "kind": "",
+ "host_filter": null,
+ "variables": "",
+ "has_active_failures": false,
+ "total_hosts": 1,
+ "hosts_with_active_failures": 0,
+ "total_groups": 0,
+ "groups_with_active_failures": 0,
+ "has_inventory_sources": false,
+ "total_inventory_sources": 0,
+ "inventory_sources_with_failures": 0,
+ "insights_credential": null,
+ "pending_deletion": false
+ }
+ ]
+ }
+ }
+}
diff --git a/test/ansible-python-dg/mock-payloads/job-execution.json b/test/ansible-python-dg/mock-payloads/job-execution.json
new file mode 100644
index 0000000..b32e7c0
--- /dev/null
+++ b/test/ansible-python-dg/mock-payloads/job-execution.json
@@ -0,0 +1,216 @@
+{
+ "httpRequest" : {
+ "method" : "GET",
+ "path" : .PATH_JOB_EXECUTION_PAYLOAD
+ },
+ "httpResponse" : {
+ "body" : {
+ "id": "456",
+ "type": "job",
+ "url": "/api/v2/jobs/456/",
+ "related": {
+ "created_by": "/api/v2/users/1/",
+ "labels": "/api/v2/jobs/456/labels/",
+ "inventory": "/api/v2/inventories/1/",
+ "project": "/api/v2/projects/8/",
+ "extra_credentials": "/api/v2/jobs/456/extra_credentials/",
+ "credentials": "/api/v2/jobs/456/credentials/",
+ "unified_job_template": "/api/v2/job_templates/123/",
+ "stdout": "/api/v2/jobs/456/stdout/",
+ "job_events": "/api/v2/jobs/456/job_events/",
+ "job_host_summaries": "/api/v2/jobs/456/job_host_summaries/",
+ "activity_stream": "/api/v2/jobs/456/activity_stream/",
+ "notifications": "/api/v2/jobs/456/notifications/",
+ "job_template": "/api/v2/job_templates/123/",
+ "cancel": "/api/v2/jobs/456/cancel/",
+ "create_schedule": "/api/v2/jobs/456/create_schedule/",
+ "relaunch": "/api/v2/jobs/456/relaunch/"
+ },
+ "summary_fields": {
+ "inventory": {
+ "id": 1,
+ "name": "Demo Inventory",
+ "description": "",
+ "has_active_failures": false,
+ "total_hosts": 1,
+ "hosts_with_active_failures": 0,
+ "total_groups": 0,
+ "groups_with_active_failures": 0,
+ "has_inventory_sources": false,
+ "total_inventory_sources": 0,
+ "inventory_sources_with_failures": 0,
+ "organization_id": 1,
+ "kind": ""
+ },
+ "project": {
+ "id": 8,
+ "name": "cds_playbooks",
+ "description": "CDS - cds_playbooks Project",
+ "status": "ok",
+ "scm_type": ""
+ },
+ "job_template": {
+ "id": "123",
+ "name": "hello_world_job_template",
+ "description": "hello_world Runner Job Template"
+ },
+ "unified_job_template": {
+ "id": "123",
+ "name": "hello_world_job_template",
+ "description": "hello_world Runner Job Template",
+ "unified_job_type": "job"
+ },
+ "instance_group": {
+ "name": "tower",
+ "id": 1
+ },
+ "created_by": {
+ "id": 1,
+ "username": "admin",
+ "first_name": "",
+ "last_name": ""
+ },
+ "user_capabilities": {
+ "delete": true,
+ "start": true
+ },
+ "labels": {
+ "count": 0,
+ "results": []
+ },
+ "extra_credentials": [],
+ "credentials": []
+ },
+ "created": "2019-06-12T11:21:26.891986Z",
+ "modified": "2019-06-12T11:21:27.355185Z",
+ "name": "hello_world_job_template",
+ "description": "hello_world Runner Job Template",
+ "job_type": "run",
+ "inventory": 1,
+ "project": 8,
+ "playbook": "hello_world.yml",
+ "forks": 0,
+ "limit": "",
+ "verbosity": 0,
+ "extra_vars": "{\"tor_group\": \"vEPC\", \"site_id\": \"3 - Belmont\"}",
+ "job_tags": "",
+ "force_handlers": false,
+ "skip_tags": "",
+ "start_at_task": "",
+ "timeout": 0,
+ "use_fact_cache": false,
+ "unified_job_template": "123",
+ "launch_type": "manual",
+ "status": "successful",
+ "failed": false,
+ "started": "2019-06-12T11:21:27.510766Z",
+ "finished": "2019-06-12T11:21:48.993385Z",
+ "elapsed": 21.483,
+ "job_args": "[\"ansible-playbook\", \"-u\", \"root\", \"-i\", \"/tmp/awx_223_ft8hu4p4/tmptmtwllu4\", \"-e\", \"@/tmp/awx_223_ft8hu4p4/env/extravars\", \"hello_world.yml\"]",
+ "job_cwd": "/var/lib/awx/projects/cds_playbooks_folder",
+ "job_env": {
+ "HOSTNAME": "awx",
+ "LC_ALL": "en_US.UTF-8",
+ "VIRTUAL_ENV": "/var/lib/awx/venv/ansible",
+ "PATH": "/var/lib/awx/venv/ansible/bin:/var/lib/awx/venv/awx/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
+ "SUPERVISOR_GROUP_NAME": "tower-processes",
+ "PWD": "/var/lib/awx",
+ "LANG": "en_US.UTF-8",
+ "PS1": "(awx) ",
+ "SUPERVISOR_ENABLED": "1",
+ "HOME": "/var/lib/awx",
+ "SHLVL": "2",
+ "LANGUAGE": "en_US.UTF-8",
+ "LC_CTYPE": "en_US.UTF-8",
+ "SUPERVISOR_PROCESS_NAME": "dispatcher",
+ "SUPERVISOR_SERVER_URL": "unix:///tmp/supervisor.sock",
+ "DJANGO_SETTINGS_MODULE": "awx.settings.production",
+ "DJANGO_LIVE_TEST_SERVER_ADDRESS": "localhost:9013-9199",
+ "TZ": "UTC",
+ "ANSIBLE_FORCE_COLOR": "True",
+ "ANSIBLE_HOST_KEY_CHECKING": "False",
+ "ANSIBLE_INVENTORY_UNPARSED_FAILED": "True",
+ "ANSIBLE_PARAMIKO_RECORD_HOST_KEYS": "False",
+ "ANSIBLE_VENV_PATH": "/var/lib/awx/venv/ansible",
+ "AWX_PRIVATE_DATA_DIR": "/tmp/awx_223_ft8hu4p4",
+ "PYTHONPATH": "/var/lib/awx/venv/ansible/lib/python2.7/site-packages:/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/lib:",
+ "JOB_ID": "456",
+ "INVENTORY_ID": "1",
+ "PROJECT_REVISION": "",
+ "ANSIBLE_RETRY_FILES_ENABLED": "False",
+ "MAX_EVENT_RES": "700000",
+ "ANSIBLE_CALLBACK_PLUGINS": "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/plugins/callback",
+ "AWX_HOST": "https://towerhost",
+ "ANSIBLE_SSH_CONTROL_PATH_DIR": "/tmp/awx_223_ft8hu4p4/cp",
+ "ANSIBLE_STDOUT_CALLBACK": "awx_display",
+ "AWX_ISOLATED_DATA_DIR": "/tmp/awx_223_ft8hu4p4/artifacts/456"
+ },
+ "job_explanation": "",
+ "execution_node": "awx",
+ "controller_node": "",
+ "result_traceback": "",
+ "event_processing_finished": true,
+ "job_template": "123",
+ "passwords_needed_to_start": [],
+ "ask_diff_mode_on_launch": false,
+ "ask_variables_on_launch": true,
+ "ask_limit_on_launch": true,
+ "ask_tags_on_launch": true,
+ "ask_skip_tags_on_launch": true,
+ "ask_job_type_on_launch": false,
+ "ask_verbosity_on_launch": false,
+ "ask_inventory_on_launch": true,
+ "ask_credential_on_launch": true,
+ "allow_simultaneous": false,
+ "artifacts": {
+ "interface_groups": [
+ "NSO-Openstack-NFVI-SRIOV-Shared"
+ ],
+ "host_groups": "NSO-Openstack-NFVI-SRIOV-Shared_999, ",
+ "topology": {
+ "tor-8.tenlab-cloud": [
+ {
+ "interface_lldp_description": "sriov-s-2",
+ "interface_group": "NSO-Openstack-NFVI-SRIOV-Shared",
+ "lldp_interface_id": 740,
+ "compute_device": "nfvi-compute-14.tenlab-nfvi",
+ "interface_parent_name": null,
+ "interface_name": "TenGigE0/0/0/19",
+ "host_aggregate": "vLNS",
+ "tor_device": "tor-8.tenlab-cloud",
+ "compute_interface": "sriov-s-2"
+ }
+ ],
+ "tor-7.tenlab-cloud": [
+ {
+ "interface_lldp_description": "sriov-s-1",
+ "interface_group": "NSO-Openstack-NFVI-SRIOV-Shared",
+ "lldp_interface_id": 698,
+ "compute_device": "nfvi-compute-14.tenlab-nfvi",
+ "interface_parent_name": null,
+ "interface_name": "TenGigE0/0/0/19",
+ "host_aggregate": "vLNS",
+ "tor_device": "tor-7.tenlab-cloud",
+ "compute_interface": "sriov-s-1"
+ }
+ ]
+ }
+ },
+ "scm_revision": "",
+ "instance_group": 1,
+ "diff_mode": false,
+ "job_slice_number": 0,
+ "job_slice_count": 1,
+ "host_status_counts": {
+ "ok": 1
+ },
+ "playbook_counts": {
+ "play_count": 1,
+ "task_count": 2
+ },
+ "custom_virtualenv": "/var/lib/awx/venv/ansible",
+ "credential": null,
+ "vault_credential": null
+ }
+ }
+}
diff --git a/test/ansible-python-dg/mock-payloads/job-output.json b/test/ansible-python-dg/mock-payloads/job-output.json
new file mode 100644
index 0000000..cd861c3
--- /dev/null
+++ b/test/ansible-python-dg/mock-payloads/job-output.json
@@ -0,0 +1,24 @@
+{
+ "httpRequest" : {
+ "method" : "GET",
+ "path" : .PATH_JOB_OUTPUT_PAYLOAD
+ },
+ "httpResponse" : {
+ "body" : "
+
+ PLAY [Hello World Sample] ******************************************************
+
+ TASK [Gathering Facts] *********************************************************
+ ok: [localhost]
+
+ TASK [Hello Message] ***********************************************************
+ ok: [localhost] => {
+ \"msg\": \"Hello World!\"
+ }
+
+ PLAY RECAP *********************************************************************
+ localhost : ok=2 changed=0 unreachable=0 failed=0
+
+"
+ }
+}
diff --git a/test/ansible-python-dg/mock-payloads/job-template.json b/test/ansible-python-dg/mock-payloads/job-template.json
new file mode 100644
index 0000000..942bed2
--- /dev/null
+++ b/test/ansible-python-dg/mock-payloads/job-template.json
@@ -0,0 +1,224 @@
+{
+ "httpRequest" : {
+ "method" : "GET",
+ "path" : .PATH_JT_PAYLOAD
+ },
+ "httpResponse" : {
+ "body" : {
+ "id": "123",
+ "type": "job_template",
+ "url": "/api/v2/job_templates/123/",
+ "related": {
+ "named_url": "/api/v2/job_templates/hello_world_job_template/",
+ "created_by": "/api/v2/users/1/",
+ "modified_by": "/api/v2/users/1/",
+ "labels": "/api/v2/job_templates/123/labels/",
+ "inventory": "/api/v2/inventories/1/",
+ "project": "/api/v2/projects/8/",
+ "extra_credentials": "/api/v2/job_templates/123/extra_credentials/",
+ "credentials": "/api/v2/job_templates/123/credentials/",
+ "last_job": "/api/v2/jobs/222/",
+ "jobs": "/api/v2/job_templates/123/jobs/",
+ "schedules": "/api/v2/job_templates/123/schedules/",
+ "activity_stream": "/api/v2/job_templates/123/activity_stream/",
+ "launch": "/api/v2/job_templates/123/launch/",
+ "notification_templates_any": "/api/v2/job_templates/123/notification_templates_any/",
+ "notification_templates_success": "/api/v2/job_templates/123/notification_templates_success/",
+ "notification_templates_error": "/api/v2/job_templates/123/notification_templates_error/",
+ "access_list": "/api/v2/job_templates/123/access_list/",
+ "survey_spec": "/api/v2/job_templates/123/survey_spec/",
+ "object_roles": "/api/v2/job_templates/123/object_roles/",
+ "instance_groups": "/api/v2/job_templates/123/instance_groups/",
+ "slice_workflow_jobs": "/api/v2/job_templates/123/slice_workflow_jobs/",
+ "copy": "/api/v2/job_templates/123/copy/"
+ },
+ "summary_fields": {
+ "inventory": {
+ "id": 1,
+ "name": "Demo Inventory",
+ "description": "",
+ "has_active_failures": false,
+ "total_hosts": 1,
+ "hosts_with_active_failures": 0,
+ "total_groups": 0,
+ "groups_with_active_failures": 0,
+ "has_inventory_sources": false,
+ "total_inventory_sources": 0,
+ "inventory_sources_with_failures": 0,
+ "organization_id": 1,
+ "kind": ""
+ },
+ "project": {
+ "id": 8,
+ "name": "cds_playbooks",
+ "description": "CDS - cds_playbooks Project",
+ "status": "ok",
+ "scm_type": ""
+ },
+ "last_job": {
+ "id": 222,
+ "name": "hello_world_job_template",
+ "description": "hello_world Runner Job Template",
+ "finished": "2019-06-12T11:20:27.892787Z",
+ "status": "successful",
+ "failed": false
+ },
+ "last_update": {
+ "id": 222,
+ "name": "hello_world_job_template",
+ "description": "hello_world Runner Job Template",
+ "status": "successful",
+ "failed": false
+ },
+ "created_by": {
+ "id": 1,
+ "username": "admin",
+ "first_name": "",
+ "last_name": ""
+ },
+ "modified_by": {
+ "id": 1,
+ "username": "admin",
+ "first_name": "",
+ "last_name": ""
+ },
+ "object_roles": {
+ "admin_role": {
+ "description": "Can manage all aspects of the job template",
+ "name": "Admin",
+ "id": 51
+ },
+ "execute_role": {
+ "description": "May run the job template",
+ "name": "Execute",
+ "id": 52
+ },
+ "read_role": {
+ "description": "May view settings for the job template",
+ "name": "Read",
+ "id": 53
+ }
+ },
+ "user_capabilities": {
+ "edit": true,
+ "delete": true,
+ "start": true,
+ "schedule": true,
+ "copy": true
+ },
+ "labels": {
+ "count": 0,
+ "results": []
+ },
+ "survey": {
+ "title": "",
+ "description": ""
+ },
+ "recent_jobs": [
+ {
+ "id": 222,
+ "status": "successful",
+ "finished": "2019-06-12T11:20:27.892787Z",
+ "type": "job"
+ },
+ {
+ "id": 65,
+ "status": "successful",
+ "finished": "2019-06-03T18:27:19.114796Z",
+ "type": "job"
+ },
+ {
+ "id": 64,
+ "status": "successful",
+ "finished": "2019-06-03T18:26:53.606618Z",
+ "type": "job"
+ },
+ {
+ "id": 63,
+ "status": "successful",
+ "finished": "2019-06-03T18:24:36.072943Z",
+ "type": "job"
+ },
+ {
+ "id": 62,
+ "status": "successful",
+ "finished": "2019-06-03T18:17:50.616528Z",
+ "type": "job"
+ },
+ {
+ "id": 61,
+ "status": "successful",
+ "finished": "2019-06-03T18:04:42.995611Z",
+ "type": "job"
+ },
+ {
+ "id": 60,
+ "status": "successful",
+ "finished": "2019-06-03T17:47:13.983951Z",
+ "type": "job"
+ },
+ {
+ "id": 50,
+ "status": "successful",
+ "finished": "2019-05-30T15:47:55.700161Z",
+ "type": "job"
+ },
+ {
+ "id": 49,
+ "status": "successful",
+ "finished": "2019-05-29T14:46:51.615926Z",
+ "type": "job"
+ },
+ {
+ "id": 47,
+ "status": "successful",
+ "finished": "2019-05-27T20:23:58.656709Z",
+ "type": "job"
+ }
+ ],
+ "extra_credentials": [],
+ "credentials": []
+ },
+ "created": "2019-05-21T19:28:05.953730Z",
+ "modified": "2019-05-21T20:06:55.728697Z",
+ "name": "hello_world_job_template",
+ "description": "hello_world Runner Job Template",
+ "job_type": "run",
+ "inventory": 1,
+ "project": 8,
+ "playbook": "hello_world.yml",
+ "forks": 0,
+ "limit": "",
+ "verbosity": 0,
+ "extra_vars": "",
+ "job_tags": "",
+ "force_handlers": false,
+ "skip_tags": "",
+ "start_at_task": "",
+ "timeout": 0,
+ "use_fact_cache": false,
+ "last_job_run": "2019-06-12T11:20:27.892787Z",
+ "last_job_failed": false,
+ "next_job_run": null,
+ "status": "successful",
+ "host_config_key": "",
+ "ask_diff_mode_on_launch": false,
+ "ask_variables_on_launch": true,
+ "ask_limit_on_launch": true,
+ "ask_tags_on_launch": true,
+ "ask_skip_tags_on_launch": true,
+ "ask_job_type_on_launch": false,
+ "ask_verbosity_on_launch": false,
+ "ask_inventory_on_launch": true,
+ "ask_credential_on_launch": true,
+ "survey_enabled": true,
+ "become_enabled": false,
+ "diff_mode": false,
+ "allow_simultaneous": false,
+ "custom_virtualenv": null,
+ "job_slice_count": 1,
+ "credential": null,
+ "vault_credential": null
+ }
+ }
+}
diff --git a/test/ansible-python-dg/mock-payloads/post_job-template-launch.json b/test/ansible-python-dg/mock-payloads/post_job-template-launch.json
new file mode 100644
index 0000000..531e471
--- /dev/null
+++ b/test/ansible-python-dg/mock-payloads/post_job-template-launch.json
@@ -0,0 +1,144 @@
+{
+ "httpRequest" : {
+ "method" : "POST",
+ "path" : .PATH_POST_JT_LAUNCH_PAYLOAD
+ },
+ "httpResponse" : {
+ "body" : {
+ "job": "456",
+ "ignored_fields": {},
+ "id": "456",
+ "type": "job",
+ "url": "/api/v2/jobs/456/",
+ "related": {
+ "created_by": "/api/v2/users/1/",
+ "modified_by": "/api/v2/users/1/",
+ "labels": "/api/v2/jobs/456/labels/",
+ "inventory": "/api/v2/inventories/1/",
+ "project": "/api/v2/projects/8/",
+ "extra_credentials": "/api/v2/jobs/456/extra_credentials/",
+ "credentials": "/api/v2/jobs/456/credentials/",
+ "unified_job_template": "/api/v2/job_templates/123/",
+ "stdout": "/api/v2/jobs/456/stdout/",
+ "job_events": "/api/v2/jobs/456/job_events/",
+ "job_host_summaries": "/api/v2/jobs/456/job_host_summaries/",
+ "activity_stream": "/api/v2/jobs/456/activity_stream/",
+ "notifications": "/api/v2/jobs/456/notifications/",
+ "job_template": "/api/v2/job_templates/123/",
+ "cancel": "/api/v2/jobs/456/cancel/",
+ "create_schedule": "/api/v2/jobs/456/create_schedule/",
+ "relaunch": "/api/v2/jobs/456/relaunch/"
+ },
+ "summary_fields": {
+ "inventory": {
+ "id": 1,
+ "name": "Demo Inventory",
+ "description": "",
+ "has_active_failures": false,
+ "total_hosts": 1,
+ "hosts_with_active_failures": 0,
+ "total_groups": 0,
+ "groups_with_active_failures": 0,
+ "has_inventory_sources": false,
+ "total_inventory_sources": 0,
+ "inventory_sources_with_failures": 0,
+ "organization_id": 1,
+ "kind": ""
+ },
+ "project": {
+ "id": 8,
+ "name": "cds_playbooks",
+ "description": "CDS - cds_playbooks Project",
+ "status": "ok",
+ "scm_type": ""
+ },
+ "job_template": {
+ "id": "123",
+ "name": "hello_world_job_template",
+ "description": "hello_world Runner Job Template"
+ },
+ "unified_job_template": {
+ "id": "123",
+ "name": "hello_world_job_template",
+ "description": "hello_world Runner Job Template",
+ "unified_job_type": "job"
+ },
+ "created_by": {
+ "id": 1,
+ "username": "admin",
+ "first_name": "",
+ "last_name": ""
+ },
+ "modified_by": {
+ "id": 1,
+ "username": "admin",
+ "first_name": "",
+ "last_name": ""
+ },
+ "user_capabilities": {
+ "delete": true,
+ "start": true
+ },
+ "labels": {
+ "count": 0,
+ "results": []
+ },
+ "extra_credentials": [],
+ "credentials": []
+ },
+ "created": "2019-06-12T11:21:26.891986Z",
+ "modified": "2019-06-12T11:21:27.016410Z",
+ "name": "hello_world_job_template",
+ "description": "hello_world Runner Job Template",
+ "job_type": "run",
+ "inventory": 1,
+ "project": 8,
+ "playbook": "hello_world.yml",
+ "forks": 0,
+ "limit": "",
+ "verbosity": 0,
+ "extra_vars": "{\"tor_group\": \"vEPC\", \"site_id\": \"3 - Belmont\"}",
+ "job_tags": "",
+ "force_handlers": false,
+ "skip_tags": "",
+ "start_at_task": "",
+ "timeout": 0,
+ "use_fact_cache": false,
+ "unified_job_template": "123",
+ "launch_type": "manual",
+ "status": "pending",
+ "failed": false,
+ "started": null,
+ "finished": null,
+ "elapsed": 0,
+ "job_args": "",
+ "job_cwd": "",
+ "job_env": {},
+ "job_explanation": "",
+ "execution_node": "",
+ "controller_node": "",
+ "result_traceback": "",
+ "event_processing_finished": false,
+ "job_template": "123",
+ "passwords_needed_to_start": [],
+ "ask_diff_mode_on_launch": false,
+ "ask_variables_on_launch": true,
+ "ask_limit_on_launch": true,
+ "ask_tags_on_launch": true,
+ "ask_skip_tags_on_launch": true,
+ "ask_job_type_on_launch": false,
+ "ask_verbosity_on_launch": false,
+ "ask_inventory_on_launch": true,
+ "ask_credential_on_launch": true,
+ "allow_simultaneous": false,
+ "artifacts": {},
+ "scm_revision": "",
+ "instance_group": null,
+ "diff_mode": false,
+ "job_slice_number": 0,
+ "job_slice_count": 1,
+ "credential": null,
+ "vault_credential": null
+ }
+ }
+}
diff --git a/test/ansible-python-dg/success/expected-response.json b/test/ansible-python-dg/success/expected-response.json
new file mode 100644
index 0000000..833c2eb
--- /dev/null
+++ b/test/ansible-python-dg/success/expected-response.json
@@ -0,0 +1,30 @@
+{
+ "correlationUUID": null,
+ "commonHeader": {
+ "timestamp": "2020-05-26T01:11:00.914Z",
+ "originatorId": "System",
+ "requestId": "ansible-python-dg-success",
+ "subRequestId": "ansible-python-dg-success-1",
+ "flags": null
+ },
+ "actionIdentifiers": {
+ "blueprintName": "RT-ansible-python-dg",
+ "blueprintVersion": "1.0.0",
+ "actionName": "run-dg",
+ "mode": "sync"
+ },
+ "status": {
+ "code": 200,
+ "eventType": "EVENT_COMPONENT_EXECUTED",
+ "timestamp": "2020-05-26T01:11:17.384Z",
+ "errorMessage": null,
+ "message": "success"
+ },
+ "payload": {
+ "run-dg-response": {
+ "execute-command-logs": [
+ "TenGigE0/0/0/19"
+ ]
+ }
+ }
+}
diff --git a/test/ansible-python-dg/success/request-payload.json b/test/ansible-python-dg/success/request-payload.json
new file mode 100644
index 0000000..bf68498
--- /dev/null
+++ b/test/ansible-python-dg/success/request-payload.json
@@ -0,0 +1,27 @@
+{
+ "commonHeader": {
+ "originatorId": "System",
+ "requestId": "ansible-python-dg-success",
+ "subRequestId": "ansible-python-dg-success-1"
+ },
+ "actionIdentifiers": {
+ "blueprintName": "RT-ansible-python-dg",
+ "blueprintVersion": "1.0.0",
+ "actionName": "run-dg",
+ "mode": "sync"
+ },
+ "payload": {
+ "run-dg-request": {
+ "endpoint-selector": "awx",
+ "job-template-name": "hello_world_job_template",
+ "inventory": "Demo Inventory",
+ "limit": "123",
+ "tags": "some-tag",
+ "skip-tags": "some-skip-tag",
+ "extra-vars": {
+ "site_id": "3 - Belmont",
+ "tor_group": "vEPC"
+ }
+ }
+ }
+}
diff --git a/test/ansible-python-dg/success/test.sh b/test/ansible-python-dg/success/test.sh
new file mode 100644
index 0000000..105a17f
--- /dev/null
+++ b/test/ansible-python-dg/success/test.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+#
+# Copyright (C) 2020 Bell Canada.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+CBA_NAME="ansible-python-dg"
+TEST_NAME="success"
+TEST_NUMBER=$RANDOM
+
+mkdir -p "$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/"
+RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-headers"
+RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-payload"
+
+REQUEST_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/request-payload.json"
+EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/expected-response.json"
+
+. ./$TEST_DIRECTORY/utils.sh
+
+echo "Running test: $CBA_NAME:$TEST_NUMBER:$TEST_NAME"
+
+echo 'Calling CDS process'
+process_cba $REQUEST_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE $RESPONSE_HEADERS_FILE
+
+echo 'Assert statuscode'
+assert_status_code 200 $RESPONSE_HEADERS_FILE
+
+echo 'Assert payload'
+assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE