Krzysztof Kuzmicki | 5e6967f | 2021-10-01 12:22:06 +0200 | [diff] [blame^] | 1 | *** Settings *** |
| 2 | Documentation The main interface for interacting with 5G Bulkpm. |
| 3 | Library RequestsLibrary |
| 4 | Library OperatingSystem |
| 5 | Library String |
| 6 | Library JSONLibrary |
| 7 | Resource ../mr_interface.robot |
| 8 | Resource ../dr_interface.robot |
| 9 | Resource ../consul_interface.robot |
| 10 | Resource ../chart_museum.robot |
| 11 | |
| 12 | *** Variables *** |
| 13 | ${INVENTORY_SERVER} ${GLOBAL_INVENTORY_SERVER_PROTOCOL}://${GLOBAL_INVENTORY_SERVER_NAME}:${GLOBAL_INVENTORY_SERVER_PORT} |
| 14 | ${DEPLOYMENT_SERVER} ${GLOBAL_DEPLOYMENT_HANDLER_SERVER_PROTOCOL}://${GLOBAL_DEPLOYMENT_HANDLER_SERVER_NAME}:${GLOBAL_DEPLOYMENT_HANDLER_SERVER_PORT} |
| 15 | ${DR_ENDPOINT} ${GLOBAL_DMAAP_DR_PROV_SERVER_PROTOCOL}://${GLOBAL_INJECTED_DMAAP_DR_PROV_IP_ADDR}:${GLOBAL_DMAAP_DR_PROV_SERVER_PORT} |
| 16 | ${DMAAP_BC_SERVER} ${GLOBAL_BC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_BC_IP_ADDR}:${GLOBAL_BC_HTTPS_SERVER_PORT} |
| 17 | ${VES_HEALTH_CHECK_PATH} ${GLOBAL_DCAE_VES_HTTPS_PROTOCOL}://${GLOBAL_INJECTED_DCAE_VES_HOST}:${GLOBAL_DCAE_VES_HTTPS_SERVER_PORT} |
| 18 | ${MR_PUBLISH_TEMPLATE} mr/mr_publish.jinja |
| 19 | ${INVENTORY_ENDPOINT} /dcae-service-types |
| 20 | ${XNF_SFTP_BLUEPRINT_PATH} ${EXECDIR}/robot/assets/usecases/5gbulkpm/k8s-sftp.yaml |
| 21 | ${XNF_HTTPS_BLUEPRINT_PATH} ${EXECDIR}/robot/assets/usecases/5gbulkpm/k8s-https.yaml |
| 22 | ${BLUEPRINT_TEMPLATE_PATH} ${EXECDIR}/robot/assets/usecases/5gbulkpm/blueprintTemplate.json |
| 23 | ${DEPLOYMENT_ENDPOINT} dcae-deployments |
| 24 | ${MR_TOPIC_CHECK_PATH} /topics |
| 25 | ${DR_SUB_CHECK_PATH} /internal/prov |
| 26 | ${MR_TOPIC_URL_PATH} /events/org.onap.dmaap.mr.PERFORMANCE_MEASUREMENTS/CG1/C1 |
| 27 | ${MR_TOPIC_URL_PATH_FOR_POST} /events/org.onap.dmaap.mr.PERFORMANCE_MEASUREMENTS |
| 28 | ${DMAAP_BC_MR_CLIENT_PATH} /webapi/mr_clients |
| 29 | ${DMAAP_BC_MR_CLUSTER_PATH} /webapi/mr_clusters |
| 30 | ${PMMAPPER_HEALTH_CHECK_PATH} /healthcheck |
| 31 | ${JSON_DATA_FILE} ${EXECDIR}/robot/assets/usecases/5gbulkpm/Notification.json |
| 32 | ${VES_LISTENER_PATH} /eventListener/v7 |
| 33 | ${PMMAPPER_SUB_ROLE_DATA} ${EXECDIR}/robot/assets/usecases/5gbulkpm/sub.json |
| 34 | ${PMMAPPER_MR_CLUSTER_DATA} ${EXECDIR}/robot/assets/usecases/5gbulkpm/mr_clusters.json |
| 35 | ${NEXUS3} ${GLOBAL_INJECTED_NEXUS_DOCKER_REPO} |
| 36 | ${SET_KNOWN_HOSTS_FILE_PATH} kubectl set env deployment/$(kubectl get deployment -n onap | grep datafile | awk '{print $1}') KNOWN_HOSTS_FILE_PATH=/home/datafile/.ssh/known_hosts -n onap |
| 37 | ${CHECK_ENV_SET} kubectl set env pod/$(kubectl get pod -n onap | grep datafile | awk '{print $1}') --list -n onap |
| 38 | ${COPY_RSA_KEY} kubectl cp /tmp/known_hosts $(kubectl get pod -n onap | grep datafile | awk '{print $1}'):/home/datafile/.ssh/known_hosts -n onap |
| 39 | ${CHECK_DFC_LOGS} kubectl logs $(kubectl get pod -n onap | grep datafile | awk '{print $1}') -n onap --tail=4 |
| 40 | ${EXPECTED_PRINT} StrictHostKeyChecking is enabled but environment variable KNOWN_HOSTS_FILE_PATH is not set or points to not existing file |
| 41 | ${MONGO_BLUEPRINT_PATH} ${EXECDIR}/robot/assets/cmpv2/k8s-mongo.yaml |
| 42 | ${PNF_SIMULATOR_BLUEPRINT_PATH} ${EXECDIR}/robot/assets/cmpv2/k8s-pnf-simulator.yaml |
| 43 | ${MONGO_VES_CLIENT_BLUEPRINT_PATH} ${EXECDIR}/robot/assets/cmpv2/k8s-mongo-ves-client.yaml |
| 44 | ${VES_CLIENT_BLUEPRINT_PATH} ${EXECDIR}/robot/assets/cmpv2/k8s-ves-client.yaml |
| 45 | ${VES_INPUTS} deployment/VesTlsCmpv2Inputs.jinja |
| 46 | ${pm_notification_event} dfc/notification.jinja |
| 47 | ${consul_change_event} dfc/consul.jinja |
| 48 | ${ves_client_single_event}= ves/pnf_simulator_single_event.jinja |
| 49 | ${SFTP_HELM_CHARTS} ${EXECDIR}/robot/assets/helm/sftp |
| 50 | ${HELM_RELEASE} kubectl --namespace onap get pods | sed 's/ .*//' | grep robot | sed 's/-.*//' |
| 51 | |
| 52 | *** Keywords *** |
| 53 | |
| 54 | xNF PM File Validate |
| 55 | [Documentation] |
| 56 | ... This keyword gathers all events from message router topic and validates if in recived data is present an expected string: "${expected_pm_str}" . |
| 57 | [Arguments] ${expected_pm_str} |
| 58 | ${timestamp}= Get Time epoch |
| 59 | ${resp}= Run MR Auth Get Request ${MR_TOPIC_URL_PATH} ${GLOBAL_DCAE_USERNAME} ${GLOBAL_DCAE_PASSWORD} |
| 60 | Should Contain ${resp.text} ${expected_pm_str} |
| 61 | |
| 62 | Topic Validate |
| 63 | [Arguments] ${value} |
| 64 | ${timestamp}= Get Current Date |
| 65 | ${dict}= Create Dictionary timestamp=${timestamp} |
| 66 | Templating.Create Environment mr ${GLOBAL_TEMPLATE_FOLDER} |
| 67 | ${data}= Templating.Apply Template mr ${MR_PUBLISH_TEMPLATE} ${dict} |
| 68 | ${resp}= Run MR Auth Post Request (User And Pass) ${MR_TOPIC_URL_PATH_FOR_POST} ${GLOBAL_DCAE_USERNAME} ${GLOBAL_DCAE_PASSWORD} ${data} |
| 69 | Should Be Equal As Strings ${resp.status_code} 200 |
| 70 | ${resp}= Run MR Auth Get Request ${MR_TOPIC_URL_PATH} ${GLOBAL_DCAE_USERNAME} ${GLOBAL_DCAE_PASSWORD} |
| 71 | Should Contain ${resp.text} ${value} |
| 72 | |
| 73 | Send File Ready Event to VES Collector and Deploy all DCAE Applications |
| 74 | [Arguments] ${pm_file} ${file_format_type} ${file_format_version} |
| 75 | Disable Warnings |
| 76 | Setting Global Variables |
| 77 | Send File Ready Event to VES Collector ${pm_file} ${file_format_type} ${file_format_version} |
| 78 | Add chart repository chart-museum http://chart-museum:80 onapinitializer demo123456! |
| 79 | Log To Console Deploying Data File Collector |
| 80 | Deploying Data File Collector |
| 81 | Log To Console Deploying 3GPP PM Mapper |
| 82 | Deploying 3GPP PM Mapper |
| 83 | Log To Console Deploying SFTP Server As xNF |
| 84 | Deploying SFTP Server As xNF |
| 85 | Checking PERFORMANCE_MEASUREMENTS Topic In Message Router |
| 86 | DR Bulk PM Feed Check |
| 87 | DR PM Mapper Subscriber Check |
| 88 | |
| 89 | Usecase Teardown |
| 90 | Disable Warnings |
| 91 | Uninstall helm charts ${ONAP_HELM_RELEASE}-dfc |
| 92 | Uninstall helm charts ${ONAP_HELM_RELEASE}-pmmapper |
| 93 | Uninstall helm charts ${ONAP_HELM_RELEASE}-sftp |
| 94 | |
| 95 | Setting Global Variables |
| 96 | ${test_variables} = Create Dictionary |
| 97 | Set To Dictionary ${test_variables} FILE_FORMAT_TYPE=org.3GPP.32.435#measCollec |
| 98 | ... FILE_FORMAT_VERSION=V10 |
| 99 | ... PM_FILE_PATH=${EXECDIR}/robot/assets/usecases/5gbulkpm/pmfiles/A20181002.0000-1000-0015-1000_5G.xml.gz |
| 100 | ... EXPECTED_PM_STR=perf3gpp_RnNode-Ericsson_pmMeasResult |
| 101 | Set Global Variable ${GLOBAL_TEST_VARIABLES} ${test_variables} |
| 102 | ${command_output} = Run And Return Rc And Output ${HELM_RELEASE} |
| 103 | Should Be Equal As Integers ${command_output[0]} 0 |
| 104 | Set Global Variable ${ONAP_HELM_RELEASE} ${command_output[1]} |
| 105 | |
| 106 | Send File Ready Event to VES Collector |
| 107 | [Arguments] ${pm_file} ${file_format_type} ${file_format_version} |
| 108 | Disable Warnings |
| 109 | ${headers}= Create Dictionary content-type=application/json |
| 110 | ${fileready}= OperatingSystem.Get File ${JSON_DATA_FILE} |
| 111 | ${auth}= Create List ${GLOBAL_DCAE_VES_USERNAME} ${GLOBAL_DCAE_VES_PASSWORD} |
| 112 | ${session}= Create Session ves ${VES_HEALTH_CHECK_PATH} auth=${auth} |
| 113 | ${resp}= Post Request ves ${VES_LISTENER_PATH} data=${fileready} headers=${headers} |
| 114 | Should Be Equal As Strings ${resp.status_code} 202 |
| 115 | ${VES_FILE_READY_NOTIFICATION} Set Variable {"event":{"commonEventHeader":{"version":"4.0.1","vesEventListenerVersion":"7.0.1","domain":"notification","eventName":"Noti_RnNode-Ericsson_FileReady","eventId":"FileReady_1797490e-10ae-4d48-9ea7-3d7d790b25e1","lastEpochMicrosec":8745745764578,"priority":"Normal","reportingEntityName":"otenb5309","sequence":0,"sourceName":"oteNB5309","startEpochMicrosec":8745745764578,"timeZoneOffset":"UTC+05.30"},"notificationFields":{"changeIdentifier":"PM_MEAS_FILES","changeType":"FileReady","notificationFieldsVersion":"2.0","arrayOfNamedHashMap":[{"name":"${pm_file}","hashMap":{"location":"sftp://bulkpm:bulkpm@${ONAP_HELM_RELEASE}-sftp:22/upload/${pm_file}","compression":"gzip","fileFormatType":"${file_format_type}","fileFormatVersion":"${file_format_version}"}}]}}} |
| 116 | ${resp}= Post Request ves ${VES_LISTENER_PATH} data=${VES_FILE_READY_NOTIFICATION} headers=${headers} |
| 117 | Should Be Equal As Strings ${resp.status_code} 202 |
| 118 | |
| 119 | Upload PM Files to xNF SFTP Server |
| 120 | [Arguments] ${pm_file_path} |
| 121 | Open Connection ${ONAP_HELM_RELEASE}-sftp |
| 122 | Login bulkpm bulkpm |
| 123 | ${epoch}= Get Current Date result_format=epoch |
| 124 | ${pm_file}= Set Variable A${epoch}.xml.gz |
| 125 | Put File ${pm_file_path} upload/${pm_file} |
| 126 | [Return] ${pm_file} |
| 127 | |
| 128 | Upload PM Files to xNF HTTPS Server |
| 129 | [Arguments] ${pm_file_path} ${https_server} |
| 130 | ${epoch}= Get Current Date result_format=epoch |
| 131 | Set Variable A${epoch}.xml.gz |
| 132 | Copy File ${pm_file_path} tmp/${pm_file} |
| 133 | ${fileData}= Get Binary File tmp/${pm_file} |
| 134 | ${file_part}= Create List ${pm_file} ${fileData} application/octet-stream |
| 135 | ${fileParts}= Create Dictionary |
| 136 | Set to Dictionary ${fileParts} uploaded_file=${file_part} |
| 137 | ${auth}= Create List demo demo123456! |
| 138 | ${session}= Create Session https http://${https_server}:80 auth=${auth} |
| 139 | ${resp}= Post Request https /upload.php files=${fileParts} |
| 140 | Should Be Equal As Strings ${resp.status_code} 200 |
| 141 | [Return] ${pm_file} |
| 142 | |
| 143 | Check Given Print In DFC Log |
| 144 | [Arguments] ${check_dfc_logs} |
| 145 | ${dfc_logs}= Run Given Command On DFC Container ${CHECK_DFC_LOGS} |
| 146 | Should Contain ${dfc_logs} HostKey has been changed |
| 147 | |
| 148 | Run Given Command On DFC Container |
| 149 | [Arguments] ${user_command} |
| 150 | ${run_command} = Run And Return Rc And Output ${user_command} |
| 151 | ${command_output} = Set Variable ${run_command[1]} |
| 152 | ${regexp_matches} = Get Regexp Matches ${command_output} .*(\\s|\\[)+(.+-datafile-collector).* 2 |
| 153 | ${dfc_container_name} = Set Variable ${regexp_matches[0]} |
| 154 | ${new_command} = Set Variable ${user_command} ${dfc_container_name} |
| 155 | ${command_output} = Run And Return Rc And Output ${new_command} |
| 156 | Should Be Equal As Integers ${command_output[0]} 0 |
| 157 | ${log} = Set Variable ${command_output[1]} |
| 158 | [Return] ${log} |
| 159 | |
| 160 | Check Known Hosts In Env |
| 161 | [Arguments] ${CHECK_KNOWN_HOSTS} |
| 162 | ${check} = Run And Return Rc And Output ${CHECK_KNOWN_HOSTS} |
| 163 | Should Be Equal As Integers ${check[0]} 0 |
| 164 | ${env} = Set Variable ${check[1]} |
| 165 | ${string_matches} = Get Lines Containing String ${env} KNOWN_HOSTS_FILE_PATH=/home/datafile/.ssh/known_host case_insensitive=True |
| 166 | ${output} = Should Not Be Empty ${string_matches} |
| 167 | [Return] ${output} |
| 168 | |
| 169 | Deploying Data File Collector |
| 170 | Install helm charts chart-museum dcae-datafile-collector ${ONAP_HELM_RELEASE}-dfc 3 min |
| 171 | |
| 172 | Deploying 3GPP PM Mapper |
| 173 | Install helm charts chart-museum dcae-pm-mapper ${ONAP_HELM_RELEASE}-pmmapper 3 min |
| 174 | |
| 175 | Deploying SFTP Server As xNF |
| 176 | ${override} = Set Variable --set fullnameOverride=${ONAP_HELM_RELEASE}-sftp |
| 177 | Install helm charts from folder ${SFTP_HELM_CHARTS} ${ONAP_HELM_RELEASE}-sftp set_values_override=${override} |
| 178 | |
| 179 | Checking PERFORMANCE_MEASUREMENTS Topic In Message Router |
| 180 | ${headers}= Create Dictionary content-type=application/json |
| 181 | ${subdata}= OperatingSystem.Get File ${PMMAPPER_SUB_ROLE_DATA} |
| 182 | ${session}= Create Session dmaapbc ${DMAAP_BC_SERVER} |
| 183 | ${resp}= Post Request dmaapbc ${DMAAP_BC_MR_CLIENT_PATH} data=${subdata} headers=${headers} |
| 184 | Wait Until Keyword Succeeds 5 minute 5 sec Topic Validate success |
| 185 | ${resp}= Run MR Get Request ${MR_TOPIC_CHECK_PATH} |
| 186 | Should Be Equal As Strings ${resp.status_code} 200 |
| 187 | ${topics}= Set Variable ${resp.json().get('topics')} |
| 188 | List Should Contain Value ${topics} org.onap.dmaap.mr.PERFORMANCE_MEASUREMENTS |
| 189 | ${resp}= Run MR Auth Get Request ${MR_TOPIC_URL_PATH} ${GLOBAL_DCAE_USERNAME} ${GLOBAL_DCAE_PASSWORD} |
| 190 | Should Be Equal As Strings ${resp.status_code} 200 |
| 191 | |
| 192 | DR Bulk PM Feed Check |
| 193 | ${resp}= Run DR Get Request ${DR_SUB_CHECK_PATH} |
| 194 | Should Contain ${resp.text} bulk_pm_feed |
| 195 | |
| 196 | DR PM Mapper Subscriber Check |
| 197 | ${resp}= Run DR Get Request ${DR_SUB_CHECK_PATH} |
| 198 | Should Contain ${resp.text} https://dcae-pm-mapper:8443/delivery |
| 199 | |
| 200 | Setting KNOWN_HOSTS_FILE_PATH Environment Variable in DFC |
| 201 | ${rc}= Run and Return RC ${SET_KNOWN_HOSTS_FILE_PATH} |
| 202 | Should Be Equal As Integers ${rc} 0 |
| 203 | Wait Until Keyword Succeeds 5 min 10s Check Known Hosts In Env ${CHECK_ENV_SET} |
| 204 | ${GET_RSA_KEY}= Set Variable kubectl exec $(kubectl get pod -n onap | grep ${ONAP_HELM_RELEASE}-sftp | awk '{print $1}') -n onap -- ssh-keyscan -t rsa ${ONAP_HELM_RELEASE}-sftp > /tmp/known_hosts |
| 205 | ${rc}= Run and Return RC ${GET_RSA_KEY} |
| 206 | Should Be Equal As Integers ${rc} 0 |
| 207 | ${rc}= Run and Return RC ${COPY_RSA_KEY} |
| 208 | Should Be Equal As Integers ${rc} 0 |
| 209 | |
| 210 | Uploading PM Files to xNF SFTP Server |
| 211 | ${pm_file}= Upload PM Files to xNF SFTP Server ${GLOBAL_TEST_VARIABLES["PM_FILE_PATH"]} |
| 212 | Set Global Variable ${PM_FILE} ${pm_file} |
| 213 | |
| 214 | Sending File Ready Event to VES Collector |
| 215 | Send File Ready Event to VES Collector ${PM_FILE} ${GLOBAL_TEST_VARIABLES["FILE_FORMAT_TYPE"]} ${GLOBAL_TEST_VARIABLES["FILE_FORMAT_VERSION"]} |
| 216 | |
| 217 | Verifying 3GPP Perf VES Content On PERFORMANCE_MEASUREMENTS Topic |
| 218 | Wait Until Keyword Succeeds 2 min 5 sec xNF PM File Validate ${GLOBAL_TEST_VARIABLES["EXPECTED_PM_STR"]} |
| 219 | |
| 220 | Changing SFTP Server RSA Key in DFC |
| 221 | ${get_known_hosts_file}= OperatingSystem.Get File /tmp/known_hosts |
| 222 | ${change_rsa_key}= Replace String ${get_known_hosts_file} A a |
| 223 | Create File /tmp/known_hosts ${change_rsa_key} |
| 224 | ${rc}= Run and Return RC ${COPY_RSA_KEY} |
| 225 | Should Be Equal As Integers ${rc} 0 |
| 226 | |
| 227 | Checking DFC Logs After KNOWN_HOSTS_FILE_PATH Env Variable Added |
| 228 | ${dfc_logs}= Run Given Command On DFC Container ${CHECK_DFC_LOGS} |
| 229 | Should Not Contain ${dfc_logs} ${EXPECTED_PRINT} |
| 230 | |
| 231 | Checking DFC Logs After SFTP Server RSA Key Changed |
| 232 | Wait Until Keyword Succeeds 5 min 30 sec Check Given Print In DFC LOG ${CHECK_DFC_LOGS} |
| 233 | |
| 234 | Check DFC logs |
| 235 | [Arguments] ${DFC_LOG_CHECK} |
| 236 | ${rc} = Run and Return RC ${DFC_LOG_CHECK} |
| 237 | Should Be Equal As Integers ${rc} 0 |