blob: 9bba481758e24fbd67c940c4ab1364a3fc304e44 [file] [log] [blame]
rajendrajaiswal47b64d72019-02-06 16:09:24 +00001*** Settings ***
2Documentation Testing PM Mapper functionality
rajendrajaiswal47b64d72019-02-06 16:09:24 +00003Library Collections
rajendrajaiswal8f0afd82019-02-11 12:30:26 +00004Library OperatingSystem
5Library RequestsLibrary
rajendrajaiswal47b64d72019-02-06 16:09:24 +00006Library Process
rajendrajaiswal37452e42019-04-02 08:40:58 +00007Library String
rajendrajaiswal47b64d72019-02-06 16:09:24 +00008
JoeOLeary4ec2b9d2019-02-25 10:14:53 +00009Test Setup Create Session mapper_session ${PMMAPPER_BASE_URL}
10Test Teardown Delete All Sessions
11
rajendrajaiswal47b64d72019-02-06 16:09:24 +000012
13*** Variables ***
rajendrajaiswal37452e42019-04-02 08:40:58 +000014${CLI_EXEC_CLI_CONFIG} { head -n 6 | tail -2;} < /tmp/pmmapper.log
rajendrajaiswal140bfd22019-02-14 14:47:15 +000015${CLI_EXEC_CLI_SUBS} curl -k https://${DR_PROV_IP}:8443/internal/prov
JoeOLeary4ec2b9d2019-02-25 10:14:53 +000016${PMMAPPER_BASE_URL} http://${PMMAPPER_IP}:8081
17${DELIVERY_ENDPOINT} /delivery
Gerard Hickey0e009032019-03-05 15:45:31 +000018${HEALTHCHECK_ENDPOINT} /healthcheck
rajendrajaiswal37452e42019-04-02 08:40:58 +000019${RECONFIGURE_ENDPOINT} /reconfigure
rajendrajaiswalb60c9ee2019-03-15 12:31:17 +000020${NO_MANAGED_ELEMENT_PATH} %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/A_no_managed_element.xml
21${NO_MEASDATA_PATH} %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/A_no_measdata.xml
Gerard Hickey0e009032019-03-05 15:45:31 +000022${VALID_METADATA_PATH} %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/valid_metadata.json
Gerard Hickey80f8f462019-03-14 12:41:05 +000023${DIFF_VENDOR_METADATA} %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/diff_vendor_metadata.json
Gerard Hickey67739262019-04-09 13:35:14 +000024${NON_XML_FILE} %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/diff_vendor_metadata.json
rajendrajaiswal3b202f02019-04-09 10:37:49 +000025${CLI_EXEC_CLI_PM_LOG} docker exec pmmapper /bin/sh -c "tail -15 /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log"
rajendrajaiswal37452e42019-04-02 08:40:58 +000026${PUBLISH_NODE_URL} https://${DR_NODE_IP}:8443/publish/1
27${TYPE-A_PM_DATA_FILE_PATH} %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/A20181002.0000-1000-0015-1000_5G.xml
28${TYPE-C_PM_DATA_FILE_PATH} %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/C20190328.0000-0015.xml
rajendrajaiswal84f3d0c2019-03-06 11:47:06 +000029${PUBLISH_CONTENT_TYPE} application/octet-stream
rajendrajaiswalb60c9ee2019-03-15 12:31:17 +000030${CLI_EXEC_VENDOR_FILTER} curl 'http://${CONSUL_IP}:8500/v1/kv/pmmapper?dc=dc1' -X PUT -H 'Accept: application/^Con' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data @$WORKSPACE/tests/dcaegen2-pmmapper/pmmapper/assets/vendor_filter_config.json
31${CLI_EXEC_PM_FILTER} curl 'http://${CONSUL_IP}:8500/v1/kv/pmmapper?dc=dc1' -X PUT -H 'Accept: application/^Con' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' --data @$WORKSPACE/tests/dcaegen2-pmmapper/pmmapper/assets/pm_filter_config.json
32${CLI_RESTART_PMMAPPER} docker restart pmmapper
33${CLI_DELETE_SUB1} curl -i -X DELETE -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:DGL" -k https://localhost:8443/subs/1
34${CLI_DELETE_SUB2} curl -i -X DELETE -H "Content-Type:application/vnd.dmaap-dr.subscription" -H "X-DMAAP-DR-ON-BEHALF-OF:DGL" -k https://localhost:8443/subs/2
rajendrajaiswal37452e42019-04-02 08:40:58 +000035${CLI_MESSAGE_ROUTER_TOPIC} curl http://${DMAAP_MR_IP}:3904/events/PM_MAPPER/CG1/C1?timeout=1000
36${CLI_MR_EVENT_COUNT} curl http://${DMAAP_MR_IP}:3904/events/PM_MAPPER/CG1/C1?timeout=1000 | egrep -o 'measInfoId1|measInfoId2|measInfoId3' > /tmp/mr.log
37${CLI_MR_LOG} cat /tmp/mr.log
rajendrajaiswal47b64d72019-02-06 16:09:24 +000038
39*** Test Cases ***
rajendrajaiswal140bfd22019-02-14 14:47:15 +000040Verify PM Mapper Receive Configuraton From Config Binding Service
rajendrajaiswal47b64d72019-02-06 16:09:24 +000041 [Tags] PM_MAPPER_01
rajendrajaiswal140bfd22019-02-14 14:47:15 +000042 [Documentation] Verify 3gpp pm mapper successfully receive config data from CBS
Gerard Hickeybf1ee242019-03-12 11:34:51 +000043 CheckLog ${CLI_EXEC_CLI_CONFIG} Received pm-mapper configuration
rajendrajaiswal140bfd22019-02-14 14:47:15 +000044
Gerard Hickey0e009032019-03-05 15:45:31 +000045Verify Health Check returns 200 when a REST GET request to healthcheck url
rajendrajaiswal37452e42019-04-02 08:40:58 +000046 [Tags] PM_MAPPER_02
Gerard Hickey0e009032019-03-05 15:45:31 +000047 [Documentation] Verify Health Check returns 200 when a REST GET request to healthcheck url
48 [Timeout] 1 minute
49 ${resp}= Get Request mapper_session ${HEALTHCHECK_ENDPOINT}
Gerard Hickeybf1ee242019-03-12 11:34:51 +000050 VerifyResponse ${resp.status_code} 200
Gerard Hickey0e009032019-03-05 15:45:31 +000051
JoeOLeary4ec2b9d2019-02-25 10:14:53 +000052Verify 3GPP PM Mapper responds appropriately when no metadata is provided
rajendrajaiswal37452e42019-04-02 08:40:58 +000053 [Tags] PM_MAPPER_03
JoeOLeary4ec2b9d2019-02-25 10:14:53 +000054 [Documentation] Verify 3GPP PM Mapper responds 400 with the message "Missing Metadata." when no metadata is provided
55 [Timeout] 1 minute
56 ${headers}= Create Dictionary X-ONAP-RequestID=1 Content-Type=application/xml
JoeOLeary667bd592019-03-05 09:21:26 +000057 ${resp}= Put Request mapper_session ${DELIVERY_ENDPOINT}/filename data='${EMPTY}' headers=${headers}
Gerard Hickeybf1ee242019-03-12 11:34:51 +000058 VerifyResponse ${resp.status_code} 400
59 VerifyResponse ${resp.content} Missing Metadata.
60 CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=1
JoeOLeary4ec2b9d2019-02-25 10:14:53 +000061
62Verify 3GPP PM Mapper responds appropriately when invalid metadata is provided
rajendrajaiswal37452e42019-04-02 08:40:58 +000063 [Tags] PM_MAPPER_04
JoeOLeary4ec2b9d2019-02-25 10:14:53 +000064 [Documentation] Verify 3GPP PM Mapper responds 400 with the message "Malformed Metadata." when invalid metadata is provided
65 [Timeout] 1 minute
rajendrajaiswal7572f8d2019-03-07 14:28:47 +000066 ${headers}= Create Dictionary X-ONAP-RequestID=2 X-DMAAP-DR-META='not metadata' Content-Type=application/xml
JoeOLeary667bd592019-03-05 09:21:26 +000067 ${resp}= Put Request mapper_session ${DELIVERY_ENDPOINT}/filename data='${EMPTY}' headers=${headers}
Gerard Hickeybf1ee242019-03-12 11:34:51 +000068 VerifyResponse ${resp.status_code} 400
69 VerifyResponse ${resp.content} Malformed Metadata.
70 CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=2
JoeOLeary4ec2b9d2019-02-25 10:14:53 +000071
rajendrajaiswal37452e42019-04-02 08:40:58 +000072Verify 3GPP PM Mapper maps Type-A file and publish 3gpp perf VES evnets to message router
73 [Tags] PM_MAPPER_05
74 [Documentation] Verify 3GPP PM Mapper maps Type-A file and publish 3gpp perf VES evnets to message router.
rajendrajaiswal84f3d0c2019-03-06 11:47:06 +000075 [Timeout] 1 minute
rajendrajaiswal37452e42019-04-02 08:40:58 +000076 SendToDatarouter ${TYPE-A_PM_DATA_FILE_PATH} ${VALID_METADATA_PATH} X-ONAP-RequestID=3
rajendrajaiswal59a78502019-03-21 16:31:19 +000077 CheckLog ${CLI_EXEC_CLI_PM_LOG} Successfully published VES events to messagerouter
Gerard Hickeybf1ee242019-03-12 11:34:51 +000078 CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=3
rajendrajaiswal59a78502019-03-21 16:31:19 +000079 Sleep 10s
80 CheckLog ${CLI_MESSAGE_ROUTER_TOPIC} perf3gpp_gnb-Ericsson_pmMeasResult
Gerard Hickey0e009032019-03-05 15:45:31 +000081
rajendrajaiswal37452e42019-04-02 08:40:58 +000082Verify that PM Mapper maps Type-C xml file and publish 3gpp perf VES evnets to message router.
83 [Tags] PM_MAPPER_06
84 [Documentation] Verify that PM Mapper maps Type-C xml file and publish 3gpp perf VES evnets to message router.
85 [Timeout] 1 minute
86 SendToDatarouter ${TYPE-C_PM_DATA_FILE_PATH} ${VALID_METADATA_PATH} X-ONAP-RequestID=4
87 CheckLog ${CLI_EXEC_CLI_PM_LOG} Successfully published VES events to messagerouter
88 CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=4
89 Run Process ${CLI_MR_EVENT_COUNT} shell=yes
90 CheckLog ${CLI_MR_LOG} measInfoId1
91 CheckLog ${CLI_MR_LOG} measInfoId2
92 CheckLog ${CLI_MR_LOG} measInfoId3
93
rajendrajaiswal7572f8d2019-03-07 14:28:47 +000094Verify that PM Mapper logs successful when a file that contains no measdata is provided
rajendrajaiswal59a78502019-03-21 16:31:19 +000095 [Tags] PM_MAPPER_07
rajendrajaiswal7572f8d2019-03-07 14:28:47 +000096 [Documentation] Verify that PM Mapper logs successful when a file that contains no measdata is provided
97 [Timeout] 1 minute
rajendrajaiswal37452e42019-04-02 08:40:58 +000098 SendToDatarouter ${NO_MEASDATA_PATH} ${VALID_METADATA_PATH} X-ONAP-RequestID=5
rajendrajaiswal59a78502019-03-21 16:31:19 +000099 CheckLog ${CLI_EXEC_CLI_PM_LOG} MeasData is empty
rajendrajaiswal37452e42019-04-02 08:40:58 +0000100 CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=5
rajendrajaiswal7572f8d2019-03-07 14:28:47 +0000101
102Verify that PM Mapper throws Event failed validation against schema error when no managed element content is provided
rajendrajaiswal59a78502019-03-21 16:31:19 +0000103 [Tags] PM_MAPPER_08
rajendrajaiswal7572f8d2019-03-07 14:28:47 +0000104 [Documentation] Verify 3gpp pm mapper responds with an error when no managed element content is provided
105 [Timeout] 1 minute
rajendrajaiswal37452e42019-04-02 08:40:58 +0000106 SendToDatarouter ${NO_MANAGED_ELEMENT_PATH} ${VALID_METADATA_PATH} X-ONAP-RequestID=6
Gerard Hickeybf1ee242019-03-12 11:34:51 +0000107 CheckLog ${CLI_EXEC_CLI_PM_LOG} XML validation failed
rajendrajaiswal37452e42019-04-02 08:40:58 +0000108 CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=6
Gerard Hickey0e009032019-03-05 15:45:31 +0000109
Gerard Hickey80f8f462019-03-14 12:41:05 +0000110Verify that PM Mapper correctly identifies a file that should not be mapped based on metadata filtering.
rajendrajaiswal59a78502019-03-21 16:31:19 +0000111 [Tags] PM_MAPPER_09
Gerard Hickey80f8f462019-03-14 12:41:05 +0000112 [Documentation] Verify that PM Mapper correctly identifies a file that should not be mapped based on metadata filtering.
113 [Timeout] 1 minute
rajendrajaiswal37452e42019-04-02 08:40:58 +0000114 ${cli_cmd_output}= Run Process ${CLI_EXEC_VENDOR_FILTER} shell=yes
rajendrajaiswalb60c9ee2019-03-15 12:31:17 +0000115 Should Be Equal As Strings ${cli_cmd_output.rc} 0
rajendrajaiswal37452e42019-04-02 08:40:58 +0000116 ${resp}= Get Request mapper_session ${RECONFIGURE_ENDPOINT}
117 Sleep 5s
118 SendToDatarouter ${TYPE-A_PM_DATA_FILE_PATH} ${DIFF_VENDOR_METADATA} X-ONAP-RequestID=7
119 CheckLog ${CLI_EXEC_CLI_PM_LOG} Metadata does not match any filters
120 CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=7
Gerard Hickey80f8f462019-03-14 12:41:05 +0000121
Gerard Hickey67739262019-04-09 13:35:14 +0000122Verify that PM Mapper correctly identifies a non-xml file.
123 [Tags] PM_MAPPER_10
124 [Documentation] Verify that PM Mapper correctly identifies a non-xml file.
125 [Timeout] 1 minute
126 SendToDatarouter ${NON_XML_FILE} ${VALID_METADATA_PATH} X-ONAP-RequestID=8
127 CheckLog ${CLI_EXEC_CLI_PM_LOG} PM measurement file type not supported
128 CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=8
129
130
rajendrajaiswal8f0afd82019-02-11 12:30:26 +0000131*** Keywords ***
132
rajendrajaiswal37452e42019-04-02 08:40:58 +0000133SendToDatarouter
134 [Arguments] ${filepath} ${metadatapath} ${request_id}
135 ${pmdata}= Get File ${filepath}
136 ${metatdata} Get File ${metadatapath}
137 ${filename} Fetch From Right ${filepath} /
138 ${resp}= PutCall ${PUBLISH_NODE_URL}/${filename} ${request_id} ${pmdata} ${metatdata.replace("\n","")} pmmapper
139 VerifyResponse ${resp.status_code} 204
140 Sleep 10s
rajendrajaiswal84f3d0c2019-03-06 11:47:06 +0000141
142PutCall
rajendrajaiswal37452e42019-04-02 08:40:58 +0000143 [Arguments] ${url} ${request_id} ${data} ${meta} ${user}
144 ${headers}= Create Dictionary X-ONAP-RequestID=${request_id} X-DMAAP-DR-META=${meta} Content-Type=application/octet-stream X-DMAAP-DR-ON-BEHALF-OF=${user} Authorization=Basic cG1tYXBwZXI6cG1tYXBwZXI=
145 ${resp}= Evaluate requests.put('${url}', data="""${data}""", headers=${headers}, verify=False, allow_redirects=False) requests
146 [Return] ${resp}
Gerard Hickeybf1ee242019-03-12 11:34:51 +0000147
Gerard Hickeybf1ee242019-03-12 11:34:51 +0000148CheckLog
rajendrajaiswal37452e42019-04-02 08:40:58 +0000149 [Arguments] ${cli_exec_log_Path} ${string_to_check_in_log}
Gerard Hickeybf1ee242019-03-12 11:34:51 +0000150 ${cli_cmd_output}= Run Process ${cli_exec_log_Path} shell=yes
151 Log ${cli_cmd_output.stdout}
152 Should Be Equal As Strings ${cli_cmd_output.rc} 0
153 Should Contain ${cli_cmd_output.stdout} ${string_to_check_in_log}
154
155VerifyResponse
156 [Arguments] ${actual_response_value} ${expected_response_value}
157 Should Be Equal As Strings ${actual_response_value} ${expected_response_value}