blob: 69fd82a71c472aa526d239514a3af954eb07c706 [file] [log] [blame]
TorstenThieme53450ff2021-05-11 09:44:33 +00001# 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 ***
16Documentation Negative test states of ONU Go adapter with ATT workflows only (not for DT/TT workflow!)
17Suite Setup Setup Suite
18Suite Teardown Teardown Suite
19Test Setup Setup
20Test Teardown Teardown
21Library Collections
22Library String
23Library OperatingSystem
24Library XML
25Library RequestsLibrary
26Library ../../libraries/DependencyLibrary.py
27Resource ../../libraries/onos.robot
28Resource ../../libraries/voltctl.robot
29Resource ../../libraries/voltha.robot
30Resource ../../libraries/utils.robot
31Resource ../../libraries/k8s.robot
32Resource ../../libraries/onu_utilities.robot
33Resource ../../libraries/bbsim.robot
34Resource ../../variables/variables.robot
35
TorstenThieme8adefc22022-03-01 12:36:19 +000036Library kafka_robot.KafkaClient log_level=DEBUG WITH NAME kafka
37Library grpc_robot.VolthaTools WITH NAME volthatools
38
TorstenThieme53450ff2021-05-11 09:44:33 +000039*** Variables ***
TorstenThieme8adefc22022-03-01 12:36:19 +000040${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
TorstenThieme53450ff2021-05-11 09:44:33 +000047${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 Campanella388cd872022-02-10 09:11:39 +010052# example: -v kvstoreprefix:voltha/voltha_voltha
53${kvstoreprefix} voltha/voltha_voltha
TorstenThieme53450ff2021-05-11 09:44:33 +000054# 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
TorstenThieme8adefc22022-03-01 12:36:19 +000057# 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
TorstenThieme53450ff2021-05-11 09:44:33 +000069# 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 Windlassb1bda362021-11-24 11:54:36 +000083# 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
TorstenThieme53450ff2021-05-11 09:44:33 +000088
89*** Test Cases ***
90ONU 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
TorstenThieme8adefc22022-03-01 12:36:19 +000097 ... AND kafka.Records Clear
TorstenThieme53450ff2021-05-11 09:44:33 +000098 ... 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
TorstenThieme8adefc22022-03-01 12:36:19 +0000109 ${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}
TorstenThieme517b7ce2022-12-19 11:56:34 +0000113 # 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
TorstenThieme373adfe2021-12-16 13:03:04 +0000125 [Teardown] Run Keywords Printout ONU Serial Number and Device Id print2console=${print2console}
126 ... AND Run Keyword If ${logging} Collect Logs
TorstenThieme53450ff2021-05-11 09:44:33 +0000127 ... AND Stop Logging ONUStateTest
128
129
130*** Keywords ***
131Setup Suite
132 [Documentation] Set up the test suite
Andrea Campanella82add372021-11-05 12:01:15 +0100133 Start Logging Setup or Teardown Setup-${SUITE NAME}
TorstenThieme53450ff2021-05-11 09:44:33 +0000134 ${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 Windlass4288c6a2021-09-28 07:22:06 +0000144 ... ELSE IF "${techprofile}"=="1T4GEM" Set Tech Profile 1T4GEM ${INFRA_NAMESPACE}
145 ... ELSE IF "${techprofile}"=="1T8GEM" Set Tech Profile 1T8GEM ${INFRA_NAMESPACE}
TorstenThieme53450ff2021-05-11 09:44:33 +0000146 ... ELSE Fail The TechProfile (${techprofile}) is not valid!
TorstenThieme53450ff2021-05-11 09:44:33 +0000147 # delete etcd MIB Template Data
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000148 Delete MIB Template Data ${INFRA_NAMESPACE}
TorstenThieme53450ff2021-05-11 09:44:33 +0000149 # delete etcd onu data
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000150 Delete ONU Go Adapter ETCD Data namespace=${INFRA_NAMESPACE} validate=True
TorstenThieme8adefc22022-03-01 12:36:19 +0000151 # 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 Campanella82add372021-11-05 12:01:15 +0100164 Run Keyword If ${logging} Collect Logs
165 Stop Logging Setup or Teardown Setup-${SUITE NAME}
TorstenThieme53450ff2021-05-11 09:44:33 +0000166
167Teardown 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 Campanella82add372021-11-05 12:01:15 +0100171 Start Logging Setup or Teardown Teardown-${SUITE NAME}
TorstenThieme53450ff2021-05-11 09:44:33 +0000172 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
TorstenThieme8adefc22022-03-01 12:36:19 +0000176 # 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 Windlass4288c6a2021-09-28 07:22:06 +0000180 Wait Until Keyword Succeeds ${timeout} 1s Validate Onu Data In Etcd ${INFRA_NAMESPACE} 0 ${kvstoreprefix}
181 ... without_pm_data=False
TorstenThieme731a7592021-07-01 14:26:54 +0000182 Wait for Ports in ONOS for all OLTs ${ONOS_SSH_IP} ${ONOS_SSH_PORT} 0 BBSM ${timeout}
Andrea Campanella82add372021-11-05 12:01:15 +0100183 Run Keyword If ${logging} Collect Logs
184 Stop Logging Setup or Teardown Teardown-${SUITE NAME}
TorstenThieme53450ff2021-05-11 09:44:33 +0000185 Close All ONOS SSH Connections
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000186 Remove Tech Profile ${INFRA_NAMESPACE}
TorstenThieme8adefc22022-03-01 12:36:19 +0000187
188Validate 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}!