diff options
author | Morgan Richomme <morgan.richomme@orange.com> | 2020-12-04 21:44:23 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-12-04 21:44:23 +0000 |
commit | bfffa2d982cc506979aaa0b96b6bb352c8dda9a7 (patch) | |
tree | 1093505679ce13406d66b9ccc5fd78884923ea37 /cds-regression-test/test/lock-device | |
parent | 81b196b4c766c7dec927405da1a831cd437c5466 (diff) | |
parent | d3cdace51db473c93540229da3a0fd061120957c (diff) |
Merge "cds-bash script package"
Diffstat (limited to 'cds-regression-test/test/lock-device')
12 files changed, 296 insertions, 0 deletions
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 |