blob: 11b19b785ee5d7d92b3b157573b3057e7e605448 [file] [log] [blame]
Lasse Kaihlavirtaa3f68d12021-05-21 12:59:08 +03001*** Settings ***
2Documentation Testing PM Mapper functionality
3Library Collections
4Library OperatingSystem
5Library RequestsLibrary
6Library Process
7Library String
8Library libraries/DockerContainerManager.py
9Library libraries/LogReader.py
10
11*** Variables ***
12
13${ASSETS_PATH} %{WORKSPACE}/tests/filesprocessingconfigpmmapper/assets
14${NR_VALID_METADATA_PATH} ${ASSETS_PATH}/valid_metadata.json
15${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"
16${PUBLISH_NODE_URL} https://${DR_NODE_IP}:8443/publish/1
17${CLI_EXEC_LOGS_LIST} docker exec datarouter-node /bin/sh -c "ls /opt/app/datartr/logs"
Remigiusz Janeczek6ddc3102021-05-26 17:58:44 +020018${DOCKER_CLIENT_IMAGE} onap/org.onap.dcaegen2.services.pm-mapper:latest
Lasse Kaihlavirtaa3f68d12021-05-21 12:59:08 +030019${CLIENT_CONTAINER_NAME} pmmapper
20${FILE_PATH} ${ASSETS_PATH}/ABigFile.xml
21${CONFIG_ENVS_1_1} ${ASSETS_PATH}/config_1_1.env
22${CONFIG_ENVS_4_1} ${ASSETS_PATH}/config_4_1.env
23${CONFIG_ENVS_10_1} ${ASSETS_PATH}/config_10_1.env
24${CONFIG_ENVS_1_10} ${ASSETS_PATH}/config_1_10.env
25
26*** Test Cases ***
27
28Verify that PM Mapper rejects 6-9 messages when limitRate is 1 and threads count is 1
29 [Tags] FILES_PROCESSING_CONFIG_PM_MAPPER_1
30 [Documentation] Verify that PM Mapper rejects 6-9/10 messages. Configuration: limitRate=1, threadsCount=1
31 [Timeout] 15 minute
32
33 RestartPmmapper ${CONFIG_ENVS_1_1}
34
35 ${testname}= Set Variable Afirst-
36
37 SendFilesToDatarouter ${testname}
38 ${alllogs}= GetLogsOutput
39 ${filtered_logs}= GetFilteredLogs ${alllogs} ${testname}
40 ${dropped_nr}= GetDroppedNumber ${filtered_logs}
Joanna Jeremicz4ec32432022-01-31 13:03:27 +010041 ${received_nr}= GetReceivedNumber ${filtered_logs}
Lasse Kaihlavirtaa3f68d12021-05-21 12:59:08 +030042
43 Sleep 40s
44 ${isCorrectDroppedCount}= Evaluate ${5} < ${dropped_nr} < ${10}
Joanna Jeremicz4ec32432022-01-31 13:03:27 +010045 ${isCorrectReceivedCount}= Evaluate ${0} < ${received_nr} < ${5}
Lasse Kaihlavirtaa3f68d12021-05-21 12:59:08 +030046 SavePmMapperLogsAndDroppedCount config_1_1 ${dropped_nr}
47 Should Be True ${isCorrectDroppedCount} Pm-mapper drop: ${dropped_nr} messages. Expected drop count: 6-9
Joanna Jeremicz4ec32432022-01-31 13:03:27 +010048 Should Be True ${isCorrectReceivedCount} Pm-mapper received ${received_nr} messages. Expected received count: 1-4
Lasse Kaihlavirtaa3f68d12021-05-21 12:59:08 +030049 ClearLogs
50
51Verify that PM Mapper rejects 0 messages when limitRate is 10 and threads count is 1
52 [Tags] FILES_PROCESSING_CONFIG_PM_MAPPER_2
53 [Documentation] Verify that PM Mapper rejects 0/10 messages. Configuration: limitRate=10, threadsCount=1
54 [Timeout] 25 minute
55
56 RestartPmmapper ${CONFIG_ENVS_10_1}
57
58 ${testname}= Set Variable Athird-
59
60 SendFilesToDatarouter ${testname}
61 ${alllogs}= GetLogsOutput
62 ${filtered_logs}= GetFilteredLogs ${alllogs} ${testname}
63 ${dropped_nr}= GetDroppedNumber ${filtered_logs}
Joanna Jeremicz4ec32432022-01-31 13:03:27 +010064 ${received_nr}= GetReceivedNumber ${filtered_logs}
Lasse Kaihlavirtaa3f68d12021-05-21 12:59:08 +030065
66 Sleep 15s
67 SavePmMapperLogsAndDroppedCount config_10_1 ${dropped_nr}
68 Should Be Equal As Numbers ${dropped_nr} 0 Pm-mapper drop: ${dropped_nr} messages. Expected drop count: 0
Joanna Jeremicz4ec32432022-01-31 13:03:27 +010069 Should Be Equal As Numbers ${received_nr} 10 Pm-mapper received ${received_nr} messages. Expected received count: 10
Lasse Kaihlavirtaa3f68d12021-05-21 12:59:08 +030070 ClearLogs
71
72Verify that PM Mapper rejects 0 messages when limitRate is 1 and threads count is 10
73 [Tags] FILES_PROCESSING_CONFIG_PM_MAPPER_3
74 [Documentation] Verify that PM Mapper rejects 0/10 messages. Configuration: limitRate=1, threadsCount=10
75 [Timeout] 25 minute
76
77 RestartPmmapper ${CONFIG_ENVS_1_10}
78
79 ${testname}= Set Variable Afourth-
80
81 SendFilesToDatarouter ${testname}
82 ${alllogs}= GetLogsOutput
83 ${filtered_logs}= GetFilteredLogs ${alllogs} ${testname}
84 ${dropped_nr}= GetDroppedNumber ${filtered_logs}
Joanna Jeremicz4ec32432022-01-31 13:03:27 +010085 ${received_nr}= GetReceivedNumber ${filtered_logs}
Lasse Kaihlavirtaa3f68d12021-05-21 12:59:08 +030086
87 Sleep 15s
88 SavePmMapperLogsAndDroppedCount config_1_10 ${dropped_nr}
89 Should Be Equal As Numbers ${dropped_nr} 0 Pm-mapper drop: ${dropped_nr} messages. Expected drop count: 0
Joanna Jeremicz4ec32432022-01-31 13:03:27 +010090 Should Be Equal As Numbers ${received_nr} 10 Pm-mapper received ${received_nr} messages. Expected received count: 10
Lasse Kaihlavirtaa3f68d12021-05-21 12:59:08 +030091 ClearLogs
92
93*** Keywords ***
94
95SendFilesToDatarouter
96 [Arguments] ${testnr}
97 FOR ${i} IN RANGE 10
98 SendToDatarouter ${FILE_PATH} ${NR_VALID_METADATA_PATH} X-ONAP-RequestID=${i} ${testnr} ${i}
99 END
100 Sleep 20s
101
102SendToDatarouter
103 [Arguments] ${filepath} ${metadatapath} ${request_id} ${testnr} ${i}
104 ${pmdata}= Get File ${filepath}
105 ${metatdata} Get File ${metadatapath}
106 ${newFilename} Catenate SEPARATOR= ${testnr} ${i} .xml
107 ${resp}= PutCall ${PUBLISH_NODE_URL}/${newFilename} ${request_id} ${pmdata} ${metatdata.replace("\n","")} pmmapper
108 VerifyResponse ${resp.status_code} 204
109
110PutCall
111 [Arguments] ${url} ${request_id} ${data} ${meta} ${user}
112 ${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=
113 ${resp}= Evaluate requests.put('${url}', data="""${data}""", headers=${headers}, verify=False, allow_redirects=False) requests
114 [Return] ${resp}
115
116VerifyResponse
117 [Arguments] ${actual_response_value} ${expected_response_value}
118 Should Be Equal As Strings ${actual_response_value} ${expected_response_value}
119
120ClearLogs
121 Run Process ${CLI_EXEC_CLI_PM_LOG_CLEAR} shell=yes
122
123GetLogsOutput
124 ${filesString}= Run Process ${CLI_EXEC_LOGS_LIST} shell=yes
125 ${filesList}= Get Log Files List ${filesString.stdout}
126 ${output}= Set Variable ${EMPTY}
127 FOR ${file} IN @{filesList}
128 ${file_path}= Catenate SEPARATOR= "cat /opt/app/datartr/logs/ ${file} "
129 ${exec}= Catenate docker exec datarouter-node /bin/sh -c ${file_path}
130 ${single_file}= Run Process ${exec} shell=yes
131 ${output}= Catenate SEPARATOR=\n ${output} ${single_file.stdout}
Remigiusz Janeczek6ddc3102021-05-26 17:58:44 +0200132 Log ${output}
Lasse Kaihlavirtaa3f68d12021-05-21 12:59:08 +0300133 END
134 [Return] ${output}
135
136GetFilteredLogs
137 [Arguments] ${all_logs} ${testname}
138 ${filtered_logs}= Filter Unique ${all_logs} ${testname}
139 [Return] ${filtered_logs}
140
141GetDroppedNumber
142 [Arguments] ${logs_output}
Joanna Jeremicz4ec32432022-01-31 13:03:27 +0100143 ${number}= Get Number Of Element Occurrences In Logs ${logs_output} |429|
144 [Return] ${number}
145
146GetReceivedNumber
147 [Arguments] ${logs_output}
148 ${number}= Get Number Of Element Occurrences In Logs ${logs_output} |200|
Lasse Kaihlavirtaa3f68d12021-05-21 12:59:08 +0300149 [Return] ${number}
150
151RestartPmmapper
152 [Arguments] ${envs}
153 Remove Container ${CLIENT_CONTAINER_NAME}
154 Sleep 5s
155 Run Pmmapper Container ${DOCKER_CLIENT_IMAGE} ${CLIENT_CONTAINER_NAME} ${envs} ${DR_NODE_IP} ${NODE_IP}
156 Sleep 15s
157
158SavePmMapperLogsAndDroppedCount
159 [Arguments] ${test_name} ${dropped_count}
Joanna Jeremicz4ec32432022-01-31 13:03:27 +0100160 Run Process echo "Dropped: ${dropped_count}" > %{WORKSPACE}/archives/${test_name}_dropped_count.log shell=yes
161 Run Process docker logs ${CLIENT_CONTAINER_NAME} > %{WORKSPACE}/archives/${test_name}_pm_mapper_container_logs.log shell=yes
Lasse Kaihlavirtaa3f68d12021-05-21 12:59:08 +0300162