bd02e7ff93e4c33c4aebd16e7cda1b96c1984ba9
[integration/csit.git] / tests / dcaegen2-pmmapper / pmmapper / pmmapper.robot
1 *** Settings ***
2 Documentation     Testing PM Mapper functionality
3 Library           Collections
4 Library           OperatingSystem
5 Library           RequestsLibrary
6 Library           Process
7 Library           String
8
9 Test Setup        Create Session  mapper_session  ${PMMAPPER_BASE_URL}
10 Test Teardown     CleanSessionsAndLogs
11
12 *** Variables ***
13 ${CLI_EXEC_CLI_CONFIG}                   { head -n 100 | tail -50;} < /tmp/pmmapper.log
14 ${CLI_EXEC_CLI_SUBS}                     curl -k https://${DR_PROV_IP}:8443/internal/prov
15 ${PMMAPPER_BASE_URL}                     http://${PMMAPPER_IP}:8081
16 ${DELIVERY_ENDPOINT}                     /delivery
17 ${HEALTHCHECK_ENDPOINT}                  /healthcheck
18 ${RECONFIGURE_ENDPOINT}                  /reconfigure
19 ${NO_MANAGED_ELEMENT_PATH}               %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/A_no_managed_element.xml
20 ${NO_MEASDATA_PATH}                      %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/A_no_measdata.xml
21 ${VALID_METADATA_PATH}                   %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/valid_metadata.json
22 ${NR_VALID_METADATA_PATH}                %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/new_radio/valid_metadata.json
23 ${DIFF_VENDOR_METADATA}                  %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/diff_vendor_metadata.json
24 ${NON_XML_FILE}                          %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/diff_vendor_metadata.json
25 ${CLI_EXEC_CLI_PM_LOG}                   docker exec pmmapper /bin/sh -c "cat /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log"
26 ${CLI_EXEC_CLI_PM_LOG_CLEAR}             docker exec pmmapper /bin/sh -c "echo -n "" > /var/log/ONAP/dcaegen2/services/pm-mapper/pm-mapper_output.log"
27 ${PUBLISH_NODE_URL}                      https://${DR_NODE_IP}:8443/publish/1
28 ${TYPE-A_PM_DATA_FILE_PATH}              %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/A20181002.0000-1000-0015-1000_5G.xml
29 ${TYPE-C_PM_DATA_FILE_PATH}              %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/C20190328.0000-0015.xml
30 ${NR-TYPE-A_PM_DATA_FILE_PATH}           %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/new_radio/A20181004.0000-1000-0015-1000_5G.xml
31 ${NR-TYPE-C_PM_DATA_FILE_PATH}           %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/new_radio/C20190329.0000-0015.xml
32 ${NR-TYPE-PM_DATA_FILE_PATH}             %{WORKSPACE}/tests/dcaegen2-pmmapper/pmmapper/assets/new_radio/PM202007171301+020024C202007171207+0200-1215+0200_45678.xml
33 ${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
34 ${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
35 ${CLI_EXEC_PM_FILTER_regex}              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_regex_config.json
36 ${CLI_MESSAGE_ROUTER_TOPIC}              curl http://${DMAAP_MR_IP}:3904/events/PM_MAPPER/CG1/C1?timeout=1000 > /tmp/mr.log
37 ${CLI_MR_LOG}                            cat /tmp/mr.log
38
39
40 *** Test Cases ***
41 Verify PM Mapper Receive Configuraton From Config Binding Service
42     [Tags]                          PM_MAPPER_01
43     [Documentation]                 Verify 3gpp pm mapper successfully receive config data from CBS
44     CheckLog                        ${CLI_EXEC_CLI_CONFIG}           Received pm-mapper configuration from ConfigBinding Service
45
46 Verify Health Check returns 200 when a REST GET request to healthcheck url
47     [Tags]                          PM_MAPPER_02
48     [Documentation]                 Verify Health Check returns 200 when a REST GET request to healthcheck url
49     [Timeout]                       1 minute
50     ${resp}=                        Get Request                      mapper_session  ${HEALTHCHECK_ENDPOINT}
51     VerifyResponse                  ${resp.status_code}              200
52
53 Verify 3GPP PM Mapper responds appropriately when no metadata is provided
54     [Tags]                          PM_MAPPER_03
55     [Documentation]                 Verify 3GPP PM Mapper responds 400 with the message "Missing Metadata." when no metadata is provided
56     [Timeout]                       1 minute
57     ${headers}=                     Create Dictionary               X-ONAP-RequestID=3  Content-Type=application/xml
58     ${resp}=                        Put Request                     mapper_session  ${DELIVERY_ENDPOINT}/filename    data='${EMPTY}'    headers=${headers}
59     VerifyResponse                  ${resp.status_code}             400
60     VerifyResponse                  ${resp.content}                 Missing Metadata.
61     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}          RequestID=3
62
63 Verify 3GPP PM Mapper responds appropriately when invalid metadata is provided
64     [Tags]                          PM_MAPPER_04
65     [Documentation]                 Verify 3GPP PM Mapper responds 400 with the message "Malformed Metadata." when invalid metadata is provided
66     [Timeout]                       1 minute
67     ${headers}=                     Create Dictionary               X-ONAP-RequestID=4  X-DMAAP-DR-META='not metadata'  Content-Type=application/xml
68     ${resp}=                        Put Request                     mapper_session  ${DELIVERY_ENDPOINT}/filename  data='${EMPTY}'  headers=${headers}
69     VerifyResponse                  ${resp.status_code}             400
70     VerifyResponse                  ${resp.content}                 Malformed Metadata.
71     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}          RequestID=4
72
73 Verify that PM Mapper logs successful when a file that contains no measdata is provided
74     [Tags]                          PM_MAPPER_05
75     [Documentation]                 Verify that PM Mapper logs successful when a file that contains no measdata is provided
76     [Timeout]                       1 minute
77     SendToDatarouter                ${NO_MEASDATA_PATH}              ${VALID_METADATA_PATH}            X-ONAP-RequestID=5
78     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}           MeasData is empty
79     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}           RequestID=5
80
81 Verify that PM Mapper throws Event failed validation against schema error when no managed element content is provided
82     [Tags]                          PM_MAPPER_06
83     [Documentation]                 Verify 3gpp pm mapper responds with an error when no managed element content is provided
84     [Timeout]                       1 minute
85     SendToDatarouter                ${NO_MANAGED_ELEMENT_PATH}       ${VALID_METADATA_PATH}             X-ONAP-RequestID=6
86     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}           XML validation failed
87     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}           RequestID=6
88
89 Verify that PM Mapper maps Type-C xml file and publish 3gpp perf VES evnets to message router
90     [Tags]                          PM_MAPPER_07
91     [Documentation]                 Verify that PM Mapper maps Type-C xml file and publish 3gpp perf VES evnets to message router.
92     [Timeout]                       1 minute
93     SendToDatarouter                ${TYPE-C_PM_DATA_FILE_PATH}      ${VALID_METADATA_PATH}           X-ONAP-RequestID=7
94     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}           Successfully published VES events to messagerouter
95
96 Verify 3GPP PM Mapper maps Type-A file based on counter filtering and publish 3gpp perf VES evnets to message router
97     [Tags]                          PM_MAPPER_08
98     [Documentation]                 Verify 3GPP PM Mapper maps Type-A file and publish 3gpp perf VES evnets to message router.
99     [Timeout]                       1 minute
100     ${cli_cmd_output}=              Run Process                      ${CLI_EXEC_PM_FILTER}             shell=yes
101     ${resp}=                        Get Request                      mapper_session                    ${RECONFIGURE_ENDPOINT}
102     Sleep                           5s
103     SendToDatarouter                ${TYPE-A_PM_DATA_FILE_PATH}      ${VALID_METADATA_PATH}            X-ONAP-RequestID=8
104     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}           Successfully published VES events to messagerouter
105
106 Verify that PM Mapper correctly identifies a file that should not be mapped based on metadata filtering.
107     [Tags]                          PM_MAPPER_09
108     [Documentation]                 Verify that PM Mapper correctly identifies a file that should not be mapped based on metadata filtering.
109     [Timeout]                       1 minute
110     ${cli_cmd_output}=              Run Process                      ${CLI_EXEC_VENDOR_FILTER}         shell=yes
111     Should Be Equal As Strings      ${cli_cmd_output.rc}             0
112     ${resp}=                        Get Request                      mapper_session                    ${RECONFIGURE_ENDPOINT}
113     Sleep                           5s
114     SendToDatarouter                ${TYPE-A_PM_DATA_FILE_PATH}      ${DIFF_VENDOR_METADATA}           X-ONAP-RequestID=9
115     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}           RequestID=9
116     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}           Metadata does not match any filters
117
118 Verify that PM Mapper correctly identifies a non-xml file.
119     [Tags]                          PM_MAPPER_10
120     [Documentation]                 Verify that PM Mapper correctly identifies a non-xml file.
121     [Timeout]                       1 minute
122     SendToDatarouter                ${NON_XML_FILE}                  ${VALID_METADATA_PATH}             X-ONAP-RequestID=10
123     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}           PM measurement file must have an extension of .xml
124     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}           RequestID=10
125
126 Verify that PM Mapper correctly maps an NR Type-A file based on counter filtering and publish 3gpp perf VES events to message router.
127     [Tags]                          PM_MAPPER_11
128     [Documentation]                 Verify 3GPP PM Mapper maps an NR Type-A file and publish 3gpp perf VES evnets to message router.
129     [Timeout]                       1 minute
130     ${cli_cmd_output}=              Run Process                      ${CLI_EXEC_PM_FILTER}             shell=yes
131     ${resp}=                        Get Request                      mapper_session                    ${RECONFIGURE_ENDPOINT}
132     Sleep                           5s
133     SendToDatarouter                ${NR-TYPE-A_PM_DATA_FILE_PATH}   ${NR_VALID_METADATA_PATH}            X-ONAP-RequestID=11
134     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}           Successfully published VES events to messagerouter
135
136 Verify that PM Mapper correctly maps an NR Type-C file based on counter filtering and publish 3gpp perf VES events to message router.
137     [Tags]                          PM_MAPPER_12
138     [Documentation]                 Verify that PM Mapper maps an NR Type-C xml file and publish 3gpp perf VES evnets to message router.
139     [Timeout]                       1 minute
140     SendToDatarouter                ${NR-TYPE-C_PM_DATA_FILE_PATH}    ${NR_VALID_METADATA_PATH}           X-ONAP-RequestID=12
141     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}            Successfully published VES events to messagerouter
142
143 Verify 3GPP PM Mapper maps Type-A file based on counter filtering with regexp
144     [Tags]                          PM_MAPPER_13
145     [Documentation]                 Verify 3GPP PM Mapper maps Type-A file based on counter filtering with wildcards/regexp and publish 3gpp perf VES evnets to message router.
146     [Timeout]                       1 minute
147     ${cli_cmd_output}=              Run Process                      ${CLI_EXEC_PM_FILTER_regex}             shell=yes
148     ${resp}=                        Get Request                      mapper_session                    ${RECONFIGURE_ENDPOINT}
149     Sleep                           5s
150     SendToDatarouter                ${TYPE-A_PM_DATA_FILE_PATH}      ${VALID_METADATA_PATH}            X-ONAP-RequestID=13
151     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}           Successfully published VES events to messagerouter
152
153 Verify that password receive from CBS are successfully encrypted
154     [Tags]                          PM_MAPPER_14
155     [Documentation]                 Verify that password receive from CBS are successfully encrypted.
156     CheckLog                        ${CLI_EXEC_CLI_CONFIG}           "aaf_password": *****
157     CheckLog                        ${CLI_EXEC_CLI_CONFIG}           "password": *****
158
159 Verify that PM Mapper correctly maps an NR Type-PM file based on counter filtering and publish 3gpp perf VES events to message router.
160     [Tags]                          PM_MAPPER_15
161     [Documentation]                 Verify that PM Mapper maps an NR Type-PM xml file and publish 3gpp perf VES evnets to message router.
162     [Timeout]                       1 minute
163     SendToDatarouter                ${NR-TYPE-PM_DATA_FILE_PATH}      ${NR_VALID_METADATA_PATH}           X-ONAP-RequestID=15
164     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}            RequestID=15
165     CheckLog                        ${CLI_EXEC_CLI_PM_LOG}            Successfully published VES events to messagerouter
166
167 *** Keywords ***
168
169 SendToDatarouter
170     [Arguments]                     ${filepath}                      ${metadatapath}            ${request_id}
171     ${pmdata}=                      Get File                         ${filepath}
172     ${metatdata}                    Get File                         ${metadatapath}
173     ${filename}                     Fetch From Right                 ${filepath}                /
174     ${resp}=                        PutCall                          ${PUBLISH_NODE_URL}/${filename}        ${request_id}    ${pmdata}    ${metatdata.replace("\n","")}    pmmapper
175     VerifyResponse                  ${resp.status_code}              204
176     Sleep                           10s
177
178 PutCall
179     [Arguments]                     ${url}                           ${request_id}              ${data}            ${meta}          ${user}
180     ${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=
181     ${resp}=                        Evaluate                         requests.put('${url}', data="""${data}""", headers=${headers}, verify=False, allow_redirects=False)    requests
182     [Return]                        ${resp}
183
184 CheckLog
185     [Arguments]                     ${cli_exec_log_Path}             ${string_to_check_in_log}
186     ${cli_cmd_output}=              Run Process                      ${cli_exec_log_Path}                     shell=yes
187     Log                             ${cli_cmd_output.stdout}
188     Should Be Equal As Strings      ${cli_cmd_output.rc}             0
189     Should Contain                  ${cli_cmd_output.stdout}         ${string_to_check_in_log}
190
191 VerifyResponse
192     [Arguments]                     ${actual_response_value}         ${expected_response_value}
193     Should Be Equal As Strings      ${actual_response_value}         ${expected_response_value}
194
195 ClearLogs
196     Run Process                     ${CLI_EXEC_CLI_PM_LOG_CLEAR}                     shell=yes
197
198 CleanSessionsAndLogs
199     Delete All Sessions
200     ClearLogs