TorstenThieme | 0c8cc6f | 2022-02-16 13:48:21 +0000 | [diff] [blame] | 1 | # Copyright 2022 - present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | *** Settings *** |
| 16 | Documentation Test of open ONU go adapter MIB audit |
| 17 | ... in case of kafka pod runs in k8s cluster - kafka has to deploy with following EXTRA_HELM_FLAGS |
| 18 | ... --set externalAccess.enabled=true, |
| 19 | ... --set externalAccess.service.type=NodePort, |
| 20 | ... --set externalAccess.service.nodePorts[0]=${KAFKA_PORT}, |
| 21 | ... --set externalAccess.service.domain=${KAFKA_IP} |
| 22 | ... with e.g. service.domain=10.0.02.15 or 127.0.0.1 and service.nodePorts[0]=30201! |
| 23 | ... For voltha-infra prefix kafka. is needed e.g.: --set kafka.externalAccess.enabled=true |
| 24 | Suite Setup Setup Suite |
| 25 | Suite Teardown Teardown Suite |
| 26 | Test Setup Setup |
| 27 | Test Teardown Teardown |
| 28 | Library Collections |
| 29 | Library String |
| 30 | Library OperatingSystem |
| 31 | Library XML |
| 32 | Library RequestsLibrary |
| 33 | Library ../../libraries/DependencyLibrary.py |
| 34 | Resource ../../libraries/onos.robot |
| 35 | Resource ../../libraries/voltctl.robot |
| 36 | Resource ../../libraries/voltha.robot |
| 37 | Resource ../../libraries/utils.robot |
| 38 | Resource ../../libraries/k8s.robot |
| 39 | Resource ../../libraries/onu_utilities.robot |
| 40 | Resource ../../libraries/bbsim.robot |
| 41 | Resource ../../variables/variables.robot |
| 42 | |
| 43 | Library kafka_robot.KafkaClient log_level=DEBUG WITH NAME kafka |
| 44 | Library grpc_robot.VolthaTools WITH NAME volthatools |
| 45 | |
| 46 | |
| 47 | *** Variables *** |
| 48 | ${NAMESPACE} voltha |
| 49 | ${INFRA_NAMESPACE} default |
| 50 | ${timeout} 60s |
| 51 | ${of_id} 0 |
| 52 | ${logical_id} 0 |
| 53 | ${has_dataplane} True |
| 54 | ${external_libs} True |
| 55 | ${teardown_device} True |
| 56 | ${scripts} ../../scripts |
| 57 | # Per-test logging on failure is turned off by default; set this variable to enable |
| 58 | ${container_log_dir} ${None} |
| 59 | |
| 60 | # logging flag to enable Collect Logs, can be passed via the command line too |
| 61 | # example: -v logging:True |
| 62 | ${logging} False |
| 63 | # determines the environment workflow: DT, TT or ATT (default) |
| 64 | # example: -v workflow:DT |
| 65 | ${workflow} ATT |
| 66 | # when voltha is running in k8s port forwarding is needed |
| 67 | # example: -v PORT_FORWARDING:False |
| 68 | ${PORT_FORWARDING} True |
| 69 | # kafka ip e.g. ip of master host where k8s is running |
| 70 | # example: -v KAFKA_IP:10.0.2.15 |
| 71 | ${KAFKA_IP} 127.0.0.1 |
| 72 | # kafka port: port of kafka nodeport |
| 73 | # example: -v KAFKA_PORT:30201 |
| 74 | ${KAFKA_PORT} 30201 |
| 75 | # kafka service port: service port of kafka nodeport |
| 76 | # example: -v KAFKA_SVC_PORT:9094 |
| 77 | ${KAFKA_SVC_PORT} 9094 |
| 78 | # onu MIB audit interval |
| 79 | # example: -v ONU_MIB_AUDIT_INTERVAL:50s |
| 80 | ${ONU_MIB_AUDIT_INTERVAL} 60s |
| 81 | # MDS mitsmatches per ONU |
| 82 | # example: -v MDS_MISMATCHES_PER_ONU:2 |
| 83 | ${MDS_MISMATCHES_PER_ONU} 3 |
| 84 | # if True execution will be paused before clean up, only use in case of manual testing, do not use in ci pipeline! |
| 85 | # example: -v pausebeforecleanup:True |
| 86 | ${pausebeforecleanup} False |
| 87 | # if True some outputs to console are done during running tests e.g. long duration flow test |
| 88 | # example: -v print2console:True |
| 89 | ${print2console} False |
| 90 | ${suppressaddsubscriber} True |
| 91 | |
| 92 | # flag to choose the subscriber provisioning command type in ONOS |
| 93 | # TT often provision a single services for a subscriber (eg: hsia, voip, ...) one after the other. |
| 94 | # if set to True, command used is "volt-add-subscriber-unitag" |
| 95 | # if set to False, comand used is "volt-add-subscriber-access" |
| 96 | ${unitag_sub} False |
| 97 | |
| 98 | *** Test Cases *** |
| 99 | Check Mib Audit |
| 100 | [Documentation] Validates the ONU Go adapter MIB audit |
| 101 | [Tags] functional CheckMibAudit |
| 102 | [Setup] Start Logging CheckMibAudit |
| 103 | kafka.Records Clear |
| 104 | ${interval}= Calculate Interval ${ONU_MIB_AUDIT_INTERVAL} |
| 105 | FOR ${I} IN RANGE 1 ${MDS_MISMATCHES_PER_ONU} + 1 |
| 106 | Run Keyword If ${print2console} Log \r\nInvalidate MDS ${I} of ${MDS_MISMATCHES_PER_ONU}. console=yes |
| 107 | Set Wrong MDS Counter All ONUs ${NAMESPACE} |
| 108 | ${list_onu_device_id} Create List |
| 109 | Build ONU Device Id List ${list_onu_device_id} |
| 110 | Run Keyword If ${print2console} Log Check for device events that indicate a failed MDS check. console=yes |
| 111 | Wait Until Keyword Succeeds ${interval} 5s Validate MIB Audits All ONUs ${list_onu_device_id} |
| 112 | kafka.Records Clear |
| 113 | Run Keyword If ${print2console} Log Sanity Test after MIB Audit. console=yes |
| 114 | Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT ${suppressaddsubscriber} |
| 115 | ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT ${suppressaddsubscriber} |
| 116 | ... ELSE Perform Sanity Test ${suppressaddsubscriber} |
| 117 | Run Keyword If ${print2console} Log Disable ONUs. console=yes |
| 118 | Disable Onu Device |
| 119 | Current State Test All Onus tech-profile-config-delete-success |
| 120 | Wait for all ONU Ports in ONOS Disabled ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${unitag_sub} |
| 121 | Run Keyword If ${print2console} Log Enable ONUs. console=yes |
| 122 | Enable Onu Device |
| 123 | Run Keyword If ${print2console} Log Sanity Test after Enable ONUs. console=yes |
| 124 | Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT ${suppressaddsubscriber} |
| 125 | ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT ${suppressaddsubscriber} |
| 126 | ... ELSE Perform Sanity Test ${suppressaddsubscriber} |
| 127 | END |
| 128 | [Teardown] Run Keywords Printout ONU Serial Number and Device Id print2console=${print2console} |
| 129 | ... AND Run Keyword If ${logging} Collect Logs |
| 130 | ... AND Stop Logging CheckMibAudit |
| 131 | |
| 132 | |
| 133 | *** Keywords *** |
| 134 | Setup Suite |
| 135 | [Documentation] Set up the test suite |
| 136 | Start Logging Setup or Teardown Setup-${SUITE NAME} |
| 137 | # set tech profiles |
| 138 | ${preload_tech_profile}= Set Variable If ${unitag_sub} and "${workflow}"=="TT" and not ${has_dataplane} True False |
| 139 | Set Suite Variable ${preload_tech_profile} |
| 140 | Run Keyword If ${preload_tech_profile} Set Tech Profile TT-HSIA ${INFRA_NAMESPACE} 64 |
| 141 | Run Keyword If ${preload_tech_profile} Set Tech Profile TT-VoIP ${INFRA_NAMESPACE} 65 |
| 142 | Run Keyword If ${preload_tech_profile} Set Tech Profile TT-multi-uni-MCAST-AdditionalBW-None ${INFRA_NAMESPACE} 66 |
| 143 | Common Test Suite Setup |
| 144 | ${switch_type}= Get Variable Value ${web_power_switch.type} |
| 145 | Run Keyword If "${switch_type}"!="" Set Global Variable ${powerswitch_type} ${switch_type} |
| 146 | # set ${kafka} depending on environment in case of port-forward is needed |
| 147 | ${rc} ${kafka}= Run Keyword If ${PORT_FORWARDING} Run and Return Rc and Output |
| 148 | ... kubectl get svc -n ${INFRA_NAMESPACE} | grep kafka-0-external | awk '{print $1}' |
| 149 | Run Keyword If ${PORT_FORWARDING} Should Not Be Empty ${kafka} Service kafka-0-external not found |
| 150 | # start port forwarding if needed (when voltha runs in k8s) |
| 151 | ${portFwdHandle} = Run Keyword If ${PORT_FORWARDING} Start Process |
| 152 | ... kubectl port-forward --address 0.0.0.0 --namespace default svc/${kafka} ${KAFKA_PORT}:${KAFKA_SVC_PORT} & |
| 153 | ... shell=true |
| 154 | Set Suite Variable ${portFwdHandle} |
| 155 | Sleep 5s |
| 156 | # open connection to read kafka bus |
| 157 | Wait Until Keyword Succeeds 3x 5s |
| 158 | ... kafka.Connection Open ${KAFKA_IP} ${KAFKA_PORT} voltha.events timestamp_from=0 |
| 159 | # enable OLT(s) and bring up ONU(s) |
| 160 | Setup |
| 161 | Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT |
| 162 | ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT |
| 163 | ... ELSE Perform Sanity Test |
| 164 | Stop Logging Setup or Teardown Setup-${SUITE NAME} |
| 165 | |
| 166 | Teardown Suite |
| 167 | [Documentation] tear down the test suite |
| 168 | Run Keyword If ${pausebeforecleanup} Import Library Dialogs |
| 169 | Run Keyword If ${pausebeforecleanup} Pause Execution Press OK to continue with clean up! |
| 170 | Run Keyword If ${pausebeforecleanup} Log Teardown will be continued... console=yes |
| 171 | # close connection to kafka |
| 172 | kafka.Connection Close |
| 173 | # stop port forwarding if started |
| 174 | Run Keyword If ${PORT_FORWARDING} Terminate Process ${portFwdHandle} kill=true |
| 175 | # call common suite teardown |
| 176 | utils.Teardown Suite |
| 177 | Close All ONOS SSH Connections |
| 178 | Set Suite Variable ${TechProfile} ${EMPTY} |
| 179 | Run Keyword If ${preload_tech_profile} Remove Tech Profile ${INFRA_NAMESPACE} 64 |
| 180 | Run Keyword If ${preload_tech_profile} Remove Tech Profile ${INFRA_NAMESPACE} 65 |
| 181 | Run Keyword If ${preload_tech_profile} Remove Tech Profile ${INFRA_NAMESPACE} 66 |
| 182 | |
| 183 | Validate MIB Audits All ONUs |
| 184 | [Documentation] Validates MIB Audit Events per ONU |
| 185 | [Arguments] ${list_onu_device_id} |
| 186 | ${Kafka_Records}= kafka.Records Get voltha.events |
| 187 | ${RecordsLength}= Get Length ${Kafka_Records} |
| 188 | FOR ${Index} IN RANGE 0 ${RecordsLength} |
| 189 | ${metric}= Set Variable ${Kafka_Records[${Index}]} |
| 190 | ${message}= Get From Dictionary ${metric} message |
| 191 | ${event}= volthatools.Events Decode Event ${message} return_default=true |
| 192 | Continue For Loop If not 'device_event' in ${event} |
| 193 | ${event_name}= Get From Dictionary ${event['device_event']} device_event_name |
| 194 | Continue For Loop If "${event_name}" != "ONU_MIB_AUDIT_FAILURE_MDS" |
| 195 | ${resource_id}= Get From Dictionary ${event['device_event']} resource_id |
| 196 | Remove Values From List ${list_onu_device_id} ${resource_id} |
| 197 | END |
| 198 | Should Be Empty ${list_onu_device_id} Missing MIB Audits for ONUs ${list_onu_device_id}! |
| 199 | |
| 200 | Calculate Interval |
| 201 | [Documentation] Converts the passed value in seconds, adds percentage and return it w/o unit |
| 202 | ... Conversion to string is needed to remove float format! |
| 203 | [Arguments] ${val} ${percentage}=0.2 ${unit}=True |
| 204 | ${seconds}= Convert Time ${val} |
| 205 | ${seconds}= evaluate ${seconds}+${seconds}*0.2 |
| 206 | ${seconds}= Convert To String ${seconds} |
| 207 | ${seconds}= Get Substring ${seconds} 0 -2 |
| 208 | ${seconds}= Set Variable If ${unit} ${seconds}s ${seconds} |
| 209 | [return] ${seconds} |