TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 1 | # Copyright 2021 - 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 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 | 373adfe | 2021-12-16 13:03:04 +0000 | [diff] [blame] | 113 | [Teardown] Run Keywords Printout ONU Serial Number and Device Id print2console=${print2console} |
| 114 | ... AND Run Keyword If ${logging} Collect Logs |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 115 | ... AND Stop Logging ONUStateTest |
| 116 | |
| 117 | |
| 118 | *** Keywords *** |
| 119 | Setup Suite |
| 120 | [Documentation] Set up the test suite |
Andrea Campanella | 82add37 | 2021-11-05 12:01:15 +0100 | [diff] [blame] | 121 | Start Logging Setup or Teardown Setup-${SUITE NAME} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 122 | ${LogInfo}= Catenate |
| 123 | ... \r\nPassed arguments: |
| 124 | ... techprofile:${techprofile}, |
| 125 | ... debugmode:${debugmode}, logging:${logging}, pausebeforecleanup:${pausebeforecleanup}, |
| 126 | ... print2console:${print2console} |
| 127 | Log ${LogInfo} console=yes |
| 128 | Common Test Suite Setup |
| 129 | ${techprofile}= Set Variable If "${techprofile}"=="1T1GEM" default ${techprofile} |
| 130 | Set Suite Variable ${techprofile} |
| 131 | Run Keyword If "${techprofile}"=="default" Log To Console \nTechProfile:default (1T1GEM) |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 132 | ... ELSE IF "${techprofile}"=="1T4GEM" Set Tech Profile 1T4GEM ${INFRA_NAMESPACE} |
| 133 | ... ELSE IF "${techprofile}"=="1T8GEM" Set Tech Profile 1T8GEM ${INFRA_NAMESPACE} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 134 | ... ELSE Fail The TechProfile (${techprofile}) is not valid! |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 135 | # delete etcd MIB Template Data |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 136 | Delete MIB Template Data ${INFRA_NAMESPACE} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 137 | # delete etcd onu data |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 138 | Delete ONU Go Adapter ETCD Data namespace=${INFRA_NAMESPACE} validate=True |
TorstenThieme | 8adefc2 | 2022-03-01 12:36:19 +0000 | [diff] [blame] | 139 | # set ${kafka} depending on environment in case of port-forward is needed |
| 140 | ${rc} ${kafka}= Run Keyword If ${PORT_FORWARDING} Run and Return Rc and Output |
| 141 | ... kubectl get svc -n ${INFRA_NAMESPACE} | grep kafka-0-external | awk '{print $1}' |
| 142 | Run Keyword If ${PORT_FORWARDING} Should Not Be Empty ${kafka} Service kafka-0-external not found |
| 143 | # start port forwarding if needed (when voltha runs in k8s) |
| 144 | ${portFwdHandle} = Run Keyword If ${PORT_FORWARDING} Start Process |
| 145 | ... kubectl port-forward --address 0.0.0.0 --namespace default svc/${kafka} ${KAFKA_PORT}:${KAFKA_SVC_PORT} & |
| 146 | ... shell=true |
| 147 | Set Suite Variable ${portFwdHandle} |
| 148 | Sleep 5s |
| 149 | # open connection to read kafka bus |
| 150 | Wait Until Keyword Succeeds 3x 5s |
| 151 | ... kafka.Connection Open ${KAFKA_IP} ${KAFKA_PORT} voltha.events timestamp_from=0 |
Andrea Campanella | 82add37 | 2021-11-05 12:01:15 +0100 | [diff] [blame] | 152 | Run Keyword If ${logging} Collect Logs |
| 153 | Stop Logging Setup or Teardown Setup-${SUITE NAME} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 154 | |
| 155 | Teardown Suite |
| 156 | [Documentation] Replaces the Suite Teardown in utils.robot. |
| 157 | ... Cleans up and checks all ONU ports disabled in ONOS. |
| 158 | ... Furthermore gives the possibility to pause the execution. |
Andrea Campanella | 82add37 | 2021-11-05 12:01:15 +0100 | [diff] [blame] | 159 | Start Logging Setup or Teardown Teardown-${SUITE NAME} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 160 | Run Keyword If ${pausebeforecleanup} Import Library Dialogs |
| 161 | Run Keyword If ${pausebeforecleanup} Pause Execution Press OK to continue with clean up! |
| 162 | Run Keyword If ${pausebeforecleanup} Log Teardown will be continued... console=yes |
| 163 | Run Keyword If ${teardown_device} Delete All Devices and Verify |
TorstenThieme | 8adefc2 | 2022-03-01 12:36:19 +0000 | [diff] [blame] | 164 | # close connection to kafka |
| 165 | kafka.Connection Close |
| 166 | # stop port forwarding if started |
| 167 | Run Keyword If ${PORT_FORWARDING} Terminate Process ${portFwdHandle} kill=true |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 168 | Wait Until Keyword Succeeds ${timeout} 1s Validate Onu Data In Etcd ${INFRA_NAMESPACE} 0 ${kvstoreprefix} |
| 169 | ... without_pm_data=False |
TorstenThieme | 731a759 | 2021-07-01 14:26:54 +0000 | [diff] [blame] | 170 | 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] | 171 | Run Keyword If ${logging} Collect Logs |
| 172 | Stop Logging Setup or Teardown Teardown-${SUITE NAME} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 173 | Close All ONOS SSH Connections |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 174 | Remove Tech Profile ${INFRA_NAMESPACE} |
TorstenThieme | 8adefc2 | 2022-03-01 12:36:19 +0000 | [diff] [blame] | 175 | |
| 176 | Validate Failed OMCI Communication All ONUs |
| 177 | [Documentation] Validates Failed OMCI communication Events per ONU |
| 178 | [Arguments] ${list_onu_device_id} |
| 179 | ${Kafka_Records}= kafka.Records Get voltha.events |
| 180 | ${RecordsLength}= Get Length ${Kafka_Records} |
| 181 | FOR ${Index} IN RANGE 0 ${RecordsLength} |
| 182 | ${metric}= Set Variable ${Kafka_Records[${Index}]} |
| 183 | ${message}= Get From Dictionary ${metric} message |
| 184 | ${event}= volthatools.Events Decode Event ${message} return_default=true |
| 185 | Continue For Loop If not 'device_event' in ${event} |
| 186 | ${event_name}= Get From Dictionary ${event['device_event']} device_event_name |
| 187 | Continue For Loop If "${event_name}" != "ONU_OMCI_COMMUNICATION_FAILURE_CONFIG" |
| 188 | ${resource_id}= Get From Dictionary ${event['device_event']} resource_id |
| 189 | Remove Values From List ${list_onu_device_id} ${resource_id} |
| 190 | END |
| 191 | Should Be Empty ${list_onu_device_id} Missing MIB Audits for ONUs ${list_onu_device_id}! |