From: Gary Wu Date: Fri, 12 Apr 2019 15:54:32 +0000 (+0000) Subject: Merge "Attempt to check CSIT Consul and CBS discovery fix" X-Git-Tag: 4.0.0-ONAP~52 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=5124ab5b8dad3dff35da2ceec74ca0e2645117e6;hp=26125b14101098f87dfa5d8d0671cab00e8e27f5;p=integration%2Fcsit.git Merge "Attempt to check CSIT Consul and CBS discovery fix" --- diff --git a/plans/usecases/5G-bulkpm/assets/datafile_endpoints.json b/plans/usecases/5G-bulkpm/assets/datafile_endpoints.json index 2e2b67a8..d07e3d82 100644 --- a/plans/usecases/5G-bulkpm/assets/datafile_endpoints.json +++ b/plans/usecases/5G-bulkpm/assets/datafile_endpoints.json @@ -26,10 +26,10 @@ }, "ftp": { "ftpesConfiguration": { - "keyCert": "/config/ftpKey.jks", + "keyCert": "/config/dfc.jks", "keyPassword": "secret", - "trustedCA": "/config/ftpKey.jks", - "trustedCAPassword": "secret" + "trustedCa": "/config/ftp.jks", + "trustedCaPassword": "secret" } }, "security": { diff --git a/plans/usecases/5G-bulkpm/composefile/docker-compose-e2e.yml b/plans/usecases/5G-bulkpm/composefile/docker-compose-e2e.yml index 86c5fe3b..7880656b 100644 --- a/plans/usecases/5G-bulkpm/composefile/docker-compose-e2e.yml +++ b/plans/usecases/5G-bulkpm/composefile/docker-compose-e2e.yml @@ -22,6 +22,7 @@ services: retries: 5 extra_hosts: - "dmaap-dr-node:1.1.1.1" + - "dcae-pm-mapper:3.3.3.3" datarouter-node: image: nexus3.onap.org:10001/onap/dmaap/datarouter-node:2.1.0-SNAPSHOT-latest @@ -37,6 +38,7 @@ services: condition: service_healthy extra_hosts: - "dmaap-dr-prov:2.2.2.2" + - "dcae-pm-mapper:3.3.3.3" datarouter-subscriber: image: nexus3.onap.org:10001/onap/dmaap/datarouter-subscriber:2.1.0-SNAPSHOT-latest diff --git a/plans/usecases/5G-bulkpm/setup.sh b/plans/usecases/5G-bulkpm/setup.sh index 265ec96c..1bba4f30 100644 --- a/plans/usecases/5G-bulkpm/setup.sh +++ b/plans/usecases/5G-bulkpm/setup.sh @@ -70,8 +70,6 @@ cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/res mkdir docker-compose cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose cp $WORKSPACE/plans/usecases/5G-bulkpm/composefile/docker-compose-e2e.yml $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose/docker-compose.yml -cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/docker-databus-controller.conf /tmp/ -sed -i 's/DMAAPMR/'$DMAAP_MR_IP'/g' /tmp/docker-databus-controller.conf docker login -u docker -p docker nexus3.onap.org:10001 docker-compose up -d @@ -179,6 +177,7 @@ cp $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotification. sed -i 's/sftpserver/'${SFTP_IP}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json sed -i 's/sftpport/'${SFTP_PORT}'/g' $WORKSPACE/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotificationUpdated.json docker cp $WORKSPACE/plans/usecases/5G-bulkpm/assets/xNF.pm.xml.gz sftp:/home/admin/ +docker cp $WORKSPACE/tests/dcaegen2-pmmapper/pmmapper/assets/A20181002.0000-1000-0015-1000_5G.xml.gz sftp:/home/admin/ # Data Router Configuration: # Create default feed and create file consumer subscriber on data router @@ -205,15 +204,25 @@ sed -i 's/1.1.1.1/'$DR_NODE_IP'/g' docker-compose.yml sed -i 's/4.4.4.4/'$DMAAP_MR_IP'/g' docker-compose.yml docker-compose up -d +cd $WORKSPACE/archives/dmaapdr/datarouter/datarouter-docker-compose/src/main/resources/docker-compose +PMMAPPER_IP=$(docker inspect '--format={{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pmmapper) +docker kill datarouter-node +docker kill datarouter-prov +sed -i 's/1.1.1.1/'$DR_NODE_IP'/g' docker-compose.yml +sed -i 's/2.2.2.2/'$DR_PROV_IP'/g' docker-compose.yml +sed -i 's/3.3.3.3/'$PMMAPPER_IP'/g' docker-compose.yml +docker-compose up -d + # Setting up PM Mapper certs. docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/cert.jks.b64 pmmapper:opt/app/pm-mapper/etc/ docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/jks.pass pmmapper:opt/app/pm-mapper/etc/ docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/trust.jks.b64 pmmapper:opt/app/pm-mapper/etc/ docker cp $WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/trust.pass pmmapper:opt/app/pm-mapper/etc/ docker restart pmmapper +sleep 5 # Create PM Mapper feed and create PM Mapper subscriber on data router -curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" --data-ascii @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/createFeed.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443 +#curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" --data-ascii @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/createFeed.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443 curl -v -X POST -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:pmmapper" --data-ascii @$WORKSPACE/plans/dcaegen2-pmmapper/pmmapper/assets/addSubscriber.json --post301 --location-trusted -k https://${DR_PROV_IP}:8443/subscribe/1 # Create PM Mapper tocic in Message Router diff --git a/plans/usecases/5G-bulkpm/teardown.sh b/plans/usecases/5G-bulkpm/teardown.sh index 5b3d1710..782a289c 100644 --- a/plans/usecases/5G-bulkpm/teardown.sh +++ b/plans/usecases/5G-bulkpm/teardown.sh @@ -1,9 +1,15 @@ #!/bin/bash echo "Starting teardown script" docker exec dfc /bin/sh -c "less /var/log/ONAP/application.log" > /tmp/dfc_docker.log +echo "===== DFC LOG ========" cat /tmp/dfc_docker.log sleep 3 -rm /tmp/dfc_docker.log.robot +echo "===== PM MAPPER LOG ========" +cat /tmp/pmmapper_docker.log.robot +sleep 2 +echo "===== MR LOG ========" +cat /tmp/mr.log +sleep 2 kill-instance.sh $DMAAP kill-instance.sh $KAFKA kill-instance.sh $ZOOKEEPER diff --git a/scripts/clamp/clone_clamp_and_change_dockercompose.sh b/scripts/clamp/clone_clamp_and_change_dockercompose.sh index c807091e..5970ab2f 100755 --- a/scripts/clamp/clone_clamp_and_change_dockercompose.sh +++ b/scripts/clamp/clone_clamp_and_change_dockercompose.sh @@ -35,7 +35,7 @@ git clone --depth 1 http://gerrit.onap.org/r/clamp -b $GERRIT_BRANCH cd clamp/extra/docker/clamp/ # Pull the Clamp docker image from nexus instead of local image by default in the docker-compose.yml -sed -i '/image: onap\/clamp/c\ image: nexus3.onap.org:10001\/onap\/clamp' docker-compose.yml +sed -i '/image: onap\/clamp/c\ image: nexus3.onap.org:10001\/onap\/clamp:4.0-STAGING-latest' docker-compose.yml # Change config to take third_party_proxy:8085 for SDC, Policy and DCAE simulator sed -i 's/}/,\"clamp.config.policy.pdpUrl1\":\"http:\/\/third_party_proxy:8085\/pdp\/ , testpdp, alpha123\",\"clamp.config.policy.pdpUrl2\":\"http:\/\/third_party_proxy:8085\/pdp\/ , testpdp, alpha123\",\"clamp.config.policy.papUrl\":\"http:\/\/third_party_proxy:8085\/pap\/ , testpap, alpha123\",\"clamp.config.policy.clientId\":\"python\",\"clamp.config.policy.clientKey\":\"dGVzdA==\",\"clamp.config.sdc.catalog.url\":\"http:\/\/third_party_proxy:8085\/sdc\/v1\/catalog\/\",\"clamp.config.sdc.hostUrl\":\"http:\/\/third_party_proxy:8085\",\"clamp.config.sdc.serviceUrl\":\"http:\/\/third_party_proxy:8085\/sdc\/v1\/catalog\/services\",\"clamp.config.dcae.inventory.url\":\"http:\/\/third_party_proxy:8085\",\"clamp.config.dcae.dispatcher.url\":\"http:\/\/third_party_proxy:8085\",\"spring.profiles.active\":\"clamp-default,clamp-default-user,clamp-sdc-controller\",\"server.ssl.client-auth\":\"want\"}/g' clamp.env diff --git a/scripts/vid/start_vid_containers.sh b/scripts/vid/start_vid_containers.sh index c8804349..c1c09bcd 100644 --- a/scripts/vid/start_vid_containers.sh +++ b/scripts/vid/start_vid_containers.sh @@ -32,7 +32,7 @@ docker-compose up -d --build # WAIT 5 minutes maximum and test every 5 seconds if VID up using HealthCheck API -TIME_OUT=1200 +TIME_OUT=300 INTERVAL=5 TIME=0 diff --git a/tests/dcaegen2-pmmapper/pmmapper/assets/.gitattributes b/tests/dcaegen2-pmmapper/pmmapper/assets/.gitattributes new file mode 100644 index 00000000..57cdc503 --- /dev/null +++ b/tests/dcaegen2-pmmapper/pmmapper/assets/.gitattributes @@ -0,0 +1 @@ +*.gz binary diff --git a/tests/dcaegen2-pmmapper/pmmapper/assets/A20181002.0000-1000-0015-1000_5G.xml.gz b/tests/dcaegen2-pmmapper/pmmapper/assets/A20181002.0000-1000-0015-1000_5G.xml.gz new file mode 100644 index 00000000..32865fc1 Binary files /dev/null and b/tests/dcaegen2-pmmapper/pmmapper/assets/A20181002.0000-1000-0015-1000_5G.xml.gz differ diff --git a/tests/policy/suite1/Policy-CSIT.robot b/tests/policy/suite1/Policy-CSIT.robot index 7855b76b..514cc840 100644 --- a/tests/policy/suite1/Policy-CSIT.robot +++ b/tests/policy/suite1/Policy-CSIT.robot @@ -21,6 +21,8 @@ ${CREATE_OOF_HPA_TEMPLATE} ${CURDIR}/oofpolicy_HPA_R1.template ${CREATE_SDNC_VFW_TEMPLATE} ${CURDIR}/sdncnamingpolicy_vFW.template ${CREATE_SDNC_VPG_TEMPLATE} ${CURDIR}/sdncnamingpolicy_vPG.template ${PUSH_POLICY_TEMPLATE} ${CURDIR}/pushpolicy.template +${MULTIPLE_PUSH_POLICY_TEMPLATE} ${CURDIR}/multiple_pushpolicy.template +${MULTIPLE_UNPUSH_POLICY_TEMPLATE} ${CURDIR}/multiple_unpushpolicy.template ${CREATE_OPS_VDNS_TEMPLATE} ${CURDIR}/opspolicy_VDNS_R1.template ${DEL_POLICY_TEMPLATE} ${CURDIR}/deletepolicy.template ${GETCONFIG_TEMPLATE} ${CURDIR}/getconfigpolicy.template @@ -44,6 +46,9 @@ ${OOF_POLICY_HPA_NAME} HPA ${OOF_POLICY_HPA_TYPE} Optimization ${SDNC_POLICY_VFW_NAME} ONAP_vFW_Naming ${SDNC_POLICY_VPG_NAME} ONAP_vPG_Naming +${MULTIPLE_PUSH_POLICY_NAME1} com.testBase1 +${MULTIPLE_PUSH_POLICY_NAME2} com.testBase2 +${MULTIPLE_PUSH_POLICY_NAME3} com.testBase3 ${file_path} ../testsuite/robot/assets/templates/ControlLoopDemo__closedLoopControlName.drl ${RESOURCE_PATH_UPLOAD} /pdp/api/policyEngineImport?importParametersJson=%7B%22serviceName%22%3A%22Manyu456%22%2C%20%22serviceType%22%3A%22BRMSPARAM%22%7D ${CREATE_OPS_VCPE_TEMPLATE} ${CURDIR}/opspolicy_vCPE_R1.template @@ -120,6 +125,14 @@ HPA Get OOF Policy ListPolicy ListPolicy test com.Config_Sample.1.xml +Multiple Push Policy + ${MULTIPLE_PUSH_POLICY_NAME1}= Create Ops VDNS Policy + ${MULTIPLE_PUSH_POLICY_NAME2}= Create Ops VDNS Policy + ${MULTIPLE_PUSH_POLICY_NAME3}= Create Ops VDNS Policy + Push Multiple Policy test ${MULTIPLE_PUSH_POLICY_NAME1} ${MULTIPLE_PUSH_POLICY_NAME2} ${MULTIPLE_PUSH_POLICY_NAME3} ${OPS_POLICY_VDNS_TYPE} + Sleep 5s + Delete Multiple Policy test ${MULTIPLE_PUSH_POLICY_NAME1} ${MULTIPLE_PUSH_POLICY_NAME2} ${MULTIPLE_PUSH_POLICY_NAME3} ${OPS_POLICY_VDNS_TYPE} + *** Keywords *** VFW Policy Tests @@ -372,3 +385,19 @@ ListPolicy test ${put_resp} = policy_interface.Run Policy Post Request ${RESOURCE_PATH_LISTPOLICY} ${output} Should Be Equal As Strings ${put_resp.status_code} 200 +Push Multiple Policy test + [Documentation] Push Multiple Policy + [Arguments] ${policyname1} ${policyname2} ${policyname3} ${policytype} + ${dict}= Create Dictionary policy_name1=${policyname1} policy_name2=${policyname2} policy_name3=${policyname3} policy_type=${policytype} + ${output} = Fill JSON Template File ${MULTIPLE_PUSH_POLICY_TEMPLATE} ${dict} + ${put_resp} = Run Policy Put Request ${RESOURCE_PATH_CREATE_PUSH} ${output} + Should Be Equal As Strings ${put_resp.status_code} 200 + +Delete Multiple Policy test + [Documentation] Delete Multiple Policy + [Arguments] ${policyname1} ${policyname2} ${policyname3} ${policytype} + ${dict}= Create Dictionary policy_name1=${policyname1} policy_name2=${policyname2} policy_name3=${policyname3} policy_type=${policytype} + ${output} = Fill JSON Template File ${MULTIPLE_UNPUSH_POLICY_TEMPLATE} ${dict} + ${put_resp} = Run Policy Delete Request ${RESOURCE_PATH_CREATE_DELETE} ${output} + Should Be Equal As Strings ${put_resp.status_code} 200 + diff --git a/tests/policy/suite1/multiple_pushpolicy.template b/tests/policy/suite1/multiple_pushpolicy.template new file mode 100644 index 00000000..5f20b647 --- /dev/null +++ b/tests/policy/suite1/multiple_pushpolicy.template @@ -0,0 +1,5 @@ +{ + "policyName":"${policy_name1},${policy_name2},${policy_name3}", + "policyType":"${policy_type}", + "pdpGroup":"default" +} diff --git a/tests/policy/suite1/multiple_unpushpolicy.template b/tests/policy/suite1/multiple_unpushpolicy.template new file mode 100644 index 00000000..afee7aeb --- /dev/null +++ b/tests/policy/suite1/multiple_unpushpolicy.template @@ -0,0 +1,6 @@ +{ + "policyName": "${policy_name1},${policy_name2},${policy_name3}", + "policyType": "${policy_type}", + "policyComponent": "PDP", + "pdpGroup": "default" +} diff --git a/tests/usecases/5G-bulkpm/BulkpmE2E.robot b/tests/usecases/5G-bulkpm/BulkpmE2E.robot index dcf97210..84243cba 100644 --- a/tests/usecases/5G-bulkpm/BulkpmE2E.robot +++ b/tests/usecases/5G-bulkpm/BulkpmE2E.robot @@ -20,8 +20,12 @@ ${CLI_EXEC_CLI} curl -k https://${DR_PROV_IP}:8443/inte ${CLI_EXEC_CLI_FILECONSUMER} docker exec fileconsumer-node /bin/sh -c "ls /opt/app/subscriber/delivery | grep .xml" ${CLI_EXEC_CLI_DFC_LOG} docker exec dfc /bin/sh -c "cat /var/log/ONAP/application.log" > /tmp/dfc_docker.log.robot ${CLI_EXEC_CLI_DFC_LOG_GREP} grep "Publish to DR successful!" /tmp/dfc_docker.log.robot -${CLI_EXEC_CLI_FILECONSUMER_CP} docker cp fileconsumer-node:/opt/app/subscriber/delivery/xNF.pm.xml.M %{WORKSPACE} -${CLI_EXEC_RENAME_METADATA} mv %{WORKSPACE}/xNF.pm.xml.M %{WORKSPACE}/metadata.json +${CLI_EXEC_CLI_FILECONSUMER_CP} docker cp fileconsumer-node:/opt/app/subscriber/delivery/A20181002.0000-1000-0015-1000_5G.xml.M %{WORKSPACE} +${CLI_EXEC_RENAME_METADATA} mv %{WORKSPACE}/A20181002.0000-1000-0015-1000_5G.xml.M %{WORKSPACE}/metadata.json +${CLI_EXEC_CLI_PMMAPPER_LOG} docker exec pmmapper /bin/sh -c "cat /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log" > /tmp/pmmapper_docker.log.robot +${CLI_EXEC_CLI_PMMAPPER_LOG_GREP} grep "XML validation successful Event" /tmp/pmmapper_docker.log.robot +${CLI_EXEC_MR_PMMAPPER_TOPIC} curl http://${DMAAP_MR_IP}:3904/events/PM_MAPPER/CG1/C1?timeout=1000 > /tmp/mr.log +${CLI_EXEC_CLI_PMMAPPER_TOPIC_LOG_GREP} grep "perf3gpp_RnNode-Ericsson_pmMeasResult" /tmp/mr.log ${metadataSchemaPath} %{WORKSPACE}/tests/usecases/5G-bulkpm/assets/metadata.schema.json ${metadataJsonPath} %{WORKSPACE}/metadata.json @@ -86,7 +90,7 @@ Verify Fileconsumer Receive PM file from Data Router ${cli_cmd_output}= Run Process ${CLI_EXEC_CLI_FILECONSUMER} shell=yes Log ${cli_cmd_output.stdout} Should Be Equal As Strings ${cli_cmd_output.rc} 0 - Should Contain ${cli_cmd_output.stdout} xNF.pm.xml + Should Contain ${cli_cmd_output.stdout} A20181002.0000-1000-0015-1000_5G.xml Verify File Consumer Receive valid metadata from Data Router [Tags] Bulk_PM_E2E_06 @@ -94,8 +98,30 @@ Verify File Consumer Receive valid metadata from Data Router ${cli_cmd_output}= Run Process ${CLI_EXEC_CLI_FILECONSUMER} shell=yes Log ${cli_cmd_output.stdout} Should Be Equal As Strings ${cli_cmd_output.rc} 0 - Should Contain ${cli_cmd_output.stdout} xNF.pm.xml.M + Should Contain ${cli_cmd_output.stdout} A20181002.0000-1000-0015-1000_5G.xml.M ${cli_cmd_output}= Run Process ${CLI_EXEC_CLI_FILECONSUMER_CP} shell=yes ${cli_cmd_output}= Run Process ${CLI_EXEC_RENAME_METADATA} shell=yes ${validation_result}= Validate ${metadataSchemaPath} ${metadataJsonPath} - Should Be Equal As Strings ${validation_result} 0 \ No newline at end of file + Should Be Equal As Strings ${validation_result} 0 + +Verify PM-Mapper successfully receives uncompressed the PM XML file + [Tags] Bulk_PM_E2E_07 + [Documentation] Check that PM-Mapper receives the uncompressed PM XML file + ${cli_cmd_output}= Run Process ${CLI_EXEC_CLI_PMMAPPER_LOG} shell=yes + Log ${cli_cmd_output.stdout} + Should Be Equal As Strings ${cli_cmd_output.rc} 0 + ${cli_cmd_output}= Run Process ${CLI_EXEC_CLI_PMMAPPER_LOG_GREP} shell=yes + Log ${cli_cmd_output.stdout} + Should Be Equal As Strings ${cli_cmd_output.rc} 0 + Should Contain ${cli_cmd_output.stdout} XML validation successful Event + +Verify PM-Mapper successfully publishes PMMeasResult VES onto the Message Router Topic PM_MAPPER + [Tags] Bulk_PM_E2E_08 + [Documentation] Check that PM-Mapper publishes VES onto the Message Router + ${cli_cmd_output}= Run Process ${CLI_EXEC_MR_PMMAPPER_TOPIC} shell=yes + Log ${cli_cmd_output.stdout} + Should Be Equal As Strings ${cli_cmd_output.rc} 0 + ${cli_cmd_output}= Run Process ${CLI_EXEC_CLI_PMMAPPER_TOPIC_LOG_GREP} shell=yes + Log ${cli_cmd_output.stdout} + Should Be Equal As Strings ${cli_cmd_output.rc} 0 + Should Contain ${cli_cmd_output.stdout} perf3gpp_RnNode-Ericsson_pmMeasResult \ No newline at end of file diff --git a/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotification.json b/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotification.json index d5d8fd05..375dbd80 100644 --- a/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotification.json +++ b/tests/usecases/5G-bulkpm/assets/json_events/FileExistNotification.json @@ -19,9 +19,9 @@ "changeType": "FileReady", "notificationFieldsVersion": "2.0", "arrayOfNamedHashMap": [ - { "name": "xNF.pm.xml.gz", + { "name": "A20181002.0000-1000-0015-1000_5G.xml.gz", "hashMap":{ - "location": "sftp://admin:admin@sftpserver:sftpport/xNF.pm.xml.gz", + "location": "sftp://admin:admin@sftpserver:sftpport/A20181002.0000-1000-0015-1000_5G.xml.gz", "compression": "gzip", "fileFormatType": "org.3GPP.32.435#measCollec", "fileFormatVersion": "V10" diff --git a/tests/vid/resources/simulators/Dockerfile b/tests/vid/resources/simulators/Dockerfile index e6586b1e..de5b5fe8 100644 --- a/tests/vid/resources/simulators/Dockerfile +++ b/tests/vid/resources/simulators/Dockerfile @@ -5,8 +5,9 @@ ARG component ENV component=$component COPY SO.py / -ADD ./test_data_assets/ / +RUN mkdir test_data_assets +ADD ./test_data_assets/ /test_data_assets EXPOSE 8443 -CMD python ./SO.py expected_${component}_requests.json expected_${component}_responses.json +CMD python ./SO.py /test_data_assets/expected_${component}_requests.json /test_data_assets/expected_${component}_responses.json diff --git a/tests/vid/resources/simulators/SO.py b/tests/vid/resources/simulators/SO.py index fa481b38..12fd7763 100644 --- a/tests/vid/resources/simulators/SO.py +++ b/tests/vid/resources/simulators/SO.py @@ -26,10 +26,13 @@ DEFAULT_PORT = 8443 class SOHandler(BaseHTTPRequestHandler): - def __init__(self, expected_requests, expected_responses, *args, **kwargs): + def __init__(self, expected_requests, expected_responses, requests, responses, *args, **kwargs): self._expected_requests = expected_requests self._expected_responses = expected_responses + self._requests = requests["requests"] + self._responses = responses["responses"] + self._known_endpoints = self._get_known_endpoints() super().__init__(*args, **kwargs) def do_POST(self): @@ -44,15 +47,26 @@ class SOHandler(BaseHTTPRequestHandler): return def do_GET(self): - logging.info( - 'GET called. Expected GET REQUEST: ' + json.dumps( - self._expected_requests["get"]) + '\nExpected GET response: ' + - json.dumps(self._expected_responses["get"])) - self.send_response(200) - self._set_headers() - - self.wfile.write(json.dumps(self._expected_responses["get"]).encode("utf-8")) - return self._expected_responses["get"] + print(self._known_endpoints) + if self._does_path_exist_as_endpoint(): + expected_response = self._get_response_by_path() + if expected_response: + self.send_response(expected_response["responseCode"]) + self._set_headers() + self.wfile.write(json.dumps(expected_response["body"]).encode("utf-8")) + else: + response_body = "{\"message:\" \"no response for endpoint\"}" + self.send_response(400) + self._set_headers() + self.wfile.write(json.dumps(response_body).encode("utf-8")) + else: + logging.info('GET called. Expected GET REQUEST: ' + + json.dumps(self._expected_requests["get"]) + + '\nExpected GET response: ' + + json.dumps(self._expected_responses["get"])) + self.send_response(200) + self._set_headers() + self.wfile.write(json.dumps(self._expected_responses["get"]).encode("utf-8")) def do_PUT(self): request_body_json = self._get_request_body() @@ -80,9 +94,7 @@ class SOHandler(BaseHTTPRequestHandler): def _apply_expected_data(self, request_body_json): if self.path == '/setResponse': logging.info("IN PUT /setResponse: " + str(request_body_json)) - print("TYPE: %s and text: %s", type(request_body_json), str(request_body_json)) self._expected_responses.update(request_body_json) - print("TYPE: %s", type(request_body_json)) elif self.path == '/setRequest': logging.info("IN PUT /setRequest: " + str(request_body_json)) self._expected_requests.update(request_body_json) @@ -91,6 +103,37 @@ class SOHandler(BaseHTTPRequestHandler): self.send_header('Content-Type', 'application/json') self.end_headers() + def _get_response_by_path(self): + for response in self._responses: + if response["path"] == self.path: + return response + + def _does_path_exist_as_endpoint(self): + does_exist = False + for ep in self._known_endpoints: + if ep == self.path: + does_exist = True + break + return does_exist + + def _create_path_from_request(self, request): + base_uri = request["path"] + query_params = request["queryParams"] + return base_uri + self._get_params_uri(query_params) + + def _get_known_endpoints(self): + endpoints = [] + for request in self._requests: + endpoints.append(self._create_path_from_request(request)) + return endpoints + + @staticmethod + def _get_params_uri(query_params): + params_uri = "?" + for parameter in query_params: + params_uri += parameter + '=' + query_params.get(parameter, '') + '&' + return params_uri[:-1] + class JsonFileToDictReader(object): @@ -101,10 +144,13 @@ class JsonFileToDictReader(object): def init_so_simulator(): + requests = JsonFileToDictReader.read_expected_test_data("test_data_assets/requests.json") + responses = JsonFileToDictReader.read_expected_test_data("test_data_assets/responses.json") + expected_so_requests = JsonFileToDictReader.read_expected_test_data(argv[1]) expected_so_responses = JsonFileToDictReader.read_expected_test_data(argv[2]) logging.basicConfig(level=logging.INFO) - handler = partial(SOHandler, expected_so_requests, expected_so_responses) + handler = partial(SOHandler, expected_so_requests, expected_so_responses, requests, responses) handler.protocol_version = "HTTP/1.0" httpd = HTTPServer(('', DEFAULT_PORT), handler) logging.info("serving on: " + str(httpd.socket.getsockname())) diff --git a/tests/vid/resources/simulators/test_data_assets/endpoint_not_found.json b/tests/vid/resources/simulators/test_data_assets/endpoint_not_found.json new file mode 100644 index 00000000..3419e15c --- /dev/null +++ b/tests/vid/resources/simulators/test_data_assets/endpoint_not_found.json @@ -0,0 +1,4 @@ +{ + "responseCode": 404, + "message": "invalid endpoint" +} \ No newline at end of file diff --git a/tests/vid/resources/simulators/test_data_assets/requests.json b/tests/vid/resources/simulators/test_data_assets/requests.json new file mode 100644 index 00000000..e94d26a6 --- /dev/null +++ b/tests/vid/resources/simulators/test_data_assets/requests.json @@ -0,0 +1,33 @@ +{ + "requests": [ + { + "method": "GET", + "path": "/aai/v13/service-design-and-creation/models", + "queryParams": { + "depth": "2", + "model-invariant-id": "88a71d72-ec80-4357-808e-f288823cb353" + } + }, + { + "method": "GET", + "path": "/aai/v../business/customers/customer/MSO_1610_ST", + "queryParams": { + "depth": "2" + } + }, + { + "method": "GET", + "path": "/aai/v13/query", + "queryParams": { + "format": "simple" + } + }, + { + "method": "GET", + "path": "/workflowSpecifications/v1/workflows", + "queryParams": { + "vnfModelVersionId": "103b4a1b-4a15-4559-a019-1ff132180c7c" + } + } + ] +} \ No newline at end of file diff --git a/tests/vid/resources/simulators/test_data_assets/responses.json b/tests/vid/resources/simulators/test_data_assets/responses.json new file mode 100644 index 00000000..fb862e15 --- /dev/null +++ b/tests/vid/resources/simulators/test_data_assets/responses.json @@ -0,0 +1,220 @@ +{ + "responses": [ + { + "responseCode": 200, + "path": "/aai/v13/service-design-and-creation/models?depth=2&model-invariant-id=88a71d72-ec80-4357-808e-f288823cb353", + "body": { + "model": [ + { + "model-invariant-id": "88a71d72-ec80-4357-808e-f288823cb353", + "model-type": "resource", + "resource-version": "1549550682576", + "model-vers": { + "model-ver": [ + { + "model-version-id": "d2dcf256-2687-4631-9e36-1b7fc352b7bf", + "model-name": "HealthVF", + "model-version": "1.0", + "model-description": "HealthVSP", + "resource-version": "1549550682585", + "model-elements": { + "model-element": [ + { + "model-element-uuid": "ad8c74b6-d2ff-48a7-8fcb-4cf653efc1f9", + "new-data-del-flag": "T", + "cardinality": "unbounded", + "resource-version": "1549550682592", + "relationship-list": { + "relationship": [ + { + "related-to": "model-ver", + "relationship-label": "org.onap.relationships.inventory.IsA", + "related-link": "/aai/v13/service-design-and-creation/models/model/acc6edd8-a8d4-4b93-afaa-0994068be14c/model-vers/model-ver/93a6166f-b3d5-4f06-b4ba-aed48d009ad9", + "relationship-data": [ + { + "relationship-key": "model.model-invariant-id", + "relationship-value": "acc6edd8-a8d4-4b93-afaa-0994068be14c" + } + ], + "related-to-property": [ + { + "property-key": "model-ver.model-name", + "property-value": "generic-vnf" + } + ] + } + ] + } + } + ] + }, + "relationship-list": { + "relationship": [ + { + "related-to": "model-element", + "relationship-label": "org.onap.relationships.inventory.IsA", + "related-link": "/aai/v13/service-design-and-creation/models/model/4b5158b9-a0d5-4aeb-90a8-474bc2ccd8af/model-vers/model-ver/ba463093-6f2c-4d22-aa8d-fb4615660db2/model-elements/model-element/57d23b71-d5a0-484d-ac7c-1b94e9a1563e/model-elements/model-element/5d290a6a-3b35-46bb-a2d7-1b9c9f520c39", + "relationship-data": [ + { + "relationship-key": "model.model-invariant-id", + "relationship-value": "4b5158b9-a0d5-4aeb-90a8-474bc2ccd8af" + } + ] + } + ] + } + } + ] + } + } + ] + } + }, + { + "responseCode": 200, + "path": "/aai/v../business/customers/customer/MSO_1610_ST?depth=2", + "body": { + "global-customer-id": "MSO_1610_ST", + "subscriber-name": "MSO_1610_ST", + "subscriber-type": "INFRA", + "resource-version": "1549008901724", + "service-subscriptions": { + "service-subscription": [ + { + "service-type": "gNB", + "resource-version": "1549008901954", + "service-instances": { + "service-instance": [ + { + "service-instance-id": "40003c27-2876-4f3a-8a23-ef1ad7ef665a", + "service-instance-name": "AwServicePreload3", + "service-type": "vAwServiceType", + "environment-context": "General_Revenue-Bearing", + "workload-context": "Production", + "model-invariant-id": "33ebe1a9-1df3-4c35-b8a0-cd0504159511", + "model-version-id": "41658d87-b37c-4237-9a56-d27d1e430da6", + "resource-version": "1550761112266", + "orchestration-status": "Active", + "relationship-list": { + "relationship": [ + { + "related-to": "project", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v13/business/projects/project/AwTestProject", + "relationship-data": [ + { + "relationship-key": "project.project-name", + "relationship-value": "AwTestProject" + } + ] + } + ] + } + } + ] + }, + "relationship-list": { + "relationship": [ + { + "related-to": "tenant", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/982c540f6e69488eb6be5664255e00c0", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "CloudOwner" + } + ], + "related-to-property": [ + { + "property-key": "tenant.tenant-name", + "property-value": "onap-wro" + } + ] + } + ] + } + } + ] + } + } + }, + { + "responseCode": 200, + "path": "/aai/v13/query?format=simple", + "body": { + "results": [ + { + "id": "385160", + "node-type": "service-instance", + "url": "/aai/v13/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vLB/service-instances/service-instance/12965035-a690-400c-bf18-211a5b4710c8", + "properties": { + "service-instance-id": "12965035-a690-400c-bf18-211a5b4710c8", + "service-instance-name": "ws-service-02", + "service-type": "vAwServiceType", + "environment-context": "General_Revenue-Bearing", + "workload-context": "Production", + "model-invariant-id": "33ebe1a9-1df3-4c35-b8a0-cd0504159511", + "model-version-id": "cb8501da-6e03-40e0-900c-ef0df30d1183", + "resource-version": "1551434658559", + "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/12965035-a690-400c-bf18-211a5b4710c8/service-data/service-topology/", + "orchestration-status": "Active" + }, + "related-to": [ + { + "id": "200768", + "relationship-label": "org.onap.relationships.inventory.Uses", + "node-type": "project", + "url": "/aai/v13/business/projects/project/Project-Demonstration" + } + ] + } + ] + } + }, + { + "responseCode": 200, + "path": "/workflowSpecifications/v1/workflows?vnfModelVersionId=103b4a1b-4a15-4559-a019-1ff132180c7c", + "body": { + "workflowSpecificationList": [ + { + "workflowSpecification": { + "artifactInfo": { + "artifactType": "workflow", + "artifactUuid": "ab6478e4-ea33-3346-ac12-ab121484a333", + "artifactName": "inPlaceSoftwareUpdate-1_0.bpmn", + "artifactVersion": "1.0", + "artifactDescription": "xyz xyz", + "workflowName": "inPlaceSoftwareUpdate", + "operationName": "inPlaceSoftwareUpdate", + "workflowSource": "sdc", + "workflowResourceTarget": "vnf" + }, + "activitySequence": [ + { + "name": "VNFQuiesceTrafficActivity", + "description": "Activity to QuiesceTraffic on VNF" + } + ], + "workflowInputParameters": [ + { + "label": "Cloud Owner", + "inputType": "text", + "required": true, + "validation": [ + { + "maxLength": "7", + "allowableChars": "[a-zA-Z0-9]*" + } + ], + "soFieldName": "cloudOwner", + "soPayloadLocation": "cloudConfiguration" + } + ] + } + } + ] + } + } + ] +} \ No newline at end of file