From 3fe70c777050581f090f1bcc9ebf9e44857d0b56 Mon Sep 17 00:00:00 2001 From: vrvarma Date: Fri, 28 Sep 2018 10:30:00 -0400 Subject: Initial implementation of optf-osdf csit Fixing osdf, simulator startup scripts Split the setup & functional test cases Add robot keywords for test suites Refactoring test suites based on comments Change-Id: Ic96343968ec919ac3c5272bc953bbaeb974f2393 Signed-off-by: vrvarma Issue-ID: OPTFRA-286 --- tests/optf-osdf/osdf/__init__.robot | 4 + tests/optf-osdf/osdf/data/pci-opt-request.json | 20 ++++ tests/optf-osdf/osdf/data/placement_request.json | 102 +++++++++++++++++++++ tests/optf-osdf/osdf/optf_osdf_setup.robot | 12 +++ tests/optf-osdf/osdf/optf_osdf_test.robot | 48 ++++++++++ .../optf-osdf/osdf/resources/common-keywords.robot | 50 ++++++++++ 6 files changed, 236 insertions(+) create mode 100644 tests/optf-osdf/osdf/__init__.robot create mode 100644 tests/optf-osdf/osdf/data/pci-opt-request.json create mode 100644 tests/optf-osdf/osdf/data/placement_request.json create mode 100644 tests/optf-osdf/osdf/optf_osdf_setup.robot create mode 100644 tests/optf-osdf/osdf/optf_osdf_test.robot create mode 100644 tests/optf-osdf/osdf/resources/common-keywords.robot (limited to 'tests/optf-osdf/osdf') diff --git a/tests/optf-osdf/osdf/__init__.robot b/tests/optf-osdf/osdf/__init__.robot new file mode 100644 index 00000000..fb654d7b --- /dev/null +++ b/tests/optf-osdf/osdf/__init__.robot @@ -0,0 +1,4 @@ +*** Settings *** +Documentation Integration - Suite 1 + + diff --git a/tests/optf-osdf/osdf/data/pci-opt-request.json b/tests/optf-osdf/osdf/data/pci-opt-request.json new file mode 100644 index 00000000..7ec9ab5f --- /dev/null +++ b/tests/optf-osdf/osdf/data/pci-opt-request.json @@ -0,0 +1,20 @@ +{ + "requestInfo": { + "transactionId": "xxx-xxx-xxxx", + "requestId": "yyy-yyy-yyyy", + "callbackUrl": "https://wiki.onap.org:5000/callbackUrl/", + "sourceId": "SO", + "requestType": "create", + "numSolutions": 1, + "optimizers": [ + "placement" + ], + "timeout": 600 + }, + "cellInfo": { + "networkId": "1000", + "cellIdList": [ + "cell0" + ] + } +} \ No newline at end of file diff --git a/tests/optf-osdf/osdf/data/placement_request.json b/tests/optf-osdf/osdf/data/placement_request.json new file mode 100644 index 00000000..d9b16ca5 --- /dev/null +++ b/tests/optf-osdf/osdf/data/placement_request.json @@ -0,0 +1,102 @@ +{ + "requestInfo": { + "transactionId": "xxx-xxx-xxxx", + "requestId": "yyy-yyy-yyyy", + "callbackUrl": "https://wiki.onap.org:5000/callbackUrl/", + "sourceId": "SO", + "requestType": "create", + "numSolutions": 1, + "optimizers": ["placement"], + "timeout": 600 + }, + "placementInfo": { + "requestParameters": { "customerLatitude": 32.89748, "customerLongitude": -97.040443, "customerName": "xyz" }, + "subscriberInfo": {"globalSubscriberId": "xxx-xx-xxx", "subscriberName": "subscriber_x"}, + "placementDemands": [ + { + "resourceModuleName": "vGMuxInfra", + "serviceResourceId": "vGMuxInfra-xx", + "tenantId": "vGMuxInfra-tenant", + "resourceModelInfo": { + "modelInvariantId": "vGMuxInfra-modelInvariantId", + "modelVersionId": "vGMuxInfra-versionId", + "modelName": "vGMuxInfra-model", + "modelType": "resource", + "modelVersion": "1.0", + "modelCustomizationName": "vGMuxInfra-customeModelName" + } + }, + { + "resourceModuleName": "vG", + "serviceResourceId": "71d563e8-e714-4393-8f99-cc480144a05e", + "tenantId": "vG-tenant", + "resourceModelInfo": { + "modelInvariantId": "vG-modelInvariantId", + "modelVersionId": "vG-versionId", + "modelName": "vG-model", + "modelType": "resource", + "modelVersion": "1.0", + "modelCustomizationName": "vG-customeModelName" + }, + "existingCandidates": [ + { + "identifierType": "serviceInstanceId", + "cloudOwner": "", + "identifiers": ["gjhd-098-fhd-987"] + } + ], + "excludedCandidates": [ + { + "identifierType": "serviceInstanceId", + "cloudOwner": "", + "identifiers": ["gjhd-098-fhd-987"] + }, + { + "identifierType": "vimId", + "cloudOwner": "vmware", + "identifiers": ["NYMDT67"] + } + ], + "requiredCandidates": [ + { + "identifierType": "vimId", + "cloudOwner": "amazon", + "identifiers": ["TXAUS219"] + } + ] + } + ] + }, + "serviceInfo": { + "serviceInstanceId": "d61b2543-5914-4b8f-8e81-81e38575b8ec", + "serviceName": "vCPE", + "modelInfo": { + "modelInvariantId": "vCPE-invariantId", + "modelVersionId": "vCPE-versionId", + "modelName": "vCPE-model", + "modelType": "service", + "modelVersion": "1.0", + "modelCustomizationName": "vCPE-customeModelName" + } + }, + "licenseInfo": { + "licenseDemands": [ + { + "resourceModuleName": "vGMuxInfra", + "serviceResourceId": "vGMuxInfra-xx", + "resourceModelInfo": { + "modelInvariantId": "vGMuxInfra-modelInvariantId", + "modelVersionId": "vGMuxInfra-versionId", + "modelName": "vGMuxInfra-model", + "modelType": "resource", + "modelVersion": "1.0", + "modelCustomizationName": "vGMuxInfra-customeModelName" + }, + "existingLicenses": { + "entitlementPoolUUID": ["87257b49-9602-4ca1-9817-094e52bc873b", "43257b49-9602-4fe5-9337-094e52bc9435"], + "licenseKeyGroupUUID": ["87257b49-9602-4ca1-9817-094e52bc873b", "43257b49-9602-4fe5-9337-094e52bc9435"] + } + } + ] + } +} \ No newline at end of file diff --git a/tests/optf-osdf/osdf/optf_osdf_setup.robot b/tests/optf-osdf/osdf/optf_osdf_setup.robot new file mode 100644 index 00000000..fdf7f3e3 --- /dev/null +++ b/tests/optf-osdf/osdf/optf_osdf_setup.robot @@ -0,0 +1,12 @@ +*** Settings *** +Documentation Suite description +Resource ./resources/common-keywords.robot + +*** Test Cases *** +Check OSDF_SIM Docker Container + [Documentation] It checks osdf_simulator docker container is running + Verify Docker RC Status osdf_sim + +Check OSDF Docker Container + [Documentation] It checks optf-osdf docker container is running + Verify Docker RC Status optf-osdf \ No newline at end of file diff --git a/tests/optf-osdf/osdf/optf_osdf_test.robot b/tests/optf-osdf/osdf/optf_osdf_test.robot new file mode 100644 index 00000000..c3921d5c --- /dev/null +++ b/tests/optf-osdf/osdf/optf_osdf_test.robot @@ -0,0 +1,48 @@ +*** Settings *** +Library json +Library OperatingSystem +Resource ./resources/common-keywords.robot + +Suite Teardown Delete All Sessions + +*** Variables *** +${osdf_host} ${OSDF_HOSTNAME}:${OSDF_PORT} +&{placement_auth} = username=test password=testpwd +&{wrong_authorization} = username=test password=test +&{pci_auth}= username=pci_test password=pci_testpwd + +*** Test Cases *** +Healthcheck + [Documentation] It sends a REST GET request to healthcheck url + ${resp}= Http Get ${osdf_host} /api/oof/v1/healthcheck + Should Be Equal As Integers ${resp.status_code} 200 + +SendPlacementWithInvalidAuth + [Documentation] It sends a POST request to osdf fail authentication + ${data}= Get Binary File ${CURDIR}${/}data${/}placement_request.json + ${resp}= Http Post host=${osdf_host} restUrl=/api/oof/v1/placement data=${data} auth=${wrong_authorization} + ${response_json} json.loads ${resp.content} + Should Be Equal Unauthorized, check username and password ${response_json['serviceException']['text']} + Should Be Equal As Integers ${resp.status_code} 401 + +SendPlacementWithValidAuth + [Documentation] It sends a POST request to osdf with correct authentication + ${data}= Get Binary File ${CURDIR}${/}data${/}placement_request.json + ${resp}= Http Post host=${osdf_host} restUrl=/api/oof/v1/placement data=${data} auth=${placement_auth} + ${response_json} json.loads ${resp.content} + Should Be Equal As Integers ${resp.status_code} 202 + Should Be Equal accepted ${response_json['requestStatus']} + +#SendPCIOptimizationWithAuth +# [Documentation] It sends a POST request PCI Optimization service +# +# ${data}= Get Binary File ${CURDIR}${/}data${/}pci-opt-request.json +# ${resp}= Http Post host=${osdf_host} restUrl=/api/oof/v1/pci data=${data} auth=${pci_auth} +# ${response_json} json.loads ${resp.content} +# Should Be Equal As Integers ${resp.status_code} 202 +# Should Be Equal accepted ${response_json['requestStatus']} + + + + + diff --git a/tests/optf-osdf/osdf/resources/common-keywords.robot b/tests/optf-osdf/osdf/resources/common-keywords.robot new file mode 100644 index 00000000..ea45f09d --- /dev/null +++ b/tests/optf-osdf/osdf/resources/common-keywords.robot @@ -0,0 +1,50 @@ +*** Settings *** +Documentation Suite description +Library OperatingSystem +Library RequestsLibrary +Library json +Library RequestsLibrary +*** Variables *** +&{headers}= Content-Type=application/json Accept=application/json +*** Keywords *** +Verify Docker RC Status + [Documentation] Method to verify whether docker instance is up and running + [Arguments] ${process_name} + ${rc} ${output}= Run and Return RC and Output docker ps + Log To Console ********************* + Log To Console retrurn_code = ${rc} + Log To Console output = ${output} + Should Be Equal As Integers ${rc} 0 + Should Contain ${output} ${process_name} + +Http Get + [Documentation] Wrapper for Http GET + [Arguments] ${host} ${restUrl} + Create Session optf-osdf ${host} + ${resp}= Get Request optf-osdf ${restUrl} headers=${headers} + Log To Console ********************* + Log To Console response = ${resp} + Log To Console body = ${resp.text} + [Return] ${resp} + +Http Post + [Documentation] Wrapper for Http POST + [Arguments] ${host} ${restUrl} ${auth} ${data} + ${pci_auth}= Create List ${auth['username']} ${auth['password']} + Create Session optf-osdf ${host} headers=${headers} auth=${pci_auth} + ${resp}= Post Request optf-osdf ${restUrl} data=${data} headers=${headers} + Log To Console ********************* + Log To Console response = ${resp} + Log To Console body = ${resp.text} + [Return] ${resp} + +Http Put + [Documentation] Wrapper for Http PUT + [Arguments] ${host} ${restUrl} ${auth} ${data} + ${pci_auth}= Create List ${auth['username']} ${auth['password']} + Create Session optf-osdf ${host} headers=${headers} auth=${pci_auth} + ${resp}= Put Request optf-osdf ${restUrl} data=${data} headers=${headers} + Log To Console ********************* + Log To Console response = ${resp} + Log To Console body = ${resp.text} + [Return] ${resp} \ No newline at end of file -- cgit 1.2.3-korg