blob: a9474672549acc71fd60fb34c3cd4610b0f1e3c4 [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
7
JoeOLeary4ec2b9d2019-02-25 10:14:53 +00008Test Setup Create Session mapper_session ${PMMAPPER_BASE_URL}
9Test Teardown Delete All Sessions
10
rajendrajaiswal47b64d72019-02-06 16:09:24 +000011
12*** Variables ***
rajendrajaiswal7f7dab02019-02-15 10:23:53 +000013${CLI_EXEC_CLI_CONFIG} { head -n 5 | tail -1;} < /tmp/pmmapper.log
rajendrajaiswal140bfd22019-02-14 14:47:15 +000014${CLI_EXEC_CLI_SUBS} curl -k https://${DR_PROV_IP}:8443/internal/prov
JoeOLeary4ec2b9d2019-02-25 10:14:53 +000015${PMMAPPER_BASE_URL} http://${PMMAPPER_IP}:8081
16${DELIVERY_ENDPOINT} /delivery
Gerard Hickey0e009032019-03-05 15:45:31 +000017${HEALTHCHECK_ENDPOINT} /healthcheck
18${NO_MANAGED_ELEMENT_PATH} %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/no_managed_element.xml
19${NO_MEASDATA_PATH} %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/no_measdata.xml
20${MEASD_RESULT_PATH} %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/meas_result.xml
21${VALID_METADATA_PATH} %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/valid_metadata.json
Gerard Hickey80f8f462019-03-14 12:41:05 +000022${DIFF_VENDOR_METADATA} %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/diff_vendor_metadata.json
Gerard Hickey0e009032019-03-05 15:45:31 +000023${CLI_EXEC_CLI_PM_LOG} docker exec pmmapper /bin/sh -c "tail -5 /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log"
rajendrajaiswal84f3d0c2019-03-06 11:47:06 +000024${PUBLISH_NODE_URL} https://${DR_NODE_IP}:8443/publish/1/pm.xml
rajendrajaiswal86cccfe2019-03-08 10:40:12 +000025${PM_DATA_FILE_PATH} %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/A20181002.0000-1000-0015-1000_5G.xml
rajendrajaiswal84f3d0c2019-03-06 11:47:06 +000026${PUBLISH_CONTENT_TYPE} application/octet-stream
27
rajendrajaiswal47b64d72019-02-06 16:09:24 +000028
29*** Test Cases ***
30
rajendrajaiswal140bfd22019-02-14 14:47:15 +000031Verify PM Mapper Receive Configuraton From Config Binding Service
rajendrajaiswal47b64d72019-02-06 16:09:24 +000032 [Tags] PM_MAPPER_01
rajendrajaiswal140bfd22019-02-14 14:47:15 +000033 [Documentation] Verify 3gpp pm mapper successfully receive config data from CBS
Gerard Hickeybf1ee242019-03-12 11:34:51 +000034 CheckLog ${CLI_EXEC_CLI_CONFIG} Received pm-mapper configuration
rajendrajaiswal140bfd22019-02-14 14:47:15 +000035
36Verify 3GPP PM Mapper Subscribes to Data Router
37 [Tags] PM_MAPPER_02
rajendrajaiswala1574702019-02-14 10:29:45 +000038 [Documentation] Verify 3gpp pm mapper subscribes to data router
Gerard Hickeybf1ee242019-03-12 11:34:51 +000039 CheckLog ${CLI_EXEC_CLI_SUBS} 3gpppmmapper
Gerard Hickey21d9ecb2019-03-12 15:00:50 +000040 CheckLog ${CLI_EXEC_CLI_SUBS} "privilegedSubscriber":true
41
rajendrajaiswal8f0afd82019-02-11 12:30:26 +000042
Gerard Hickey0e009032019-03-05 15:45:31 +000043Verify Health Check returns 200 when a REST GET request to healthcheck url
44 [Tags] PM_MAPPER_03
45 [Documentation] Verify Health Check returns 200 when a REST GET request to healthcheck url
46 [Timeout] 1 minute
47 ${resp}= Get Request mapper_session ${HEALTHCHECK_ENDPOINT}
Gerard Hickeybf1ee242019-03-12 11:34:51 +000048 VerifyResponse ${resp.status_code} 200
Gerard Hickey0e009032019-03-05 15:45:31 +000049
JoeOLeary4ec2b9d2019-02-25 10:14:53 +000050Verify 3GPP PM Mapper responds appropriately when no metadata is provided
rajendrajaiswal7572f8d2019-03-07 14:28:47 +000051 [Tags] PM_MAPPER_04
JoeOLeary4ec2b9d2019-02-25 10:14:53 +000052 [Documentation] Verify 3GPP PM Mapper responds 400 with the message "Missing Metadata." when no metadata is provided
53 [Timeout] 1 minute
54 ${headers}= Create Dictionary X-ONAP-RequestID=1 Content-Type=application/xml
JoeOLeary667bd592019-03-05 09:21:26 +000055 ${resp}= Put Request mapper_session ${DELIVERY_ENDPOINT}/filename data='${EMPTY}' headers=${headers}
Gerard Hickeybf1ee242019-03-12 11:34:51 +000056 VerifyResponse ${resp.status_code} 400
57 VerifyResponse ${resp.content} Missing Metadata.
58 CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=1
JoeOLeary4ec2b9d2019-02-25 10:14:53 +000059
60Verify 3GPP PM Mapper responds appropriately when invalid metadata is provided
rajendrajaiswal7572f8d2019-03-07 14:28:47 +000061 [Tags] PM_MAPPER_05
JoeOLeary4ec2b9d2019-02-25 10:14:53 +000062 [Documentation] Verify 3GPP PM Mapper responds 400 with the message "Malformed Metadata." when invalid metadata is provided
63 [Timeout] 1 minute
rajendrajaiswal7572f8d2019-03-07 14:28:47 +000064 ${headers}= Create Dictionary X-ONAP-RequestID=2 X-DMAAP-DR-META='not metadata' Content-Type=application/xml
JoeOLeary667bd592019-03-05 09:21:26 +000065 ${resp}= Put Request mapper_session ${DELIVERY_ENDPOINT}/filename data='${EMPTY}' headers=${headers}
Gerard Hickeybf1ee242019-03-12 11:34:51 +000066 VerifyResponse ${resp.status_code} 400
67 VerifyResponse ${resp.content} Malformed Metadata.
68 CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=2
JoeOLeary4ec2b9d2019-02-25 10:14:53 +000069
rajendrajaiswal84f3d0c2019-03-06 11:47:06 +000070Verify 3GPP PM Mapper received pushed PM data from Data Router
rajendrajaiswal7572f8d2019-03-07 14:28:47 +000071 [Tags] PM_MAPPER_06
rajendrajaiswal84f3d0c2019-03-06 11:47:06 +000072 [Documentation] Verify 3GPP PM Mapper received pushed PM data from Data Router
73 [Timeout] 1 minute
74 ${PM_DATA}= Get File ${PM_DATA_FILE_PATH}
75 ${valid_metatdata} Get File ${VALID_METADATA_PATH}
rajendrajaiswal7572f8d2019-03-07 14:28:47 +000076 ${resp}= PutCall ${PUBLISH_NODE_URL} 3 ${PM_DATA} ${PUBLISH_CONTENT_TYPE} ${valid_metatdata.replace("\n","")} pmmapper
Gerard Hickeybf1ee242019-03-12 11:34:51 +000077 VerifyResponse ${resp.status_code} 204
rajendrajaiswal84f3d0c2019-03-06 11:47:06 +000078 Sleep 10s
Gerard Hickeybf1ee242019-03-12 11:34:51 +000079 CheckLog ${CLI_EXEC_CLI_PM_LOG} XML validation successful
80 CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=3
Gerard Hickey0e009032019-03-05 15:45:31 +000081
Gerard Hickey0e009032019-03-05 15:45:31 +000082Verify that PM Mapper logs successful when a file that contains measdata is provided
rajendrajaiswal7572f8d2019-03-07 14:28:47 +000083 [Tags] PM_MAPPER_07
Gerard Hickey0e009032019-03-05 15:45:31 +000084 [Documentation] Verify that PM Mapper logs successful when a file that contains measdata is provided
85 [Timeout] 1 minute
86 ${valid_meas_result_content}= Get File ${MEASD_RESULT_PATH}
87 ${valid_metatdata} Get File ${VALID_METADATA_PATH}
88 ${headers}= Create Dictionary X-ONAP-RequestID=4 Content-Type=application/xml X-DMAAP-DR-PUBLISH-ID=4 X-DMAAP-DR-META=${valid_metatdata.replace("\n","")}
89 ${resp}= Put Request mapper_session ${DELIVERY_ENDPOINT}/filename data=${valid_meas_result_content} headers=${headers}
Gerard Hickeybf1ee242019-03-12 11:34:51 +000090 VerifyResponse ${resp.status_code} 200
91 CheckLog ${CLI_EXEC_CLI_PM_LOG} XML validation successful
92 CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=4
Gerard Hickey0e009032019-03-05 15:45:31 +000093
rajendrajaiswal7572f8d2019-03-07 14:28:47 +000094Verify that PM Mapper logs successful when a file that contains no measdata is provided
95 [Tags] PM_MAPPER_08
96 [Documentation] Verify that PM Mapper logs successful when a file that contains no measdata is provided
97 [Timeout] 1 minute
98 ${valid_no_measdata_content}= Get File ${NO_MEASDATA_PATH}
99 ${valid_metatdata} Get File ${VALID_METADATA_PATH}
100 ${headers}= Create Dictionary X-ONAP-RequestID=5 Content-Type=application/xml X-DMAAP-DR-PUBLISH-ID=3 X-DMAAP-DR-META=${valid_metatdata.replace("\n","")}
101 ${resp}= Put Request mapper_session ${DELIVERY_ENDPOINT}/filename data=${valid_no_measdata_content} headers=${headers}
Gerard Hickeybf1ee242019-03-12 11:34:51 +0000102 VerifyResponse ${resp.status_code} 200
103 CheckLog ${CLI_EXEC_CLI_PM_LOG} XML validation successful
104 CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=5
rajendrajaiswal7572f8d2019-03-07 14:28:47 +0000105
106Verify that PM Mapper throws Event failed validation against schema error when no managed element content is provided
107 [Tags] PM_MAPPER_09
108 [Documentation] Verify 3gpp pm mapper responds with an error when no managed element content is provided
109 [Timeout] 1 minute
110 ${no_managed_element_content}= Get File ${NO_MANAGED_ELEMENT_PATH}
111 ${valid_metatdata} Get File ${VALID_METADATA_PATH}
112 ${headers}= Create Dictionary X-ONAP-RequestID=6 Content-Type=application/xml X-DMAAP-DR-PUBLISH-ID=2 X-DMAAP-DR-META=${valid_metatdata.replace("\n","")}
113 ${resp}= Put Request mapper_session ${DELIVERY_ENDPOINT}/filename data=${no_managed_element_content} headers=${headers}
Gerard Hickeybf1ee242019-03-12 11:34:51 +0000114 VerifyResponse ${resp.status_code} 200
115 CheckLog ${CLI_EXEC_CLI_PM_LOG} XML validation failed
116 CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=6
Gerard Hickey0e009032019-03-05 15:45:31 +0000117
Gerard Hickey80f8f462019-03-14 12:41:05 +0000118Verify that PM Mapper correctly identifies a file that should not be mapped based on metadata filtering.
119 [Tags] PM_MAPPER_10
120 [Documentation] Verify that PM Mapper correctly identifies a file that should not be mapped based on metadata filtering.
121 [Timeout] 1 minute
122 ${valid_meas_result_content}= Get File ${MEASD_RESULT_PATH}
123 ${diff_vendor_metadata}= Get File ${DIFF_VENDOR_METADATA}
124 ${headers}= Create Dictionary X-ONAP-RequestID=7 Content-Type=application/xml X-DMAAP-DR-PUBLISH-ID=2 X-DMAAP-DR-META=${diff_vendor_metadata.replace("\n","")}
125 ${resp}= Put Request mapper_session ${DELIVERY_ENDPOINT}/filename data=${valid_meas_result_content} headers=${headers}
126 CheckLog ${CLI_EXEC_CLI_PM_LOG} Metadata does not match any filters,
127 CheckLog ${CLI_EXEC_CLI_PM_LOG} RequestID=7
128
129
Gerard Hickey0e009032019-03-05 15:45:31 +0000130
rajendrajaiswal8f0afd82019-02-11 12:30:26 +0000131*** Keywords ***
132
133PostCall
134 [Arguments] ${url} ${data}
135 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
136 ${resp}= Evaluate requests.post('${url}',data='${data}', headers=${headers},verify=False) requests
Gerard Hickey0e009032019-03-05 15:45:31 +0000137 [Return] ${resp}
rajendrajaiswal84f3d0c2019-03-06 11:47:06 +0000138
139PutCall
rajendrajaiswal7572f8d2019-03-07 14:28:47 +0000140 [Arguments] ${url} ${request_id} ${data} ${content_type} ${meta} ${user}
141 ${headers}= Create Dictionary X-ONAP-RequestID=${request_id} X-DMAAP-DR-META=${meta} Content-Type=${content_type} X-DMAAP-DR-ON-BEHALF-OF=${user} Authorization=Basic cG1tYXBwZXI6cG1tYXBwZXI=
rajendrajaiswal84f3d0c2019-03-06 11:47:06 +0000142 ${resp}= Evaluate requests.put('${url}', data="""${data}""", headers=${headers}, verify=False, allow_redirects=False) requests
143 [Return] ${resp}
Gerard Hickeybf1ee242019-03-12 11:34:51 +0000144
145
146CheckLog
147 [Arguments] ${cli_exec_log_Path} ${string_to_check_in_log}
148 ${cli_cmd_output}= Run Process ${cli_exec_log_Path} shell=yes
149 Log ${cli_cmd_output.stdout}
150 Should Be Equal As Strings ${cli_cmd_output.rc} 0
151 Should Contain ${cli_cmd_output.stdout} ${string_to_check_in_log}
152
153VerifyResponse
154 [Arguments] ${actual_response_value} ${expected_response_value}
155 Should Be Equal As Strings ${actual_response_value} ${expected_response_value}