Joey Armstrong | 9fadcbe | 2024-01-17 19:00:37 -0500 | [diff] [blame] | 1 | # Copyright 2022-2024 Open Networking Foundation (ONF) and the ONF Contributors |
TorstenThieme | 0c8cc6f | 2022-02-16 13:48:21 +0000 | [diff] [blame] | 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 |
TorstenThieme | d9cc06e | 2022-11-09 12:12:46 +0000 | [diff] [blame] | 111 | ${event}= Set Variable ONU_MIB_AUDIT_FAILURE_MDS |
| 112 | Wait Until Keyword Succeeds ${interval} 5s Validate Events All ONUs ${list_onu_device_id} ${event} |
TorstenThieme | 0c8cc6f | 2022-02-16 13:48:21 +0000 | [diff] [blame] | 113 | kafka.Records Clear |
| 114 | Run Keyword If ${print2console} Log Sanity Test after MIB Audit. console=yes |
| 115 | Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT ${suppressaddsubscriber} |
| 116 | ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT ${suppressaddsubscriber} |
| 117 | ... ELSE Perform Sanity Test ${suppressaddsubscriber} |
| 118 | Run Keyword If ${print2console} Log Disable ONUs. console=yes |
| 119 | Disable Onu Device |
Andrea Campanella | 753510e | 2022-04-28 23:26:27 +0200 | [diff] [blame] | 120 | Run Keyword If "${workflow}"=="DT" Current State Test All Onus omci-admin-lock |
TorstenThieme | 20e1627 | 2022-07-13 06:51:18 +0000 | [diff] [blame] | 121 | ... ELSE IF "${workflow}"=="TT" Current State Test All Onus tech-profile-config-delete-success |
| 122 | ... ELSE Current State Test All Onus tech-profile-config-delete-success |
Andrea Campanella | 753510e | 2022-04-28 23:26:27 +0200 | [diff] [blame] | 123 | #check all ports are disabled in ONOS |
TorstenThieme | 0c8cc6f | 2022-02-16 13:48:21 +0000 | [diff] [blame] | 124 | Wait for all ONU Ports in ONOS Disabled ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${unitag_sub} |
| 125 | Run Keyword If ${print2console} Log Enable ONUs. console=yes |
| 126 | Enable Onu Device |
| 127 | Run Keyword If ${print2console} Log Sanity Test after Enable ONUs. console=yes |
| 128 | Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT ${suppressaddsubscriber} |
| 129 | ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT ${suppressaddsubscriber} |
| 130 | ... ELSE Perform Sanity Test ${suppressaddsubscriber} |
| 131 | END |
| 132 | [Teardown] Run Keywords Printout ONU Serial Number and Device Id print2console=${print2console} |
| 133 | ... AND Run Keyword If ${logging} Collect Logs |
| 134 | ... AND Stop Logging CheckMibAudit |
| 135 | |
| 136 | |
| 137 | *** Keywords *** |
| 138 | Setup Suite |
| 139 | [Documentation] Set up the test suite |
| 140 | Start Logging Setup or Teardown Setup-${SUITE NAME} |
| 141 | # set tech profiles |
| 142 | ${preload_tech_profile}= Set Variable If ${unitag_sub} and "${workflow}"=="TT" and not ${has_dataplane} True False |
| 143 | Set Suite Variable ${preload_tech_profile} |
| 144 | Run Keyword If ${preload_tech_profile} Set Tech Profile TT-HSIA ${INFRA_NAMESPACE} 64 |
| 145 | Run Keyword If ${preload_tech_profile} Set Tech Profile TT-VoIP ${INFRA_NAMESPACE} 65 |
| 146 | Run Keyword If ${preload_tech_profile} Set Tech Profile TT-multi-uni-MCAST-AdditionalBW-None ${INFRA_NAMESPACE} 66 |
| 147 | Common Test Suite Setup |
| 148 | ${switch_type}= Get Variable Value ${web_power_switch.type} |
| 149 | Run Keyword If "${switch_type}"!="" Set Global Variable ${powerswitch_type} ${switch_type} |
| 150 | # set ${kafka} depending on environment in case of port-forward is needed |
| 151 | ${rc} ${kafka}= Run Keyword If ${PORT_FORWARDING} Run and Return Rc and Output |
| 152 | ... kubectl get svc -n ${INFRA_NAMESPACE} | grep kafka-0-external | awk '{print $1}' |
| 153 | Run Keyword If ${PORT_FORWARDING} Should Not Be Empty ${kafka} Service kafka-0-external not found |
| 154 | # start port forwarding if needed (when voltha runs in k8s) |
| 155 | ${portFwdHandle} = Run Keyword If ${PORT_FORWARDING} Start Process |
| 156 | ... kubectl port-forward --address 0.0.0.0 --namespace default svc/${kafka} ${KAFKA_PORT}:${KAFKA_SVC_PORT} & |
| 157 | ... shell=true |
| 158 | Set Suite Variable ${portFwdHandle} |
| 159 | Sleep 5s |
| 160 | # open connection to read kafka bus |
| 161 | Wait Until Keyword Succeeds 3x 5s |
| 162 | ... kafka.Connection Open ${KAFKA_IP} ${KAFKA_PORT} voltha.events timestamp_from=0 |
| 163 | # enable OLT(s) and bring up ONU(s) |
| 164 | Setup |
| 165 | Run Keyword If "${workflow}"=="DT" Perform Sanity Test DT |
| 166 | ... ELSE IF "${workflow}"=="TT" Perform Sanity Tests TT |
| 167 | ... ELSE Perform Sanity Test |
| 168 | Stop Logging Setup or Teardown Setup-${SUITE NAME} |
| 169 | |
| 170 | Teardown Suite |
| 171 | [Documentation] tear down the test suite |
| 172 | Run Keyword If ${pausebeforecleanup} Import Library Dialogs |
| 173 | Run Keyword If ${pausebeforecleanup} Pause Execution Press OK to continue with clean up! |
| 174 | Run Keyword If ${pausebeforecleanup} Log Teardown will be continued... console=yes |
| 175 | # close connection to kafka |
| 176 | kafka.Connection Close |
| 177 | # stop port forwarding if started |
| 178 | Run Keyword If ${PORT_FORWARDING} Terminate Process ${portFwdHandle} kill=true |
| 179 | # call common suite teardown |
| 180 | utils.Teardown Suite |
| 181 | Close All ONOS SSH Connections |
| 182 | Set Suite Variable ${TechProfile} ${EMPTY} |
| 183 | Run Keyword If ${preload_tech_profile} Remove Tech Profile ${INFRA_NAMESPACE} 64 |
| 184 | Run Keyword If ${preload_tech_profile} Remove Tech Profile ${INFRA_NAMESPACE} 65 |
| 185 | Run Keyword If ${preload_tech_profile} Remove Tech Profile ${INFRA_NAMESPACE} 66 |
| 186 | |
TorstenThieme | 0c8cc6f | 2022-02-16 13:48:21 +0000 | [diff] [blame] | 187 | Calculate Interval |
| 188 | [Documentation] Converts the passed value in seconds, adds percentage and return it w/o unit |
| 189 | ... Conversion to string is needed to remove float format! |
| 190 | [Arguments] ${val} ${percentage}=0.2 ${unit}=True |
| 191 | ${seconds}= Convert Time ${val} |
| 192 | ${seconds}= evaluate ${seconds}+${seconds}*0.2 |
| 193 | ${seconds}= Convert To String ${seconds} |
| 194 | ${seconds}= Get Substring ${seconds} 0 -2 |
| 195 | ${seconds}= Set Variable If ${unit} ${seconds}s ${seconds} |
| 196 | [return] ${seconds} |