blob: bcc15b2f45c4dc53ebb97a30d94366f1b2b05a64 [file] [log] [blame]
Kailash6f5acb62019-08-28 14:38:45 -07001# Copyright 2017-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.
Kailash6f5acb62019-08-28 14:38:45 -070014# voltctl common functions
15
16*** Settings ***
17Documentation Library for various utilities
18Library SSHLibrary
Kailash6f5acb62019-08-28 14:38:45 -070019Library String
20Library DateTime
21Library Process
22Library Collections
23Library RequestsLibrary
24Library OperatingSystem
Matteo Scandolo142e6272020-04-29 17:36:59 -070025Resource ./utils.robot
Matteo Scandoloeb26a842020-05-08 10:06:24 -070026Resource ./flows.robot
Kailash6f5acb62019-08-28 14:38:45 -070027
28*** Keywords ***
Gilles Depatieb5682f82019-10-31 10:39:45 -040029Test Empty Device List
Zack Williamsa8fe75a2020-01-10 14:25:27 -070030 [Documentation] Verify that there are no devices in the system
Matteo Scandolo5899be12020-11-11 15:38:07 -080031 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -040032 Should Be Equal As Integers ${rc} 0
33 ${jsondata}= To Json ${output}
34 Log ${jsondata}
35 ${length}= Get Length ${jsondata}
David Bainbridgef81cd642019-11-20 00:14:47 +000036 Should Be Equal As Integers ${length} 0
Gilles Depatieb5682f82019-10-31 10:39:45 -040037
Kailash6f5acb62019-08-28 14:38:45 -070038Create Device
Matteo Scandolo142e6272020-04-29 17:36:59 -070039 [Arguments] ${ip} ${port} ${type}=openolt
You Wang2b550642019-10-07 14:39:48 -070040 [Documentation] Creates a device in VOLTHA
Kailash6f5acb62019-08-28 14:38:45 -070041 #create/preprovision device
Gilles Depatie675a2062019-10-22 12:44:42 -040042 ${rc} ${device_id}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080043 ... voltctl -c ${VOLTCTL_CONFIG} device create -t ${type} -H ${ip}:${port}
44 Log ${device_id}
Kailash6f5acb62019-08-28 14:38:45 -070045 Should Be Equal As Integers ${rc} 0
46 [Return] ${device_id}
47
48Enable Device
49 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -070050 [Documentation] Enables a device in VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -070051 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080052 ... voltctl -c ${VOLTCTL_CONFIG} device enable ${device_id}
Kailash6f5acb62019-08-28 14:38:45 -070053 Should Be Equal As Integers ${rc} 0
54
Suchitra Vemuri6db89412019-11-14 14:52:54 -080055Disable Device
56 [Arguments] ${device_id}
Hardik Windlassaaea3402020-03-10 19:45:45 +053057 [Documentation] Disables a device in VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -070058 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080059 ... voltctl -c ${VOLTCTL_CONFIG} device disable ${device_id}
Suchitra Vemuri6db89412019-11-14 14:52:54 -080060 Should Be Equal As Integers ${rc} 0
61
Hardik Windlassaaea3402020-03-10 19:45:45 +053062Delete Device
63 [Arguments] ${device_id}
64 [Documentation] Deletes a device in VOLTHA
65 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080066 ... voltctl -c ${VOLTCTL_CONFIG} device delete ${device_id}
Hardik Windlassaaea3402020-03-10 19:45:45 +053067 Should Be Equal As Integers ${rc} 0
68
Hemadf003682020-04-28 21:22:22 +053069Reboot Device
70 [Arguments] ${device_id}
71 [Documentation] Reboot the OLT using voltctl command
72 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080073 ... voltctl -c ${VOLTCTL_CONFIG} device reboot ${device_id}
Hemadf003682020-04-28 21:22:22 +053074 Should Be Equal As Integers ${rc} 0
75
David Bainbridgef81cd642019-11-20 00:14:47 +000076Disable Devices In Voltha
77 [Documentation] Disables all the known devices in voltha
78 [Arguments] ${filter}
79 ${arg}= Set Variable ${EMPTY}
80 ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070081 ${rc} ${devices}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080082 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB ${arg} --orderby Root -q | xargs echo -n
David Bainbridgef81cd642019-11-20 00:14:47 +000083 Should Be Equal As Integers ${rc} 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -070084 ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080085 ... voltctl -c ${VOLTCTL_CONFIG} device disable ${devices}
David Bainbridgef81cd642019-11-20 00:14:47 +000086 Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0
87
88Test Devices Disabled In Voltha
89 [Documentation] Tests to verify that all devices in VOLTHA are disabled
90 [Arguments] ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070091 ${rc} ${count}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080092 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB --filter '${filter},AdminState!=DISABLED' -q | wc -l
David Bainbridgef81cd642019-11-20 00:14:47 +000093 Should Be Equal As Integers ${rc} 0
94 Should Be Equal As Integers ${count} 0
95
96Delete Devices In Voltha
97 [Documentation] Disables all the known devices in voltha
98 [Arguments] ${filter}
99 ${arg}= Set Variable ${EMPTY}
100 ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700101 ${rc} ${devices}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800102 ... voltctl -c ${VOLTCTL_CONFIG} device list ${arg} -m 8MB --orderby Root -q | xargs echo -n
David Bainbridgef81cd642019-11-20 00:14:47 +0000103 Should Be Equal As Integers ${rc} 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700104 ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800105 ... voltctl -c ${VOLTCTL_CONFIG} device delete ${devices}
David Bainbridgef81cd642019-11-20 00:14:47 +0000106 Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0
107
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700108Get Device Flows from Voltha
109 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700110 [Documentation] Gets device flows from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700111 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800112 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m 8MB
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700113 Should Be Equal As Integers ${rc} 0
114 [Return] ${output}
115
116Get Logical Device Output from Voltha
117 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700118 [Documentation] Gets logicaldevice flows and ports from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700119 ${rc1} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800120 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice flows ${device_id}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700121 ${rc2} ${ports}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800122 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice port list ${device_id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700123 Log ${flows}
124 Log ${ports}
125 Should Be Equal As Integers ${rc1} 0
126 Should Be Equal As Integers ${rc2} 0
127
128Get Device Output from Voltha
129 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700130 [Documentation] Gets device flows and ports from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700131 ${rc1} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800132 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m 8MB
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700133 ${rc2} ${ports}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800134 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${device_id} -m 8MB
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700135 Log ${flows}
136 Log ${ports}
137 Should Be Equal As Integers ${rc1} 0
138 Should Be Equal As Integers ${rc2} 0
139
Suchitra Vemuri1a970a62019-11-26 12:52:16 -0800140Get Device List from Voltha
141 [Documentation] Gets Device List Output from Voltha
Matteo Scandolo5899be12020-11-11 15:38:07 -0800142 ${rc1} ${devices}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB
Suchitra Vemuri1a970a62019-11-26 12:52:16 -0800143 Log ${devices}
144 Should Be Equal As Integers ${rc1} 0
145
Matteo Scandolo616daab2020-05-13 11:49:24 -0700146Get Device List from Voltha by type
147 [Documentation] Gets Device List Output from Voltha applying filtering by device type
148 [Arguments] ${type}
149 ${rc1} ${devices}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800150 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -f Type=${type} -o json
Matteo Scandolo616daab2020-05-13 11:49:24 -0700151 Log ${devices}
152 Should Be Equal As Integers ${rc1} 0
153 Return From Keyword ${devices}
154
Matteo Scandolo142e6272020-04-29 17:36:59 -0700155Get Logical Device List from Voltha
156 [Documentation] Gets Logical Device List Output from Voltha (in json format)
Andrea Campanella80655eb2020-07-10 15:49:22 +0200157 ${rc1} ${devices}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800158 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice list -m 8MB -o json
Matteo Scandolo142e6272020-04-29 17:36:59 -0700159 Log ${devices}
160 Should Be Equal As Integers ${rc1} 0
161 Return From Keyword ${devices}
162
Kailash6f5acb62019-08-28 14:38:45 -0700163Validate Device
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700164 [Documentation]
ubuntu6b6e7d42020-03-02 12:35:42 -0800165 ... Parses the output of "voltctl device list" and inspects a device ${id}, specified as either
166 ... the serial number or device ID. Arguments are matched for device states of: "admin_state",
167 ... "oper_status", and "connect_status"
168 [Arguments] ${admin_state} ${oper_status} ${connect_status}
169 ... ${id}=${EMPTY} ${onu_reason}=${EMPTY} ${onu}=False
Matteo Scandolo5899be12020-11-11 15:38:07 -0800170 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400171 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700172 ${jsondata}= To Json ${output}
Kailash6f5acb62019-08-28 14:38:45 -0700173 ${length}= Get Length ${jsondata}
ubuntu6b6e7d42020-03-02 12:35:42 -0800174 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700175 FOR ${INDEX} IN RANGE 0 ${length}
176 ${value}= Get From List ${jsondata} ${INDEX}
Scott Baker780b65f2020-05-22 14:03:15 -0700177 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
178 ... Dictionary Should Contain Key ${value} adminState
179 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
180 ... Get From Dictionary ${value} adminState
181 ... ELSE
182 ... Get From Dictionary ${value} adminstate
183 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
184 ... Get From Dictionary ${value} operStatus
185 ... ELSE
186 ... Get From Dictionary ${value} operstatus
187 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
188 ... Get From Dictionary ${value} connectStatus
189 ... ELSE
190 ... Get From Dictionary ${value} connectstatus
191 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
192 ... Get From Dictionary ${value} serialNumber
193 ... ELSE
194 ... Get From Dictionary ${value} serialnumber
Gilles Depatieb5682f82019-10-31 10:39:45 -0400195 ${devId}= Get From Dictionary ${value} id
Zack Williamsec53a1b2019-09-16 15:50:52 -0700196 ${mib_state}= Get From Dictionary ${value} reason
ubuntu6b6e7d42020-03-02 12:35:42 -0800197 ${matched}= Set Variable If '${sn}' == '${id}' or '${devId}' == '${id}' True False
Andy Bavierb63f6d22020-03-12 15:34:37 -0700198 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700199 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700200 Should Be True ${matched} No match found for ${id} to validate device
Matteo Scandolo5e10b282019-11-25 10:54:32 -0700201 Log ${value}
ubuntu6b6e7d42020-03-02 12:35:42 -0800202 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
Gilles Depatie675a2062019-10-22 12:44:42 -0400203 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800204 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400205 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800206 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400207 ... values=False
Matteo Scandolo74bd5c32020-12-08 09:52:19 -0800208 Run Keyword If '${onu}' == 'True' Should Contain '${onu_reason}' '${mib_state}'
ubuntu6b6e7d42020-03-02 12:35:42 -0800209 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400210
211Validate OLT Device
ubuntu6b6e7d42020-03-02 12:35:42 -0800212 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${id}=${EMPTY}
213 [Documentation] Parses the output of "voltctl device list" and inspects device ${id}, specified
214 ... as either its serial numbner or device ID. Match on OLT Serial number or Device Id and inspect states
215 Validate Device ${admin_state} ${oper_status} ${connect_status} ${id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400216
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800217Validate OLT Devices
218 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${ids}=${EMPTY}
219 [Documentation] Parses the output of "voltctl device list" and inspects device ${id}, specified
220 ... as either its serial numbner or device ID. Match on OLT Serial number or Device Id and inspect states
221 FOR ${I} IN RANGE 0 ${olt_count}
222 ${olt_serial_number}= Get From Dictionary ${olt_ids}[${I}] sn
223 ${olt_device_id}= Get OLTDeviceID From OLT List ${olt_serial_number}
224 Validate Device ${admin_state} ${oper_status} ${connect_status} ${olt_device_id}
225 END
226
Gilles Depatieb5682f82019-10-31 10:39:45 -0400227Validate ONU Devices
228 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${List_ONU_Serial}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700229 ... ${onu_reason}=omci-flows-pushed
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700230 [Documentation] Parses the output of "voltctl device list" and inspects device ${List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400231 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
232 ... states including MIB state
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700233 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400234 Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700235 ... onu_reason=${onu_reason} onu=True
Debasish28130d02020-03-16 11:05:26 +0000236 END
237
Gilles Depatieb5682f82019-10-31 10:39:45 -0400238Validate Device Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700239 [Documentation]
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800240 ... Parses the output of voltctl device port list <device_id> and matches the port types listed
Andy Bavier90eb1a12020-03-26 11:54:35 -0700241 [Arguments] ${device_id} ${pon_type} ${ethernet_type} ${all_active}=True
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700242 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800243 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${device_id} -m 8MB -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400244 Should Be Equal As Integers ${rc} 0
245 ${jsondata}= To Json ${output}
246 Log ${jsondata}
247 ${length}= Get Length ${jsondata}
248 FOR ${INDEX} IN RANGE 0 ${length}
249 ${value}= Get From List ${jsondata} ${INDEX}
Scott Baker780b65f2020-05-22 14:03:15 -0700250 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
251 ... Dictionary Should Contain Key ${value} adminState
252 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
Hardik Windlass2b37e712020-06-12 02:13:17 +0530253 ... Get From Dictionary ${value} adminState
Scott Baker780b65f2020-05-22 14:03:15 -0700254 ... ELSE
Hardik Windlass2b37e712020-06-12 02:13:17 +0530255 ... Get From Dictionary ${value} adminstate
Scott Baker780b65f2020-05-22 14:03:15 -0700256 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
257 ... Get From Dictionary ${value} operStatus
258 ... ELSE
Hardik Windlass2b37e712020-06-12 02:13:17 +0530259 ... Get From Dictionary ${value} operstatus
Gilles Depatieb5682f82019-10-31 10:39:45 -0400260 ${type}= Get From Dictionary ${value} type
Hemaf64d34c2020-03-25 00:40:17 +0530261 Should Be Equal '${astate}' 'ENABLED' Device ${device_id} port admin_state != ENABLED values=False
Andy Bavier90eb1a12020-03-26 11:54:35 -0700262 Run Keyword If ${all_active} Should Be Equal '${opstatus}' 'ACTIVE'
263 ... Device ${device_id} port oper_status != ACTIVE values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400264 Should Be True '${type}' == '${pon_type}' or '${type}' == '${ethernet_type}'
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700265 ... Device ${device_id} port type is neither ${pon_type} or ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400266 END
267
268Validate OLT Port Types
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800269 [Documentation] Parses the output of voltctl device port list ${olt_device_id} and matches the port types listed
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700270 [Arguments] ${pon_type} ${ethernet_type}
271 Validate Device Port Types ${olt_device_id} ${pon_type} ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400272
273Validate ONU Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700274 [Arguments] ${List_ONU_Serial} ${pon_type} ${ethernet_type}
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800275 [Documentation] Parses the output of voltctl device port list for each ONU SN listed in ${List_ONU_Serial}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700276 ... and matches the port types listed
Gilles Depatieb5682f82019-10-31 10:39:45 -0400277 FOR ${serial_number} IN @{List_ONU_Serial}
278 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Andy Bavier90eb1a12020-03-26 11:54:35 -0700279 # Only first UNI port is ACTIVE; the rest are in DISCOVERED operstatus
280 Validate Device Port Types ${onu_dev_id} ${pon_type} ${ethernet_type} all_active=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400281 END
282
283Validate Device Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000284 [Arguments] ${device_id} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400285 [Documentation] Parses the output of voltctl device flows <device_id> and expects flow count > 0
Andrea Campanella80655eb2020-07-10 15:49:22 +0200286 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800287 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m 8MB -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400288 Should Be Equal As Integers ${rc} 0
289 ${jsondata}= To Json ${output}
290 Log ${jsondata}
291 ${length}= Get Length ${jsondata}
292 Log 'Number of flows = ' ${length}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000293 Run Keyword If '${flow_count}' == '${EMPTY}' Should Be True ${length} > 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400294 ... Number of flows for ${device_id} was 0
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000295 ... ELSE Should Be True ${length} == ${flow_count}
296 ... Number of flows for ${device_id} was not ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400297
298Validate OLT Flows
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800299 [Arguments] ${flow_count}=${EMPTY} ${olt_device_id}=${EMPTY}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000300 [Documentation] Parses the output of voltctl device flows ${olt_device_id}
301 ... and expects flow count == ${flow_count}
302 Validate Device Flows ${olt_device_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400303
304Validate ONU Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000305 [Arguments] ${List_ONU_Serial} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400306 [Documentation] Parses the output of voltctl device flows for each ONU SN listed in ${List_ONU_Serial}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000307 ... and expects flow count == ${flow_count}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700308 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400309 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000310 Validate Device Flows ${onu_dev_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400311 END
312
TorstenThieme401af432020-06-11 15:53:53 +0000313Validate ONU Devices With Duration
314 [Documentation]
315 ... Parses the output of "voltctl device list" and inspects all devices ${List_ONU_Serial},
316 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
317 ... states including MIB state.
318 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${onu_reason}
319 ... ${List_ONU_Serial} ${startTime} ${print2console}=False ${output_file}=${EMPTY}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000320 ... ${alternate_reason}=${EMPTY}
Matteo Scandolo5899be12020-11-11 15:38:07 -0800321 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -o json
TorstenThieme401af432020-06-11 15:53:53 +0000322 Should Be Equal As Integers ${rc} 0
323 ${timeCurrent} = Get Current Date
324 ${timeTotalMs} = Subtract Date From Date ${timeCurrent} ${startTime} result_format=number
325 ${jsondata}= To Json ${output}
326 ${length}= Get Length ${jsondata}
327 FOR ${INDEX} IN RANGE 0 ${length}
328 ${matched}= Set Variable False
329 ${value}= Get From List ${jsondata} ${INDEX}
330 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
331 ... Dictionary Should Contain Key ${value} adminState
332 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
333 ... Get From Dictionary ${value} adminState
334 ... ELSE
335 ... Get From Dictionary ${value} adminstate
336 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
337 ... Get From Dictionary ${value} operStatus
338 ... ELSE
339 ... Get From Dictionary ${value} operstatus
340 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
341 ... Get From Dictionary ${value} connectStatus
342 ... ELSE
343 ... Get From Dictionary ${value} connectstatus
344 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
345 ... Get From Dictionary ${value} serialNumber
346 ... ELSE
347 ... Get From Dictionary ${value} serialnumber
348 ${mib_state}= Get From Dictionary ${value} reason
349 ${onu_id}= Get Index From List ${List_ONU_Serial} ${sn}
350 ${matched}= Set Variable If -1 != ${onu_id} True False
351 ${matched}= Set Variable If '${astate}' == '${admin_state}' ${matched} False
352 ${matched}= Set Variable If '${opstatus}' == '${oper_status}' ${matched} False
353 ${matched}= Set Variable If '${cstatus}' == '${connect_status}' ${matched} False
TorstenThiemec3c23232021-01-13 13:06:31 +0000354 ${len}= Get Length ${alternate_reason}
355 ${matches}= Run Keyword If ${len} >= 1 Get Match Count ${alternate_reason} ${mib_state}
356 ... ELSE Set Variable 1
357 #${matched}= Set Variable If '${mib_state}' == '${onu_reason}' or '${mib_state}' == '${alternate_reason}'
358 ${matched}= Set Variable If '${mib_state}' == '${onu_reason}' or ${matches} >= 1
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000359 ... ${matched} False
TorstenThieme401af432020-06-11 15:53:53 +0000360 Run Keyword If ${matched} and ${print2console} Log
361 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec. console=yes
362 Run Keyword If ${matched} and ('${output_file}'!='${EMPTY}') Append To File ${output_file}
363 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec.
364 Run Keyword If ${matched} Remove Values From List ${List_ONU_Serial} ${sn}
365 END
366 Should Be Empty ${List_ONU_Serial} List ${List_ONU_Serial} not empty
367
TorstenThieme9949b172020-06-16 10:00:15 +0000368Validate ONU Devices MIB State With Duration
369 [Documentation]
370 ... Parses the output of "voltctl device list" and inspects all devices ${List_ONU_Serial},
371 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect MIB state.
372 [Arguments] ${onu_reason}
373 ... ${List_ONU_Serial} ${startTime} ${print2console}=False ${output_file}=${EMPTY}
374 ${type} = Set Variable brcm_openomci_onu
Andrea Campanella80655eb2020-07-10 15:49:22 +0200375 ${voltctl_commad} = Catenate SEPARATOR=
376 ... voltctl device list -m 8MB -f Type=${type} -f Reason=${onu_reason} --format '{{.SerialNumber}}'
377 ${rc} ${output}= Run and Return Rc and Output ${voltctl_commad}
TorstenThieme9949b172020-06-16 10:00:15 +0000378 Should Be Equal As Integers ${rc} 0
379 ${timeCurrent} = Get Current Date
380 ${timeTotalMs} = Subtract Date From Date ${timeCurrent} ${startTime} result_format=number
381 @{outputdata} = Split String ${output}
382 ${outputlength} = Get Length ${outputdata}
383 ${onulength} = Get Length ${List_ONU_Serial}
384 ${Matches} = Run Keyword If ${outputlength}<=${onulength}
385 ... Compare Lists ${outputdata} ${List_ONU_Serial}
386 ... ELSE Compare Lists ${List_ONU_Serial} ${outputdata}
387 ${length} = Get Length ${Matches}
388 FOR ${INDEX} IN RANGE 0 ${length}
389 ${sn}= Get From List ${Matches} ${INDEX}
390 Run Keyword If ${print2console} Log
391 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec. console=yes
392 Run Keyword If ('${output_file}'!='${EMPTY}') Append To File ${output_file}
393 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec.
394 Remove Values From List ${List_ONU_Serial} ${sn}
395 END
396 Should Be Empty ${List_ONU_Serial} List ${List_ONU_Serial} not empty
397
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000398Validate ONU Device By Device Id
399 [Documentation]
400 ... Parses the output of "voltctl device list" filtered by device id and inspects states including reason.
401 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${onu_reason} ${onu_id}
Matteo Scandolo5899be12020-11-11 15:38:07 -0800402 ${cmd} Catenate voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${onu_id} -m 8MB -o json
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000403 ${rc} ${output}= Run and Return Rc and Output ${cmd}
404 Should Be Equal As Integers ${rc} 0
405 ${jsondata}= To Json ${output}
406 ${length}= Get Length ${jsondata}
407 Should Be Equal As Integers ${length} 1 No match found for ${onu_id} to validate device
408 ${value}= Get From List ${jsondata} 0
409 Log ${value}
410 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
411 ... Dictionary Should Contain Key ${value} adminState
412 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
413 ... Get From Dictionary ${value} adminState
414 ... ELSE
415 ... Get From Dictionary ${value} adminstate
416 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
417 ... Get From Dictionary ${value} operStatus
418 ... ELSE
419 ... Get From Dictionary ${value} operstatus
420 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
421 ... Get From Dictionary ${value} connectStatus
422 ... ELSE
423 ... Get From Dictionary ${value} connectstatus
424 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
425 ... Get From Dictionary ${value} serialNumber
426 ... ELSE
427 ... Get From Dictionary ${value} serialnumber
428 ${devId}= Get From Dictionary ${value} id
429 ${mib_state}= Get From Dictionary ${value} reason
430 Should Be Equal '${devId}' '${onu_id}' No match found for ${onu_id} to validate device
431 ... values=False
432 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
433 ... values=False
434 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
435 ... values=False
436 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
437 ... values=False
438 Should Be Equal '${mib_state}' '${onu_reason}'
439 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
440
441
TorstenThieme9949b172020-06-16 10:00:15 +0000442Compare Lists
443 [Documentation]
444 ... Compares both lists and put all matches in the returned list
445 [Arguments] ${ListIterate} ${ListCompare}
446 @{list} = Create List
447 ${length} = Get Length ${ListIterate}
448 FOR ${INDEX} IN RANGE 0 ${length}
449 ${sn}= Get From List ${ListIterate} ${INDEX}
450 ${onu_id}= Get Index From List ${ListCompare} ${sn}
451 Run Keyword If -1 != ${onu_id} Append To List ${list} ${sn}
452 END
453 [Return] ${list}
454
Gilles Depatieb5682f82019-10-31 10:39:45 -0400455Validate Logical Device
456 [Documentation] Validate Logical Device is listed
Matteo Scandolo5899be12020-11-11 15:38:07 -0800457 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} logicaldevice list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400458 Should Be Equal As Integers ${rc} 0
459 ${jsondata}= To Json ${output}
460 Log ${jsondata}
461 ${length}= Get Length ${jsondata}
462 FOR ${INDEX} IN RANGE 0 ${length}
463 ${value}= Get From List ${jsondata} ${INDEX}
464 ${devid}= Get From Dictionary ${value} id
Scott Baker2ab2a0c2020-06-05 12:51:47 -0700465 ${rootdev}= Get From Dictionary ${value} rootDeviceId
466 ${desc}= Get From Dictionary ${value} desc
467 ${sn}= Get From Dictionary ${desc} serialNum
Gilles Depatieb5682f82019-10-31 10:39:45 -0400468 Exit For Loop
469 END
470 Should Be Equal '${rootdev}' '${olt_device_id}' Root Device does not match ${olt_device_id} values=False
471 Should Be Equal '${sn}' '${BBSIM_OLT_SN}' Logical Device ${sn} does not match ${BBSIM_OLT_SN}
472 ... values=False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700473 [Return] ${devid}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400474
475Validate Logical Device Ports
476 [Arguments] ${logical_device_id}
477 [Documentation] Validate Logical Device Ports are listed and are > 0
478 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800479 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice port list ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400480 Should Be Equal As Integers ${rc} 0
481 ${jsondata}= To Json ${output}
482 Log ${jsondata}
483 ${length}= Get Length ${jsondata}
484 Should Be True ${length} > 0 Number of ports for ${logical_device_id} was 0
485
486Validate Logical Device Flows
487 [Arguments] ${logical_device_id}
488 [Documentation] Validate Logical Device Flows are listed and are > 0
489 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800490 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice flows ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400491 Should Be Equal As Integers ${rc} 0
492 ${jsondata}= To Json ${output}
493 Log ${jsondata}
494 ${length}= Get Length ${jsondata}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700495 Should Be True ${length} > 0 Number of flows for ${logical_device_id} was 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400496
Hardik Windlass16cdf962020-04-29 15:26:50 +0530497Retrieve OLT PON Ports
498 [Arguments] ${olt_device_id}
499 [Documentation] Retrieves the list of PON ports from the OLT device
500 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800501 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530502 Should Be Equal As Integers ${rc} 0
503 ${jsondata}= To Json ${output}
504 Log ${jsondata}
505 ${length}= Get Length ${jsondata}
506 ${olt_pon_list}= Create List
507 FOR ${INDEX} IN RANGE 0 ${length}
508 ${value}= Get From List ${jsondata} ${INDEX}
509 ${type}= Get From Dictionary ${value} type
510 ${portno}= Get From Dictionary ${value} portNo
511 ${peers}= Get From Dictionary ${value} peers
512 ${len_peers}= Get Length ${peers}
513 Run Keyword If '${type}' == 'PON_OLT' and ${len_peers} > 0
514 ... Append To List ${olt_pon_list} ${portno}
515 END
516 [Return] ${olt_pon_list}
517
518Retrieve Peer List From OLT PON Port
519 [Arguments] ${olt_device_id} ${pon_port}
520 [Documentation] Retrieves the list of peer device ids list from the OLT PON port
521 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800522 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530523 Should Be Equal As Integers ${rc} 0
524 ${jsondata}= To Json ${output}
525 Log ${jsondata}
526 ${length}= Get Length ${jsondata}
527 ${matched}= Set Variable False
528 FOR ${INDEX} IN RANGE 0 ${length}
529 ${value}= Get From List ${jsondata} ${INDEX}
530 ${type}= Get From Dictionary ${value} type
531 ${portno}= Get From Dictionary ${value} portNo
532 ${peers}= Get From Dictionary ${value} peers
533 ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
534 Exit For Loop If ${matched}
535 END
536 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
537 ${length}= Get Length ${peers}
538 ${olt_peer_list}= Create List
539 FOR ${INDEX} IN RANGE 0 ${length}
540 ${value}= Get From List ${peers} ${INDEX}
541 ${peer_id}= Get From Dictionary ${value} deviceId
542 Append To List ${olt_peer_list} ${peer_id}
543 END
544 [Return] ${olt_peer_list}
545
546Validate OLT PON Port Status
547 [Arguments] ${olt_device_id} ${pon_port} ${admin_state} ${oper_status}
548 [Documentation] Verifies the state of the PON port of the OLT
549 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800550 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530551 Should Be Equal As Integers ${rc} 0
552 ${jsondata}= To Json ${output}
553 Log ${jsondata}
554 ${length}= Get Length ${jsondata}
555 ${matched}= Set Variable False
556 FOR ${INDEX} IN RANGE 0 ${length}
557 ${value}= Get From List ${jsondata} ${INDEX}
558 ${type}= Get From Dictionary ${value} type
559 ${portno}= Get From Dictionary ${value} portNo
560 ${astate}= Get From Dictionary ${value} adminState
561 ${opstatus}= Get From Dictionary ${value} operStatus
562 ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
563 Exit For Loop If ${matched}
564 END
565 Should Be True ${matched} No PON port found for OLT ${olt_device_id} ${pon_port}
566 Log ${value}
567 Should Be Equal '${astate}' '${admin_state}' OLT PON Port admin_state != ${admin_state}
568 ... values=False
569 Should Be Equal '${opstatus}' '${oper_status}' OLT PON Port oper_status != ${oper_status}
570 ... values=False
571
572DisableOrEnable OLT PON Port
573 [Arguments] ${operation} ${olt_device_id} ${portno}
574 [Documentation] Disables or Enables the PON port of the OLT
575 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800576 ... voltctl -c ${VOLTCTL_CONFIG} device port ${operation} ${olt_device_id} ${portno}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530577 Should Be Equal As Integers ${rc} 0
578
Gilles Depatieb5682f82019-10-31 10:39:45 -0400579Retrieve Peer List From OLT
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700580 [Arguments] ${olt_peer_list}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400581 [Documentation] Retrieve the list of peer device id list from port list
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700582 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800583 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400584 Should Be Equal As Integers ${rc} 0
585 ${jsondata}= To Json ${output}
586 Log ${jsondata}
587 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700588 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400589 FOR ${INDEX} IN RANGE 0 ${length}
590 ${value}= Get From List ${jsondata} ${INDEX}
591 ${type}= Get From Dictionary ${value} type
592 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700593 ${matched}= Set Variable If '${type}' == 'PON_OLT' True False
594 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400595 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700596 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400597 ${length}= Get Length ${peers}
598 FOR ${INDEX} IN RANGE 0 ${length}
599 ${value}= Get From List ${peers} ${INDEX}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530600 ${peer_id}= Get From Dictionary ${value} deviceId
Gilles Depatieb5682f82019-10-31 10:39:45 -0400601 Append To List ${olt_peer_list} ${peer_id}
602 END
603
604Validate OLT Peer Id List
605 [Arguments] ${olt_peer_id_list}
606 [Documentation] Match each entry in the ${olt_peer_id_list} against ONU device ids.
607 FOR ${peer_id} IN @{olt_peer_id_list}
608 Match OLT Peer Id ${peer_id}
609 END
610
611Match OLT Peer Id
612 [Arguments] ${olt_peer_id}
613 [Documentation] Lookup the OLT Peer Id in against the list of ONU device Ids
Matteo Scandolo5899be12020-11-11 15:38:07 -0800614 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400615 Should Be Equal As Integers ${rc} 0
616 ${jsondata}= To Json ${output}
617 Log ${jsondata}
618 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700619 ${matched}= Set Variable False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700620 FOR ${INDEX} IN RANGE 0 ${length}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400621 ${value}= Get From List ${jsondata} ${INDEX}
622 ${devid}= Get From Dictionary ${value} id
Andy Bavierb63f6d22020-03-12 15:34:37 -0700623 ${matched}= Set Variable If '${devid}' == '${olt_peer_id}' True False
624 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400625 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700626 Should Be True ${matched} Peer id ${olt_peer_id} does not match any ONU device id
Gilles Depatieb5682f82019-10-31 10:39:45 -0400627
628Validate ONU Peer Id
629 [Arguments] ${olt_device_id} ${List_ONU_Serial}
630 [Documentation] Match each ONU peer to that of the OLT device id
631 FOR ${onu_serial} IN @{List_ONU_Serial}
632 ${onu_dev_id}= Get Device ID From SN ${onu_serial}
633 Match ONU Peer Id ${onu_dev_id}
634 END
635
636Match ONU Peer Id
637 [Arguments] ${onu_dev_id}
638 [Documentation] Match an ONU peer to that of the OLT device id
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800639 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800640 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${onu_dev_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400641 Should Be Equal As Integers ${rc} 0
642 ${jsondata}= To Json ${output}
643 Log ${jsondata}
644 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700645 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400646 FOR ${INDEX} IN RANGE 0 ${length}
647 ${value}= Get From List ${jsondata} ${INDEX}
648 ${type}= Get From Dictionary ${value} type
649 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700650 ${matched}= Set Variable If '${type}' == 'PON_ONU' True False
651 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400652 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700653 Should Be True ${matched} No PON port found for ONU ${onu_dev_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400654 ${length}= Get Length ${peers}
655 FOR ${INDEX} IN RANGE 0 ${length}
656 ${value}= Get From List ${peers} ${INDEX}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530657 ${peer_id}= Get From Dictionary ${value} deviceId
Gilles Depatieb5682f82019-10-31 10:39:45 -0400658 END
659 Should Be Equal '${peer_id}' '${olt_device_id}'
660 ... Mismatch between ONU peer ${peer_id} and OLT device id ${olt_device_id} values=False
Kailash6f5acb62019-08-28 14:38:45 -0700661
Kailash6f5acb62019-08-28 14:38:45 -0700662Get Device ID From SN
663 [Arguments] ${serial_number}
664 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700665 ${rc} ${id}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800666 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=SerialNumber=${serial_number} --format='{{.Id}}'
Andy Bavier8fca0452019-12-16 15:30:11 -0700667 Should Be Equal As Integers ${rc} 0
668 Log ${id}
Kailash6f5acb62019-08-28 14:38:45 -0700669 [Return] ${id}
670
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700671Get Logical Device ID From SN
672 [Arguments] ${serial_number}
673 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700674 ${rc} ${id}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800675 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice list --filter=Desc.SerialNum=${serial_number} --format='{{.Id}}'
Andy Bavier8fca0452019-12-16 15:30:11 -0700676 Should Be Equal As Integers ${rc} 0
677 Log ${id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700678 [Return] ${id}
679
Gilles Depatieb5682f82019-10-31 10:39:45 -0400680Build ONU SN List
Andrea Campanella6391f842020-11-16 10:01:18 +0100681 [Arguments] ${serial_numbers} ${olt_serial_number}=${EMPTY} ${num_onus}=${num_all_onus}
682 [Documentation] Appends all ONU SNs for the given OLT to the ${serial_numbers} list
Gilles Depatieb5682f82019-10-31 10:39:45 -0400683 FOR ${INDEX} IN RANGE 0 ${num_onus}
Andrea Campanella6391f842020-11-16 10:01:18 +0100684 Run Keyword IF "${olt_serial_number}"=="${hosts.src[${INDEX}].olt}" or "${olt_serial_number}"=="${EMPTY}"
685 ... Append To List ${serial_numbers} ${hosts.src[${INDEX}].onu}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400686 END
687
688Get SN From Device ID
689 [Arguments] ${device_id}
690 [Documentation] Gets the device id by matching for ${device_id}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700691 ${rc} ${sn}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800692 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${device_id} --format='{{.SerialNumber}}'
Gilles Depatieb5682f82019-10-31 10:39:45 -0400693 Should Be Equal As Integers ${rc} 0
Andy Bavier8fca0452019-12-16 15:30:11 -0700694 Log ${sn}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400695 [Return] ${sn}
696
Scott Baker60e570d2020-02-02 22:10:13 -0800697Get Parent ID From Device ID
698 [Arguments] ${device_id}
699 [Documentation] Gets the device id by matching for ${device_id}
700 ${rc} ${pid}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800701 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${device_id} --format='{{.ParentId}}'
Scott Baker60e570d2020-02-02 22:10:13 -0800702 Should Be Equal As Integers ${rc} 0
703 Log ${pid}
704 [Return] ${pid}
705
Kailash6f5acb62019-08-28 14:38:45 -0700706Validate Device Removed
707 [Arguments] ${id}
708 [Documentation] Verifys that device, ${serial_number}, has been removed
Matteo Scandolo5899be12020-11-11 15:38:07 -0800709 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -o json
Andy Bavier8fca0452019-12-16 15:30:11 -0700710 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700711 ${jsondata}= To Json ${output}
712 Log ${jsondata}
713 ${length}= Get Length ${jsondata}
714 @{ids}= Create List
Zack Williamsec53a1b2019-09-16 15:50:52 -0700715 FOR ${INDEX} IN RANGE 0 ${length}
716 ${value}= Get From List ${jsondata} ${INDEX}
717 ${device_id}= Get From Dictionary ${value} id
718 Append To List ${ids} ${device_id}
719 END
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700720 List Should Not Contain Value ${ids} ${id}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800721
Andrea Campanella4e507882020-11-26 11:33:11 +0100722Validate all ONUS for OLT Removed
723 [Arguments] ${num_all_onus} ${hosts} ${olt_serial_number} ${timeout}
724 [Documentation] Verifys that all the ONUS for OLT ${serial_number}, has been removed
725 FOR ${J} IN RANGE 0 ${num_all_onus}
726 ${src}= Set Variable ${hosts.src[${J}]}
727 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
728 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
729 ... Validate Device Removed ${src['onu']}
730 END
731
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800732Reboot ONU
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000733 [Arguments] ${onu_id} ${validate_device}=True
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800734 [Documentation] Using voltctl command reboot ONU and verify that ONU comes up to running state
Matteo Scandolo5899be12020-11-11 15:38:07 -0800735 ${rc} ${devices}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device reboot ${onu_id}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800736 Should Be Equal As Integers ${rc} 0
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000737 Run Keyword If ${validate_device} Run Keyword And Continue On Failure Wait Until Keyword Succeeds
738 ... 60s 1s Validate ONU Device By Device Id ENABLED DISCOVERED REACHABLE rebooting ${onu_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700739
740Assert ONUs in Voltha
741 [Arguments] ${count}
742 [Documentation] Check that a certain number of devices reached the ACTIVE/ENABLE state
743 ${rc1} ${devices}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800744 ... voltctl -c ${VOLTCTL_CONFIG} -m 8M device list | grep -v OLT | grep ACTIVE | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700745 Should Be Equal As Integers ${rc1} 0
746 Should Be Equal As Integers ${devices} ${count}
747
748Wait for ONUs in VOLTHA
749 [Arguments] ${count}
750 [Documentation] Waits until a certain number of devices reached the ACTIVE/ENABLE state
751 Wait Until Keyword Succeeds 10m 5s Assert ONUs In Voltha ${count}
752
753Count Logical Devices flows
754 [Documentation] Count the flows across logical devices in VOLTHA
755 [Arguments] ${targetFlows}
756 ${output}= Get Logical Device List From Voltha
757 ${logical_devices}= To Json ${output}
758 ${total_flows}= Set Variable 0
759 FOR ${device} IN @{logical_devices}
760 ${rc} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800761 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice flows ${device['id']} | grep -v ID | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700762 Should Be Equal As Integers ${rc} 0
763 ${total_flows}= Evaluate ${total_flows} + ${flows}
764 END
Matteo Scandolo616daab2020-05-13 11:49:24 -0700765 ${msg}= Format String Found {total_flows} flows of {targetFlows} expected
766 ... total_flows=${total_flows} targetFlows=${targetFlows}
767 Log ${msg}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700768 Should Be Equal As Integers ${targetFlows} ${total_flows}
769
770Wait for Logical Devices flows
771 [Documentation] Waits until the flows have been provisioned in the logical device
772 [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200773 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700774 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200775 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700776 Log ${targetFlows}
777 # TODO extend Validate Logical Device Flows to check the correct number of flows
778 Wait Until Keyword Succeeds 10m 5s Count Logical Devices flows ${targetFlows}
779
Matteo Scandolo616daab2020-05-13 11:49:24 -0700780Count OpenOLT Device Flows
781 [Documentation] Count the flows across openolt devices in VOLTHA
782 [Arguments] ${targetFlows}
783 ${output}= Get Device List from Voltha by type openolt
784 ${devices}= To Json ${output}
785 ${total_flows}= Set Variable 0
786 FOR ${device} IN @{devices}
787 ${rc} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800788 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device['id']} | grep -v ID | wc -l
Matteo Scandolo616daab2020-05-13 11:49:24 -0700789 Should Be Equal As Integers ${rc} 0
790 ${total_flows}= Evaluate ${total_flows} + ${flows}
791 END
792 ${msg}= Format String Found {total_flows} flows of {targetFlows} expected
793 ... total_flows=${total_flows} targetFlows=${targetFlows}
794 Log ${msg}
795 Should Be Equal As Integers ${targetFlows} ${total_flows}
796
797Wait for OpenOLT Devices flows
798 [Documentation] Waits until the flows have been provisioned in the openolt devices
799 [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200800 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700801 ${beforeFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
802 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandoloda854b02020-09-01 16:20:51 -0700803 # In the physical device we only have 2 data plane flows (on the PON) instead of 4
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700804 ${afterFlows}= Evaluate ${beforeFlows} - (${uni_count} * 2)
Matteo Scandoloda854b02020-09-01 16:20:51 -0700805 # In the TT workflow we have multiple service,
806 # so we need to remove 6 flows per each UNI that are only on the ONU device
807 ${ttFlows}= Evaluate ${beforeFlows} - (${uni_count} * 6)
808 ${afterFlows}= Set Variable If $workflow=='tt' ${ttFlows} ${afterFlows}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700809 ${targetFlows}= Set Variable If $provisioned=='true' ${afterFlows} ${beforeFlows}
Matteo Scandolo616daab2020-05-13 11:49:24 -0700810 Log ${targetFlows}
Hardik Windlass2b37e712020-06-12 02:13:17 +0530811 Wait Until Keyword Succeeds 10m 5s Count OpenOLT Device Flows ${targetFlows}