blob: 99d5a621d45d6b0a1f51c14213fb9b1b48e62977 [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}
TorstenThieme373adfe2021-12-16 13:03:04 +0000113 [Teardown] Run Keywords Printout ONU Serial Number and Device Id print2console=${print2console}
114 ... AND Run Keyword If ${logging} Collect Logs
TorstenThieme53450ff2021-05-11 09:44:33 +0000115 ... AND Stop Logging ONUStateTest
116
117
118*** Keywords ***
119Setup Suite
120 [Documentation] Set up the test suite
Andrea Campanella82add372021-11-05 12:01:15 +0100121 Start Logging Setup or Teardown Setup-${SUITE NAME}
TorstenThieme53450ff2021-05-11 09:44:33 +0000122 ${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 Windlass4288c6a2021-09-28 07:22:06 +0000132 ... ELSE IF "${techprofile}"=="1T4GEM" Set Tech Profile 1T4GEM ${INFRA_NAMESPACE}
133 ... ELSE IF "${techprofile}"=="1T8GEM" Set Tech Profile 1T8GEM ${INFRA_NAMESPACE}
TorstenThieme53450ff2021-05-11 09:44:33 +0000134 ... ELSE Fail The TechProfile (${techprofile}) is not valid!
TorstenThieme53450ff2021-05-11 09:44:33 +0000135 # delete etcd MIB Template Data
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000136 Delete MIB Template Data ${INFRA_NAMESPACE}
TorstenThieme53450ff2021-05-11 09:44:33 +0000137 # delete etcd onu data
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000138 Delete ONU Go Adapter ETCD Data namespace=${INFRA_NAMESPACE} validate=True
TorstenThieme8adefc22022-03-01 12:36:19 +0000139 # 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 Campanella82add372021-11-05 12:01:15 +0100152 Run Keyword If ${logging} Collect Logs
153 Stop Logging Setup or Teardown Setup-${SUITE NAME}
TorstenThieme53450ff2021-05-11 09:44:33 +0000154
155Teardown 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 Campanella82add372021-11-05 12:01:15 +0100159 Start Logging Setup or Teardown Teardown-${SUITE NAME}
TorstenThieme53450ff2021-05-11 09:44:33 +0000160 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
TorstenThieme8adefc22022-03-01 12:36:19 +0000164 # 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 Windlass4288c6a2021-09-28 07:22:06 +0000168 Wait Until Keyword Succeeds ${timeout} 1s Validate Onu Data In Etcd ${INFRA_NAMESPACE} 0 ${kvstoreprefix}
169 ... without_pm_data=False
TorstenThieme731a7592021-07-01 14:26:54 +0000170 Wait for Ports in ONOS for all OLTs ${ONOS_SSH_IP} ${ONOS_SSH_PORT} 0 BBSM ${timeout}
Andrea Campanella82add372021-11-05 12:01:15 +0100171 Run Keyword If ${logging} Collect Logs
172 Stop Logging Setup or Teardown Teardown-${SUITE NAME}
TorstenThieme53450ff2021-05-11 09:44:33 +0000173 Close All ONOS SSH Connections
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000174 Remove Tech Profile ${INFRA_NAMESPACE}
TorstenThieme8adefc22022-03-01 12:36:19 +0000175
176Validate 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}!