Lasse Kaihlavirta | a3f68d1 | 2021-05-21 12:59:08 +0300 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Testing PM Mapper functionality |
| 3 | Library Collections |
| 4 | Library OperatingSystem |
| 5 | Library RequestsLibrary |
| 6 | Library Process |
| 7 | Library String |
| 8 | Library libraries/DockerContainerManager.py |
| 9 | Library 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 Janeczek | 6ddc310 | 2021-05-26 17:58:44 +0200 | [diff] [blame] | 18 | ${DOCKER_CLIENT_IMAGE} onap/org.onap.dcaegen2.services.pm-mapper:latest |
Lasse Kaihlavirta | a3f68d1 | 2021-05-21 12:59:08 +0300 | [diff] [blame] | 19 | ${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 | |
| 28 | Verify 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 Jeremicz | 4ec3243 | 2022-01-31 13:03:27 +0100 | [diff] [blame] | 41 | ${received_nr}= GetReceivedNumber ${filtered_logs} |
Lasse Kaihlavirta | a3f68d1 | 2021-05-21 12:59:08 +0300 | [diff] [blame] | 42 | |
| 43 | Sleep 40s |
| 44 | ${isCorrectDroppedCount}= Evaluate ${5} < ${dropped_nr} < ${10} |
Joanna Jeremicz | 4ec3243 | 2022-01-31 13:03:27 +0100 | [diff] [blame] | 45 | ${isCorrectReceivedCount}= Evaluate ${0} < ${received_nr} < ${5} |
Lasse Kaihlavirta | a3f68d1 | 2021-05-21 12:59:08 +0300 | [diff] [blame] | 46 | SavePmMapperLogsAndDroppedCount config_1_1 ${dropped_nr} |
| 47 | Should Be True ${isCorrectDroppedCount} Pm-mapper drop: ${dropped_nr} messages. Expected drop count: 6-9 |
Joanna Jeremicz | 4ec3243 | 2022-01-31 13:03:27 +0100 | [diff] [blame] | 48 | Should Be True ${isCorrectReceivedCount} Pm-mapper received ${received_nr} messages. Expected received count: 1-4 |
Lasse Kaihlavirta | a3f68d1 | 2021-05-21 12:59:08 +0300 | [diff] [blame] | 49 | ClearLogs |
| 50 | |
| 51 | Verify 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 Jeremicz | 4ec3243 | 2022-01-31 13:03:27 +0100 | [diff] [blame] | 64 | ${received_nr}= GetReceivedNumber ${filtered_logs} |
Lasse Kaihlavirta | a3f68d1 | 2021-05-21 12:59:08 +0300 | [diff] [blame] | 65 | |
| 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 Jeremicz | 4ec3243 | 2022-01-31 13:03:27 +0100 | [diff] [blame] | 69 | Should Be Equal As Numbers ${received_nr} 10 Pm-mapper received ${received_nr} messages. Expected received count: 10 |
Lasse Kaihlavirta | a3f68d1 | 2021-05-21 12:59:08 +0300 | [diff] [blame] | 70 | ClearLogs |
| 71 | |
| 72 | Verify 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 Jeremicz | 4ec3243 | 2022-01-31 13:03:27 +0100 | [diff] [blame] | 85 | ${received_nr}= GetReceivedNumber ${filtered_logs} |
Lasse Kaihlavirta | a3f68d1 | 2021-05-21 12:59:08 +0300 | [diff] [blame] | 86 | |
| 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 Jeremicz | 4ec3243 | 2022-01-31 13:03:27 +0100 | [diff] [blame] | 90 | Should Be Equal As Numbers ${received_nr} 10 Pm-mapper received ${received_nr} messages. Expected received count: 10 |
Lasse Kaihlavirta | a3f68d1 | 2021-05-21 12:59:08 +0300 | [diff] [blame] | 91 | ClearLogs |
| 92 | |
| 93 | *** Keywords *** |
| 94 | |
| 95 | SendFilesToDatarouter |
| 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 | |
| 102 | SendToDatarouter |
| 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 | |
| 110 | PutCall |
| 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 | |
| 116 | VerifyResponse |
| 117 | [Arguments] ${actual_response_value} ${expected_response_value} |
| 118 | Should Be Equal As Strings ${actual_response_value} ${expected_response_value} |
| 119 | |
| 120 | ClearLogs |
| 121 | Run Process ${CLI_EXEC_CLI_PM_LOG_CLEAR} shell=yes |
| 122 | |
| 123 | GetLogsOutput |
| 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 Janeczek | 6ddc310 | 2021-05-26 17:58:44 +0200 | [diff] [blame] | 132 | Log ${output} |
Lasse Kaihlavirta | a3f68d1 | 2021-05-21 12:59:08 +0300 | [diff] [blame] | 133 | END |
| 134 | [Return] ${output} |
| 135 | |
| 136 | GetFilteredLogs |
| 137 | [Arguments] ${all_logs} ${testname} |
| 138 | ${filtered_logs}= Filter Unique ${all_logs} ${testname} |
| 139 | [Return] ${filtered_logs} |
| 140 | |
| 141 | GetDroppedNumber |
| 142 | [Arguments] ${logs_output} |
Joanna Jeremicz | 4ec3243 | 2022-01-31 13:03:27 +0100 | [diff] [blame] | 143 | ${number}= Get Number Of Element Occurrences In Logs ${logs_output} |429| |
| 144 | [Return] ${number} |
| 145 | |
| 146 | GetReceivedNumber |
| 147 | [Arguments] ${logs_output} |
| 148 | ${number}= Get Number Of Element Occurrences In Logs ${logs_output} |200| |
Lasse Kaihlavirta | a3f68d1 | 2021-05-21 12:59:08 +0300 | [diff] [blame] | 149 | [Return] ${number} |
| 150 | |
| 151 | RestartPmmapper |
| 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 | |
| 158 | SavePmMapperLogsAndDroppedCount |
| 159 | [Arguments] ${test_name} ${dropped_count} |
Joanna Jeremicz | 4ec3243 | 2022-01-31 13:03:27 +0100 | [diff] [blame] | 160 | 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 Kaihlavirta | a3f68d1 | 2021-05-21 12:59:08 +0300 | [diff] [blame] | 162 | |