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