diff options
author | SantoshB <santosh.bayas@amdocs.com> | 2020-10-15 14:57:57 +0530 |
---|---|---|
committer | mrichomme <morgan.richomme@orange.com> | 2020-11-12 14:52:33 +0100 |
commit | d3cdace51db473c93540229da3a0fd061120957c (patch) | |
tree | d2d4f1031c7d577d51fe27b6daf1a1e80cdb409d /cds-regression-test/test | |
parent | 8e75c091c8f2079b8ae59ae544fbd19bbef3f963 (diff) |
cds-bash script package
Issue-ID: CCSDK-2913
Change-Id: I2f97b0c78314019d5002e8563c4e433ae5e816b9
Signed-off-by: SantoshB <santosh.bayas@amdocs.com>
Signed-off-by: mrichomme <morgan.richomme@orange.com>
Diffstat (limited to 'cds-regression-test/test')
250 files changed, 8972 insertions, 0 deletions
diff --git a/cds-regression-test/test/ansible-python-dg/ansible-python-dg-enrichment-test.sh b/cds-regression-test/test/ansible-python-dg/ansible-python-dg-enrichment-test.sh new file mode 100644 index 0000000..26dfa99 --- /dev/null +++ b/cds-regression-test/test/ansible-python-dg/ansible-python-dg-enrichment-test.sh @@ -0,0 +1,16 @@ +#!/bin/bash +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 + +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/cds-regression-test/test/ansible-python-dg/ansible-python-dg-upload-test.sh b/cds-regression-test/test/ansible-python-dg/ansible-python-dg-upload-test.sh new file mode 100644 index 0000000..f3abae1 --- /dev/null +++ b/cds-regression-test/test/ansible-python-dg/ansible-python-dg-upload-test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +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/cds-regression-test/test/ansible-python-dg/dummy-request-payload.json b/cds-regression-test/test/ansible-python-dg/dummy-request-payload.json new file mode 100644 index 0000000..f04d745 --- /dev/null +++ b/cds-regression-test/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/cds-regression-test/test/ansible-python-dg/init-mockserver.sh b/cds-regression-test/test/ansible-python-dg/init-mockserver.sh new file mode 100644 index 0000000..b777714 --- /dev/null +++ b/cds-regression-test/test/ansible-python-dg/init-mockserver.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +CBA_NAME="ansible-python-dg" +DIR_PAYLOADS="$TEST_DIRECTORY/$CBA_NAME/mock-payloads" + + +# JOB TEMPLATE +echo "Mocking Job Template route..." +JT_PAYLOAD="job-template.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$JT_PAYLOAD" + +# JOB TEMPLATE LAUNCH - GET +echo "Mocking Job Template Launch GET route..." +GET_JT_LAUNCH_PAYLOAD="get_job-template-launch.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$GET_JT_LAUNCH_PAYLOAD" + +# JOB TEMPLATE LAUNCH +echo "Mocking Inventory route..." +INVENTORY_PAYLOAD="inventory.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$INVENTORY_PAYLOAD" + +# JOB TEMPLATE LAUNCH - POST +echo "Mocking Job Template Launch POST route..." +POST_JT_LAUNCH_PAYLOAD="post_job-template-launch.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$POST_JT_LAUNCH_PAYLOAD" + +# JOB EXECUTION +echo "Mocking Job Execution route..." +JOB_EXECUTION_PAYLOAD="job-execution.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$JOB_EXECUTION_PAYLOAD" + +# JOB OUTPUT +echo "Mocking Job Output route..." +JOB_OUTPUT_PAYLOAD="job-output.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$JOB_OUTPUT_PAYLOAD" diff --git a/cds-regression-test/test/ansible-python-dg/mock-payloads/get_job-template-launch.json b/cds-regression-test/test/ansible-python-dg/mock-payloads/get_job-template-launch.json new file mode 100644 index 0000000..f4d0020 --- /dev/null +++ b/cds-regression-test/test/ansible-python-dg/mock-payloads/get_job-template-launch.json @@ -0,0 +1,46 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/ansible-python-dg/success/api/v2/job_templates/123/launch/" + }, + "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/cds-regression-test/test/ansible-python-dg/mock-payloads/inventory.json b/cds-regression-test/test/ansible-python-dg/mock-payloads/inventory.json new file mode 100644 index 0000000..87cfdfb --- /dev/null +++ b/cds-regression-test/test/ansible-python-dg/mock-payloads/inventory.json @@ -0,0 +1,110 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/ansible-python-dg/success/api/v2/inventories/" + }, + "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/cds-regression-test/test/ansible-python-dg/mock-payloads/job-execution.json b/cds-regression-test/test/ansible-python-dg/mock-payloads/job-execution.json new file mode 100644 index 0000000..34772d7 --- /dev/null +++ b/cds-regression-test/test/ansible-python-dg/mock-payloads/job-execution.json @@ -0,0 +1,216 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/ansible-python-dg/success/api/v2/jobs/456/" + }, + "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/cds-regression-test/test/ansible-python-dg/mock-payloads/job-output.json b/cds-regression-test/test/ansible-python-dg/mock-payloads/job-output.json new file mode 100644 index 0000000..4877737 --- /dev/null +++ b/cds-regression-test/test/ansible-python-dg/mock-payloads/job-output.json @@ -0,0 +1,24 @@ +{ + "httpRequest" : { + "method" : "GET", + "path" : "/ansible-python-dg/success/api/v2/jobs/456/stdout/" + }, + "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/cds-regression-test/test/ansible-python-dg/mock-payloads/job-template.json b/cds-regression-test/test/ansible-python-dg/mock-payloads/job-template.json new file mode 100644 index 0000000..5b78274 --- /dev/null +++ b/cds-regression-test/test/ansible-python-dg/mock-payloads/job-template.json @@ -0,0 +1,224 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/ansible-python-dg/success/api/v2/job_templates/hello_world_job_template/" + }, + "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/cds-regression-test/test/ansible-python-dg/mock-payloads/post_job-template-launch.json b/cds-regression-test/test/ansible-python-dg/mock-payloads/post_job-template-launch.json new file mode 100644 index 0000000..da92392 --- /dev/null +++ b/cds-regression-test/test/ansible-python-dg/mock-payloads/post_job-template-launch.json @@ -0,0 +1,144 @@ +{ + "httpRequest": { + "method": "POST", + "path": "/ansible-python-dg/success/api/v2/job_templates/123/launch/" + }, + "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/cds-regression-test/test/ansible-python-dg/success/expected-response.json b/cds-regression-test/test/ansible-python-dg/success/expected-response.json new file mode 100644 index 0000000..833c2eb --- /dev/null +++ b/cds-regression-test/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/cds-regression-test/test/ansible-python-dg/success/request-payload.json b/cds-regression-test/test/ansible-python-dg/success/request-payload.json new file mode 100644 index 0000000..bf68498 --- /dev/null +++ b/cds-regression-test/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/cds-regression-test/test/ansible-python-dg/success/test.sh b/cds-regression-test/test/ansible-python-dg/success/test.sh new file mode 100644 index 0000000..8977244 --- /dev/null +++ b/cds-regression-test/test/ansible-python-dg/success/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +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 diff --git a/cds-regression-test/test/bootstrap.sh b/cds-regression-test/test/bootstrap.sh new file mode 100755 index 0000000..36641ed --- /dev/null +++ b/cds-regression-test/test/bootstrap.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Starting from Frankfurt CDS release, we need to bootstrap on the first execution. + +# bootstrap files output filenames +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/bootstrap-response-headers" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/bootstrap-response-payload" + +if [ ${CDS_VERSION} == "elalto" ]; then + echo "Skipping bootstrap for elalto release" +else + echo "Bootstrapping CDS" + . ./$TEST_DIRECTORY/utils.sh + bootstrap_cds ${RESPONSE_PAYLOAD_FILE} ${RESPONSE_HEADERS_FILE} + echo "DEBUG::: RESPONSE_HEADERS_FILE: ${RESPONSE_HEADERS_FILE}" + cat ${RESPONSE_HEADERS_FILE} + echo "DEBUG::: RESPONSE_PAYLOAD_FILE: ${RESPONSE_PAYLOAD_FILE}" + cat ${RESPONSE_PAYLOAD_FILE} + assert_status_code 200 ${RESPONSE_HEADERS_FILE} +fi diff --git a/cds-regression-test/test/cli/cli-enrichment-test.sh b/cds-regression-test/test/cli/cli-enrichment-test.sh new file mode 100755 index 0000000..a41a1ea --- /dev/null +++ b/cds-regression-test/test/cli/cli-enrichment-test.sh @@ -0,0 +1,16 @@ +#!/bin/bash +CBA_NAME="cli" +TEST_NAME="$CBA_NAME-enrichment" +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +echo "Compressing CBA: $CBA_NAME" +compress_cba_versioned $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/cds-regression-test/test/cli/cli-upload-test.sh b/cds-regression-test/test/cli/cli-upload-test.sh new file mode 100755 index 0000000..7285cd4 --- /dev/null +++ b/cds-regression-test/test/cli/cli-upload-test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +CBA_NAME="cli" +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/cds-regression-test/test/cli/command-fail/resources/elalto/expected-response.json b/cds-regression-test/test/cli/command-fail/resources/elalto/expected-response.json new file mode 100644 index 0000000..b7b29e2 --- /dev/null +++ b/cds-regression-test/test/cli/command-fail/resources/elalto/expected-response.json @@ -0,0 +1,27 @@ +{ + "commonHeader": { + "timestamp": "2020-02-11T21:24:35.215Z", + "originatorId": "System", + "requestId": "regression-test-cli-command-fail", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-02-11T21:24:36.824Z", + "errorMessage": "Failed to execute commands, below the output : \nCommand : nonExistCommand", + "message": "failure" + }, + "payload": { + "cli-response": { + "response-data": "Error" + } + } +} diff --git a/cds-regression-test/test/cli/command-fail/resources/elalto/request-payload.json b/cds-regression-test/test/cli/command-fail/resources/elalto/request-payload.json new file mode 100644 index 0000000..db861c9 --- /dev/null +++ b/cds-regression-test/test/cli/command-fail/resources/elalto/request-payload.json @@ -0,0 +1,25 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli" + }, + "payload": { + "cli-request": { + "host": "cds-regression-sshmock", + "username": "cdstest", + "password": "testcds", + "port": "22", + "connectionTimeOut": "5000", + "commands": [ + "nonExistCommand" + ] + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-cli-command-fail", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/cli/command-fail/resources/frankfurt/expected-response.json b/cds-regression-test/test/cli/command-fail/resources/frankfurt/expected-response.json new file mode 100644 index 0000000..6b71773 --- /dev/null +++ b/cds-regression-test/test/cli/command-fail/resources/frankfurt/expected-response.json @@ -0,0 +1,34 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-04T15:05:20.003Z", + "originatorId": "System", + "requestId": "regression-test-cli-command-fail", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-06-04T15:05:41.528Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "cli-response": { + "response-data": [ + { + "command": "nonExistCommand", + "deviceOutput": "nonExistCommand\r\n/ $ nonExistCommand\r\n-ash: nonExistCommand: not found\r\n/ $ \u001b[6n", + "successful": true + } + ] + } + } +} diff --git a/cds-regression-test/test/cli/command-fail/resources/frankfurt/request-payload.json b/cds-regression-test/test/cli/command-fail/resources/frankfurt/request-payload.json new file mode 100644 index 0000000..700271e --- /dev/null +++ b/cds-regression-test/test/cli/command-fail/resources/frankfurt/request-payload.json @@ -0,0 +1,26 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli" + }, + "payload": { + "cli-request": { + "host": "cds-regression-sshmock", + "username": "cdstest", + "password": "testcds", + "port": "22", + "connectionTimeOut": "5000", + "logging": true, + "commands": [ + "nonExistCommand" + ] + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-cli-command-fail", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/cli/command-fail/test.sh b/cds-regression-test/test/cli/command-fail/test.sh new file mode 100755 index 0000000..a150680 --- /dev/null +++ b/cds-regression-test/test/cli/command-fail/test.sh @@ -0,0 +1,30 @@ +#!/bin/bash +CBA_NAME="cli" +TEST_NAME="command-fail" +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" + +RESOURCES_DIR="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/resources/$CDS_VERSION" +REQUEST_PAYLOAD_FILE="$RESOURCES_DIR/request-payload.json" +EXPECTED_PAYLOAD_FILE="$RESOURCES_DIR/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 + +if [ "${CDS_VERSION} " == "elalto " ]; then + echo 'Assert statuscode 500' + assert_status_code 500 $RESPONSE_HEADERS_FILE +else + echo 'Assert statuscode 200' + assert_status_code 200 $RESPONSE_HEADERS_FILE +fi + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/cli/dummy-request-payload.json b/cds-regression-test/test/cli/dummy-request-payload.json new file mode 100644 index 0000000..62d2f92 --- /dev/null +++ b/cds-regression-test/test/cli/dummy-request-payload.json @@ -0,0 +1,14 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "dummy-request-should-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "dummy", + "mode": "sync" + }, + "payload": {} +} diff --git a/cds-regression-test/test/cli/success/resources/elalto/expected-response.json b/cds-regression-test/test/cli/success/resources/elalto/expected-response.json new file mode 100644 index 0000000..a813478 --- /dev/null +++ b/cds-regression-test/test/cli/success/resources/elalto/expected-response.json @@ -0,0 +1,27 @@ +{ + "commonHeader": { + "timestamp": "2020-02-11T21:19:57.762Z", + "originatorId": "System", + "requestId": "regression-test-cli", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-02-11T21:20:00.446Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "cli-response": { + "response-data": "\nCommand : pwd\n/\n\nCommand : ls\nbin\ndev\netc\nlib\n" + } + } +} diff --git a/cds-regression-test/test/cli/success/resources/elalto/request-payload.json b/cds-regression-test/test/cli/success/resources/elalto/request-payload.json new file mode 100644 index 0000000..8019144 --- /dev/null +++ b/cds-regression-test/test/cli/success/resources/elalto/request-payload.json @@ -0,0 +1,26 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli" + }, + "payload": { + "cli-request": { + "host": "cds-regression-sshmock", + "username": "cdstest", + "password": "testcds", + "port": "22", + "connectionTimeOut": "5000", + "commands": [ + "pwd", + "ls" + ] + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-cli", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/cli/success/resources/frankfurt/expected-response.json b/cds-regression-test/test/cli/success/resources/frankfurt/expected-response.json new file mode 100644 index 0000000..55248cb --- /dev/null +++ b/cds-regression-test/test/cli/success/resources/frankfurt/expected-response.json @@ -0,0 +1,38 @@ +{ + "commonHeader": { + "timestamp": "2020-05-25T20:54:11.024Z", + "originatorId": "System", + "requestId": "regression-test-cli", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-05-25T20:54:21.453Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "cli-response": { + "response-data": [ + { + "command": "pwd", + "deviceOutput": "pwd\r\n/ $ pwd\r\n/\r\n/ $ \u001b[6n", + "successful": true + }, + { + "command": "ls", + "deviceOutput": "pwd\r\n/ $ pwd\r\n/\r\n/ $ \u001b[6nls\r\n\u001b[1;34mbin\u001b[m \u001b[1;34mdev\u001b[m \u001b[1;34metc\u001b[m \u001b[1;34mlib\u001b[m\r\n/ $ \u001b[6n", + "successful": true + } + ] + } + } +} diff --git a/cds-regression-test/test/cli/success/resources/frankfurt/request-payload.json b/cds-regression-test/test/cli/success/resources/frankfurt/request-payload.json new file mode 100644 index 0000000..0438a7c --- /dev/null +++ b/cds-regression-test/test/cli/success/resources/frankfurt/request-payload.json @@ -0,0 +1,27 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli" + }, + "payload": { + "cli-request": { + "host": "cds-regression-sshmock", + "username": "cdstest", + "password": "testcds", + "port": "22", + "connectionTimeOut": "5000", + "logging": true, + "commands": [ + "pwd", + "ls" + ] + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-cli", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/cli/success/test.sh b/cds-regression-test/test/cli/success/test.sh new file mode 100755 index 0000000..6a589d5 --- /dev/null +++ b/cds-regression-test/test/cli/success/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash +CBA_NAME="cli" +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" + +RESOURCES_DIR="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/resources/$CDS_VERSION" +REQUEST_PAYLOAD_FILE="$RESOURCES_DIR/request-payload.json" +EXPECTED_PAYLOAD_FILE="$RESOURCES_DIR/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 200' +assert_status_code 200 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/exit_on_failure.sh b/cds-regression-test/test/exit_on_failure.sh new file mode 100755 index 0000000..733e9a6 --- /dev/null +++ b/cds-regression-test/test/exit_on_failure.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ "$(wc -c $FAILED_TESTS_DIRECTORY/*|awk '/total/ {print $1}')" -gt 0 ] +then + echo "exiting due to presence of files in FAILED_TESTS_DIRECTORY" + wc -c $FAILED_TESTS_DIRECTORY/* + exit 1; +fi diff --git a/cds-regression-test/test/lock-device/dummy-request-payload.json b/cds-regression-test/test/lock-device/dummy-request-payload.json new file mode 100644 index 0000000..c3ca13c --- /dev/null +++ b/cds-regression-test/test/lock-device/dummy-request-payload.json @@ -0,0 +1,14 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "dummy-request-should-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "dummy", + "mode": "sync" + }, + "payload": {} +} diff --git a/cds-regression-test/test/lock-device/lock-device-enrichment-test.sh b/cds-regression-test/test/lock-device/lock-device-enrichment-test.sh new file mode 100644 index 0000000..6c549dd --- /dev/null +++ b/cds-regression-test/test/lock-device/lock-device-enrichment-test.sh @@ -0,0 +1,21 @@ +#!/bin/bash +if [ "${CDS_VERSION} " == "elalto " ]; then + echo "Skipping, not available in elalto" + return 0 +fi + +CBA_NAME="lock-device" +TEST_NAME="$CBA_NAME-enrichment" +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +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/cds-regression-test/test/lock-device/lock-device-upload-test.sh b/cds-regression-test/test/lock-device/lock-device-upload-test.sh new file mode 100644 index 0000000..902c6c7 --- /dev/null +++ b/cds-regression-test/test/lock-device/lock-device-upload-test.sh @@ -0,0 +1,25 @@ +#!/bin/bash +if [ "${CDS_VERSION} " == "elalto " ]; then + echo "Skipping, not available in elalto" + return 0 +fi + +CBA_NAME="lock-device" +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/cds-regression-test/test/lock-device/success/expected-payloads/expected-payload-1.json b/cds-regression-test/test/lock-device/success/expected-payloads/expected-payload-1.json new file mode 100644 index 0000000..b70b502 --- /dev/null +++ b/cds-regression-test/test/lock-device/success/expected-payloads/expected-payload-1.json @@ -0,0 +1,28 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-30T17:46:47.772Z", + "originatorId": "System", + "requestId": "lock-request-1", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-06-30T17:47:02.922Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "resolve-deploy-kotlin-response": { + "response-data": "Success: lock-request-1" + } + } +} diff --git a/cds-regression-test/test/lock-device/success/expected-payloads/expected-payload-2.json b/cds-regression-test/test/lock-device/success/expected-payloads/expected-payload-2.json new file mode 100644 index 0000000..bd0dfdc --- /dev/null +++ b/cds-regression-test/test/lock-device/success/expected-payloads/expected-payload-2.json @@ -0,0 +1,28 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-30T17:46:50.008Z", + "originatorId": "System", + "requestId": "lock-request-2", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-06-30T17:47:18.221Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "resolve-deploy-kotlin-response": { + "response-data": "Success: lock-request-2" + } + } +} diff --git a/cds-regression-test/test/lock-device/success/expected-payloads/expected-payload-3.json b/cds-regression-test/test/lock-device/success/expected-payloads/expected-payload-3.json new file mode 100644 index 0000000..9743758 --- /dev/null +++ b/cds-regression-test/test/lock-device/success/expected-payloads/expected-payload-3.json @@ -0,0 +1,26 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-30T17:46:51.761Z", + "originatorId": "System", + "requestId": "lock-request-3", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-06-30T17:47:12.301Z", + "errorMessage": "Failed in ComponentScriptExecutor : Failed to acquire lock within timeout, failed to get execution property(node_templates/execute-kotlin/attributes/response-data)", + "message": "failure" + }, + "payload": { + "resolve-deploy-kotlin-response": {} + } +} diff --git a/cds-regression-test/test/lock-device/success/expected-payloads/expected-payload-4.json b/cds-regression-test/test/lock-device/success/expected-payloads/expected-payload-4.json new file mode 100644 index 0000000..3b916ed --- /dev/null +++ b/cds-regression-test/test/lock-device/success/expected-payloads/expected-payload-4.json @@ -0,0 +1,26 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-30T17:46:54.081Z", + "originatorId": "System", + "requestId": "lock-request-4", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-06-30T17:47:14.865Z", + "errorMessage": "Failed in ComponentScriptExecutor : Failed to acquire lock within timeout, failed to get execution property(node_templates/execute-kotlin/attributes/response-data)", + "message": "failure" + }, + "payload": { + "resolve-deploy-kotlin-response": {} + } +} diff --git a/cds-regression-test/test/lock-device/success/request-payloads/request-payload-1.json b/cds-regression-test/test/lock-device/success/request-payloads/request-payload-1.json new file mode 100644 index 0000000..20be12a --- /dev/null +++ b/cds-regression-test/test/lock-device/success/request-payloads/request-payload-1.json @@ -0,0 +1,20 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin" + }, + "payload": { + "resolve-deploy-kotlin-request": { + "resolve-deploy-kotlin-properties": { + "lock-acquire-timeout": 5 + } + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "lock-request-1", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/lock-device/success/request-payloads/request-payload-2.json b/cds-regression-test/test/lock-device/success/request-payloads/request-payload-2.json new file mode 100644 index 0000000..3fdc8d2 --- /dev/null +++ b/cds-regression-test/test/lock-device/success/request-payloads/request-payload-2.json @@ -0,0 +1,20 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin" + }, + "payload": { + "resolve-deploy-kotlin-request": { + "resolve-deploy-kotlin-properties": { + "lock-acquire-timeout": 25 + } + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "lock-request-2", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/lock-device/success/request-payloads/request-payload-3.json b/cds-regression-test/test/lock-device/success/request-payloads/request-payload-3.json new file mode 100644 index 0000000..f0277bc --- /dev/null +++ b/cds-regression-test/test/lock-device/success/request-payloads/request-payload-3.json @@ -0,0 +1,20 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin" + }, + "payload": { + "resolve-deploy-kotlin-request": { + "resolve-deploy-kotlin-properties": { + "lock-acquire-timeout": 15 + } + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "lock-request-3", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/lock-device/success/request-payloads/request-payload-4.json b/cds-regression-test/test/lock-device/success/request-payloads/request-payload-4.json new file mode 100644 index 0000000..2ba6b89 --- /dev/null +++ b/cds-regression-test/test/lock-device/success/request-payloads/request-payload-4.json @@ -0,0 +1,20 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin" + }, + "payload": { + "resolve-deploy-kotlin-request": { + "resolve-deploy-kotlin-properties": { + "lock-acquire-timeout": 15 + } + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "lock-request-4", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/lock-device/success/test.sh b/cds-regression-test/test/lock-device/success/test.sh new file mode 100644 index 0000000..5553e5f --- /dev/null +++ b/cds-regression-test/test/lock-device/success/test.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +CBA_NAME="lock-device" +TEST_NAME="success" +TEST_NUMBER=$RANDOM +mkdir -p "$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/" + +. ./$TEST_DIRECTORY/utils.sh + +echo "Running test: $CBA_NAME:$TEST_NUMBER:$TEST_NAME" + +for i in `seq 1 4` +do + echo "Sending request $i" + RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-headers-$i" + RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-payload-$i" + REQUEST_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/request-payloads/request-payload-$i.json" + + process_cba $REQUEST_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE $RESPONSE_HEADERS_FILE & + pids[${i}]=$! + sleep 3 +done + +echo "Waiting for responses" +for pid in ${pids[*]} +do + wait $pid +done + +echo "Assert payload - request 1" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-payload-1" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/expected-payloads/expected-payload-1.json" +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE + +echo "Assert payload - request 2" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-payload-2" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/expected-payloads/expected-payload-2.json" +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE + +echo "Assert payload - request 3" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-payload-3" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/expected-payloads/expected-payload-3.json" +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE + +echo "Assert payload - request 4" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-payload-4" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/expected-payloads/expected-payload-4.json" +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/netconf/dummy-request-payload.json b/cds-regression-test/test/netconf/dummy-request-payload.json new file mode 100644 index 0000000..acc4f92 --- /dev/null +++ b/cds-regression-test/test/netconf/dummy-request-payload.json @@ -0,0 +1,14 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "dummy-request-should-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "dummy", + "mode": "sync" + }, + "payload": {} +} diff --git a/cds-regression-test/test/netconf/jython/connect-fail/expected-response.json b/cds-regression-test/test/netconf/jython/connect-fail/expected-response.json new file mode 100644 index 0000000..ff0cceb --- /dev/null +++ b/cds-regression-test/test/netconf/jython/connect-fail/expected-response.json @@ -0,0 +1,29 @@ +{ + "commonHeader": { + "timestamp": "2020-02-04T14:16:32.798Z", + "originatorId": "System", + "requestId": "regression-test-netconf-jython-connect-fail", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-jython", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-02-04T14:16:32.824Z", + "errorMessage": "org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfException: 127.0.0.1:17830: Failed to establish SSH session", + "message": "failure" + }, + "payload": { + "netconf-jython-response": { + "response-data": { + "deploySuccess": false + } + } + } +} diff --git a/cds-regression-test/test/netconf/jython/connect-fail/request-payload.json b/cds-regression-test/test/netconf/jython/connect-fail/request-payload.json new file mode 100644 index 0000000..9a9f240 --- /dev/null +++ b/cds-regression-test/test/netconf/jython/connect-fail/request-payload.json @@ -0,0 +1,19 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-jython" + }, + "payload": { + "netconf-jython-request": { + "netconf-host": "127.0.0.1", + "netconf-timeout": 5 + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-netconf-jython-connect-fail", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/netconf/jython/connect-fail/test.sh b/cds-regression-test/test/netconf/jython/connect-fail/test.sh new file mode 100755 index 0000000..670fa49 --- /dev/null +++ b/cds-regression-test/test/netconf/jython/connect-fail/test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +CBA_NAME="netconf" +LANG="jython" +TEST_NAME="connect-fail" +TEST_NUMBER=$RANDOM + +mkdir -p "$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/" +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-headers" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-payload" + +REQUEST_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/request-payload.json" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$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 500' +assert_status_code 500 $RESPONSE_HEADERS_FILE + +echo 'Assert connect fail payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/netconf/jython/success/expected-response.json b/cds-regression-test/test/netconf/jython/success/expected-response.json new file mode 100644 index 0000000..6408577 --- /dev/null +++ b/cds-regression-test/test/netconf/jython/success/expected-response.json @@ -0,0 +1,29 @@ +{ + "commonHeader": { + "timestamp": "2020-02-03T13:40:43.697Z", + "originatorId": "System", + "requestId": "regression-test-netconf-jython", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-jython", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-02-03T13:40:51.835Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "netconf-jython-response": { + "response-data": { + "deploySuccess": true + } + } + } +} diff --git a/cds-regression-test/test/netconf/jython/success/request-payload.json b/cds-regression-test/test/netconf/jython/success/request-payload.json new file mode 100644 index 0000000..dcaaeb1 --- /dev/null +++ b/cds-regression-test/test/netconf/jython/success/request-payload.json @@ -0,0 +1,19 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-jython" + }, + "payload": { + "netconf-jython-request": { + "netconf-host": "odl-netconf-testtool", + "netconf-timeout": 30 + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-netconf-jython", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/netconf/jython/success/test.sh b/cds-regression-test/test/netconf/jython/success/test.sh new file mode 100755 index 0000000..4b3e2c0 --- /dev/null +++ b/cds-regression-test/test/netconf/jython/success/test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +CBA_NAME="netconf" +LANG="jython" +TEST_NAME="success" +TEST_NUMBER=$RANDOM + +mkdir -p "$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/" +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-headers" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-payload" + +REQUEST_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/request-payload.json" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$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 200' +assert_status_code 200 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/netconf/kotlin/connect-fail/expected-response.json b/cds-regression-test/test/netconf/kotlin/connect-fail/expected-response.json new file mode 100644 index 0000000..9334b50 --- /dev/null +++ b/cds-regression-test/test/netconf/kotlin/connect-fail/expected-response.json @@ -0,0 +1,29 @@ +{ + "commonHeader": { + "timestamp": "2020-02-04T14:16:32.798Z", + "originatorId": "System", + "requestId": "regression-test-netconf-kotlin-connect-fail", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-kotlin", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-02-04T14:16:32.824Z", + "errorMessage": "org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfException: 127.0.0.1:17830: Failed to establish SSH session", + "message": "failure" + }, + "payload": { + "netconf-kotlin-response": { + "response-data": { + "deploySuccess": false + } + } + } +} diff --git a/cds-regression-test/test/netconf/kotlin/connect-fail/request-payload.json b/cds-regression-test/test/netconf/kotlin/connect-fail/request-payload.json new file mode 100644 index 0000000..8cac64a --- /dev/null +++ b/cds-regression-test/test/netconf/kotlin/connect-fail/request-payload.json @@ -0,0 +1,19 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-kotlin" + }, + "payload": { + "netconf-kotlin-request": { + "netconf-host": "127.0.0.1", + "netconf-timeout": 5 + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-netconf-kotlin-connect-fail", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/netconf/kotlin/connect-fail/test.sh b/cds-regression-test/test/netconf/kotlin/connect-fail/test.sh new file mode 100755 index 0000000..d30e5ab --- /dev/null +++ b/cds-regression-test/test/netconf/kotlin/connect-fail/test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +CBA_NAME="netconf" +LANG="kotlin" +TEST_NAME="connect-fail" +TEST_NUMBER=$RANDOM + +mkdir -p "$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/" +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-headers" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-payload" + +REQUEST_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/request-payload.json" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$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 500' +assert_status_code 500 $RESPONSE_HEADERS_FILE + +echo 'Assert connect fail payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/netconf/kotlin/success/expected-response.json b/cds-regression-test/test/netconf/kotlin/success/expected-response.json new file mode 100644 index 0000000..dfb81d7 --- /dev/null +++ b/cds-regression-test/test/netconf/kotlin/success/expected-response.json @@ -0,0 +1,29 @@ +{ + "commonHeader": { + "timestamp": "2020-02-03T13:40:43.697Z", + "originatorId": "System", + "requestId": "regression-test-netconf-kotlin", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-kotlin", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-02-03T13:40:51.835Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "netconf-kotlin-response": { + "response-data": { + "deploySuccess": true + } + } + } +} diff --git a/cds-regression-test/test/netconf/kotlin/success/request-payload.json b/cds-regression-test/test/netconf/kotlin/success/request-payload.json new file mode 100644 index 0000000..412614f --- /dev/null +++ b/cds-regression-test/test/netconf/kotlin/success/request-payload.json @@ -0,0 +1,19 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-kotlin" + }, + "payload": { + "netconf-kotlin-request": { + "netconf-host": "odl-netconf-testtool", + "netconf-timeout": 30 + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-netconf-kotlin", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/netconf/kotlin/success/test.sh b/cds-regression-test/test/netconf/kotlin/success/test.sh new file mode 100755 index 0000000..8de0e6f --- /dev/null +++ b/cds-regression-test/test/netconf/kotlin/success/test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +CBA_NAME="netconf" +LANG="kotlin" +TEST_NAME="success" +TEST_NUMBER=$RANDOM + +mkdir -p "$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/" +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-headers" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-payload" + +REQUEST_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/request-payload.json" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$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 200' +assert_status_code 200 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/netconf/netconf-enrichment-test.sh b/cds-regression-test/test/netconf/netconf-enrichment-test.sh new file mode 100755 index 0000000..3c76ce4 --- /dev/null +++ b/cds-regression-test/test/netconf/netconf-enrichment-test.sh @@ -0,0 +1,17 @@ +#!/bin/bash +CBA_NAME="netconf" +TEST_NAME="$CBA_NAME-enrichment" +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +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/cds-regression-test/test/netconf/netconf-upload-test.sh b/cds-regression-test/test/netconf/netconf-upload-test.sh new file mode 100755 index 0000000..933a7b2 --- /dev/null +++ b/cds-regression-test/test/netconf/netconf-upload-test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +CBA_NAME="netconf" +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/cds-regression-test/test/py-executor/connection-fail/expected-response.json b/cds-regression-test/test/py-executor/connection-fail/expected-response.json new file mode 100644 index 0000000..93b2598 --- /dev/null +++ b/cds-regression-test/test/py-executor/connection-fail/expected-response.json @@ -0,0 +1,25 @@ +{ + "commonHeader": { + "timestamp": "2020-05-19T17:26:02.923Z", + "originatorId": "System", + "requestId": "123456", + "subRequestId": "1234-12234", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-py-executor", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-05-19T17:26:02.926Z", + "errorMessage": "Failed in ComponentRemoteScriptExecutor : UNAVAILABLE: io exception, failed to get execution property(node_templates/execute-connection-fail/attributes/status)", + "message": "failure" + }, + "payload": { + "connection-fail-response": {} + } +} diff --git a/cds-regression-test/test/py-executor/connection-fail/request-payload.json b/cds-regression-test/test/py-executor/connection-fail/request-payload.json new file mode 100644 index 0000000..7273340 --- /dev/null +++ b/cds-regression-test/test/py-executor/connection-fail/request-payload.json @@ -0,0 +1,16 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "123456", + "subRequestId": "1234-12234" + }, + "actionIdentifiers": { + "blueprintName": "RT-py-executor", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "payload": { + "connection-fail-request": {} + } +} diff --git a/cds-regression-test/test/py-executor/connection-fail/test.sh b/cds-regression-test/test/py-executor/connection-fail/test.sh new file mode 100644 index 0000000..b4b77e6 --- /dev/null +++ b/cds-regression-test/test/py-executor/connection-fail/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="py-executor" +TEST_NAME="connection-fail" +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 500 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/py-executor/dummy-request-payload.json b/cds-regression-test/test/py-executor/dummy-request-payload.json new file mode 100644 index 0000000..688e5e9 --- /dev/null +++ b/cds-regression-test/test/py-executor/dummy-request-payload.json @@ -0,0 +1,14 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "dummy-request-should-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "dummy", + "mode": "sync" + }, + "payload": {} +} diff --git a/cds-regression-test/test/py-executor/failing-script/expected-response.json b/cds-regression-test/test/py-executor/failing-script/expected-response.json new file mode 100644 index 0000000..17148b0 --- /dev/null +++ b/cds-regression-test/test/py-executor/failing-script/expected-response.json @@ -0,0 +1,25 @@ +{ + "commonHeader": { + "timestamp": "2020-05-19T17:24:33.353Z", + "originatorId": "System", + "requestId": "123456", + "subRequestId": "1234-12234", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-py-executor", + "blueprintVersion": "1.0.0", + "actionName": "failing-remote-python", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-05-19T17:24:33.370Z", + "errorMessage": "Failed in ComponentRemoteScriptExecutor : UNKNOWN: Exception iterating responses: Script raised an exception, failed to get execution property(node_templates/execute-failing-remote-python/attributes/status)", + "message": "failure" + }, + "payload": { + "failing-remote-python-response": {} + } +} diff --git a/cds-regression-test/test/py-executor/failing-script/request-payload.json b/cds-regression-test/test/py-executor/failing-script/request-payload.json new file mode 100644 index 0000000..bacd876 --- /dev/null +++ b/cds-regression-test/test/py-executor/failing-script/request-payload.json @@ -0,0 +1,16 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "123456", + "subRequestId": "1234-12234" + }, + "actionIdentifiers": { + "blueprintName": "RT-py-executor", + "blueprintVersion": "1.0.0", + "actionName": "failing-remote-python", + "mode": "sync" + }, + "payload": { + "failing-remote-python-request": {} + } +} diff --git a/cds-regression-test/test/py-executor/failing-script/test.sh b/cds-regression-test/test/py-executor/failing-script/test.sh new file mode 100644 index 0000000..4386e09 --- /dev/null +++ b/cds-regression-test/test/py-executor/failing-script/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="py-executor" +TEST_NAME="failing-script" +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 500 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/py-executor/py-executor-enrichment-test.sh b/cds-regression-test/test/py-executor/py-executor-enrichment-test.sh new file mode 100644 index 0000000..e671787 --- /dev/null +++ b/cds-regression-test/test/py-executor/py-executor-enrichment-test.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +## Not tested on El Alto +if [ "${CDS_VERSION} " == "elalto " ]; then + echo "Skipping, not available in elalto" + return 0 +fi + +CBA_NAME="py-executor" +TEST_NAME="$CBA_NAME-enrichment" +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +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/cds-regression-test/test/py-executor/py-executor-upload-test.sh b/cds-regression-test/test/py-executor/py-executor-upload-test.sh new file mode 100644 index 0000000..46402e3 --- /dev/null +++ b/cds-regression-test/test/py-executor/py-executor-upload-test.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +## Not tested on El Alto +if [ "${CDS_VERSION} " == "elalto " ]; then + echo "Skipping, not available in elalto" + return 0 +fi + +CBA_NAME="py-executor" +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/cds-regression-test/test/py-executor/success/expected-response.json b/cds-regression-test/test/py-executor/success/expected-response.json new file mode 100644 index 0000000..1318508 --- /dev/null +++ b/cds-regression-test/test/py-executor/success/expected-response.json @@ -0,0 +1,32 @@ +{ + "commonHeader": { + "timestamp": "2020-05-26T13:47:27.143Z", + "originatorId": "System", + "requestId": "123456", + "subRequestId": "1234-12234", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-py-executor", + "blueprintVersion": "1.0.0", + "actionName": "remote-python", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-05-26T13:47:27.193Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "remote-python-response": { + "status": "success", + "response-data": { + "HelloWorld-request": { + "hello": "world" + } + } + } + } +} diff --git a/cds-regression-test/test/py-executor/success/request-payload.json b/cds-regression-test/test/py-executor/success/request-payload.json new file mode 100644 index 0000000..f23b0de --- /dev/null +++ b/cds-regression-test/test/py-executor/success/request-payload.json @@ -0,0 +1,16 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "123456", + "subRequestId": "1234-12234" + }, + "actionIdentifiers": { + "blueprintName": "RT-py-executor", + "blueprintVersion": "1.0.0", + "actionName": "remote-python", + "mode": "sync" + }, + "payload": { + "remote-python-request": {} + } +} diff --git a/cds-regression-test/test/py-executor/success/test.sh b/cds-regression-test/test/py-executor/success/test.sh new file mode 100644 index 0000000..d2d064a --- /dev/null +++ b/cds-regression-test/test/py-executor/success/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="py-executor" +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 diff --git a/cds-regression-test/test/remote-ansible/connection-failure/expected-response.json b/cds-regression-test/test/remote-ansible/connection-failure/expected-response.json new file mode 100644 index 0000000..301e70b --- /dev/null +++ b/cds-regression-test/test/remote-ansible/connection-failure/expected-response.json @@ -0,0 +1,28 @@ +{ + "commonHeader": { + "timestamp": "2020-05-01T19:38:57.529Z", + "originatorId": "System", + "requestId": "remote-ansible-connection-failure", + "subRequestId": "remote-ansible-connection-failure-1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-05-01T19:38:57.551Z", + "errorMessage": "error : ansible-command-logs : Failed to process on remote executor (Connect to localhost:12345 [localhost/127.0.0.1] failed: Connection refused (Connection refused))", + "message": "failure" + }, + "payload": { + "connection-fail-response": { + "ansible-command-status": "error", + "ansible-command-logs": "Failed to process on remote executor (Connect to localhost:12345 [localhost/127.0.0.1] failed: Connection refused (Connection refused))" + } + } +} diff --git a/cds-regression-test/test/remote-ansible/connection-failure/request-payload.json b/cds-regression-test/test/remote-ansible/connection-failure/request-payload.json new file mode 100644 index 0000000..08e39c7 --- /dev/null +++ b/cds-regression-test/test/remote-ansible/connection-failure/request-payload.json @@ -0,0 +1,27 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-ansible-connection-failure", + "subRequestId": "remote-ansible-connection-failure-1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "payload": { + "connection-fail-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/cds-regression-test/test/remote-ansible/connection-failure/test.sh b/cds-regression-test/test/remote-ansible/connection-failure/test.sh new file mode 100644 index 0000000..7c880fe --- /dev/null +++ b/cds-regression-test/test/remote-ansible/connection-failure/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="remote-ansible" +TEST_NAME="connection-failure" +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 500 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/remote-ansible/dummy-request-payload.json b/cds-regression-test/test/remote-ansible/dummy-request-payload.json new file mode 100644 index 0000000..5bb8112 --- /dev/null +++ b/cds-regression-test/test/remote-ansible/dummy-request-payload.json @@ -0,0 +1,14 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "dummy-request-should-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "dummy", + "mode": "sync" + }, + "payload": {} +} diff --git a/cds-regression-test/test/remote-ansible/failure/resources/elalto/expected-response.json b/cds-regression-test/test/remote-ansible/failure/resources/elalto/expected-response.json new file mode 100644 index 0000000..050e328 --- /dev/null +++ b/cds-regression-test/test/remote-ansible/failure/resources/elalto/expected-response.json @@ -0,0 +1,28 @@ +{ + "commonHeader": { + "timestamp": "2020-05-01T18:55:44.034Z", + "originatorId": "System", + "requestId": "remote-ansible-failure", + "subRequestId": "remote-ansible-failure-1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "execute-remote-ansible-failure", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-05-01T18:55:44.046Z", + "errorMessage": "error : ansible-command-logs : Failed to process on remote executor (mapper.readTree(response.body) must not be null)", + "message": "failure" + }, + "payload": { + "execute-remote-ansible-failure-response": { + "ansible-command-status": "error", + "ansible-command-logs": "Failed to process on remote executor (mapper.readTree(response.body) must not be null)" + } + } +} diff --git a/cds-regression-test/test/remote-ansible/failure/resources/elalto/request-payload.json b/cds-regression-test/test/remote-ansible/failure/resources/elalto/request-payload.json new file mode 100644 index 0000000..a4589ae --- /dev/null +++ b/cds-regression-test/test/remote-ansible/failure/resources/elalto/request-payload.json @@ -0,0 +1,27 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-ansible-failure", + "subRequestId": "remote-ansible-failure-1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "execute-remote-ansible-failure", + "mode": "sync" + }, + "payload": { + "execute-remote-ansible-failure-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/cds-regression-test/test/remote-ansible/failure/resources/frankfurt/expected-response.json b/cds-regression-test/test/remote-ansible/failure/resources/frankfurt/expected-response.json new file mode 100644 index 0000000..713b934 --- /dev/null +++ b/cds-regression-test/test/remote-ansible/failure/resources/frankfurt/expected-response.json @@ -0,0 +1,29 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-02T21:03:35.836Z", + "originatorId": "System", + "requestId": "remote-ansible-failure", + "subRequestId": "remote-ansible-failure-1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "execute-remote-ansible-failure", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-06-02T21:03:38.655Z", + "errorMessage": "error : ansible-command-logs : Workflow/Job template hello_world_job_template does not exists", + "message": "failure" + }, + "payload": { + "execute-remote-ansible-failure-response": { + "ansible-command-status": "error", + "ansible-command-logs": "Workflow/Job template hello_world_job_template does not exists" + } + } +} diff --git a/cds-regression-test/test/remote-ansible/failure/resources/frankfurt/request-payload.json b/cds-regression-test/test/remote-ansible/failure/resources/frankfurt/request-payload.json new file mode 100644 index 0000000..a4589ae --- /dev/null +++ b/cds-regression-test/test/remote-ansible/failure/resources/frankfurt/request-payload.json @@ -0,0 +1,27 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-ansible-failure", + "subRequestId": "remote-ansible-failure-1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "execute-remote-ansible-failure", + "mode": "sync" + }, + "payload": { + "execute-remote-ansible-failure-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/cds-regression-test/test/remote-ansible/failure/test.sh b/cds-regression-test/test/remote-ansible/failure/test.sh new file mode 100644 index 0000000..c044762 --- /dev/null +++ b/cds-regression-test/test/remote-ansible/failure/test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +CBA_NAME="remote-ansible" +TEST_NAME="failure" +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" + +RESOURCES_DIR="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/resources/$CDS_VERSION" +REQUEST_PAYLOAD_FILE="$RESOURCES_DIR/request-payload.json" +EXPECTED_PAYLOAD_FILE="$RESOURCES_DIR/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 500 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/remote-ansible/init-mockserver.sh b/cds-regression-test/test/remote-ansible/init-mockserver.sh new file mode 100755 index 0000000..c737b9e --- /dev/null +++ b/cds-regression-test/test/remote-ansible/init-mockserver.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +CBA_NAME="remote-ansible" +DIR_PAYLOADS="$TEST_DIRECTORY/$CBA_NAME/mock-payloads" + +# JOB TEMPLATE +echo "Mocking Job Template route..." +JT_PAYLOAD="job-template.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$JT_PAYLOAD" + +# JOB TEMPLATE ERROR +echo "Mocking Job Template Error route..." +JT_ERR_PAYLOAD="job-template-error.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$JT_ERR_PAYLOAD" + +# JOB TEMPLATE LAUNCH - GET +echo "Mocking Job Template Launch GET route..." +GET_JT_LAUNCH_PAYLOAD="get_job-template-launch.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$GET_JT_LAUNCH_PAYLOAD" + +# JOB TEMPLATE LAUNCH +echo "Mocking Inventory route..." +INVENTORY_PAYLOAD="inventory.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$INVENTORY_PAYLOAD" + +# JOB TEMPLATE LAUNCH - POST +echo "Mocking Job Template Launch POST route..." +POST_JT_LAUNCH_PAYLOAD="post_job-template-launch.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$POST_JT_LAUNCH_PAYLOAD" + +# JOB EXECUTION +echo "Mocking Job Execution route..." +JOB_EXECUTION_PAYLOAD="job-execution.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$JOB_EXECUTION_PAYLOAD" + +# JOB OUTPUT +echo "Mocking Job Output route..." +JOB_OUTPUT_PAYLOAD="job-output.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$JOB_OUTPUT_PAYLOAD" diff --git a/cds-regression-test/test/remote-ansible/mock-payloads/get_job-template-launch.json b/cds-regression-test/test/remote-ansible/mock-payloads/get_job-template-launch.json new file mode 100644 index 0000000..ed7904d --- /dev/null +++ b/cds-regression-test/test/remote-ansible/mock-payloads/get_job-template-launch.json @@ -0,0 +1,46 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/remote-ansible/success/api/v2/job_templates/123/launch/" + }, + "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/cds-regression-test/test/remote-ansible/mock-payloads/inventory.json b/cds-regression-test/test/remote-ansible/mock-payloads/inventory.json new file mode 100644 index 0000000..165b929 --- /dev/null +++ b/cds-regression-test/test/remote-ansible/mock-payloads/inventory.json @@ -0,0 +1,110 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/remote-ansible/success/api/v2/inventories/" + }, + "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/cds-regression-test/test/remote-ansible/mock-payloads/job-execution.json b/cds-regression-test/test/remote-ansible/mock-payloads/job-execution.json new file mode 100644 index 0000000..e8df26b --- /dev/null +++ b/cds-regression-test/test/remote-ansible/mock-payloads/job-execution.json @@ -0,0 +1,183 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/remote-ansible/success/api/v2/jobs/456/" + }, + "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": {}, + "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/cds-regression-test/test/remote-ansible/mock-payloads/job-output.json b/cds-regression-test/test/remote-ansible/mock-payloads/job-output.json new file mode 100644 index 0000000..4ae2a49 --- /dev/null +++ b/cds-regression-test/test/remote-ansible/mock-payloads/job-output.json @@ -0,0 +1,24 @@ +{ + "httpRequest" : { + "method" : "GET", + "path" : "/remote-ansible/success/api/v2/jobs/456/stdout/" + }, + "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/cds-regression-test/test/remote-ansible/mock-payloads/job-template-error.json b/cds-regression-test/test/remote-ansible/mock-payloads/job-template-error.json new file mode 100644 index 0000000..49a9798 --- /dev/null +++ b/cds-regression-test/test/remote-ansible/mock-payloads/job-template-error.json @@ -0,0 +1,8 @@ +{ + "httpRequest": { + "path": "/remote-ansible/failure/api/v2/job_templates/hello_world_job_template/" + }, + "httpResponse": { + "statusCode": 500 + } +} diff --git a/cds-regression-test/test/remote-ansible/mock-payloads/job-template.json b/cds-regression-test/test/remote-ansible/mock-payloads/job-template.json new file mode 100644 index 0000000..10552c4 --- /dev/null +++ b/cds-regression-test/test/remote-ansible/mock-payloads/job-template.json @@ -0,0 +1,224 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/remote-ansible/success/api/v2/job_templates/hello_world_job_template/" + }, + "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/cds-regression-test/test/remote-ansible/mock-payloads/post_job-template-launch.json b/cds-regression-test/test/remote-ansible/mock-payloads/post_job-template-launch.json new file mode 100644 index 0000000..8484374 --- /dev/null +++ b/cds-regression-test/test/remote-ansible/mock-payloads/post_job-template-launch.json @@ -0,0 +1,144 @@ +{ + "httpRequest": { + "method": "POST", + "path": "/remote-ansible/success/api/v2/job_templates/123/launch/" + }, + "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/cds-regression-test/test/remote-ansible/remote-ansible-enrichment-test.sh b/cds-regression-test/test/remote-ansible/remote-ansible-enrichment-test.sh new file mode 100755 index 0000000..9e4de45 --- /dev/null +++ b/cds-regression-test/test/remote-ansible/remote-ansible-enrichment-test.sh @@ -0,0 +1,16 @@ +#!/bin/bash +CBA_NAME="remote-ansible" +TEST_NAME="$CBA_NAME-enrichment" +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +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/cds-regression-test/test/remote-ansible/remote-ansible-upload-test.sh b/cds-regression-test/test/remote-ansible/remote-ansible-upload-test.sh new file mode 100755 index 0000000..334b9b9 --- /dev/null +++ b/cds-regression-test/test/remote-ansible/remote-ansible-upload-test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +CBA_NAME="remote-ansible" +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/cds-regression-test/test/remote-ansible/success/expected-response.json b/cds-regression-test/test/remote-ansible/success/expected-response.json new file mode 100644 index 0000000..9dce094 --- /dev/null +++ b/cds-regression-test/test/remote-ansible/success/expected-response.json @@ -0,0 +1,29 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-03T16:20:03.527Z", + "originatorId": "System", + "requestId": "remote-ansible-success", + "subRequestId": "remote-ansible-success-1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "execute-remote-ansible-success", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-06-03T16:20:18.859Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "execute-remote-ansible-success-response": { + "ansible-command-status": "successful", + "ansible-command-logs": "Output for Job 456 :\n 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\n" + } + } +} diff --git a/cds-regression-test/test/remote-ansible/success/request-payload.json b/cds-regression-test/test/remote-ansible/success/request-payload.json new file mode 100644 index 0000000..3718c4d --- /dev/null +++ b/cds-regression-test/test/remote-ansible/success/request-payload.json @@ -0,0 +1,27 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-ansible-success", + "subRequestId": "remote-ansible-success-1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "execute-remote-ansible-success", + "mode": "sync" + }, + "payload": { + "execute-remote-ansible-success-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/cds-regression-test/test/remote-ansible/success/test.sh b/cds-regression-test/test/remote-ansible/success/test.sh new file mode 100644 index 0000000..eab16ca --- /dev/null +++ b/cds-regression-test/test/remote-ansible/success/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="remote-ansible" +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_versioned 200 $RESPONSE_HEADERS_FILE $RESPONSE_PAYLOAD_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/remote-python/connection-fail/resources/elalto/expected-response.json b/cds-regression-test/test/remote-python/connection-fail/resources/elalto/expected-response.json new file mode 100644 index 0000000..2ab445b --- /dev/null +++ b/cds-regression-test/test/remote-python/connection-fail/resources/elalto/expected-response.json @@ -0,0 +1,29 @@ +{ + "correlationUUID": "9f53fea6-c288-4d19-8d85-93832294f21a", + "commonHeader": { + "timestamp": "2020-07-20T18:15:21.593Z", + "originatorId": "System", + "requestId": "remote-python-connection-fail", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-07-20T18:15:22.846Z", + "errorMessage": "FAILURE : prepare-env : Command failed during env. preparation... timeout(120) requestId (remote-python-connection-fail). grpcError: (Connection refused: /127.0.0.1:4242)", + "message": "failure" + }, + "payload": { + "connection-fail-response": { + "execute-command-payload": "", + "execute-command-logs": "" + } + } +} diff --git a/cds-regression-test/test/remote-python/connection-fail/resources/elalto/request-payload.json b/cds-regression-test/test/remote-python/connection-fail/resources/elalto/request-payload.json new file mode 100644 index 0000000..4bcf8e2 --- /dev/null +++ b/cds-regression-test/test/remote-python/connection-fail/resources/elalto/request-payload.json @@ -0,0 +1,16 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-python-connection-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "payload": { + "connection-fail-request": {} + } +} diff --git a/cds-regression-test/test/remote-python/connection-fail/resources/frankfurt/expected-response.json b/cds-regression-test/test/remote-python/connection-fail/resources/frankfurt/expected-response.json new file mode 100644 index 0000000..c9b15bd --- /dev/null +++ b/cds-regression-test/test/remote-python/connection-fail/resources/frankfurt/expected-response.json @@ -0,0 +1,29 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-09T21:02:52.783Z", + "originatorId": "System", + "requestId": "remote-python-connection-fail", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-06-09T21:02:53.142Z", + "errorMessage": "FAILURE : prepare-env : Command failed during env. preparation... timeout(120) requestId (remote-python-connection-fail). grpcError: (finishConnect(..) failed: Connection refused: /127.0.0.1:4242)", + "message": "failure" + }, + "payload": { + "connection-fail-response": { + "execute-command-logs": "[]", + "execute-command-payload": "{}" + } + } +} diff --git a/cds-regression-test/test/remote-python/connection-fail/resources/frankfurt/request-payload.json b/cds-regression-test/test/remote-python/connection-fail/resources/frankfurt/request-payload.json new file mode 100644 index 0000000..4bcf8e2 --- /dev/null +++ b/cds-regression-test/test/remote-python/connection-fail/resources/frankfurt/request-payload.json @@ -0,0 +1,16 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-python-connection-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "payload": { + "connection-fail-request": {} + } +} diff --git a/cds-regression-test/test/remote-python/connection-fail/test.sh b/cds-regression-test/test/remote-python/connection-fail/test.sh new file mode 100644 index 0000000..4d3a38f --- /dev/null +++ b/cds-regression-test/test/remote-python/connection-fail/test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +CBA_NAME="remote-python" +TEST_NAME="connection-fail" +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" + +RESOURCES_DIR="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/resources/$CDS_VERSION" +REQUEST_PAYLOAD_FILE="$RESOURCES_DIR/request-payload.json" +EXPECTED_PAYLOAD_FILE="$RESOURCES_DIR/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 500 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/remote-python/dummy-request-payload.json b/cds-regression-test/test/remote-python/dummy-request-payload.json new file mode 100644 index 0000000..688e5e9 --- /dev/null +++ b/cds-regression-test/test/remote-python/dummy-request-payload.json @@ -0,0 +1,14 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "dummy-request-should-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "dummy", + "mode": "sync" + }, + "payload": {} +} diff --git a/cds-regression-test/test/remote-python/failing-script/expected-response.json b/cds-regression-test/test/remote-python/failing-script/expected-response.json new file mode 100644 index 0000000..119b135 --- /dev/null +++ b/cds-regression-test/test/remote-python/failing-script/expected-response.json @@ -0,0 +1,33 @@ +{ + "correlationUUID": "0ae1f48a-ec91-4573-af76-070ec42e2cdd", + "commonHeader": { + "timestamp": "2020-07-02T23:46:04.959Z", + "originatorId": "System", + "requestId": "remote-python-failing-script", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "failing-remote-python", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-07-02T23:46:22.167Z", + "errorMessage": "FAILURE : execute-command : [\"Intentionally raised exception!\"]", + "message": "failure" + }, + "payload": { + "failing-remote-python-response": { + "execute-command-payload": { + "errorMessage": "Intentionally raised exception!" + }, + "execute-command-logs": [ + "Intentionally raised exception!" + ] + } + } +} diff --git a/cds-regression-test/test/remote-python/failing-script/request-payload.json b/cds-regression-test/test/remote-python/failing-script/request-payload.json new file mode 100644 index 0000000..d4c612c --- /dev/null +++ b/cds-regression-test/test/remote-python/failing-script/request-payload.json @@ -0,0 +1,16 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-python-failing-script", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "failing-remote-python", + "mode": "sync" + }, + "payload": { + "failing-remote-python-request": {} + } +} diff --git a/cds-regression-test/test/remote-python/failing-script/test.sh b/cds-regression-test/test/remote-python/failing-script/test.sh new file mode 100755 index 0000000..1c394a3 --- /dev/null +++ b/cds-regression-test/test/remote-python/failing-script/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="remote-python" +TEST_NAME="failing-script" +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 500 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/remote-python/remote-python-enrichment-test.sh b/cds-regression-test/test/remote-python/remote-python-enrichment-test.sh new file mode 100755 index 0000000..e2344bd --- /dev/null +++ b/cds-regression-test/test/remote-python/remote-python-enrichment-test.sh @@ -0,0 +1,16 @@ +#!/bin/bash +CBA_NAME="remote-python" +TEST_NAME="$CBA_NAME-enrichment" +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +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/cds-regression-test/test/remote-python/remote-python-upload-test.sh b/cds-regression-test/test/remote-python/remote-python-upload-test.sh new file mode 100755 index 0000000..f62490c --- /dev/null +++ b/cds-regression-test/test/remote-python/remote-python-upload-test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +CBA_NAME="remote-python" +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/cds-regression-test/test/remote-python/success/expected-response.json b/cds-regression-test/test/remote-python/success/expected-response.json new file mode 100644 index 0000000..8b0149f --- /dev/null +++ b/cds-regression-test/test/remote-python/success/expected-response.json @@ -0,0 +1,36 @@ +{ + "correlationUUID": "9acac95d-9b17-4224-9fe1-0cdb652d027c", + "commonHeader": { + "timestamp": "2020-07-02T22:52:50.662Z", + "originatorId": "System", + "requestId": "remote-python-request", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "remote-python", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-07-02T22:53:05.357Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "remote-python-response": { + "execute-command-payload": { + "abc": [ + "xyz", + "qqq" + ] + }, + "execute-command-logs": [ + "remote executor regression" + ] + } + } +} diff --git a/cds-regression-test/test/remote-python/success/request-payload.json b/cds-regression-test/test/remote-python/success/request-payload.json new file mode 100644 index 0000000..b3b9be8 --- /dev/null +++ b/cds-regression-test/test/remote-python/success/request-payload.json @@ -0,0 +1,16 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-python-request", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "remote-python", + "mode": "sync" + }, + "payload": { + "remote-python-request": {} + } +} diff --git a/cds-regression-test/test/remote-python/success/test.sh b/cds-regression-test/test/remote-python/success/test.sh new file mode 100755 index 0000000..1afabbb --- /dev/null +++ b/cds-regression-test/test/remote-python/success/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="remote-python" +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 diff --git a/cds-regression-test/test/reset-verify-mockserver.sh b/cds-regression-test/test/reset-verify-mockserver.sh new file mode 100644 index 0000000..8b3ecf6 --- /dev/null +++ b/cds-regression-test/test/reset-verify-mockserver.sh @@ -0,0 +1,10 @@ +#!/bin/bash +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/reset-mockserver-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +echo "Reset mockserver - $TEST_NUMBER" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/reset" > /dev/null 2> $RESPONSE_HEADERS_FILE +echo 'Assert status 200' +assert_status_code 200 $RESPONSE_HEADERS_FILE diff --git a/cds-regression-test/test/resource-resolution/data-dict/RT-db.json b/cds-regression-test/test/resource-resolution/data-dict/RT-db.json new file mode 100644 index 0000000..d8e1daf --- /dev/null +++ b/cds-regression-test/test/resource-resolution/data-dict/RT-db.json @@ -0,0 +1,30 @@ +{ + "name": "RT-db", + "data_type": "string", + "description": "DB request for regression test", + "tags": "datetime", + "updatedBy": "Selfish", + "definition": { + "name": "RT-db", + "tags": "RT-db", + "updated-by": "Selffish", + "property": { + "description": "DB request for regression test", + "type": "string" + }, + "sources": { + "processor-db": { + "type": "source-db", + "properties": { + "endpoint-selector": "db-endpoint", + "type": "SQL", + "query": "select sdnctl.RESOURCE_RESOLUTION.value from sdnctl.RESOURCE_RESOLUTION where value='ok'", + "input-key-mapping": {}, + "output-key-mapping": { + "value": "value" + } + } + } + } + } +} diff --git a/cds-regression-test/test/resource-resolution/data-dict/RT-kotlin.json b/cds-regression-test/test/resource-resolution/data-dict/RT-kotlin.json new file mode 100644 index 0000000..c521792 --- /dev/null +++ b/cds-regression-test/test/resource-resolution/data-dict/RT-kotlin.json @@ -0,0 +1,26 @@ +{ + "name": "kotlin-script", + "data_type": "string", + "description": "Kotlin script used to read properties.", + "tags": "kotlin-script", + "updatedBy": "Self-fish", + "definition": { + "name": "kotlin-script", + "updated-by": "Selffish", + "tags": "properties-capability-source", + "property": { + "description": "Kotlin script used to read properties.", + "type": "string" + }, + "sources": { + "capability": { + "type": "source-capability", + "properties": { + "script-type": "kotlin", + "script-class-reference": "cba.cds.RT.ResolvPropertiesKt", + "instance-dependencies": [] + } + } + } + } +} diff --git a/cds-regression-test/test/resource-resolution/data-dict/RT-rest-delete.json b/cds-regression-test/test/resource-resolution/data-dict/RT-rest-delete.json new file mode 100644 index 0000000..c1cef3b --- /dev/null +++ b/cds-regression-test/test/resource-resolution/data-dict/RT-rest-delete.json @@ -0,0 +1,32 @@ +{ + "name": "RT-rest-delete", + "data_type": "string", + "description": "Rest DELETE request for regression test", + "tags": "RT-rest-delete", + "updatedBy": "Selfish", + "definition": { + "name": "RT-rest-delete", + "tags": "RT-rest-delete", + "updated-by": "Selffish", + "property": { + "description": "Rest DELETE request for regression test", + "type": "string" + }, + "sources": { + "sdnc": { + "type": "source-rest", + "properties": { + "type": "string", + "verb": "DELETE", + "url-path": "/delete", + "endpoint-selector": "rest-endpoint", + "path": "", + "input-key-mapping": {}, + "output-key-mapping": { + "value": "value" + } + } + } + } + } +} diff --git a/cds-regression-test/test/resource-resolution/data-dict/RT-rest-get.json b/cds-regression-test/test/resource-resolution/data-dict/RT-rest-get.json new file mode 100644 index 0000000..210ac27 --- /dev/null +++ b/cds-regression-test/test/resource-resolution/data-dict/RT-rest-get.json @@ -0,0 +1,32 @@ +{ + "name": "RT-rest-get", + "data_type": "string", + "description": "Rest GET request for regression test", + "tags": "RT-rest-get", + "updatedBy": "Selfish", + "definition": { + "name": "RT-rest-get", + "tags": "RT-rest-get", + "updated-by": "Selffish", + "property": { + "description": "Rest GET request for regression test", + "type": "string" + }, + "sources": { + "sdnc": { + "type": "source-rest", + "properties": { + "type": "string", + "verb": "GET", + "url-path": "/get", + "endpoint-selector": "rest-endpoint", + "path": "", + "input-key-mapping": {}, + "output-key-mapping": { + "value": "value" + } + } + } + } + } +} diff --git a/cds-regression-test/test/resource-resolution/data-dict/RT-rest-patch.json b/cds-regression-test/test/resource-resolution/data-dict/RT-rest-patch.json new file mode 100644 index 0000000..41f94da --- /dev/null +++ b/cds-regression-test/test/resource-resolution/data-dict/RT-rest-patch.json @@ -0,0 +1,32 @@ +{ + "name": "RT-rest-patch", + "data_type": "string", + "description": "Rest PATCH request for regression test", + "tags": "RT-rest-patch", + "updatedBy": "Selfish", + "definition": { + "name": "RT-rest-patch", + "tags": "RT-rest-patch", + "updated-by": "Selffish", + "property": { + "description": "Rest PATCH request for regression test", + "type": "string" + }, + "sources": { + "sdnc": { + "type": "source-rest", + "properties": { + "type": "string", + "verb": "PATCH", + "url-path": "/patch", + "endpoint-selector": "rest-endpoint", + "path": "", + "input-key-mapping": {}, + "output-key-mapping": { + "value": "value" + } + } + } + } + } +} diff --git a/cds-regression-test/test/resource-resolution/data-dict/RT-rest-post.json b/cds-regression-test/test/resource-resolution/data-dict/RT-rest-post.json new file mode 100644 index 0000000..63721bb --- /dev/null +++ b/cds-regression-test/test/resource-resolution/data-dict/RT-rest-post.json @@ -0,0 +1,32 @@ +{ + "name": "RT-rest-post", + "data_type": "string", + "description": "Rest POST request for regression test", + "tags": "RT-rest-post", + "updatedBy": "Selfish", + "definition": { + "name": "RT-rest-post", + "tags": "RT-rest-post", + "updated-by": "Selffish", + "property": { + "description": "Rest POST request for regression test", + "type": "string" + }, + "sources": { + "sdnc": { + "type": "source-rest", + "properties": { + "type": "string", + "verb": "POST", + "url-path": "/post", + "endpoint-selector": "rest-endpoint", + "path": "", + "input-key-mapping": {}, + "output-key-mapping": { + "value": "value" + } + } + } + } + } +} diff --git a/cds-regression-test/test/resource-resolution/data-dict/RT-rest-put.json b/cds-regression-test/test/resource-resolution/data-dict/RT-rest-put.json new file mode 100644 index 0000000..cf165d3 --- /dev/null +++ b/cds-regression-test/test/resource-resolution/data-dict/RT-rest-put.json @@ -0,0 +1,32 @@ +{ + "name": "RT-rest-put", + "data_type": "string", + "description": "Rest PUT request for regression test", + "tags": "RT-rest-put", + "updatedBy": "Selfish", + "definition": { + "name": "RT-rest-put", + "tags": "RT-rest-put", + "updated-by": "Selffish", + "property": { + "description": "Rest PUT request for regression test", + "type": "string" + }, + "sources": { + "sdnc": { + "type": "source-rest", + "properties": { + "type": "string", + "verb": "PUT", + "url-path": "/put", + "endpoint-selector": "rest-endpoint", + "path": "", + "input-key-mapping": {}, + "output-key-mapping": { + "value": "value" + } + } + } + } + } +} diff --git a/cds-regression-test/test/resource-resolution/dummy-request-payload.json b/cds-regression-test/test/resource-resolution/dummy-request-payload.json new file mode 100644 index 0000000..60b3442 --- /dev/null +++ b/cds-regression-test/test/resource-resolution/dummy-request-payload.json @@ -0,0 +1,14 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "dummy-request-should-fail", + "subRequestId": "11" + }, + "actionIdentifiers": { + "blueprintName": "RT-resource-resolution", + "blueprintVersion": "1.0.0", + "actionName": "dummy", + "mode": "sync" + }, + "payload": {} +} diff --git a/cds-regression-test/test/resource-resolution/force-resolution/expected-payloads/expected-response-1.json b/cds-regression-test/test/resource-resolution/force-resolution/expected-payloads/expected-response-1.json new file mode 100644 index 0000000..efb6282 --- /dev/null +++ b/cds-regression-test/test/resource-resolution/force-resolution/expected-payloads/expected-response-1.json @@ -0,0 +1,31 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-05-07T22:18:06.901Z", + "originatorId": "System", + "requestId": "1234", + "subRequestId": "1234-12234", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-resource-resolution", + "blueprintVersion": "1.0.0", + "actionName": "resource-resolution", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-05-07T22:18:22.289Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "resource-resolution-response": { + "meshed-template": { + "helloworld-velocity": "{\n \"default\": \"ok\",\n \"input\": \"ok\",\n \"script\": {\n \"python\": \"ok\",\n \"kotlin\": \"ok\"\n },\n \"db\": \"ok\",\n \"rest\": {\n \"GET\": \"get:ok\",\n \"POST\": \"post:ok\",\n \"PUT\": \"put:ok\",\n \"PATCH\": \"patch:ok\",\n \"DELETE\": \"delete:ok\"\n }\n}\n", + "helloworld-jinja": "{\n \"default\": \"ok\",\n \"input\": \"ok\",\n \"script\": {\n \"python\": \"ok\",\n \"kotlin\": {\n \"base\": \"ok\"\n \"from suspend function\": \"ok\"\n }\n },\n \"db\": \"ok\",\n \"rest\": {\n \"GET\": \"get:ok\",\n \"POST\": \"post:ok\",\n \"PUT\": \"put:ok\",\n \"PATCH\": \"patch:ok\",\n \"DELETE\": \"delete:ok\"\n }\n}\n" + } + } + } +} diff --git a/cds-regression-test/test/resource-resolution/force-resolution/expected-payloads/expected-response-2.json b/cds-regression-test/test/resource-resolution/force-resolution/expected-payloads/expected-response-2.json new file mode 100644 index 0000000..5d52426 --- /dev/null +++ b/cds-regression-test/test/resource-resolution/force-resolution/expected-payloads/expected-response-2.json @@ -0,0 +1,31 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-05-07T22:18:06.901Z", + "originatorId": "System", + "requestId": "1234", + "subRequestId": "1234-12234", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-resource-resolution", + "blueprintVersion": "1.0.0", + "actionName": "resource-resolution", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-05-07T22:18:22.289Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "resource-resolution-response": { + "meshed-template": { + "helloworld-velocity": "{\n \"default\": \"ok\",\n \"input\": \"ok-ok\",\n \"script\": {\n \"python\": \"ok\",\n \"kotlin\": \"ok\"\n },\n \"db\": \"ok\",\n \"rest\": {\n \"GET\": \"get:ok\",\n \"POST\": \"post:ok\",\n \"PUT\": \"put:ok\",\n \"PATCH\": \"patch:ok\",\n \"DELETE\": \"delete:ok\"\n }\n}\n", + "helloworld-jinja": "{\n \"default\": \"ok\",\n \"input\": \"ok-ok\",\n \"script\": {\n \"python\": \"ok\",\n \"kotlin\": {\n \"base\": \"ok\"\n \"from suspend function\": \"ok\"\n }\n },\n \"db\": \"ok\",\n \"rest\": {\n \"GET\": \"get:ok\",\n \"POST\": \"post:ok\",\n \"PUT\": \"put:ok\",\n \"PATCH\": \"patch:ok\",\n \"DELETE\": \"delete:ok\"\n }\n}\n" + } + } + } +} diff --git a/cds-regression-test/test/resource-resolution/force-resolution/request-payloads/request-payload-1.json b/cds-regression-test/test/resource-resolution/force-resolution/request-payloads/request-payload-1.json new file mode 100644 index 0000000..91e4612 --- /dev/null +++ b/cds-regression-test/test/resource-resolution/force-resolution/request-payloads/request-payload-1.json @@ -0,0 +1,26 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "1234", + "subRequestId": "1234-12234" + }, + "actionIdentifiers": { + "blueprintName": "RT-resource-resolution", + "blueprintVersion": "1.0.0", + "actionName": "resource-resolution", + "mode": "sync" + }, + "payload": { + "resource-resolution-request": { + "template-prefix": [ + "helloworld-velocity", + "helloworld-jinja" + ], + "resolution-key": "regression-test", + "resource-resolution-properties": { + "v_input": "ok", + "j_input": "ok" + } + } + } +} diff --git a/cds-regression-test/test/resource-resolution/force-resolution/request-payloads/request-payload-2.json b/cds-regression-test/test/resource-resolution/force-resolution/request-payloads/request-payload-2.json new file mode 100644 index 0000000..de8a797 --- /dev/null +++ b/cds-regression-test/test/resource-resolution/force-resolution/request-payloads/request-payload-2.json @@ -0,0 +1,26 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "1234", + "subRequestId": "1234-12234" + }, + "actionIdentifiers": { + "blueprintName": "RT-resource-resolution", + "blueprintVersion": "1.0.0", + "actionName": "resource-resolution", + "mode": "sync" + }, + "payload": { + "resource-resolution-request": { + "template-prefix": [ + "helloworld-velocity", + "helloworld-jinja" + ], + "resolution-key": "regression-test", + "resource-resolution-properties": { + "v_input": "ok-ok", + "j_input": "ok-ok" + } + } + } +} diff --git a/cds-regression-test/test/resource-resolution/force-resolution/test.sh b/cds-regression-test/test/resource-resolution/force-resolution/test.sh new file mode 100644 index 0000000..013df7e --- /dev/null +++ b/cds-regression-test/test/resource-resolution/force-resolution/test.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +CBA_NAME="resource-resolution" +TEST_NAME="force-resolution" +TEST_NUMBER=$RANDOM + +REQUEST_PAYLOAD_DIR="request-payloads" +EXPECTED_PAYLOAD_DIR="expected-payloads" + +mkdir -p "$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/" +RESPONSE_HEADERS_FILE_1="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-headers-1" +RESPONSE_PAYLOAD_FILE_1="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-payload-1" +REQUEST_PAYLOAD_FILE_1="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/$REQUEST_PAYLOAD_DIR/request-payload-1.json" +EXPECTED_PAYLOAD_FILE_1="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/$EXPECTED_PAYLOAD_DIR/expected-response-1.json" + +RESPONSE_HEADERS_FILE_2="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-headers-2" +RESPONSE_PAYLOAD_FILE_2="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-payload-2" +REQUEST_PAYLOAD_FILE_2="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/$REQUEST_PAYLOAD_DIR/request-payload-2.json" +EXPECTED_PAYLOAD_FILE_2="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/$EXPECTED_PAYLOAD_DIR/expected-response-2.json" + +. ./$TEST_DIRECTORY/utils.sh + +echo "Running test: $CBA_NAME:$TEST_NUMBER:$TEST_NAME" +echo "Running initial ressource-resolution to resolve template..." +process_cba $REQUEST_PAYLOAD_FILE_1 $RESPONSE_PAYLOAD_FILE_1 $RESPONSE_HEADERS_FILE_1 + +echo 'Assert statuscode' +assert_status_code 200 $RESPONSE_HEADERS_FILE_1 + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE_1 $RESPONSE_PAYLOAD_FILE_1 + + +# Verify force-resolution +## Same resolution-key, different input values from above test. +## Force-resolution is enabled in the CBA so we shouldn't get the same resolved template as above. +echo "Running the same ressource-resolution but with different inputs..." +process_cba $REQUEST_PAYLOAD_FILE_2 $RESPONSE_PAYLOAD_FILE_2 $RESPONSE_HEADERS_FILE_2 + +echo 'Assert statuscode' +assert_status_code 200 $RESPONSE_HEADERS_FILE_2 + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE_2 $RESPONSE_PAYLOAD_FILE_2 diff --git a/cds-regression-test/test/resource-resolution/init-mockserver.sh b/cds-regression-test/test/resource-resolution/init-mockserver.sh new file mode 100755 index 0000000..005ed2f --- /dev/null +++ b/cds-regression-test/test/resource-resolution/init-mockserver.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d '{ + "httpRequest" : { + "method" : "GET", + "path" : "/get" + }, + "httpResponse" : { + "body" : "{\"value\": \"get:ok\"}" + } +}' + +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d '{ + "httpRequest" : { + "method" : "POST", + "path" : "/post" + }, + "httpResponse" : { + "body" : "{\"value\": \"post:ok\"}" + } +}' + +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d '{ + "httpRequest" : { + "method" : "PUT", + "path" : "/put" + }, + "httpResponse" : { + "body" : "{\"value\": \"put:ok\"}" + } +}' + +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d '{ + "httpRequest" : { + "method" : "PATCH", + "path" : "/patch" + }, + "httpResponse" : { + "body" : "{\"value\": \"patch:ok\"}" + } +}' + +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d '{ + "httpRequest" : { + "method" : "DELETE", + "path" : "/delete" + }, + "httpResponse" : { + "body" : "{\"value\": \"delete:ok\"}" + } +}' diff --git a/cds-regression-test/test/resource-resolution/resource-resolution-enrichment-test.sh b/cds-regression-test/test/resource-resolution/resource-resolution-enrichment-test.sh new file mode 100755 index 0000000..79236ae --- /dev/null +++ b/cds-regression-test/test/resource-resolution/resource-resolution-enrichment-test.sh @@ -0,0 +1,16 @@ +#!/bin/bash +CBA_NAME="resource-resolution" +TEST_NAME="$CBA_NAME-enrichment" +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +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/cds-regression-test/test/resource-resolution/resource-resolution-upload-dd.sh b/cds-regression-test/test/resource-resolution/resource-resolution-upload-dd.sh new file mode 100755 index 0000000..96f1007 --- /dev/null +++ b/cds-regression-test/test/resource-resolution/resource-resolution-upload-dd.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +TEST_NAME="upload-data-dict" +TEST_NUMBER=$RANDOM +REQUEST_DD_PAYLOAD_DIR="$TEST_DIRECTORY/resource-resolution/data-dict" + +. ./$TEST_DIRECTORY/utils.sh + +# delete useless log file +rm $FAILED_TESTS_LOG + +DD_PAYLOADS=$(ls $REQUEST_DD_PAYLOAD_DIR) +for DD_PAYLOAD in $DD_PAYLOADS +do + echo "Uploading DD : $DD_PAYLOAD" + PAYLOAD_NAME=$(echo "$DD_PAYLOAD" | cut -d '.' -f1) + RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$PAYLOAD_NAME-$TEST_NUMBER-response-headers" + RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$PAYLOAD_NAME-$TEST_NUMBER-response-payload" + PAYLOAD_FILE="$REQUEST_DD_PAYLOAD_DIR/$DD_PAYLOAD" + FAILED_TESTS_LOG="$FAILED_TESTS_DIRECTORY/$TEST_NAME-$PAYLOAD_NAME-$TEST_NUMBER.log" + + # create log life + touch $FAILED_TESTS_LOG + + upload_dd $PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE $RESPONSE_HEADERS_FILE + + echo 'Assert status 200' + assert_status_code 200 $RESPONSE_HEADERS_FILE +done diff --git a/cds-regression-test/test/resource-resolution/resource-resolution-upload-test.sh b/cds-regression-test/test/resource-resolution/resource-resolution-upload-test.sh new file mode 100755 index 0000000..16c7326 --- /dev/null +++ b/cds-regression-test/test/resource-resolution/resource-resolution-upload-test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +CBA_NAME="resource-resolution" +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/cds-regression-test/test/resource-resolution/success/expected-payloads/expected-response.json b/cds-regression-test/test/resource-resolution/success/expected-payloads/expected-response.json new file mode 100644 index 0000000..efb6282 --- /dev/null +++ b/cds-regression-test/test/resource-resolution/success/expected-payloads/expected-response.json @@ -0,0 +1,31 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-05-07T22:18:06.901Z", + "originatorId": "System", + "requestId": "1234", + "subRequestId": "1234-12234", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-resource-resolution", + "blueprintVersion": "1.0.0", + "actionName": "resource-resolution", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-05-07T22:18:22.289Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "resource-resolution-response": { + "meshed-template": { + "helloworld-velocity": "{\n \"default\": \"ok\",\n \"input\": \"ok\",\n \"script\": {\n \"python\": \"ok\",\n \"kotlin\": \"ok\"\n },\n \"db\": \"ok\",\n \"rest\": {\n \"GET\": \"get:ok\",\n \"POST\": \"post:ok\",\n \"PUT\": \"put:ok\",\n \"PATCH\": \"patch:ok\",\n \"DELETE\": \"delete:ok\"\n }\n}\n", + "helloworld-jinja": "{\n \"default\": \"ok\",\n \"input\": \"ok\",\n \"script\": {\n \"python\": \"ok\",\n \"kotlin\": {\n \"base\": \"ok\"\n \"from suspend function\": \"ok\"\n }\n },\n \"db\": \"ok\",\n \"rest\": {\n \"GET\": \"get:ok\",\n \"POST\": \"post:ok\",\n \"PUT\": \"put:ok\",\n \"PATCH\": \"patch:ok\",\n \"DELETE\": \"delete:ok\"\n }\n}\n" + } + } + } +} diff --git a/cds-regression-test/test/resource-resolution/success/request-payloads/request-payload.json b/cds-regression-test/test/resource-resolution/success/request-payloads/request-payload.json new file mode 100644 index 0000000..91e4612 --- /dev/null +++ b/cds-regression-test/test/resource-resolution/success/request-payloads/request-payload.json @@ -0,0 +1,26 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "1234", + "subRequestId": "1234-12234" + }, + "actionIdentifiers": { + "blueprintName": "RT-resource-resolution", + "blueprintVersion": "1.0.0", + "actionName": "resource-resolution", + "mode": "sync" + }, + "payload": { + "resource-resolution-request": { + "template-prefix": [ + "helloworld-velocity", + "helloworld-jinja" + ], + "resolution-key": "regression-test", + "resource-resolution-properties": { + "v_input": "ok", + "j_input": "ok" + } + } + } +} diff --git a/cds-regression-test/test/resource-resolution/success/test.sh b/cds-regression-test/test/resource-resolution/success/test.sh new file mode 100755 index 0000000..c43c276 --- /dev/null +++ b/cds-regression-test/test/resource-resolution/success/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="resource-resolution" +TEST_NAME="success" +TEST_NUMBER=$RANDOM + +REQUEST_PAYLOAD_DIR="request-payloads" +EXPECTED_PAYLOAD_DIR="expected-payloads" + +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_DIR/request-payload.json" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/$EXPECTED_PAYLOAD_DIR/expected-response.json" + +. ./$TEST_DIRECTORY/utils.sh + +echo "Running test: $CBA_NAME:$TEST_NUMBER:$TEST_NAME" +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 diff --git a/cds-regression-test/test/test/ansible-python-dg/ansible-python-dg-enrichment-test.sh b/cds-regression-test/test/test/ansible-python-dg/ansible-python-dg-enrichment-test.sh new file mode 100644 index 0000000..26dfa99 --- /dev/null +++ b/cds-regression-test/test/test/ansible-python-dg/ansible-python-dg-enrichment-test.sh @@ -0,0 +1,16 @@ +#!/bin/bash +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 + +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/cds-regression-test/test/test/ansible-python-dg/ansible-python-dg-upload-test.sh b/cds-regression-test/test/test/ansible-python-dg/ansible-python-dg-upload-test.sh new file mode 100644 index 0000000..f3abae1 --- /dev/null +++ b/cds-regression-test/test/test/ansible-python-dg/ansible-python-dg-upload-test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +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/cds-regression-test/test/test/ansible-python-dg/dummy-request-payload.json b/cds-regression-test/test/test/ansible-python-dg/dummy-request-payload.json new file mode 100644 index 0000000..f04d745 --- /dev/null +++ b/cds-regression-test/test/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/cds-regression-test/test/test/ansible-python-dg/init-mockserver.sh b/cds-regression-test/test/test/ansible-python-dg/init-mockserver.sh new file mode 100644 index 0000000..b777714 --- /dev/null +++ b/cds-regression-test/test/test/ansible-python-dg/init-mockserver.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +CBA_NAME="ansible-python-dg" +DIR_PAYLOADS="$TEST_DIRECTORY/$CBA_NAME/mock-payloads" + + +# JOB TEMPLATE +echo "Mocking Job Template route..." +JT_PAYLOAD="job-template.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$JT_PAYLOAD" + +# JOB TEMPLATE LAUNCH - GET +echo "Mocking Job Template Launch GET route..." +GET_JT_LAUNCH_PAYLOAD="get_job-template-launch.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$GET_JT_LAUNCH_PAYLOAD" + +# JOB TEMPLATE LAUNCH +echo "Mocking Inventory route..." +INVENTORY_PAYLOAD="inventory.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$INVENTORY_PAYLOAD" + +# JOB TEMPLATE LAUNCH - POST +echo "Mocking Job Template Launch POST route..." +POST_JT_LAUNCH_PAYLOAD="post_job-template-launch.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$POST_JT_LAUNCH_PAYLOAD" + +# JOB EXECUTION +echo "Mocking Job Execution route..." +JOB_EXECUTION_PAYLOAD="job-execution.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$JOB_EXECUTION_PAYLOAD" + +# JOB OUTPUT +echo "Mocking Job Output route..." +JOB_OUTPUT_PAYLOAD="job-output.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$JOB_OUTPUT_PAYLOAD" diff --git a/cds-regression-test/test/test/ansible-python-dg/mock-payloads/get_job-template-launch.json b/cds-regression-test/test/test/ansible-python-dg/mock-payloads/get_job-template-launch.json new file mode 100644 index 0000000..f4d0020 --- /dev/null +++ b/cds-regression-test/test/test/ansible-python-dg/mock-payloads/get_job-template-launch.json @@ -0,0 +1,46 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/ansible-python-dg/success/api/v2/job_templates/123/launch/" + }, + "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/cds-regression-test/test/test/ansible-python-dg/mock-payloads/inventory.json b/cds-regression-test/test/test/ansible-python-dg/mock-payloads/inventory.json new file mode 100644 index 0000000..87cfdfb --- /dev/null +++ b/cds-regression-test/test/test/ansible-python-dg/mock-payloads/inventory.json @@ -0,0 +1,110 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/ansible-python-dg/success/api/v2/inventories/" + }, + "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/cds-regression-test/test/test/ansible-python-dg/mock-payloads/job-execution.json b/cds-regression-test/test/test/ansible-python-dg/mock-payloads/job-execution.json new file mode 100644 index 0000000..34772d7 --- /dev/null +++ b/cds-regression-test/test/test/ansible-python-dg/mock-payloads/job-execution.json @@ -0,0 +1,216 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/ansible-python-dg/success/api/v2/jobs/456/" + }, + "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/cds-regression-test/test/test/ansible-python-dg/mock-payloads/job-output.json b/cds-regression-test/test/test/ansible-python-dg/mock-payloads/job-output.json new file mode 100644 index 0000000..4877737 --- /dev/null +++ b/cds-regression-test/test/test/ansible-python-dg/mock-payloads/job-output.json @@ -0,0 +1,24 @@ +{ + "httpRequest" : { + "method" : "GET", + "path" : "/ansible-python-dg/success/api/v2/jobs/456/stdout/" + }, + "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/cds-regression-test/test/test/ansible-python-dg/mock-payloads/job-template.json b/cds-regression-test/test/test/ansible-python-dg/mock-payloads/job-template.json new file mode 100644 index 0000000..5b78274 --- /dev/null +++ b/cds-regression-test/test/test/ansible-python-dg/mock-payloads/job-template.json @@ -0,0 +1,224 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/ansible-python-dg/success/api/v2/job_templates/hello_world_job_template/" + }, + "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/cds-regression-test/test/test/ansible-python-dg/mock-payloads/post_job-template-launch.json b/cds-regression-test/test/test/ansible-python-dg/mock-payloads/post_job-template-launch.json new file mode 100644 index 0000000..da92392 --- /dev/null +++ b/cds-regression-test/test/test/ansible-python-dg/mock-payloads/post_job-template-launch.json @@ -0,0 +1,144 @@ +{ + "httpRequest": { + "method": "POST", + "path": "/ansible-python-dg/success/api/v2/job_templates/123/launch/" + }, + "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/cds-regression-test/test/test/ansible-python-dg/success/expected-response.json b/cds-regression-test/test/test/ansible-python-dg/success/expected-response.json new file mode 100644 index 0000000..833c2eb --- /dev/null +++ b/cds-regression-test/test/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/cds-regression-test/test/test/ansible-python-dg/success/request-payload.json b/cds-regression-test/test/test/ansible-python-dg/success/request-payload.json new file mode 100644 index 0000000..bf68498 --- /dev/null +++ b/cds-regression-test/test/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/cds-regression-test/test/test/ansible-python-dg/success/test.sh b/cds-regression-test/test/test/ansible-python-dg/success/test.sh new file mode 100644 index 0000000..8977244 --- /dev/null +++ b/cds-regression-test/test/test/ansible-python-dg/success/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +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 diff --git a/cds-regression-test/test/test/bootstrap.sh b/cds-regression-test/test/test/bootstrap.sh new file mode 100755 index 0000000..36641ed --- /dev/null +++ b/cds-regression-test/test/test/bootstrap.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Starting from Frankfurt CDS release, we need to bootstrap on the first execution. + +# bootstrap files output filenames +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/bootstrap-response-headers" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/bootstrap-response-payload" + +if [ ${CDS_VERSION} == "elalto" ]; then + echo "Skipping bootstrap for elalto release" +else + echo "Bootstrapping CDS" + . ./$TEST_DIRECTORY/utils.sh + bootstrap_cds ${RESPONSE_PAYLOAD_FILE} ${RESPONSE_HEADERS_FILE} + echo "DEBUG::: RESPONSE_HEADERS_FILE: ${RESPONSE_HEADERS_FILE}" + cat ${RESPONSE_HEADERS_FILE} + echo "DEBUG::: RESPONSE_PAYLOAD_FILE: ${RESPONSE_PAYLOAD_FILE}" + cat ${RESPONSE_PAYLOAD_FILE} + assert_status_code 200 ${RESPONSE_HEADERS_FILE} +fi diff --git a/cds-regression-test/test/test/cli/cli-enrichment-test.sh b/cds-regression-test/test/test/cli/cli-enrichment-test.sh new file mode 100755 index 0000000..a41a1ea --- /dev/null +++ b/cds-regression-test/test/test/cli/cli-enrichment-test.sh @@ -0,0 +1,16 @@ +#!/bin/bash +CBA_NAME="cli" +TEST_NAME="$CBA_NAME-enrichment" +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +echo "Compressing CBA: $CBA_NAME" +compress_cba_versioned $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/cds-regression-test/test/test/cli/cli-upload-test.sh b/cds-regression-test/test/test/cli/cli-upload-test.sh new file mode 100755 index 0000000..7285cd4 --- /dev/null +++ b/cds-regression-test/test/test/cli/cli-upload-test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +CBA_NAME="cli" +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/cds-regression-test/test/test/cli/command-fail/resources/elalto/expected-response.json b/cds-regression-test/test/test/cli/command-fail/resources/elalto/expected-response.json new file mode 100644 index 0000000..b7b29e2 --- /dev/null +++ b/cds-regression-test/test/test/cli/command-fail/resources/elalto/expected-response.json @@ -0,0 +1,27 @@ +{ + "commonHeader": { + "timestamp": "2020-02-11T21:24:35.215Z", + "originatorId": "System", + "requestId": "regression-test-cli-command-fail", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-02-11T21:24:36.824Z", + "errorMessage": "Failed to execute commands, below the output : \nCommand : nonExistCommand", + "message": "failure" + }, + "payload": { + "cli-response": { + "response-data": "Error" + } + } +} diff --git a/cds-regression-test/test/test/cli/command-fail/resources/elalto/request-payload.json b/cds-regression-test/test/test/cli/command-fail/resources/elalto/request-payload.json new file mode 100644 index 0000000..db861c9 --- /dev/null +++ b/cds-regression-test/test/test/cli/command-fail/resources/elalto/request-payload.json @@ -0,0 +1,25 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli" + }, + "payload": { + "cli-request": { + "host": "cds-regression-sshmock", + "username": "cdstest", + "password": "testcds", + "port": "22", + "connectionTimeOut": "5000", + "commands": [ + "nonExistCommand" + ] + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-cli-command-fail", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/test/cli/command-fail/resources/frankfurt/expected-response.json b/cds-regression-test/test/test/cli/command-fail/resources/frankfurt/expected-response.json new file mode 100644 index 0000000..6b71773 --- /dev/null +++ b/cds-regression-test/test/test/cli/command-fail/resources/frankfurt/expected-response.json @@ -0,0 +1,34 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-04T15:05:20.003Z", + "originatorId": "System", + "requestId": "regression-test-cli-command-fail", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-06-04T15:05:41.528Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "cli-response": { + "response-data": [ + { + "command": "nonExistCommand", + "deviceOutput": "nonExistCommand\r\n/ $ nonExistCommand\r\n-ash: nonExistCommand: not found\r\n/ $ \u001b[6n", + "successful": true + } + ] + } + } +} diff --git a/cds-regression-test/test/test/cli/command-fail/resources/frankfurt/request-payload.json b/cds-regression-test/test/test/cli/command-fail/resources/frankfurt/request-payload.json new file mode 100644 index 0000000..700271e --- /dev/null +++ b/cds-regression-test/test/test/cli/command-fail/resources/frankfurt/request-payload.json @@ -0,0 +1,26 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli" + }, + "payload": { + "cli-request": { + "host": "cds-regression-sshmock", + "username": "cdstest", + "password": "testcds", + "port": "22", + "connectionTimeOut": "5000", + "logging": true, + "commands": [ + "nonExistCommand" + ] + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-cli-command-fail", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/test/cli/command-fail/test.sh b/cds-regression-test/test/test/cli/command-fail/test.sh new file mode 100755 index 0000000..a150680 --- /dev/null +++ b/cds-regression-test/test/test/cli/command-fail/test.sh @@ -0,0 +1,30 @@ +#!/bin/bash +CBA_NAME="cli" +TEST_NAME="command-fail" +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" + +RESOURCES_DIR="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/resources/$CDS_VERSION" +REQUEST_PAYLOAD_FILE="$RESOURCES_DIR/request-payload.json" +EXPECTED_PAYLOAD_FILE="$RESOURCES_DIR/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 + +if [ "${CDS_VERSION} " == "elalto " ]; then + echo 'Assert statuscode 500' + assert_status_code 500 $RESPONSE_HEADERS_FILE +else + echo 'Assert statuscode 200' + assert_status_code 200 $RESPONSE_HEADERS_FILE +fi + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/test/cli/dummy-request-payload.json b/cds-regression-test/test/test/cli/dummy-request-payload.json new file mode 100644 index 0000000..62d2f92 --- /dev/null +++ b/cds-regression-test/test/test/cli/dummy-request-payload.json @@ -0,0 +1,14 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "dummy-request-should-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "dummy", + "mode": "sync" + }, + "payload": {} +} diff --git a/cds-regression-test/test/test/cli/success/resources/elalto/expected-response.json b/cds-regression-test/test/test/cli/success/resources/elalto/expected-response.json new file mode 100644 index 0000000..a813478 --- /dev/null +++ b/cds-regression-test/test/test/cli/success/resources/elalto/expected-response.json @@ -0,0 +1,27 @@ +{ + "commonHeader": { + "timestamp": "2020-02-11T21:19:57.762Z", + "originatorId": "System", + "requestId": "regression-test-cli", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-02-11T21:20:00.446Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "cli-response": { + "response-data": "\nCommand : pwd\n/\n\nCommand : ls\nbin\ndev\netc\nlib\n" + } + } +} diff --git a/cds-regression-test/test/test/cli/success/resources/elalto/request-payload.json b/cds-regression-test/test/test/cli/success/resources/elalto/request-payload.json new file mode 100644 index 0000000..8019144 --- /dev/null +++ b/cds-regression-test/test/test/cli/success/resources/elalto/request-payload.json @@ -0,0 +1,26 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli" + }, + "payload": { + "cli-request": { + "host": "cds-regression-sshmock", + "username": "cdstest", + "password": "testcds", + "port": "22", + "connectionTimeOut": "5000", + "commands": [ + "pwd", + "ls" + ] + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-cli", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/test/cli/success/resources/frankfurt/expected-response.json b/cds-regression-test/test/test/cli/success/resources/frankfurt/expected-response.json new file mode 100644 index 0000000..55248cb --- /dev/null +++ b/cds-regression-test/test/test/cli/success/resources/frankfurt/expected-response.json @@ -0,0 +1,38 @@ +{ + "commonHeader": { + "timestamp": "2020-05-25T20:54:11.024Z", + "originatorId": "System", + "requestId": "regression-test-cli", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-05-25T20:54:21.453Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "cli-response": { + "response-data": [ + { + "command": "pwd", + "deviceOutput": "pwd\r\n/ $ pwd\r\n/\r\n/ $ \u001b[6n", + "successful": true + }, + { + "command": "ls", + "deviceOutput": "pwd\r\n/ $ pwd\r\n/\r\n/ $ \u001b[6nls\r\n\u001b[1;34mbin\u001b[m \u001b[1;34mdev\u001b[m \u001b[1;34metc\u001b[m \u001b[1;34mlib\u001b[m\r\n/ $ \u001b[6n", + "successful": true + } + ] + } + } +} diff --git a/cds-regression-test/test/test/cli/success/resources/frankfurt/request-payload.json b/cds-regression-test/test/test/cli/success/resources/frankfurt/request-payload.json new file mode 100644 index 0000000..0438a7c --- /dev/null +++ b/cds-regression-test/test/test/cli/success/resources/frankfurt/request-payload.json @@ -0,0 +1,27 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-cli", + "blueprintVersion": "1.0.0", + "actionName": "cli" + }, + "payload": { + "cli-request": { + "host": "cds-regression-sshmock", + "username": "cdstest", + "password": "testcds", + "port": "22", + "connectionTimeOut": "5000", + "logging": true, + "commands": [ + "pwd", + "ls" + ] + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-cli", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/test/cli/success/test.sh b/cds-regression-test/test/test/cli/success/test.sh new file mode 100755 index 0000000..6a589d5 --- /dev/null +++ b/cds-regression-test/test/test/cli/success/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash +CBA_NAME="cli" +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" + +RESOURCES_DIR="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/resources/$CDS_VERSION" +REQUEST_PAYLOAD_FILE="$RESOURCES_DIR/request-payload.json" +EXPECTED_PAYLOAD_FILE="$RESOURCES_DIR/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 200' +assert_status_code 200 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/test/exit_on_failure.sh b/cds-regression-test/test/test/exit_on_failure.sh new file mode 100755 index 0000000..733e9a6 --- /dev/null +++ b/cds-regression-test/test/test/exit_on_failure.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ "$(wc -c $FAILED_TESTS_DIRECTORY/*|awk '/total/ {print $1}')" -gt 0 ] +then + echo "exiting due to presence of files in FAILED_TESTS_DIRECTORY" + wc -c $FAILED_TESTS_DIRECTORY/* + exit 1; +fi diff --git a/cds-regression-test/test/test/lock-device/dummy-request-payload.json b/cds-regression-test/test/test/lock-device/dummy-request-payload.json new file mode 100644 index 0000000..c3ca13c --- /dev/null +++ b/cds-regression-test/test/test/lock-device/dummy-request-payload.json @@ -0,0 +1,14 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "dummy-request-should-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "dummy", + "mode": "sync" + }, + "payload": {} +} diff --git a/cds-regression-test/test/test/lock-device/lock-device-enrichment-test.sh b/cds-regression-test/test/test/lock-device/lock-device-enrichment-test.sh new file mode 100644 index 0000000..6c549dd --- /dev/null +++ b/cds-regression-test/test/test/lock-device/lock-device-enrichment-test.sh @@ -0,0 +1,21 @@ +#!/bin/bash +if [ "${CDS_VERSION} " == "elalto " ]; then + echo "Skipping, not available in elalto" + return 0 +fi + +CBA_NAME="lock-device" +TEST_NAME="$CBA_NAME-enrichment" +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +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/cds-regression-test/test/test/lock-device/lock-device-upload-test.sh b/cds-regression-test/test/test/lock-device/lock-device-upload-test.sh new file mode 100644 index 0000000..902c6c7 --- /dev/null +++ b/cds-regression-test/test/test/lock-device/lock-device-upload-test.sh @@ -0,0 +1,25 @@ +#!/bin/bash +if [ "${CDS_VERSION} " == "elalto " ]; then + echo "Skipping, not available in elalto" + return 0 +fi + +CBA_NAME="lock-device" +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/cds-regression-test/test/test/lock-device/success/expected-payloads/expected-payload-1.json b/cds-regression-test/test/test/lock-device/success/expected-payloads/expected-payload-1.json new file mode 100644 index 0000000..b70b502 --- /dev/null +++ b/cds-regression-test/test/test/lock-device/success/expected-payloads/expected-payload-1.json @@ -0,0 +1,28 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-30T17:46:47.772Z", + "originatorId": "System", + "requestId": "lock-request-1", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-06-30T17:47:02.922Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "resolve-deploy-kotlin-response": { + "response-data": "Success: lock-request-1" + } + } +} diff --git a/cds-regression-test/test/test/lock-device/success/expected-payloads/expected-payload-2.json b/cds-regression-test/test/test/lock-device/success/expected-payloads/expected-payload-2.json new file mode 100644 index 0000000..bd0dfdc --- /dev/null +++ b/cds-regression-test/test/test/lock-device/success/expected-payloads/expected-payload-2.json @@ -0,0 +1,28 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-30T17:46:50.008Z", + "originatorId": "System", + "requestId": "lock-request-2", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-06-30T17:47:18.221Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "resolve-deploy-kotlin-response": { + "response-data": "Success: lock-request-2" + } + } +} diff --git a/cds-regression-test/test/test/lock-device/success/expected-payloads/expected-payload-3.json b/cds-regression-test/test/test/lock-device/success/expected-payloads/expected-payload-3.json new file mode 100644 index 0000000..9743758 --- /dev/null +++ b/cds-regression-test/test/test/lock-device/success/expected-payloads/expected-payload-3.json @@ -0,0 +1,26 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-30T17:46:51.761Z", + "originatorId": "System", + "requestId": "lock-request-3", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-06-30T17:47:12.301Z", + "errorMessage": "Failed in ComponentScriptExecutor : Failed to acquire lock within timeout, failed to get execution property(node_templates/execute-kotlin/attributes/response-data)", + "message": "failure" + }, + "payload": { + "resolve-deploy-kotlin-response": {} + } +} diff --git a/cds-regression-test/test/test/lock-device/success/expected-payloads/expected-payload-4.json b/cds-regression-test/test/test/lock-device/success/expected-payloads/expected-payload-4.json new file mode 100644 index 0000000..3b916ed --- /dev/null +++ b/cds-regression-test/test/test/lock-device/success/expected-payloads/expected-payload-4.json @@ -0,0 +1,26 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-30T17:46:54.081Z", + "originatorId": "System", + "requestId": "lock-request-4", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-06-30T17:47:14.865Z", + "errorMessage": "Failed in ComponentScriptExecutor : Failed to acquire lock within timeout, failed to get execution property(node_templates/execute-kotlin/attributes/response-data)", + "message": "failure" + }, + "payload": { + "resolve-deploy-kotlin-response": {} + } +} diff --git a/cds-regression-test/test/test/lock-device/success/request-payloads/request-payload-1.json b/cds-regression-test/test/test/lock-device/success/request-payloads/request-payload-1.json new file mode 100644 index 0000000..20be12a --- /dev/null +++ b/cds-regression-test/test/test/lock-device/success/request-payloads/request-payload-1.json @@ -0,0 +1,20 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin" + }, + "payload": { + "resolve-deploy-kotlin-request": { + "resolve-deploy-kotlin-properties": { + "lock-acquire-timeout": 5 + } + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "lock-request-1", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/test/lock-device/success/request-payloads/request-payload-2.json b/cds-regression-test/test/test/lock-device/success/request-payloads/request-payload-2.json new file mode 100644 index 0000000..3fdc8d2 --- /dev/null +++ b/cds-regression-test/test/test/lock-device/success/request-payloads/request-payload-2.json @@ -0,0 +1,20 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin" + }, + "payload": { + "resolve-deploy-kotlin-request": { + "resolve-deploy-kotlin-properties": { + "lock-acquire-timeout": 25 + } + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "lock-request-2", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/test/lock-device/success/request-payloads/request-payload-3.json b/cds-regression-test/test/test/lock-device/success/request-payloads/request-payload-3.json new file mode 100644 index 0000000..f0277bc --- /dev/null +++ b/cds-regression-test/test/test/lock-device/success/request-payloads/request-payload-3.json @@ -0,0 +1,20 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin" + }, + "payload": { + "resolve-deploy-kotlin-request": { + "resolve-deploy-kotlin-properties": { + "lock-acquire-timeout": 15 + } + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "lock-request-3", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/test/lock-device/success/request-payloads/request-payload-4.json b/cds-regression-test/test/test/lock-device/success/request-payloads/request-payload-4.json new file mode 100644 index 0000000..2ba6b89 --- /dev/null +++ b/cds-regression-test/test/test/lock-device/success/request-payloads/request-payload-4.json @@ -0,0 +1,20 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-lock-device", + "blueprintVersion": "1.0.0", + "actionName": "resolve-deploy-kotlin" + }, + "payload": { + "resolve-deploy-kotlin-request": { + "resolve-deploy-kotlin-properties": { + "lock-acquire-timeout": 15 + } + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "lock-request-4", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/test/lock-device/success/test.sh b/cds-regression-test/test/test/lock-device/success/test.sh new file mode 100644 index 0000000..5553e5f --- /dev/null +++ b/cds-regression-test/test/test/lock-device/success/test.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +CBA_NAME="lock-device" +TEST_NAME="success" +TEST_NUMBER=$RANDOM +mkdir -p "$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/" + +. ./$TEST_DIRECTORY/utils.sh + +echo "Running test: $CBA_NAME:$TEST_NUMBER:$TEST_NAME" + +for i in `seq 1 4` +do + echo "Sending request $i" + RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-headers-$i" + RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-payload-$i" + REQUEST_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/request-payloads/request-payload-$i.json" + + process_cba $REQUEST_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE $RESPONSE_HEADERS_FILE & + pids[${i}]=$! + sleep 3 +done + +echo "Waiting for responses" +for pid in ${pids[*]} +do + wait $pid +done + +echo "Assert payload - request 1" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-payload-1" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/expected-payloads/expected-payload-1.json" +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE + +echo "Assert payload - request 2" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-payload-2" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/expected-payloads/expected-payload-2.json" +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE + +echo "Assert payload - request 3" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-payload-3" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/expected-payloads/expected-payload-3.json" +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE + +echo "Assert payload - request 4" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-payload-4" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/expected-payloads/expected-payload-4.json" +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/test/netconf/dummy-request-payload.json b/cds-regression-test/test/test/netconf/dummy-request-payload.json new file mode 100644 index 0000000..acc4f92 --- /dev/null +++ b/cds-regression-test/test/test/netconf/dummy-request-payload.json @@ -0,0 +1,14 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "dummy-request-should-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "dummy", + "mode": "sync" + }, + "payload": {} +} diff --git a/cds-regression-test/test/test/netconf/jython/connect-fail/expected-response.json b/cds-regression-test/test/test/netconf/jython/connect-fail/expected-response.json new file mode 100644 index 0000000..ff0cceb --- /dev/null +++ b/cds-regression-test/test/test/netconf/jython/connect-fail/expected-response.json @@ -0,0 +1,29 @@ +{ + "commonHeader": { + "timestamp": "2020-02-04T14:16:32.798Z", + "originatorId": "System", + "requestId": "regression-test-netconf-jython-connect-fail", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-jython", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-02-04T14:16:32.824Z", + "errorMessage": "org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfException: 127.0.0.1:17830: Failed to establish SSH session", + "message": "failure" + }, + "payload": { + "netconf-jython-response": { + "response-data": { + "deploySuccess": false + } + } + } +} diff --git a/cds-regression-test/test/test/netconf/jython/connect-fail/request-payload.json b/cds-regression-test/test/test/netconf/jython/connect-fail/request-payload.json new file mode 100644 index 0000000..9a9f240 --- /dev/null +++ b/cds-regression-test/test/test/netconf/jython/connect-fail/request-payload.json @@ -0,0 +1,19 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-jython" + }, + "payload": { + "netconf-jython-request": { + "netconf-host": "127.0.0.1", + "netconf-timeout": 5 + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-netconf-jython-connect-fail", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/test/netconf/jython/connect-fail/test.sh b/cds-regression-test/test/test/netconf/jython/connect-fail/test.sh new file mode 100755 index 0000000..670fa49 --- /dev/null +++ b/cds-regression-test/test/test/netconf/jython/connect-fail/test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +CBA_NAME="netconf" +LANG="jython" +TEST_NAME="connect-fail" +TEST_NUMBER=$RANDOM + +mkdir -p "$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/" +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-headers" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-payload" + +REQUEST_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/request-payload.json" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$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 500' +assert_status_code 500 $RESPONSE_HEADERS_FILE + +echo 'Assert connect fail payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/test/netconf/jython/success/expected-response.json b/cds-regression-test/test/test/netconf/jython/success/expected-response.json new file mode 100644 index 0000000..6408577 --- /dev/null +++ b/cds-regression-test/test/test/netconf/jython/success/expected-response.json @@ -0,0 +1,29 @@ +{ + "commonHeader": { + "timestamp": "2020-02-03T13:40:43.697Z", + "originatorId": "System", + "requestId": "regression-test-netconf-jython", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-jython", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-02-03T13:40:51.835Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "netconf-jython-response": { + "response-data": { + "deploySuccess": true + } + } + } +} diff --git a/cds-regression-test/test/test/netconf/jython/success/request-payload.json b/cds-regression-test/test/test/netconf/jython/success/request-payload.json new file mode 100644 index 0000000..dcaaeb1 --- /dev/null +++ b/cds-regression-test/test/test/netconf/jython/success/request-payload.json @@ -0,0 +1,19 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-jython" + }, + "payload": { + "netconf-jython-request": { + "netconf-host": "odl-netconf-testtool", + "netconf-timeout": 30 + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-netconf-jython", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/test/netconf/jython/success/test.sh b/cds-regression-test/test/test/netconf/jython/success/test.sh new file mode 100755 index 0000000..4b3e2c0 --- /dev/null +++ b/cds-regression-test/test/test/netconf/jython/success/test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +CBA_NAME="netconf" +LANG="jython" +TEST_NAME="success" +TEST_NUMBER=$RANDOM + +mkdir -p "$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/" +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-headers" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-payload" + +REQUEST_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/request-payload.json" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$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 200' +assert_status_code 200 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/test/netconf/kotlin/connect-fail/expected-response.json b/cds-regression-test/test/test/netconf/kotlin/connect-fail/expected-response.json new file mode 100644 index 0000000..9334b50 --- /dev/null +++ b/cds-regression-test/test/test/netconf/kotlin/connect-fail/expected-response.json @@ -0,0 +1,29 @@ +{ + "commonHeader": { + "timestamp": "2020-02-04T14:16:32.798Z", + "originatorId": "System", + "requestId": "regression-test-netconf-kotlin-connect-fail", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-kotlin", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-02-04T14:16:32.824Z", + "errorMessage": "org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfException: 127.0.0.1:17830: Failed to establish SSH session", + "message": "failure" + }, + "payload": { + "netconf-kotlin-response": { + "response-data": { + "deploySuccess": false + } + } + } +} diff --git a/cds-regression-test/test/test/netconf/kotlin/connect-fail/request-payload.json b/cds-regression-test/test/test/netconf/kotlin/connect-fail/request-payload.json new file mode 100644 index 0000000..8cac64a --- /dev/null +++ b/cds-regression-test/test/test/netconf/kotlin/connect-fail/request-payload.json @@ -0,0 +1,19 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-kotlin" + }, + "payload": { + "netconf-kotlin-request": { + "netconf-host": "127.0.0.1", + "netconf-timeout": 5 + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-netconf-kotlin-connect-fail", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/test/netconf/kotlin/connect-fail/test.sh b/cds-regression-test/test/test/netconf/kotlin/connect-fail/test.sh new file mode 100755 index 0000000..d30e5ab --- /dev/null +++ b/cds-regression-test/test/test/netconf/kotlin/connect-fail/test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +CBA_NAME="netconf" +LANG="kotlin" +TEST_NAME="connect-fail" +TEST_NUMBER=$RANDOM + +mkdir -p "$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/" +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-headers" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-payload" + +REQUEST_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/request-payload.json" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$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 500' +assert_status_code 500 $RESPONSE_HEADERS_FILE + +echo 'Assert connect fail payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/test/netconf/kotlin/success/expected-response.json b/cds-regression-test/test/test/netconf/kotlin/success/expected-response.json new file mode 100644 index 0000000..dfb81d7 --- /dev/null +++ b/cds-regression-test/test/test/netconf/kotlin/success/expected-response.json @@ -0,0 +1,29 @@ +{ + "commonHeader": { + "timestamp": "2020-02-03T13:40:43.697Z", + "originatorId": "System", + "requestId": "regression-test-netconf-kotlin", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-kotlin", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-02-03T13:40:51.835Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "netconf-kotlin-response": { + "response-data": { + "deploySuccess": true + } + } + } +} diff --git a/cds-regression-test/test/test/netconf/kotlin/success/request-payload.json b/cds-regression-test/test/test/netconf/kotlin/success/request-payload.json new file mode 100644 index 0000000..412614f --- /dev/null +++ b/cds-regression-test/test/test/netconf/kotlin/success/request-payload.json @@ -0,0 +1,19 @@ +{ + "actionIdentifiers": { + "mode": "sync", + "blueprintName": "RT-netconf", + "blueprintVersion": "1.0.0", + "actionName": "netconf-kotlin" + }, + "payload": { + "netconf-kotlin-request": { + "netconf-host": "odl-netconf-testtool", + "netconf-timeout": 30 + } + }, + "commonHeader": { + "subRequestId": "1", + "requestId": "regression-test-netconf-kotlin", + "originatorId": "System" + } +} diff --git a/cds-regression-test/test/test/netconf/kotlin/success/test.sh b/cds-regression-test/test/test/netconf/kotlin/success/test.sh new file mode 100755 index 0000000..8de0e6f --- /dev/null +++ b/cds-regression-test/test/test/netconf/kotlin/success/test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +CBA_NAME="netconf" +LANG="kotlin" +TEST_NAME="success" +TEST_NUMBER=$RANDOM + +mkdir -p "$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/" +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-headers" +RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/$TEST_NUMBER/response-payload" + +REQUEST_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$TEST_NAME/request-payload.json" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$LANG/$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 200' +assert_status_code 200 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/test/netconf/netconf-enrichment-test.sh b/cds-regression-test/test/test/netconf/netconf-enrichment-test.sh new file mode 100755 index 0000000..3c76ce4 --- /dev/null +++ b/cds-regression-test/test/test/netconf/netconf-enrichment-test.sh @@ -0,0 +1,17 @@ +#!/bin/bash +CBA_NAME="netconf" +TEST_NAME="$CBA_NAME-enrichment" +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +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/cds-regression-test/test/test/netconf/netconf-upload-test.sh b/cds-regression-test/test/test/netconf/netconf-upload-test.sh new file mode 100755 index 0000000..933a7b2 --- /dev/null +++ b/cds-regression-test/test/test/netconf/netconf-upload-test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +CBA_NAME="netconf" +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/cds-regression-test/test/test/py-executor/connection-fail/expected-response.json b/cds-regression-test/test/test/py-executor/connection-fail/expected-response.json new file mode 100644 index 0000000..93b2598 --- /dev/null +++ b/cds-regression-test/test/test/py-executor/connection-fail/expected-response.json @@ -0,0 +1,25 @@ +{ + "commonHeader": { + "timestamp": "2020-05-19T17:26:02.923Z", + "originatorId": "System", + "requestId": "123456", + "subRequestId": "1234-12234", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-py-executor", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-05-19T17:26:02.926Z", + "errorMessage": "Failed in ComponentRemoteScriptExecutor : UNAVAILABLE: io exception, failed to get execution property(node_templates/execute-connection-fail/attributes/status)", + "message": "failure" + }, + "payload": { + "connection-fail-response": {} + } +} diff --git a/cds-regression-test/test/test/py-executor/connection-fail/request-payload.json b/cds-regression-test/test/test/py-executor/connection-fail/request-payload.json new file mode 100644 index 0000000..7273340 --- /dev/null +++ b/cds-regression-test/test/test/py-executor/connection-fail/request-payload.json @@ -0,0 +1,16 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "123456", + "subRequestId": "1234-12234" + }, + "actionIdentifiers": { + "blueprintName": "RT-py-executor", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "payload": { + "connection-fail-request": {} + } +} diff --git a/cds-regression-test/test/test/py-executor/connection-fail/test.sh b/cds-regression-test/test/test/py-executor/connection-fail/test.sh new file mode 100644 index 0000000..b4b77e6 --- /dev/null +++ b/cds-regression-test/test/test/py-executor/connection-fail/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="py-executor" +TEST_NAME="connection-fail" +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 500 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/test/py-executor/dummy-request-payload.json b/cds-regression-test/test/test/py-executor/dummy-request-payload.json new file mode 100644 index 0000000..688e5e9 --- /dev/null +++ b/cds-regression-test/test/test/py-executor/dummy-request-payload.json @@ -0,0 +1,14 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "dummy-request-should-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "dummy", + "mode": "sync" + }, + "payload": {} +} diff --git a/cds-regression-test/test/test/py-executor/failing-script/expected-response.json b/cds-regression-test/test/test/py-executor/failing-script/expected-response.json new file mode 100644 index 0000000..17148b0 --- /dev/null +++ b/cds-regression-test/test/test/py-executor/failing-script/expected-response.json @@ -0,0 +1,25 @@ +{ + "commonHeader": { + "timestamp": "2020-05-19T17:24:33.353Z", + "originatorId": "System", + "requestId": "123456", + "subRequestId": "1234-12234", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-py-executor", + "blueprintVersion": "1.0.0", + "actionName": "failing-remote-python", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-05-19T17:24:33.370Z", + "errorMessage": "Failed in ComponentRemoteScriptExecutor : UNKNOWN: Exception iterating responses: Script raised an exception, failed to get execution property(node_templates/execute-failing-remote-python/attributes/status)", + "message": "failure" + }, + "payload": { + "failing-remote-python-response": {} + } +} diff --git a/cds-regression-test/test/test/py-executor/failing-script/request-payload.json b/cds-regression-test/test/test/py-executor/failing-script/request-payload.json new file mode 100644 index 0000000..bacd876 --- /dev/null +++ b/cds-regression-test/test/test/py-executor/failing-script/request-payload.json @@ -0,0 +1,16 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "123456", + "subRequestId": "1234-12234" + }, + "actionIdentifiers": { + "blueprintName": "RT-py-executor", + "blueprintVersion": "1.0.0", + "actionName": "failing-remote-python", + "mode": "sync" + }, + "payload": { + "failing-remote-python-request": {} + } +} diff --git a/cds-regression-test/test/test/py-executor/failing-script/test.sh b/cds-regression-test/test/test/py-executor/failing-script/test.sh new file mode 100644 index 0000000..4386e09 --- /dev/null +++ b/cds-regression-test/test/test/py-executor/failing-script/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="py-executor" +TEST_NAME="failing-script" +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 500 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/test/py-executor/py-executor-enrichment-test.sh b/cds-regression-test/test/test/py-executor/py-executor-enrichment-test.sh new file mode 100644 index 0000000..e671787 --- /dev/null +++ b/cds-regression-test/test/test/py-executor/py-executor-enrichment-test.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +## Not tested on El Alto +if [ "${CDS_VERSION} " == "elalto " ]; then + echo "Skipping, not available in elalto" + return 0 +fi + +CBA_NAME="py-executor" +TEST_NAME="$CBA_NAME-enrichment" +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +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/cds-regression-test/test/test/py-executor/py-executor-upload-test.sh b/cds-regression-test/test/test/py-executor/py-executor-upload-test.sh new file mode 100644 index 0000000..46402e3 --- /dev/null +++ b/cds-regression-test/test/test/py-executor/py-executor-upload-test.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +## Not tested on El Alto +if [ "${CDS_VERSION} " == "elalto " ]; then + echo "Skipping, not available in elalto" + return 0 +fi + +CBA_NAME="py-executor" +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/cds-regression-test/test/test/py-executor/success/expected-response.json b/cds-regression-test/test/test/py-executor/success/expected-response.json new file mode 100644 index 0000000..1318508 --- /dev/null +++ b/cds-regression-test/test/test/py-executor/success/expected-response.json @@ -0,0 +1,32 @@ +{ + "commonHeader": { + "timestamp": "2020-05-26T13:47:27.143Z", + "originatorId": "System", + "requestId": "123456", + "subRequestId": "1234-12234", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-py-executor", + "blueprintVersion": "1.0.0", + "actionName": "remote-python", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-05-26T13:47:27.193Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "remote-python-response": { + "status": "success", + "response-data": { + "HelloWorld-request": { + "hello": "world" + } + } + } + } +} diff --git a/cds-regression-test/test/test/py-executor/success/request-payload.json b/cds-regression-test/test/test/py-executor/success/request-payload.json new file mode 100644 index 0000000..f23b0de --- /dev/null +++ b/cds-regression-test/test/test/py-executor/success/request-payload.json @@ -0,0 +1,16 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "123456", + "subRequestId": "1234-12234" + }, + "actionIdentifiers": { + "blueprintName": "RT-py-executor", + "blueprintVersion": "1.0.0", + "actionName": "remote-python", + "mode": "sync" + }, + "payload": { + "remote-python-request": {} + } +} diff --git a/cds-regression-test/test/test/py-executor/success/test.sh b/cds-regression-test/test/test/py-executor/success/test.sh new file mode 100644 index 0000000..d2d064a --- /dev/null +++ b/cds-regression-test/test/test/py-executor/success/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="py-executor" +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 diff --git a/cds-regression-test/test/test/remote-ansible/connection-failure/expected-response.json b/cds-regression-test/test/test/remote-ansible/connection-failure/expected-response.json new file mode 100644 index 0000000..301e70b --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/connection-failure/expected-response.json @@ -0,0 +1,28 @@ +{ + "commonHeader": { + "timestamp": "2020-05-01T19:38:57.529Z", + "originatorId": "System", + "requestId": "remote-ansible-connection-failure", + "subRequestId": "remote-ansible-connection-failure-1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-05-01T19:38:57.551Z", + "errorMessage": "error : ansible-command-logs : Failed to process on remote executor (Connect to localhost:12345 [localhost/127.0.0.1] failed: Connection refused (Connection refused))", + "message": "failure" + }, + "payload": { + "connection-fail-response": { + "ansible-command-status": "error", + "ansible-command-logs": "Failed to process on remote executor (Connect to localhost:12345 [localhost/127.0.0.1] failed: Connection refused (Connection refused))" + } + } +} diff --git a/cds-regression-test/test/test/remote-ansible/connection-failure/request-payload.json b/cds-regression-test/test/test/remote-ansible/connection-failure/request-payload.json new file mode 100644 index 0000000..08e39c7 --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/connection-failure/request-payload.json @@ -0,0 +1,27 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-ansible-connection-failure", + "subRequestId": "remote-ansible-connection-failure-1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "payload": { + "connection-fail-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/cds-regression-test/test/test/remote-ansible/connection-failure/test.sh b/cds-regression-test/test/test/remote-ansible/connection-failure/test.sh new file mode 100644 index 0000000..7c880fe --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/connection-failure/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="remote-ansible" +TEST_NAME="connection-failure" +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 500 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/test/remote-ansible/dummy-request-payload.json b/cds-regression-test/test/test/remote-ansible/dummy-request-payload.json new file mode 100644 index 0000000..5bb8112 --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/dummy-request-payload.json @@ -0,0 +1,14 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "dummy-request-should-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "dummy", + "mode": "sync" + }, + "payload": {} +} diff --git a/cds-regression-test/test/test/remote-ansible/failure/resources/elalto/expected-response.json b/cds-regression-test/test/test/remote-ansible/failure/resources/elalto/expected-response.json new file mode 100644 index 0000000..050e328 --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/failure/resources/elalto/expected-response.json @@ -0,0 +1,28 @@ +{ + "commonHeader": { + "timestamp": "2020-05-01T18:55:44.034Z", + "originatorId": "System", + "requestId": "remote-ansible-failure", + "subRequestId": "remote-ansible-failure-1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "execute-remote-ansible-failure", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-05-01T18:55:44.046Z", + "errorMessage": "error : ansible-command-logs : Failed to process on remote executor (mapper.readTree(response.body) must not be null)", + "message": "failure" + }, + "payload": { + "execute-remote-ansible-failure-response": { + "ansible-command-status": "error", + "ansible-command-logs": "Failed to process on remote executor (mapper.readTree(response.body) must not be null)" + } + } +} diff --git a/cds-regression-test/test/test/remote-ansible/failure/resources/elalto/request-payload.json b/cds-regression-test/test/test/remote-ansible/failure/resources/elalto/request-payload.json new file mode 100644 index 0000000..a4589ae --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/failure/resources/elalto/request-payload.json @@ -0,0 +1,27 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-ansible-failure", + "subRequestId": "remote-ansible-failure-1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "execute-remote-ansible-failure", + "mode": "sync" + }, + "payload": { + "execute-remote-ansible-failure-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/cds-regression-test/test/test/remote-ansible/failure/resources/frankfurt/expected-response.json b/cds-regression-test/test/test/remote-ansible/failure/resources/frankfurt/expected-response.json new file mode 100644 index 0000000..713b934 --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/failure/resources/frankfurt/expected-response.json @@ -0,0 +1,29 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-02T21:03:35.836Z", + "originatorId": "System", + "requestId": "remote-ansible-failure", + "subRequestId": "remote-ansible-failure-1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "execute-remote-ansible-failure", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-06-02T21:03:38.655Z", + "errorMessage": "error : ansible-command-logs : Workflow/Job template hello_world_job_template does not exists", + "message": "failure" + }, + "payload": { + "execute-remote-ansible-failure-response": { + "ansible-command-status": "error", + "ansible-command-logs": "Workflow/Job template hello_world_job_template does not exists" + } + } +} diff --git a/cds-regression-test/test/test/remote-ansible/failure/resources/frankfurt/request-payload.json b/cds-regression-test/test/test/remote-ansible/failure/resources/frankfurt/request-payload.json new file mode 100644 index 0000000..a4589ae --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/failure/resources/frankfurt/request-payload.json @@ -0,0 +1,27 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-ansible-failure", + "subRequestId": "remote-ansible-failure-1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "execute-remote-ansible-failure", + "mode": "sync" + }, + "payload": { + "execute-remote-ansible-failure-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/cds-regression-test/test/test/remote-ansible/failure/test.sh b/cds-regression-test/test/test/remote-ansible/failure/test.sh new file mode 100644 index 0000000..c044762 --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/failure/test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +CBA_NAME="remote-ansible" +TEST_NAME="failure" +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" + +RESOURCES_DIR="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/resources/$CDS_VERSION" +REQUEST_PAYLOAD_FILE="$RESOURCES_DIR/request-payload.json" +EXPECTED_PAYLOAD_FILE="$RESOURCES_DIR/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 500 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/test/remote-ansible/init-mockserver.sh b/cds-regression-test/test/test/remote-ansible/init-mockserver.sh new file mode 100755 index 0000000..c737b9e --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/init-mockserver.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +CBA_NAME="remote-ansible" +DIR_PAYLOADS="$TEST_DIRECTORY/$CBA_NAME/mock-payloads" + +# JOB TEMPLATE +echo "Mocking Job Template route..." +JT_PAYLOAD="job-template.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$JT_PAYLOAD" + +# JOB TEMPLATE ERROR +echo "Mocking Job Template Error route..." +JT_ERR_PAYLOAD="job-template-error.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$JT_ERR_PAYLOAD" + +# JOB TEMPLATE LAUNCH - GET +echo "Mocking Job Template Launch GET route..." +GET_JT_LAUNCH_PAYLOAD="get_job-template-launch.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$GET_JT_LAUNCH_PAYLOAD" + +# JOB TEMPLATE LAUNCH +echo "Mocking Inventory route..." +INVENTORY_PAYLOAD="inventory.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$INVENTORY_PAYLOAD" + +# JOB TEMPLATE LAUNCH - POST +echo "Mocking Job Template Launch POST route..." +POST_JT_LAUNCH_PAYLOAD="post_job-template-launch.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$POST_JT_LAUNCH_PAYLOAD" + +# JOB EXECUTION +echo "Mocking Job Execution route..." +JOB_EXECUTION_PAYLOAD="job-execution.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$JOB_EXECUTION_PAYLOAD" + +# JOB OUTPUT +echo "Mocking Job Output route..." +JOB_OUTPUT_PAYLOAD="job-output.json" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d "@$DIR_PAYLOADS/$JOB_OUTPUT_PAYLOAD" diff --git a/cds-regression-test/test/test/remote-ansible/mock-payloads/get_job-template-launch.json b/cds-regression-test/test/test/remote-ansible/mock-payloads/get_job-template-launch.json new file mode 100644 index 0000000..ed7904d --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/mock-payloads/get_job-template-launch.json @@ -0,0 +1,46 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/remote-ansible/success/api/v2/job_templates/123/launch/" + }, + "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/cds-regression-test/test/test/remote-ansible/mock-payloads/inventory.json b/cds-regression-test/test/test/remote-ansible/mock-payloads/inventory.json new file mode 100644 index 0000000..165b929 --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/mock-payloads/inventory.json @@ -0,0 +1,110 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/remote-ansible/success/api/v2/inventories/" + }, + "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/cds-regression-test/test/test/remote-ansible/mock-payloads/job-execution.json b/cds-regression-test/test/test/remote-ansible/mock-payloads/job-execution.json new file mode 100644 index 0000000..e8df26b --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/mock-payloads/job-execution.json @@ -0,0 +1,183 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/remote-ansible/success/api/v2/jobs/456/" + }, + "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": {}, + "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/cds-regression-test/test/test/remote-ansible/mock-payloads/job-output.json b/cds-regression-test/test/test/remote-ansible/mock-payloads/job-output.json new file mode 100644 index 0000000..4ae2a49 --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/mock-payloads/job-output.json @@ -0,0 +1,24 @@ +{ + "httpRequest" : { + "method" : "GET", + "path" : "/remote-ansible/success/api/v2/jobs/456/stdout/" + }, + "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/cds-regression-test/test/test/remote-ansible/mock-payloads/job-template-error.json b/cds-regression-test/test/test/remote-ansible/mock-payloads/job-template-error.json new file mode 100644 index 0000000..49a9798 --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/mock-payloads/job-template-error.json @@ -0,0 +1,8 @@ +{ + "httpRequest": { + "path": "/remote-ansible/failure/api/v2/job_templates/hello_world_job_template/" + }, + "httpResponse": { + "statusCode": 500 + } +} diff --git a/cds-regression-test/test/test/remote-ansible/mock-payloads/job-template.json b/cds-regression-test/test/test/remote-ansible/mock-payloads/job-template.json new file mode 100644 index 0000000..10552c4 --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/mock-payloads/job-template.json @@ -0,0 +1,224 @@ +{ + "httpRequest": { + "method": "GET", + "path": "/remote-ansible/success/api/v2/job_templates/hello_world_job_template/" + }, + "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/cds-regression-test/test/test/remote-ansible/mock-payloads/post_job-template-launch.json b/cds-regression-test/test/test/remote-ansible/mock-payloads/post_job-template-launch.json new file mode 100644 index 0000000..8484374 --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/mock-payloads/post_job-template-launch.json @@ -0,0 +1,144 @@ +{ + "httpRequest": { + "method": "POST", + "path": "/remote-ansible/success/api/v2/job_templates/123/launch/" + }, + "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/cds-regression-test/test/test/remote-ansible/remote-ansible-enrichment-test.sh b/cds-regression-test/test/test/remote-ansible/remote-ansible-enrichment-test.sh new file mode 100755 index 0000000..9e4de45 --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/remote-ansible-enrichment-test.sh @@ -0,0 +1,16 @@ +#!/bin/bash +CBA_NAME="remote-ansible" +TEST_NAME="$CBA_NAME-enrichment" +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +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/cds-regression-test/test/test/remote-ansible/remote-ansible-upload-test.sh b/cds-regression-test/test/test/remote-ansible/remote-ansible-upload-test.sh new file mode 100755 index 0000000..334b9b9 --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/remote-ansible-upload-test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +CBA_NAME="remote-ansible" +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/cds-regression-test/test/test/remote-ansible/success/expected-response.json b/cds-regression-test/test/test/remote-ansible/success/expected-response.json new file mode 100644 index 0000000..9dce094 --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/success/expected-response.json @@ -0,0 +1,29 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-03T16:20:03.527Z", + "originatorId": "System", + "requestId": "remote-ansible-success", + "subRequestId": "remote-ansible-success-1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "execute-remote-ansible-success", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-06-03T16:20:18.859Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "execute-remote-ansible-success-response": { + "ansible-command-status": "successful", + "ansible-command-logs": "Output for Job 456 :\n 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\n" + } + } +} diff --git a/cds-regression-test/test/test/remote-ansible/success/request-payload.json b/cds-regression-test/test/test/remote-ansible/success/request-payload.json new file mode 100644 index 0000000..3718c4d --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/success/request-payload.json @@ -0,0 +1,27 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-ansible-success", + "subRequestId": "remote-ansible-success-1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-ansible", + "blueprintVersion": "1.0.0", + "actionName": "execute-remote-ansible-success", + "mode": "sync" + }, + "payload": { + "execute-remote-ansible-success-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/cds-regression-test/test/test/remote-ansible/success/test.sh b/cds-regression-test/test/test/remote-ansible/success/test.sh new file mode 100644 index 0000000..eab16ca --- /dev/null +++ b/cds-regression-test/test/test/remote-ansible/success/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="remote-ansible" +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_versioned 200 $RESPONSE_HEADERS_FILE $RESPONSE_PAYLOAD_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/test/remote-python/connection-fail/resources/elalto/expected-response.json b/cds-regression-test/test/test/remote-python/connection-fail/resources/elalto/expected-response.json new file mode 100644 index 0000000..2ab445b --- /dev/null +++ b/cds-regression-test/test/test/remote-python/connection-fail/resources/elalto/expected-response.json @@ -0,0 +1,29 @@ +{ + "correlationUUID": "9f53fea6-c288-4d19-8d85-93832294f21a", + "commonHeader": { + "timestamp": "2020-07-20T18:15:21.593Z", + "originatorId": "System", + "requestId": "remote-python-connection-fail", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-07-20T18:15:22.846Z", + "errorMessage": "FAILURE : prepare-env : Command failed during env. preparation... timeout(120) requestId (remote-python-connection-fail). grpcError: (Connection refused: /127.0.0.1:4242)", + "message": "failure" + }, + "payload": { + "connection-fail-response": { + "execute-command-payload": "", + "execute-command-logs": "" + } + } +} diff --git a/cds-regression-test/test/test/remote-python/connection-fail/resources/elalto/request-payload.json b/cds-regression-test/test/test/remote-python/connection-fail/resources/elalto/request-payload.json new file mode 100644 index 0000000..4bcf8e2 --- /dev/null +++ b/cds-regression-test/test/test/remote-python/connection-fail/resources/elalto/request-payload.json @@ -0,0 +1,16 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-python-connection-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "payload": { + "connection-fail-request": {} + } +} diff --git a/cds-regression-test/test/test/remote-python/connection-fail/resources/frankfurt/expected-response.json b/cds-regression-test/test/test/remote-python/connection-fail/resources/frankfurt/expected-response.json new file mode 100644 index 0000000..c9b15bd --- /dev/null +++ b/cds-regression-test/test/test/remote-python/connection-fail/resources/frankfurt/expected-response.json @@ -0,0 +1,29 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-06-09T21:02:52.783Z", + "originatorId": "System", + "requestId": "remote-python-connection-fail", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-06-09T21:02:53.142Z", + "errorMessage": "FAILURE : prepare-env : Command failed during env. preparation... timeout(120) requestId (remote-python-connection-fail). grpcError: (finishConnect(..) failed: Connection refused: /127.0.0.1:4242)", + "message": "failure" + }, + "payload": { + "connection-fail-response": { + "execute-command-logs": "[]", + "execute-command-payload": "{}" + } + } +} diff --git a/cds-regression-test/test/test/remote-python/connection-fail/resources/frankfurt/request-payload.json b/cds-regression-test/test/test/remote-python/connection-fail/resources/frankfurt/request-payload.json new file mode 100644 index 0000000..4bcf8e2 --- /dev/null +++ b/cds-regression-test/test/test/remote-python/connection-fail/resources/frankfurt/request-payload.json @@ -0,0 +1,16 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-python-connection-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "connection-fail", + "mode": "sync" + }, + "payload": { + "connection-fail-request": {} + } +} diff --git a/cds-regression-test/test/test/remote-python/connection-fail/test.sh b/cds-regression-test/test/test/remote-python/connection-fail/test.sh new file mode 100644 index 0000000..4d3a38f --- /dev/null +++ b/cds-regression-test/test/test/remote-python/connection-fail/test.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +CBA_NAME="remote-python" +TEST_NAME="connection-fail" +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" + +RESOURCES_DIR="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/resources/$CDS_VERSION" +REQUEST_PAYLOAD_FILE="$RESOURCES_DIR/request-payload.json" +EXPECTED_PAYLOAD_FILE="$RESOURCES_DIR/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 500 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/test/remote-python/dummy-request-payload.json b/cds-regression-test/test/test/remote-python/dummy-request-payload.json new file mode 100644 index 0000000..688e5e9 --- /dev/null +++ b/cds-regression-test/test/test/remote-python/dummy-request-payload.json @@ -0,0 +1,14 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "dummy-request-should-fail", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "dummy", + "mode": "sync" + }, + "payload": {} +} diff --git a/cds-regression-test/test/test/remote-python/failing-script/expected-response.json b/cds-regression-test/test/test/remote-python/failing-script/expected-response.json new file mode 100644 index 0000000..119b135 --- /dev/null +++ b/cds-regression-test/test/test/remote-python/failing-script/expected-response.json @@ -0,0 +1,33 @@ +{ + "correlationUUID": "0ae1f48a-ec91-4573-af76-070ec42e2cdd", + "commonHeader": { + "timestamp": "2020-07-02T23:46:04.959Z", + "originatorId": "System", + "requestId": "remote-python-failing-script", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "failing-remote-python", + "mode": "sync" + }, + "status": { + "code": 500, + "eventType": "EVENT_COMPONENT_FAILURE", + "timestamp": "2020-07-02T23:46:22.167Z", + "errorMessage": "FAILURE : execute-command : [\"Intentionally raised exception!\"]", + "message": "failure" + }, + "payload": { + "failing-remote-python-response": { + "execute-command-payload": { + "errorMessage": "Intentionally raised exception!" + }, + "execute-command-logs": [ + "Intentionally raised exception!" + ] + } + } +} diff --git a/cds-regression-test/test/test/remote-python/failing-script/request-payload.json b/cds-regression-test/test/test/remote-python/failing-script/request-payload.json new file mode 100644 index 0000000..d4c612c --- /dev/null +++ b/cds-regression-test/test/test/remote-python/failing-script/request-payload.json @@ -0,0 +1,16 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-python-failing-script", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "failing-remote-python", + "mode": "sync" + }, + "payload": { + "failing-remote-python-request": {} + } +} diff --git a/cds-regression-test/test/test/remote-python/failing-script/test.sh b/cds-regression-test/test/test/remote-python/failing-script/test.sh new file mode 100755 index 0000000..1c394a3 --- /dev/null +++ b/cds-regression-test/test/test/remote-python/failing-script/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="remote-python" +TEST_NAME="failing-script" +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 500 $RESPONSE_HEADERS_FILE + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE diff --git a/cds-regression-test/test/test/remote-python/remote-python-enrichment-test.sh b/cds-regression-test/test/test/remote-python/remote-python-enrichment-test.sh new file mode 100755 index 0000000..e2344bd --- /dev/null +++ b/cds-regression-test/test/test/remote-python/remote-python-enrichment-test.sh @@ -0,0 +1,16 @@ +#!/bin/bash +CBA_NAME="remote-python" +TEST_NAME="$CBA_NAME-enrichment" +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +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/cds-regression-test/test/test/remote-python/remote-python-upload-test.sh b/cds-regression-test/test/test/remote-python/remote-python-upload-test.sh new file mode 100755 index 0000000..f62490c --- /dev/null +++ b/cds-regression-test/test/test/remote-python/remote-python-upload-test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +CBA_NAME="remote-python" +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/cds-regression-test/test/test/remote-python/success/expected-response.json b/cds-regression-test/test/test/remote-python/success/expected-response.json new file mode 100644 index 0000000..8b0149f --- /dev/null +++ b/cds-regression-test/test/test/remote-python/success/expected-response.json @@ -0,0 +1,36 @@ +{ + "correlationUUID": "9acac95d-9b17-4224-9fe1-0cdb652d027c", + "commonHeader": { + "timestamp": "2020-07-02T22:52:50.662Z", + "originatorId": "System", + "requestId": "remote-python-request", + "subRequestId": "1", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "remote-python", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-07-02T22:53:05.357Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "remote-python-response": { + "execute-command-payload": { + "abc": [ + "xyz", + "qqq" + ] + }, + "execute-command-logs": [ + "remote executor regression" + ] + } + } +} diff --git a/cds-regression-test/test/test/remote-python/success/request-payload.json b/cds-regression-test/test/test/remote-python/success/request-payload.json new file mode 100644 index 0000000..b3b9be8 --- /dev/null +++ b/cds-regression-test/test/test/remote-python/success/request-payload.json @@ -0,0 +1,16 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "remote-python-request", + "subRequestId": "1" + }, + "actionIdentifiers": { + "blueprintName": "RT-remote-python", + "blueprintVersion": "1.0.0", + "actionName": "remote-python", + "mode": "sync" + }, + "payload": { + "remote-python-request": {} + } +} diff --git a/cds-regression-test/test/test/remote-python/success/test.sh b/cds-regression-test/test/test/remote-python/success/test.sh new file mode 100755 index 0000000..1afabbb --- /dev/null +++ b/cds-regression-test/test/test/remote-python/success/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="remote-python" +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 diff --git a/cds-regression-test/test/test/reset-verify-mockserver.sh b/cds-regression-test/test/test/reset-verify-mockserver.sh new file mode 100644 index 0000000..8b3ecf6 --- /dev/null +++ b/cds-regression-test/test/test/reset-verify-mockserver.sh @@ -0,0 +1,10 @@ +#!/bin/bash +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/reset-mockserver-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +echo "Reset mockserver - $TEST_NUMBER" +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/reset" > /dev/null 2> $RESPONSE_HEADERS_FILE +echo 'Assert status 200' +assert_status_code 200 $RESPONSE_HEADERS_FILE diff --git a/cds-regression-test/test/test/resource-resolution/data-dict/RT-db.json b/cds-regression-test/test/test/resource-resolution/data-dict/RT-db.json new file mode 100644 index 0000000..d8e1daf --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/data-dict/RT-db.json @@ -0,0 +1,30 @@ +{ + "name": "RT-db", + "data_type": "string", + "description": "DB request for regression test", + "tags": "datetime", + "updatedBy": "Selfish", + "definition": { + "name": "RT-db", + "tags": "RT-db", + "updated-by": "Selffish", + "property": { + "description": "DB request for regression test", + "type": "string" + }, + "sources": { + "processor-db": { + "type": "source-db", + "properties": { + "endpoint-selector": "db-endpoint", + "type": "SQL", + "query": "select sdnctl.RESOURCE_RESOLUTION.value from sdnctl.RESOURCE_RESOLUTION where value='ok'", + "input-key-mapping": {}, + "output-key-mapping": { + "value": "value" + } + } + } + } + } +} diff --git a/cds-regression-test/test/test/resource-resolution/data-dict/RT-kotlin.json b/cds-regression-test/test/test/resource-resolution/data-dict/RT-kotlin.json new file mode 100644 index 0000000..c521792 --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/data-dict/RT-kotlin.json @@ -0,0 +1,26 @@ +{ + "name": "kotlin-script", + "data_type": "string", + "description": "Kotlin script used to read properties.", + "tags": "kotlin-script", + "updatedBy": "Self-fish", + "definition": { + "name": "kotlin-script", + "updated-by": "Selffish", + "tags": "properties-capability-source", + "property": { + "description": "Kotlin script used to read properties.", + "type": "string" + }, + "sources": { + "capability": { + "type": "source-capability", + "properties": { + "script-type": "kotlin", + "script-class-reference": "cba.cds.RT.ResolvPropertiesKt", + "instance-dependencies": [] + } + } + } + } +} diff --git a/cds-regression-test/test/test/resource-resolution/data-dict/RT-rest-delete.json b/cds-regression-test/test/test/resource-resolution/data-dict/RT-rest-delete.json new file mode 100644 index 0000000..c1cef3b --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/data-dict/RT-rest-delete.json @@ -0,0 +1,32 @@ +{ + "name": "RT-rest-delete", + "data_type": "string", + "description": "Rest DELETE request for regression test", + "tags": "RT-rest-delete", + "updatedBy": "Selfish", + "definition": { + "name": "RT-rest-delete", + "tags": "RT-rest-delete", + "updated-by": "Selffish", + "property": { + "description": "Rest DELETE request for regression test", + "type": "string" + }, + "sources": { + "sdnc": { + "type": "source-rest", + "properties": { + "type": "string", + "verb": "DELETE", + "url-path": "/delete", + "endpoint-selector": "rest-endpoint", + "path": "", + "input-key-mapping": {}, + "output-key-mapping": { + "value": "value" + } + } + } + } + } +} diff --git a/cds-regression-test/test/test/resource-resolution/data-dict/RT-rest-get.json b/cds-regression-test/test/test/resource-resolution/data-dict/RT-rest-get.json new file mode 100644 index 0000000..210ac27 --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/data-dict/RT-rest-get.json @@ -0,0 +1,32 @@ +{ + "name": "RT-rest-get", + "data_type": "string", + "description": "Rest GET request for regression test", + "tags": "RT-rest-get", + "updatedBy": "Selfish", + "definition": { + "name": "RT-rest-get", + "tags": "RT-rest-get", + "updated-by": "Selffish", + "property": { + "description": "Rest GET request for regression test", + "type": "string" + }, + "sources": { + "sdnc": { + "type": "source-rest", + "properties": { + "type": "string", + "verb": "GET", + "url-path": "/get", + "endpoint-selector": "rest-endpoint", + "path": "", + "input-key-mapping": {}, + "output-key-mapping": { + "value": "value" + } + } + } + } + } +} diff --git a/cds-regression-test/test/test/resource-resolution/data-dict/RT-rest-patch.json b/cds-regression-test/test/test/resource-resolution/data-dict/RT-rest-patch.json new file mode 100644 index 0000000..41f94da --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/data-dict/RT-rest-patch.json @@ -0,0 +1,32 @@ +{ + "name": "RT-rest-patch", + "data_type": "string", + "description": "Rest PATCH request for regression test", + "tags": "RT-rest-patch", + "updatedBy": "Selfish", + "definition": { + "name": "RT-rest-patch", + "tags": "RT-rest-patch", + "updated-by": "Selffish", + "property": { + "description": "Rest PATCH request for regression test", + "type": "string" + }, + "sources": { + "sdnc": { + "type": "source-rest", + "properties": { + "type": "string", + "verb": "PATCH", + "url-path": "/patch", + "endpoint-selector": "rest-endpoint", + "path": "", + "input-key-mapping": {}, + "output-key-mapping": { + "value": "value" + } + } + } + } + } +} diff --git a/cds-regression-test/test/test/resource-resolution/data-dict/RT-rest-post.json b/cds-regression-test/test/test/resource-resolution/data-dict/RT-rest-post.json new file mode 100644 index 0000000..63721bb --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/data-dict/RT-rest-post.json @@ -0,0 +1,32 @@ +{ + "name": "RT-rest-post", + "data_type": "string", + "description": "Rest POST request for regression test", + "tags": "RT-rest-post", + "updatedBy": "Selfish", + "definition": { + "name": "RT-rest-post", + "tags": "RT-rest-post", + "updated-by": "Selffish", + "property": { + "description": "Rest POST request for regression test", + "type": "string" + }, + "sources": { + "sdnc": { + "type": "source-rest", + "properties": { + "type": "string", + "verb": "POST", + "url-path": "/post", + "endpoint-selector": "rest-endpoint", + "path": "", + "input-key-mapping": {}, + "output-key-mapping": { + "value": "value" + } + } + } + } + } +} diff --git a/cds-regression-test/test/test/resource-resolution/data-dict/RT-rest-put.json b/cds-regression-test/test/test/resource-resolution/data-dict/RT-rest-put.json new file mode 100644 index 0000000..cf165d3 --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/data-dict/RT-rest-put.json @@ -0,0 +1,32 @@ +{ + "name": "RT-rest-put", + "data_type": "string", + "description": "Rest PUT request for regression test", + "tags": "RT-rest-put", + "updatedBy": "Selfish", + "definition": { + "name": "RT-rest-put", + "tags": "RT-rest-put", + "updated-by": "Selffish", + "property": { + "description": "Rest PUT request for regression test", + "type": "string" + }, + "sources": { + "sdnc": { + "type": "source-rest", + "properties": { + "type": "string", + "verb": "PUT", + "url-path": "/put", + "endpoint-selector": "rest-endpoint", + "path": "", + "input-key-mapping": {}, + "output-key-mapping": { + "value": "value" + } + } + } + } + } +} diff --git a/cds-regression-test/test/test/resource-resolution/dummy-request-payload.json b/cds-regression-test/test/test/resource-resolution/dummy-request-payload.json new file mode 100644 index 0000000..60b3442 --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/dummy-request-payload.json @@ -0,0 +1,14 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "dummy-request-should-fail", + "subRequestId": "11" + }, + "actionIdentifiers": { + "blueprintName": "RT-resource-resolution", + "blueprintVersion": "1.0.0", + "actionName": "dummy", + "mode": "sync" + }, + "payload": {} +} diff --git a/cds-regression-test/test/test/resource-resolution/force-resolution/expected-payloads/expected-response-1.json b/cds-regression-test/test/test/resource-resolution/force-resolution/expected-payloads/expected-response-1.json new file mode 100644 index 0000000..efb6282 --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/force-resolution/expected-payloads/expected-response-1.json @@ -0,0 +1,31 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-05-07T22:18:06.901Z", + "originatorId": "System", + "requestId": "1234", + "subRequestId": "1234-12234", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-resource-resolution", + "blueprintVersion": "1.0.0", + "actionName": "resource-resolution", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-05-07T22:18:22.289Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "resource-resolution-response": { + "meshed-template": { + "helloworld-velocity": "{\n \"default\": \"ok\",\n \"input\": \"ok\",\n \"script\": {\n \"python\": \"ok\",\n \"kotlin\": \"ok\"\n },\n \"db\": \"ok\",\n \"rest\": {\n \"GET\": \"get:ok\",\n \"POST\": \"post:ok\",\n \"PUT\": \"put:ok\",\n \"PATCH\": \"patch:ok\",\n \"DELETE\": \"delete:ok\"\n }\n}\n", + "helloworld-jinja": "{\n \"default\": \"ok\",\n \"input\": \"ok\",\n \"script\": {\n \"python\": \"ok\",\n \"kotlin\": {\n \"base\": \"ok\"\n \"from suspend function\": \"ok\"\n }\n },\n \"db\": \"ok\",\n \"rest\": {\n \"GET\": \"get:ok\",\n \"POST\": \"post:ok\",\n \"PUT\": \"put:ok\",\n \"PATCH\": \"patch:ok\",\n \"DELETE\": \"delete:ok\"\n }\n}\n" + } + } + } +} diff --git a/cds-regression-test/test/test/resource-resolution/force-resolution/expected-payloads/expected-response-2.json b/cds-regression-test/test/test/resource-resolution/force-resolution/expected-payloads/expected-response-2.json new file mode 100644 index 0000000..5d52426 --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/force-resolution/expected-payloads/expected-response-2.json @@ -0,0 +1,31 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-05-07T22:18:06.901Z", + "originatorId": "System", + "requestId": "1234", + "subRequestId": "1234-12234", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-resource-resolution", + "blueprintVersion": "1.0.0", + "actionName": "resource-resolution", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-05-07T22:18:22.289Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "resource-resolution-response": { + "meshed-template": { + "helloworld-velocity": "{\n \"default\": \"ok\",\n \"input\": \"ok-ok\",\n \"script\": {\n \"python\": \"ok\",\n \"kotlin\": \"ok\"\n },\n \"db\": \"ok\",\n \"rest\": {\n \"GET\": \"get:ok\",\n \"POST\": \"post:ok\",\n \"PUT\": \"put:ok\",\n \"PATCH\": \"patch:ok\",\n \"DELETE\": \"delete:ok\"\n }\n}\n", + "helloworld-jinja": "{\n \"default\": \"ok\",\n \"input\": \"ok-ok\",\n \"script\": {\n \"python\": \"ok\",\n \"kotlin\": {\n \"base\": \"ok\"\n \"from suspend function\": \"ok\"\n }\n },\n \"db\": \"ok\",\n \"rest\": {\n \"GET\": \"get:ok\",\n \"POST\": \"post:ok\",\n \"PUT\": \"put:ok\",\n \"PATCH\": \"patch:ok\",\n \"DELETE\": \"delete:ok\"\n }\n}\n" + } + } + } +} diff --git a/cds-regression-test/test/test/resource-resolution/force-resolution/request-payloads/request-payload-1.json b/cds-regression-test/test/test/resource-resolution/force-resolution/request-payloads/request-payload-1.json new file mode 100644 index 0000000..91e4612 --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/force-resolution/request-payloads/request-payload-1.json @@ -0,0 +1,26 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "1234", + "subRequestId": "1234-12234" + }, + "actionIdentifiers": { + "blueprintName": "RT-resource-resolution", + "blueprintVersion": "1.0.0", + "actionName": "resource-resolution", + "mode": "sync" + }, + "payload": { + "resource-resolution-request": { + "template-prefix": [ + "helloworld-velocity", + "helloworld-jinja" + ], + "resolution-key": "regression-test", + "resource-resolution-properties": { + "v_input": "ok", + "j_input": "ok" + } + } + } +} diff --git a/cds-regression-test/test/test/resource-resolution/force-resolution/request-payloads/request-payload-2.json b/cds-regression-test/test/test/resource-resolution/force-resolution/request-payloads/request-payload-2.json new file mode 100644 index 0000000..de8a797 --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/force-resolution/request-payloads/request-payload-2.json @@ -0,0 +1,26 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "1234", + "subRequestId": "1234-12234" + }, + "actionIdentifiers": { + "blueprintName": "RT-resource-resolution", + "blueprintVersion": "1.0.0", + "actionName": "resource-resolution", + "mode": "sync" + }, + "payload": { + "resource-resolution-request": { + "template-prefix": [ + "helloworld-velocity", + "helloworld-jinja" + ], + "resolution-key": "regression-test", + "resource-resolution-properties": { + "v_input": "ok-ok", + "j_input": "ok-ok" + } + } + } +} diff --git a/cds-regression-test/test/test/resource-resolution/force-resolution/test.sh b/cds-regression-test/test/test/resource-resolution/force-resolution/test.sh new file mode 100644 index 0000000..013df7e --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/force-resolution/test.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +CBA_NAME="resource-resolution" +TEST_NAME="force-resolution" +TEST_NUMBER=$RANDOM + +REQUEST_PAYLOAD_DIR="request-payloads" +EXPECTED_PAYLOAD_DIR="expected-payloads" + +mkdir -p "$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/" +RESPONSE_HEADERS_FILE_1="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-headers-1" +RESPONSE_PAYLOAD_FILE_1="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-payload-1" +REQUEST_PAYLOAD_FILE_1="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/$REQUEST_PAYLOAD_DIR/request-payload-1.json" +EXPECTED_PAYLOAD_FILE_1="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/$EXPECTED_PAYLOAD_DIR/expected-response-1.json" + +RESPONSE_HEADERS_FILE_2="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-headers-2" +RESPONSE_PAYLOAD_FILE_2="$RESPONSES_DIRECTORY/$CBA_NAME/$TEST_NAME/$TEST_NUMBER/response-payload-2" +REQUEST_PAYLOAD_FILE_2="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/$REQUEST_PAYLOAD_DIR/request-payload-2.json" +EXPECTED_PAYLOAD_FILE_2="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/$EXPECTED_PAYLOAD_DIR/expected-response-2.json" + +. ./$TEST_DIRECTORY/utils.sh + +echo "Running test: $CBA_NAME:$TEST_NUMBER:$TEST_NAME" +echo "Running initial ressource-resolution to resolve template..." +process_cba $REQUEST_PAYLOAD_FILE_1 $RESPONSE_PAYLOAD_FILE_1 $RESPONSE_HEADERS_FILE_1 + +echo 'Assert statuscode' +assert_status_code 200 $RESPONSE_HEADERS_FILE_1 + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE_1 $RESPONSE_PAYLOAD_FILE_1 + + +# Verify force-resolution +## Same resolution-key, different input values from above test. +## Force-resolution is enabled in the CBA so we shouldn't get the same resolved template as above. +echo "Running the same ressource-resolution but with different inputs..." +process_cba $REQUEST_PAYLOAD_FILE_2 $RESPONSE_PAYLOAD_FILE_2 $RESPONSE_HEADERS_FILE_2 + +echo 'Assert statuscode' +assert_status_code 200 $RESPONSE_HEADERS_FILE_2 + +echo 'Assert payload' +assert_cds_response_equals $EXPECTED_PAYLOAD_FILE_2 $RESPONSE_PAYLOAD_FILE_2 diff --git a/cds-regression-test/test/test/resource-resolution/init-mockserver.sh b/cds-regression-test/test/test/resource-resolution/init-mockserver.sh new file mode 100755 index 0000000..005ed2f --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/init-mockserver.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d '{ + "httpRequest" : { + "method" : "GET", + "path" : "/get" + }, + "httpResponse" : { + "body" : "{\"value\": \"get:ok\"}" + } +}' + +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d '{ + "httpRequest" : { + "method" : "POST", + "path" : "/post" + }, + "httpResponse" : { + "body" : "{\"value\": \"post:ok\"}" + } +}' + +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d '{ + "httpRequest" : { + "method" : "PUT", + "path" : "/put" + }, + "httpResponse" : { + "body" : "{\"value\": \"put:ok\"}" + } +}' + +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d '{ + "httpRequest" : { + "method" : "PATCH", + "path" : "/patch" + }, + "httpResponse" : { + "body" : "{\"value\": \"patch:ok\"}" + } +}' + +curl -v -X PUT "http://$MOCKSERVER_URL:$MOCKSERVER_PORT/mockserver/expectation" -d '{ + "httpRequest" : { + "method" : "DELETE", + "path" : "/delete" + }, + "httpResponse" : { + "body" : "{\"value\": \"delete:ok\"}" + } +}' diff --git a/cds-regression-test/test/test/resource-resolution/resource-resolution-enrichment-test.sh b/cds-regression-test/test/test/resource-resolution/resource-resolution-enrichment-test.sh new file mode 100755 index 0000000..79236ae --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/resource-resolution-enrichment-test.sh @@ -0,0 +1,16 @@ +#!/bin/bash +CBA_NAME="resource-resolution" +TEST_NAME="$CBA_NAME-enrichment" +TEST_NUMBER=$RANDOM +RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$TEST_NUMBER-response-headers" + +. ./$TEST_DIRECTORY/utils.sh + +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/cds-regression-test/test/test/resource-resolution/resource-resolution-upload-dd.sh b/cds-regression-test/test/test/resource-resolution/resource-resolution-upload-dd.sh new file mode 100755 index 0000000..96f1007 --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/resource-resolution-upload-dd.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +TEST_NAME="upload-data-dict" +TEST_NUMBER=$RANDOM +REQUEST_DD_PAYLOAD_DIR="$TEST_DIRECTORY/resource-resolution/data-dict" + +. ./$TEST_DIRECTORY/utils.sh + +# delete useless log file +rm $FAILED_TESTS_LOG + +DD_PAYLOADS=$(ls $REQUEST_DD_PAYLOAD_DIR) +for DD_PAYLOAD in $DD_PAYLOADS +do + echo "Uploading DD : $DD_PAYLOAD" + PAYLOAD_NAME=$(echo "$DD_PAYLOAD" | cut -d '.' -f1) + RESPONSE_HEADERS_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$PAYLOAD_NAME-$TEST_NUMBER-response-headers" + RESPONSE_PAYLOAD_FILE="$RESPONSES_DIRECTORY/$TEST_NAME-$PAYLOAD_NAME-$TEST_NUMBER-response-payload" + PAYLOAD_FILE="$REQUEST_DD_PAYLOAD_DIR/$DD_PAYLOAD" + FAILED_TESTS_LOG="$FAILED_TESTS_DIRECTORY/$TEST_NAME-$PAYLOAD_NAME-$TEST_NUMBER.log" + + # create log life + touch $FAILED_TESTS_LOG + + upload_dd $PAYLOAD_FILE $RESPONSE_PAYLOAD_FILE $RESPONSE_HEADERS_FILE + + echo 'Assert status 200' + assert_status_code 200 $RESPONSE_HEADERS_FILE +done diff --git a/cds-regression-test/test/test/resource-resolution/resource-resolution-upload-test.sh b/cds-regression-test/test/test/resource-resolution/resource-resolution-upload-test.sh new file mode 100755 index 0000000..16c7326 --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/resource-resolution-upload-test.sh @@ -0,0 +1,20 @@ +#!/bin/bash +CBA_NAME="resource-resolution" +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/cds-regression-test/test/test/resource-resolution/success/expected-payloads/expected-response.json b/cds-regression-test/test/test/resource-resolution/success/expected-payloads/expected-response.json new file mode 100644 index 0000000..efb6282 --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/success/expected-payloads/expected-response.json @@ -0,0 +1,31 @@ +{ + "correlationUUID": null, + "commonHeader": { + "timestamp": "2020-05-07T22:18:06.901Z", + "originatorId": "System", + "requestId": "1234", + "subRequestId": "1234-12234", + "flags": null + }, + "actionIdentifiers": { + "blueprintName": "RT-resource-resolution", + "blueprintVersion": "1.0.0", + "actionName": "resource-resolution", + "mode": "sync" + }, + "status": { + "code": 200, + "eventType": "EVENT_COMPONENT_EXECUTED", + "timestamp": "2020-05-07T22:18:22.289Z", + "errorMessage": null, + "message": "success" + }, + "payload": { + "resource-resolution-response": { + "meshed-template": { + "helloworld-velocity": "{\n \"default\": \"ok\",\n \"input\": \"ok\",\n \"script\": {\n \"python\": \"ok\",\n \"kotlin\": \"ok\"\n },\n \"db\": \"ok\",\n \"rest\": {\n \"GET\": \"get:ok\",\n \"POST\": \"post:ok\",\n \"PUT\": \"put:ok\",\n \"PATCH\": \"patch:ok\",\n \"DELETE\": \"delete:ok\"\n }\n}\n", + "helloworld-jinja": "{\n \"default\": \"ok\",\n \"input\": \"ok\",\n \"script\": {\n \"python\": \"ok\",\n \"kotlin\": {\n \"base\": \"ok\"\n \"from suspend function\": \"ok\"\n }\n },\n \"db\": \"ok\",\n \"rest\": {\n \"GET\": \"get:ok\",\n \"POST\": \"post:ok\",\n \"PUT\": \"put:ok\",\n \"PATCH\": \"patch:ok\",\n \"DELETE\": \"delete:ok\"\n }\n}\n" + } + } + } +} diff --git a/cds-regression-test/test/test/resource-resolution/success/request-payloads/request-payload.json b/cds-regression-test/test/test/resource-resolution/success/request-payloads/request-payload.json new file mode 100644 index 0000000..91e4612 --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/success/request-payloads/request-payload.json @@ -0,0 +1,26 @@ +{ + "commonHeader": { + "originatorId": "System", + "requestId": "1234", + "subRequestId": "1234-12234" + }, + "actionIdentifiers": { + "blueprintName": "RT-resource-resolution", + "blueprintVersion": "1.0.0", + "actionName": "resource-resolution", + "mode": "sync" + }, + "payload": { + "resource-resolution-request": { + "template-prefix": [ + "helloworld-velocity", + "helloworld-jinja" + ], + "resolution-key": "regression-test", + "resource-resolution-properties": { + "v_input": "ok", + "j_input": "ok" + } + } + } +} diff --git a/cds-regression-test/test/test/resource-resolution/success/test.sh b/cds-regression-test/test/test/resource-resolution/success/test.sh new file mode 100755 index 0000000..c43c276 --- /dev/null +++ b/cds-regression-test/test/test/resource-resolution/success/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +CBA_NAME="resource-resolution" +TEST_NAME="success" +TEST_NUMBER=$RANDOM + +REQUEST_PAYLOAD_DIR="request-payloads" +EXPECTED_PAYLOAD_DIR="expected-payloads" + +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_DIR/request-payload.json" +EXPECTED_PAYLOAD_FILE="$TEST_DIRECTORY/$CBA_NAME/$TEST_NAME/$EXPECTED_PAYLOAD_DIR/expected-response.json" + +. ./$TEST_DIRECTORY/utils.sh + +echo "Running test: $CBA_NAME:$TEST_NUMBER:$TEST_NAME" +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 diff --git a/cds-regression-test/test/test/utils.sh b/cds-regression-test/test/test/utils.sh new file mode 100755 index 0000000..a8766d3 --- /dev/null +++ b/cds-regression-test/test/test/utils.sh @@ -0,0 +1,242 @@ +#ssert_status_code()!/bin/bash +FAILED_TESTS_LOG="$FAILED_TESTS_DIRECTORY/$TEST_NAME-$RANDOM.log" + +touch $FAILED_TESTS_LOG + +# ------------------------------------------------------------------ +# CDS API +# ------------------------------------------------------------------ +CDS_AUTHORIZATION="Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==" +AUTHORIZATION_HEADER="Authorization: $CDS_AUTHORIZATION" +CONTENT_TYPE_FORM_DATA="Content-Type: multipart/form-data" +CONTENT_TYPE_APPLICATION_JSON="Content-Type: application/json" +BOOTSTRAP_ENDPOINT="api/v1/blueprint-model/bootstrap" + +# Input Arguments: +# 1. CBA name +compress_cba() { + pushd $CBA_DIRECTORY/$1 + zip -r ../$1.zip . + popd +} + + # Input Arguments: + # 1. CBA name +compress_cba_versioned() { + pushd "$CBA_DIRECTORY/$1/$CDS_VERSION" + zip -r ../../$1.zip . + popd +} + +# Sends CBA to CDS for enrichment +# +# Input Arguments: +# 1. CBA name +# 2. filepath for response header output +enrich_cba() { + curl -vs http://$CDS_URL_REGRESSION_TEST:$RUNTIME_PORT/$ENRICH_URI \ + -H "$CONTENT_TYPE_FORM_DATA" \ + -H "$AUTHORIZATION_HEADER" \ + -F file="@$CBA_DIRECTORY/$1.zip" \ + -o "$CBA_ENRICHED_FOLDER/$1.zip" \ + 2> $2 +} + +# Uploads CBA to CDS +# +# Input Arguments: +# 1. CBA name +# 2. filepath for response payload output +# 3. filepath for response header output +upload_cba() { + if [ "${CDS_VERSION} " == "elalto " ]; then + UPLOAD_ENDPOINT=${UPLOAD_URI_ELALTO} + else + UPLOAD_ENDPOINT=${UPLOAD_URI_FRANKFURT} + fi + curl -vs http://$CDS_URL_REGRESSION_TEST:$RUNTIME_PORT/${UPLOAD_ENDPOINT} \ + -H "$CONTENT_TYPE_FORM_DATA" \ + -H "$AUTHORIZATION_HEADER" \ + -F file="@$CBA_ENRICHED_FOLDER/$1.zip" \ + > $2 \ + 2> $3 +} + +# Uploads DD to CDS +# +# Input Arguments: +# 1. filepath for request payload json file +# 2. filepath for response payload output +# 3. filepath for response header output +upload_dd() { + curl -vs http://$CDS_URL_REGRESSION_TEST:$RUNTIME_PORT/$LOAD_DATA_DICT \ + -H "$CONTENT_TYPE_APPLICATION_JSON" \ + -H "$AUTHORIZATION_HEADER" \ + --data "@$1" \ + >$2 \ + 2> $3 +} + +# Sends process request to CDS +# +# Input Arguments: +# 1. filepath for request payload json file +# 2. filepath for response payload output +# 3. filepath for response header output +process_cba() { + curl -vs http://$CDS_URL_REGRESSION_TEST:$RUNTIME_PORT/$PROCESS_URI \ + -H "$CONTENT_TYPE_APPLICATION_JSON" \ + -H "$AUTHORIZATION_HEADER" \ + --data "@$1" \ + >$2 \ + 2> $3 +} + +# Bootstrap CDS request (Frankfurt and up) +# Input arguments: +# 1. filepath for response payload output +# 2. filepath for response header output +bootstrap_cds() { + curl -vs http://$CDS_URL_REGRESSION_TEST:$RUNTIME_PORT/${BOOTSTRAP_ENDPOINT} \ + -H "$CONTENT_TYPE_APPLICATION_JSON" \ + -H "$AUTHORIZATION_HEADER" \ + --data-raw '{ + "loadModelType" : true, + "loadResourceDictionary" : true, + "loadCBA" : false +}'>$1 2>$2 + +} + +# ------------------------------------------------------------------ +# Blueprint modifications +# ------------------------------------------------------------------ + + +# Sets a value in the definition json file +# Input arguments +# 1: CBA name +# 1: jq path for value to be set +# 2: value +definition_set_value() { + local BLUEPRINT_DEFINITION_FILE=`grep "Entry" $CBA_DIRECTORY/$1/TOSCA-Metadata/TOSCA.meta|awk '{ print $2 }'` + local TEMPFILE=`mktemp` + jq "$2=$3" < $CBA_DIRECTORY/$1/$BLUEPRINT_DEFINITION_FILE > $TEMPFILE + mv $TEMPFILE $CBA_DIRECTORY/$1/$BLUEPRINT_DEFINITION_FILE +} + +# Makes environment variables available for json templating using jq path +# example template { "cds-version": .CDS_VERSION } - will populate value CDS_VERSION from env +# Input arguments +# 1: template file +apply_env_to_json_template() { + local TEMPFILE=`mktemp` + jq -n env|jq -f $1 > $TEMPFILE + mv $TEMPFILE $1 +} + +# ------------------------------------------------------------------ +# Assert Functions +# ------------------------------------------------------------------ + +match() { + local input="$(cat)" + local m="$(grep -o "$1" <<<"$input")" + test "$m" || tee -a $FAILED_TESTS_LOG <<EOF +-------------------------------------------------------------------- +TEST: $TEST_NAME +match + +expected: $1 +got: +$input + +-------------------------------------------------------------------- +EOF +} + +# Asserts that 2 json files are equal +# +# Input arguments: +# 1: filepath for expected json +# 2: filepath for actual json +assert_json_equals() { + local res=`diff <(jq -S < $1) <(jq -S < $2)` + if [ "$res" ] + then + tee -a $FAILED_TESTS_LOG <<EOF +-------------------------------------------------------------------- +TEST: $TEST_NAME +assert_json_equals + +diff: +$res + + +-------------------------------------------------------------------- +EOF + fi +} + +# Asserts specific json property in provided file +# +# Input arguments: +# 1: jq filter for property, eg. .status.eventType +# 2: expected property value +# 3: filepath for jsonfile to assert +assert_json_property_equals() { + local prop=`jq "$1" <$3` + [ $prop = "$2" ] || tee -a $FAILED_TESTS_LOG <<EOF +-------------------------------------------------------------------- +TEST: $TEST_NAME +assert_json_property_equals + +expected: $2 +got: $prop + +-------------------------------------------------------------------- +EOF +} + +# Asserts CDS response payload, ignores timestamps +# +# Input arguments: +# 1. filepath for exepected payload +# 2. filepath for received payload +assert_cds_response_equals() { + EXPECTED=`mktemp` + ACTUAL=`mktemp` + #remove timestamps and correlationUUID + jq 'del(.correlationUUID,.[].timestamp?)' < $1 > $EXPECTED + jq 'del(.correlationUUID,.[].timestamp?)' < $2 > $ACTUAL + assert_json_equals $EXPECTED $ACTUAL +} + +# Asserts response status code +# +# Input arguments: +# 1. expected response code, eg. 200 +# 2. filepath for response header file + +assert_status_code() { match "^< HTTP/.* $1 " < $2; } + +# Asserts respones status code (CDS version-dependent) +# For elalto, we look for the code as returned by the query, +# but not elalto (frankfurt and onward,) we look for json return object .status.code +# Input arguments: +# 1. expected response code, eg. 200 +# 2. filepath for response header file +# 2. filepath for response payload file +assert_status_code_versioned() { + if [ "${CDS_VERSION}" == "elalto" ]; then + match "^< HTTP/.* $1 " < $2; + else + assert_json_property_equals '.status.code' $1 $3 + fi +} + +exit_on_errors() { + if [ -s $FAILED_TESTS_LOG ] + then exit 1 + fi +} diff --git a/cds-regression-test/test/utils.sh b/cds-regression-test/test/utils.sh new file mode 100755 index 0000000..a8766d3 --- /dev/null +++ b/cds-regression-test/test/utils.sh @@ -0,0 +1,242 @@ +#ssert_status_code()!/bin/bash +FAILED_TESTS_LOG="$FAILED_TESTS_DIRECTORY/$TEST_NAME-$RANDOM.log" + +touch $FAILED_TESTS_LOG + +# ------------------------------------------------------------------ +# CDS API +# ------------------------------------------------------------------ +CDS_AUTHORIZATION="Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==" +AUTHORIZATION_HEADER="Authorization: $CDS_AUTHORIZATION" +CONTENT_TYPE_FORM_DATA="Content-Type: multipart/form-data" +CONTENT_TYPE_APPLICATION_JSON="Content-Type: application/json" +BOOTSTRAP_ENDPOINT="api/v1/blueprint-model/bootstrap" + +# Input Arguments: +# 1. CBA name +compress_cba() { + pushd $CBA_DIRECTORY/$1 + zip -r ../$1.zip . + popd +} + + # Input Arguments: + # 1. CBA name +compress_cba_versioned() { + pushd "$CBA_DIRECTORY/$1/$CDS_VERSION" + zip -r ../../$1.zip . + popd +} + +# Sends CBA to CDS for enrichment +# +# Input Arguments: +# 1. CBA name +# 2. filepath for response header output +enrich_cba() { + curl -vs http://$CDS_URL_REGRESSION_TEST:$RUNTIME_PORT/$ENRICH_URI \ + -H "$CONTENT_TYPE_FORM_DATA" \ + -H "$AUTHORIZATION_HEADER" \ + -F file="@$CBA_DIRECTORY/$1.zip" \ + -o "$CBA_ENRICHED_FOLDER/$1.zip" \ + 2> $2 +} + +# Uploads CBA to CDS +# +# Input Arguments: +# 1. CBA name +# 2. filepath for response payload output +# 3. filepath for response header output +upload_cba() { + if [ "${CDS_VERSION} " == "elalto " ]; then + UPLOAD_ENDPOINT=${UPLOAD_URI_ELALTO} + else + UPLOAD_ENDPOINT=${UPLOAD_URI_FRANKFURT} + fi + curl -vs http://$CDS_URL_REGRESSION_TEST:$RUNTIME_PORT/${UPLOAD_ENDPOINT} \ + -H "$CONTENT_TYPE_FORM_DATA" \ + -H "$AUTHORIZATION_HEADER" \ + -F file="@$CBA_ENRICHED_FOLDER/$1.zip" \ + > $2 \ + 2> $3 +} + +# Uploads DD to CDS +# +# Input Arguments: +# 1. filepath for request payload json file +# 2. filepath for response payload output +# 3. filepath for response header output +upload_dd() { + curl -vs http://$CDS_URL_REGRESSION_TEST:$RUNTIME_PORT/$LOAD_DATA_DICT \ + -H "$CONTENT_TYPE_APPLICATION_JSON" \ + -H "$AUTHORIZATION_HEADER" \ + --data "@$1" \ + >$2 \ + 2> $3 +} + +# Sends process request to CDS +# +# Input Arguments: +# 1. filepath for request payload json file +# 2. filepath for response payload output +# 3. filepath for response header output +process_cba() { + curl -vs http://$CDS_URL_REGRESSION_TEST:$RUNTIME_PORT/$PROCESS_URI \ + -H "$CONTENT_TYPE_APPLICATION_JSON" \ + -H "$AUTHORIZATION_HEADER" \ + --data "@$1" \ + >$2 \ + 2> $3 +} + +# Bootstrap CDS request (Frankfurt and up) +# Input arguments: +# 1. filepath for response payload output +# 2. filepath for response header output +bootstrap_cds() { + curl -vs http://$CDS_URL_REGRESSION_TEST:$RUNTIME_PORT/${BOOTSTRAP_ENDPOINT} \ + -H "$CONTENT_TYPE_APPLICATION_JSON" \ + -H "$AUTHORIZATION_HEADER" \ + --data-raw '{ + "loadModelType" : true, + "loadResourceDictionary" : true, + "loadCBA" : false +}'>$1 2>$2 + +} + +# ------------------------------------------------------------------ +# Blueprint modifications +# ------------------------------------------------------------------ + + +# Sets a value in the definition json file +# Input arguments +# 1: CBA name +# 1: jq path for value to be set +# 2: value +definition_set_value() { + local BLUEPRINT_DEFINITION_FILE=`grep "Entry" $CBA_DIRECTORY/$1/TOSCA-Metadata/TOSCA.meta|awk '{ print $2 }'` + local TEMPFILE=`mktemp` + jq "$2=$3" < $CBA_DIRECTORY/$1/$BLUEPRINT_DEFINITION_FILE > $TEMPFILE + mv $TEMPFILE $CBA_DIRECTORY/$1/$BLUEPRINT_DEFINITION_FILE +} + +# Makes environment variables available for json templating using jq path +# example template { "cds-version": .CDS_VERSION } - will populate value CDS_VERSION from env +# Input arguments +# 1: template file +apply_env_to_json_template() { + local TEMPFILE=`mktemp` + jq -n env|jq -f $1 > $TEMPFILE + mv $TEMPFILE $1 +} + +# ------------------------------------------------------------------ +# Assert Functions +# ------------------------------------------------------------------ + +match() { + local input="$(cat)" + local m="$(grep -o "$1" <<<"$input")" + test "$m" || tee -a $FAILED_TESTS_LOG <<EOF +-------------------------------------------------------------------- +TEST: $TEST_NAME +match + +expected: $1 +got: +$input + +-------------------------------------------------------------------- +EOF +} + +# Asserts that 2 json files are equal +# +# Input arguments: +# 1: filepath for expected json +# 2: filepath for actual json +assert_json_equals() { + local res=`diff <(jq -S < $1) <(jq -S < $2)` + if [ "$res" ] + then + tee -a $FAILED_TESTS_LOG <<EOF +-------------------------------------------------------------------- +TEST: $TEST_NAME +assert_json_equals + +diff: +$res + + +-------------------------------------------------------------------- +EOF + fi +} + +# Asserts specific json property in provided file +# +# Input arguments: +# 1: jq filter for property, eg. .status.eventType +# 2: expected property value +# 3: filepath for jsonfile to assert +assert_json_property_equals() { + local prop=`jq "$1" <$3` + [ $prop = "$2" ] || tee -a $FAILED_TESTS_LOG <<EOF +-------------------------------------------------------------------- +TEST: $TEST_NAME +assert_json_property_equals + +expected: $2 +got: $prop + +-------------------------------------------------------------------- +EOF +} + +# Asserts CDS response payload, ignores timestamps +# +# Input arguments: +# 1. filepath for exepected payload +# 2. filepath for received payload +assert_cds_response_equals() { + EXPECTED=`mktemp` + ACTUAL=`mktemp` + #remove timestamps and correlationUUID + jq 'del(.correlationUUID,.[].timestamp?)' < $1 > $EXPECTED + jq 'del(.correlationUUID,.[].timestamp?)' < $2 > $ACTUAL + assert_json_equals $EXPECTED $ACTUAL +} + +# Asserts response status code +# +# Input arguments: +# 1. expected response code, eg. 200 +# 2. filepath for response header file + +assert_status_code() { match "^< HTTP/.* $1 " < $2; } + +# Asserts respones status code (CDS version-dependent) +# For elalto, we look for the code as returned by the query, +# but not elalto (frankfurt and onward,) we look for json return object .status.code +# Input arguments: +# 1. expected response code, eg. 200 +# 2. filepath for response header file +# 2. filepath for response payload file +assert_status_code_versioned() { + if [ "${CDS_VERSION}" == "elalto" ]; then + match "^< HTTP/.* $1 " < $2; + else + assert_json_property_equals '.status.code' $1 $3 + fi +} + +exit_on_errors() { + if [ -s $FAILED_TESTS_LOG ] + then exit 1 + fi +} |