Joey Armstrong | 9fadcbe | 2024-01-17 19:00:37 -0500 | [diff] [blame] | 1 | # Copyright 2021-2024 Open Networking Foundation (ONF) and the ONF Contributors |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +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 Negative test states of ONU Go adapter with ATT workflows only (not for DT/TT workflow!) |
| 17 | Suite Setup Setup Suite |
| 18 | Suite Teardown Teardown Suite |
| 19 | Test Setup Setup |
| 20 | Test Teardown Teardown |
| 21 | Library Collections |
| 22 | Library String |
| 23 | Library OperatingSystem |
| 24 | Library XML |
| 25 | Library RequestsLibrary |
| 26 | Library ../../libraries/DependencyLibrary.py |
| 27 | Resource ../../libraries/onos.robot |
| 28 | Resource ../../libraries/voltctl.robot |
| 29 | Resource ../../libraries/voltha.robot |
| 30 | Resource ../../libraries/utils.robot |
| 31 | Resource ../../libraries/k8s.robot |
| 32 | Resource ../../libraries/onu_utilities.robot |
| 33 | Resource ../../libraries/bbsim.robot |
| 34 | Resource ../../variables/variables.robot |
| 35 | |
TorstenThieme | 8adefc2 | 2022-03-01 12:36:19 +0000 | [diff] [blame] | 36 | Library kafka_robot.KafkaClient log_level=DEBUG WITH NAME kafka |
| 37 | Library grpc_robot.VolthaTools WITH NAME volthatools |
| 38 | |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 39 | *** Variables *** |
TorstenThieme | 8adefc2 | 2022-03-01 12:36:19 +0000 | [diff] [blame] | 40 | ${NAMESPACE} voltha |
| 41 | ${INFRA_NAMESPACE} default |
| 42 | ${timeout} 300s |
| 43 | ${of_id} 0 |
| 44 | ${logical_id} 0 |
| 45 | ${has_dataplane} True |
| 46 | ${external_libs} True |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 47 | ${teardown_device} True |
| 48 | ${scripts} ../../scripts |
| 49 | # Per-test logging on failure is turned off by default; set this variable to enable |
| 50 | ${container_log_dir} ${None} |
| 51 | # KV Store Prefix |
Andrea Campanella | 388cd87 | 2022-02-10 09:11:39 +0100 | [diff] [blame] | 52 | # example: -v kvstoreprefix:voltha/voltha_voltha |
| 53 | ${kvstoreprefix} voltha/voltha_voltha |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 54 | # used tech profile, can be passed via the command line too, valid values: default (=1T1GEM), 1T4GEM, 1T8GEM |
| 55 | # example: -v techprofile:1T4GEM |
| 56 | ${techprofile} default |
TorstenThieme | 8adefc2 | 2022-03-01 12:36:19 +0000 | [diff] [blame] | 57 | # when voltha is running in k8s port forwarding is needed |
| 58 | # example: -v PORT_FORWARDING:False |
| 59 | ${PORT_FORWARDING} True |
| 60 | # kafka ip e.g. ip of master host where k8s is running |
| 61 | # example: -v KAFKA_IP:10.0.2.15 |
| 62 | ${KAFKA_IP} 127.0.0.1 |
| 63 | # kafka port: port of kafka nodeport |
| 64 | # example: -v KAFKA_PORT:30201 |
| 65 | ${KAFKA_PORT} 30201 |
| 66 | # kafka service port: service port of kafka nodeport |
| 67 | # example: -v KAFKA_SVC_PORT:9094 |
| 68 | ${KAFKA_SVC_PORT} 9094 |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 69 | # flag debugmode is used, if true timeout calculation various, can be passed via the command line too |
| 70 | # example: -v debugmode:True |
| 71 | ${debugmode} False |
| 72 | # logging flag to enable Collect Logs, can be passed via the command line too |
| 73 | # example: -v logging:True |
| 74 | ${logging} False |
| 75 | # if True execution will be paused before clean up, only use in case of manual testing, do not use in ci pipeline! |
| 76 | # example: -v pausebeforecleanup:True |
| 77 | ${pausebeforecleanup} False |
| 78 | # if True some outputs to console are done during running tests e.g. long duration flow test |
| 79 | # example: -v print2console:True |
| 80 | ${print2console} False |
| 81 | ${data_dir} ../data |
| 82 | |
Hardik Windlass | b1bda36 | 2021-11-24 11:54:36 +0000 | [diff] [blame] | 83 | # flag to choose the subscriber provisioning command type in ONOS |
| 84 | # TT often provision a single services for a subscriber (eg: hsia, voip, ...) one after the other. |
| 85 | # if set to True, command used is "volt-add-subscriber-unitag" |
| 86 | # if set to False, comand used is "volt-add-subscriber-access" |
| 87 | ${unitag_sub} False |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 88 | |
| 89 | *** Test Cases *** |
| 90 | ONU Negative State Test |
| 91 | [Documentation] Validates the ONU Go adapter states will never leave starting-openomci |
| 92 | ... Due to a 'omci-response-rate' lower than 8 more OMCI messages will be through away by BBSIM than |
| 93 | ... repeated by openonu-go-adapter. So ONU will never leave starting-openomci state. |
| 94 | ... Timeout has to set at least to 300s (or more) |
| 95 | [Tags] NegativeStateTestOnuGo |
| 96 | [Setup] Run Keywords Start Logging ONUNegativeStateTest |
TorstenThieme | 8adefc2 | 2022-03-01 12:36:19 +0000 | [diff] [blame] | 97 | ... AND kafka.Records Clear |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 98 | ... AND Setup |
| 99 | # Suite Variable will be overwritten by Teardown of Current State Test All Onus |
| 100 | Set Suite Variable ${StateTestAllONUs} True |
| 101 | ${seconds}= Convert Time ${timeout} |
| 102 | ${seconds}= Convert To String ${seconds} |
| 103 | ${seconds}= Get Substring ${seconds} 0 -2 |
| 104 | FOR ${I} IN RANGE ${seconds} |
| 105 | Sleep 1s |
| 106 | Current State Test All Onus starting-openomci timeout=1x |
| 107 | Exit For Loop If not ${StateTestAllONUs} |
| 108 | END |
TorstenThieme | 8adefc2 | 2022-03-01 12:36:19 +0000 | [diff] [blame] | 109 | ${list_onu_device_id} Create List |
| 110 | Build ONU Device Id List ${list_onu_device_id} |
| 111 | Run Keyword If ${print2console} Log Check for device events that indicate a failed OMCI communication. console=yes |
| 112 | Wait Until Keyword Succeeds ${timeout} 5s Validate Failed OMCI Communication All ONUs ${list_onu_device_id} |
TorstenThieme | 517b7ce | 2022-12-19 11:56:34 +0000 | [diff] [blame] | 113 | # Validate OMCI counter statistics |
| 114 | Build ONU Device Id List ${list_onu_device_id} |
| 115 | FOR ${onu_device_id} IN @{list_onu_device_id} |
| 116 | # get ONU OMCI counter statistics per ONU |
| 117 | ${rc} ${OMCI_counter_dict}= Get OMCI counter statistics dictionary ${onu_device_id} |
| 118 | ${onu_sn}= Run Keyword If ${rc} != 0 Get SN From Device ID ${onu_device_id} |
| 119 | Run Keyword If ${rc} != 0 FAIL Could not get ONU OMCI counter statistic of ONU ${onu_sn}! |
| 120 | ${TxOmciCounterRetries}= Get From Dictionary ${OMCI_counter_dict} TxOmciCounterRetries |
| 121 | ${TxOmciCounterTimeouts}= Get From Dictionary ${OMCI_counter_dict} TxOmciCounterTimeouts |
| 122 | Should Be True 0 < ${TxOmciCounterRetries} No TxOmciCounterRetries found in baseline OMCI! |
| 123 | Should Be True 0 < ${TxOmciCounterTimeouts} No TxOmciCounterTimeouts found in baseline OMCI! |
| 124 | END |
TorstenThieme | 373adfe | 2021-12-16 13:03:04 +0000 | [diff] [blame] | 125 | [Teardown] Run Keywords Printout ONU Serial Number and Device Id print2console=${print2console} |
| 126 | ... AND Run Keyword If ${logging} Collect Logs |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 127 | ... AND Stop Logging ONUStateTest |
| 128 | |
| 129 | |
| 130 | *** Keywords *** |
| 131 | Setup Suite |
| 132 | [Documentation] Set up the test suite |
Andrea Campanella | 82add37 | 2021-11-05 12:01:15 +0100 | [diff] [blame] | 133 | Start Logging Setup or Teardown Setup-${SUITE NAME} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 134 | ${LogInfo}= Catenate |
| 135 | ... \r\nPassed arguments: |
| 136 | ... techprofile:${techprofile}, |
| 137 | ... debugmode:${debugmode}, logging:${logging}, pausebeforecleanup:${pausebeforecleanup}, |
| 138 | ... print2console:${print2console} |
| 139 | Log ${LogInfo} console=yes |
| 140 | Common Test Suite Setup |
| 141 | ${techprofile}= Set Variable If "${techprofile}"=="1T1GEM" default ${techprofile} |
| 142 | Set Suite Variable ${techprofile} |
| 143 | Run Keyword If "${techprofile}"=="default" Log To Console \nTechProfile:default (1T1GEM) |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 144 | ... ELSE IF "${techprofile}"=="1T4GEM" Set Tech Profile 1T4GEM ${INFRA_NAMESPACE} |
| 145 | ... ELSE IF "${techprofile}"=="1T8GEM" Set Tech Profile 1T8GEM ${INFRA_NAMESPACE} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 146 | ... ELSE Fail The TechProfile (${techprofile}) is not valid! |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 147 | # delete etcd MIB Template Data |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 148 | Delete MIB Template Data ${INFRA_NAMESPACE} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 149 | # delete etcd onu data |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 150 | Delete ONU Go Adapter ETCD Data namespace=${INFRA_NAMESPACE} validate=True |
TorstenThieme | 8adefc2 | 2022-03-01 12:36:19 +0000 | [diff] [blame] | 151 | # set ${kafka} depending on environment in case of port-forward is needed |
| 152 | ${rc} ${kafka}= Run Keyword If ${PORT_FORWARDING} Run and Return Rc and Output |
| 153 | ... kubectl get svc -n ${INFRA_NAMESPACE} | grep kafka-0-external | awk '{print $1}' |
| 154 | Run Keyword If ${PORT_FORWARDING} Should Not Be Empty ${kafka} Service kafka-0-external not found |
| 155 | # start port forwarding if needed (when voltha runs in k8s) |
| 156 | ${portFwdHandle} = Run Keyword If ${PORT_FORWARDING} Start Process |
| 157 | ... kubectl port-forward --address 0.0.0.0 --namespace default svc/${kafka} ${KAFKA_PORT}:${KAFKA_SVC_PORT} & |
| 158 | ... shell=true |
| 159 | Set Suite Variable ${portFwdHandle} |
| 160 | Sleep 5s |
| 161 | # open connection to read kafka bus |
| 162 | Wait Until Keyword Succeeds 3x 5s |
| 163 | ... kafka.Connection Open ${KAFKA_IP} ${KAFKA_PORT} voltha.events timestamp_from=0 |
Andrea Campanella | 82add37 | 2021-11-05 12:01:15 +0100 | [diff] [blame] | 164 | Run Keyword If ${logging} Collect Logs |
| 165 | Stop Logging Setup or Teardown Setup-${SUITE NAME} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 166 | |
| 167 | Teardown Suite |
| 168 | [Documentation] Replaces the Suite Teardown in utils.robot. |
| 169 | ... Cleans up and checks all ONU ports disabled in ONOS. |
| 170 | ... Furthermore gives the possibility to pause the execution. |
Andrea Campanella | 82add37 | 2021-11-05 12:01:15 +0100 | [diff] [blame] | 171 | Start Logging Setup or Teardown Teardown-${SUITE NAME} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 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 | Run Keyword If ${teardown_device} Delete All Devices and Verify |
TorstenThieme | 8adefc2 | 2022-03-01 12:36:19 +0000 | [diff] [blame] | 176 | # close connection to kafka |
| 177 | kafka.Connection Close |
| 178 | # stop port forwarding if started |
| 179 | Run Keyword If ${PORT_FORWARDING} Terminate Process ${portFwdHandle} kill=true |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 180 | Wait Until Keyword Succeeds ${timeout} 1s Validate Onu Data In Etcd ${INFRA_NAMESPACE} 0 ${kvstoreprefix} |
| 181 | ... without_pm_data=False |
TorstenThieme | 731a759 | 2021-07-01 14:26:54 +0000 | [diff] [blame] | 182 | Wait for Ports in ONOS for all OLTs ${ONOS_SSH_IP} ${ONOS_SSH_PORT} 0 BBSM ${timeout} |
Andrea Campanella | 82add37 | 2021-11-05 12:01:15 +0100 | [diff] [blame] | 183 | Run Keyword If ${logging} Collect Logs |
| 184 | Stop Logging Setup or Teardown Teardown-${SUITE NAME} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 185 | Close All ONOS SSH Connections |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 186 | Remove Tech Profile ${INFRA_NAMESPACE} |
TorstenThieme | 8adefc2 | 2022-03-01 12:36:19 +0000 | [diff] [blame] | 187 | |
| 188 | Validate Failed OMCI Communication All ONUs |
| 189 | [Documentation] Validates Failed OMCI communication Events per ONU |
| 190 | [Arguments] ${list_onu_device_id} |
| 191 | ${Kafka_Records}= kafka.Records Get voltha.events |
| 192 | ${RecordsLength}= Get Length ${Kafka_Records} |
| 193 | FOR ${Index} IN RANGE 0 ${RecordsLength} |
| 194 | ${metric}= Set Variable ${Kafka_Records[${Index}]} |
| 195 | ${message}= Get From Dictionary ${metric} message |
| 196 | ${event}= volthatools.Events Decode Event ${message} return_default=true |
| 197 | Continue For Loop If not 'device_event' in ${event} |
| 198 | ${event_name}= Get From Dictionary ${event['device_event']} device_event_name |
| 199 | Continue For Loop If "${event_name}" != "ONU_OMCI_COMMUNICATION_FAILURE_CONFIG" |
| 200 | ${resource_id}= Get From Dictionary ${event['device_event']} resource_id |
| 201 | Remove Values From List ${list_onu_device_id} ${resource_id} |
| 202 | END |
| 203 | Should Be Empty ${list_onu_device_id} Missing MIB Audits for ONUs ${list_onu_device_id}! |