blob: 0d51b0ecaec693e9e6b9f29c426d28af94f66a3b [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
31 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl 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 Scandolo142e6272020-04-29 17:36:59 -070043 ... ${VOLTCTL_CONFIG}; voltctl device create -t ${type} -H ${ip}:${port}
Kailash6f5acb62019-08-28 14:38:45 -070044 Should Be Equal As Integers ${rc} 0
45 [Return] ${device_id}
46
47Enable Device
48 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -070049 [Documentation] Enables a device in VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -070050 ${rc} ${output}= Run and Return Rc and Output
51 ... ${VOLTCTL_CONFIG}; voltctl device enable ${device_id}
Kailash6f5acb62019-08-28 14:38:45 -070052 Should Be Equal As Integers ${rc} 0
53
Suchitra Vemuri6db89412019-11-14 14:52:54 -080054Disable Device
55 [Arguments] ${device_id}
Hardik Windlassaaea3402020-03-10 19:45:45 +053056 [Documentation] Disables a device in VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -070057 ${rc} ${output}= Run and Return Rc and Output
58 ... ${VOLTCTL_CONFIG}; voltctl device disable ${device_id}
Suchitra Vemuri6db89412019-11-14 14:52:54 -080059 Should Be Equal As Integers ${rc} 0
60
Hardik Windlassaaea3402020-03-10 19:45:45 +053061Delete Device
62 [Arguments] ${device_id}
63 [Documentation] Deletes a device in VOLTHA
64 ${rc} ${output}= Run and Return Rc and Output
65 ... ${VOLTCTL_CONFIG}; voltctl device delete ${device_id}
66 Should Be Equal As Integers ${rc} 0
67
Hemadf003682020-04-28 21:22:22 +053068Reboot Device
69 [Arguments] ${device_id}
70 [Documentation] Reboot the OLT using voltctl command
71 ${rc} ${output}= Run and Return Rc and Output
72 ... ${VOLTCTL_CONFIG}; voltctl device reboot ${device_id}
73 Should Be Equal As Integers ${rc} 0
74
David Bainbridgef81cd642019-11-20 00:14:47 +000075Disable Devices In Voltha
76 [Documentation] Disables all the known devices in voltha
77 [Arguments] ${filter}
78 ${arg}= Set Variable ${EMPTY}
79 ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070080 ${rc} ${devices}= Run and Return Rc and Output
81 ... ${VOLTCTL_CONFIG}; voltctl device list ${arg} --orderby Root -q | xargs echo -n
David Bainbridgef81cd642019-11-20 00:14:47 +000082 Should Be Equal As Integers ${rc} 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -070083 ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output
84 ... ${VOLTCTL_CONFIG}; voltctl device disable ${devices}
David Bainbridgef81cd642019-11-20 00:14:47 +000085 Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0
86
87Test Devices Disabled In Voltha
88 [Documentation] Tests to verify that all devices in VOLTHA are disabled
89 [Arguments] ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070090 ${rc} ${count}= Run and Return Rc and Output
91 ... ${VOLTCTL_CONFIG}; voltctl device list --filter '${filter},AdminState!=DISABLED' -q | wc -l
David Bainbridgef81cd642019-11-20 00:14:47 +000092 Should Be Equal As Integers ${rc} 0
93 Should Be Equal As Integers ${count} 0
94
95Delete Devices In Voltha
96 [Documentation] Disables all the known devices in voltha
97 [Arguments] ${filter}
98 ${arg}= Set Variable ${EMPTY}
99 ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700100 ${rc} ${devices}= Run and Return Rc and Output
101 ... ${VOLTCTL_CONFIG}; voltctl device list ${arg} --orderby Root -q | xargs echo -n
David Bainbridgef81cd642019-11-20 00:14:47 +0000102 Should Be Equal As Integers ${rc} 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700103 ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output
104 ... ${VOLTCTL_CONFIG}; voltctl device delete ${devices}
David Bainbridgef81cd642019-11-20 00:14:47 +0000105 Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0
106
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700107Get Device Flows from Voltha
108 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700109 [Documentation] Gets device flows from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700110 ${rc} ${output}= Run and Return Rc and Output
111 ... ${VOLTCTL_CONFIG}; voltctl device flows ${device_id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700112 Should Be Equal As Integers ${rc} 0
113 [Return] ${output}
114
115Get Logical Device Output from Voltha
116 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700117 [Documentation] Gets logicaldevice flows and ports from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700118 ${rc1} ${flows}= Run and Return Rc and Output
119 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${device_id}
120 ${rc2} ${ports}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800121 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice port list ${device_id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700122 Log ${flows}
123 Log ${ports}
124 Should Be Equal As Integers ${rc1} 0
125 Should Be Equal As Integers ${rc2} 0
126
127Get Device Output from Voltha
128 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700129 [Documentation] Gets device flows and ports from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700130 ${rc1} ${flows}= Run and Return Rc and Output
131 ... ${VOLTCTL_CONFIG}; voltctl device flows ${device_id}
132 ${rc2} ${ports}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800133 ... ${VOLTCTL_CONFIG}; voltctl device port list ${device_id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700134 Log ${flows}
135 Log ${ports}
136 Should Be Equal As Integers ${rc1} 0
137 Should Be Equal As Integers ${rc2} 0
138
Suchitra Vemuri1a970a62019-11-26 12:52:16 -0800139Get Device List from Voltha
140 [Documentation] Gets Device List Output from Voltha
141 ${rc1} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list
142 Log ${devices}
143 Should Be Equal As Integers ${rc1} 0
144
Matteo Scandolo142e6272020-04-29 17:36:59 -0700145Get Logical Device List from Voltha
146 [Documentation] Gets Logical Device List Output from Voltha (in json format)
147 ${rc1} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl logicaldevice list -o json
148 Log ${devices}
149 Should Be Equal As Integers ${rc1} 0
150 Return From Keyword ${devices}
151
Kailash6f5acb62019-08-28 14:38:45 -0700152Validate Device
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700153 [Documentation]
ubuntu6b6e7d42020-03-02 12:35:42 -0800154 ... Parses the output of "voltctl device list" and inspects a device ${id}, specified as either
155 ... the serial number or device ID. Arguments are matched for device states of: "admin_state",
156 ... "oper_status", and "connect_status"
157 [Arguments] ${admin_state} ${oper_status} ${connect_status}
158 ... ${id}=${EMPTY} ${onu_reason}=${EMPTY} ${onu}=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400159 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
160 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700161 ${jsondata}= To Json ${output}
Kailash6f5acb62019-08-28 14:38:45 -0700162 ${length}= Get Length ${jsondata}
ubuntu6b6e7d42020-03-02 12:35:42 -0800163 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700164 FOR ${INDEX} IN RANGE 0 ${length}
165 ${value}= Get From List ${jsondata} ${INDEX}
166 ${astate}= Get From Dictionary ${value} adminstate
167 ${opstatus}= Get From Dictionary ${value} operstatus
168 ${cstatus}= Get From Dictionary ${value} connectstatus
169 ${sn}= Get From Dictionary ${value} serialnumber
Gilles Depatieb5682f82019-10-31 10:39:45 -0400170 ${devId}= Get From Dictionary ${value} id
Zack Williamsec53a1b2019-09-16 15:50:52 -0700171 ${mib_state}= Get From Dictionary ${value} reason
ubuntu6b6e7d42020-03-02 12:35:42 -0800172 ${matched}= Set Variable If '${sn}' == '${id}' or '${devId}' == '${id}' True False
Andy Bavierb63f6d22020-03-12 15:34:37 -0700173 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700174 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700175 Should Be True ${matched} No match found for ${id} to validate device
Matteo Scandolo5e10b282019-11-25 10:54:32 -0700176 Log ${value}
ubuntu6b6e7d42020-03-02 12:35:42 -0800177 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
Gilles Depatie675a2062019-10-22 12:44:42 -0400178 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800179 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400180 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800181 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400182 ... values=False
183 Run Keyword If '${onu}' == 'True' Should Be Equal '${mib_state}' '${onu_reason}'
ubuntu6b6e7d42020-03-02 12:35:42 -0800184 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400185
186Validate OLT Device
ubuntu6b6e7d42020-03-02 12:35:42 -0800187 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${id}=${EMPTY}
188 [Documentation] Parses the output of "voltctl device list" and inspects device ${id}, specified
189 ... as either its serial numbner or device ID. Match on OLT Serial number or Device Id and inspect states
190 Validate Device ${admin_state} ${oper_status} ${connect_status} ${id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400191
192Validate ONU Devices
193 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${List_ONU_Serial}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700194 ... ${onu_reason}=omci-flows-pushed
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700195 [Documentation] Parses the output of "voltctl device list" and inspects device ${List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400196 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
197 ... states including MIB state
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700198 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400199 Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700200 ... onu_reason=${onu_reason} onu=True
Debasish28130d02020-03-16 11:05:26 +0000201 END
202
Gilles Depatieb5682f82019-10-31 10:39:45 -0400203Validate Device Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700204 [Documentation]
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800205 ... Parses the output of voltctl device port list <device_id> and matches the port types listed
Andy Bavier90eb1a12020-03-26 11:54:35 -0700206 [Arguments] ${device_id} ${pon_type} ${ethernet_type} ${all_active}=True
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700207 ${rc} ${output}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800208 ... ${VOLTCTL_CONFIG}; voltctl device port list ${device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400209 Should Be Equal As Integers ${rc} 0
210 ${jsondata}= To Json ${output}
211 Log ${jsondata}
212 ${length}= Get Length ${jsondata}
213 FOR ${INDEX} IN RANGE 0 ${length}
214 ${value}= Get From List ${jsondata} ${INDEX}
215 ${astate}= Get From Dictionary ${value} adminstate
216 ${opstatus}= Get From Dictionary ${value} operstatus
217 ${type}= Get From Dictionary ${value} type
Hemaf64d34c2020-03-25 00:40:17 +0530218 Should Be Equal '${astate}' 'ENABLED' Device ${device_id} port admin_state != ENABLED values=False
Andy Bavier90eb1a12020-03-26 11:54:35 -0700219 Run Keyword If ${all_active} Should Be Equal '${opstatus}' 'ACTIVE'
220 ... Device ${device_id} port oper_status != ACTIVE values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400221 Should Be True '${type}' == '${pon_type}' or '${type}' == '${ethernet_type}'
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700222 ... Device ${device_id} port type is neither ${pon_type} or ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400223 END
224
225Validate OLT Port Types
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800226 [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 -0700227 [Arguments] ${pon_type} ${ethernet_type}
228 Validate Device Port Types ${olt_device_id} ${pon_type} ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400229
230Validate ONU Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700231 [Arguments] ${List_ONU_Serial} ${pon_type} ${ethernet_type}
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800232 [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 -0700233 ... and matches the port types listed
Gilles Depatieb5682f82019-10-31 10:39:45 -0400234 FOR ${serial_number} IN @{List_ONU_Serial}
235 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Andy Bavier90eb1a12020-03-26 11:54:35 -0700236 # Only first UNI port is ACTIVE; the rest are in DISCOVERED operstatus
237 Validate Device Port Types ${onu_dev_id} ${pon_type} ${ethernet_type} all_active=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400238 END
239
240Validate Device Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000241 [Arguments] ${device_id} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400242 [Documentation] Parses the output of voltctl device flows <device_id> and expects flow count > 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700243 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device flows ${device_id} -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 Log 'Number of flows = ' ${length}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000249 Run Keyword If '${flow_count}' == '${EMPTY}' Should Be True ${length} > 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400250 ... Number of flows for ${device_id} was 0
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000251 ... ELSE Should Be True ${length} == ${flow_count}
252 ... Number of flows for ${device_id} was not ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400253
254Validate OLT Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000255 [Arguments] ${flow_count}=${EMPTY}
256 [Documentation] Parses the output of voltctl device flows ${olt_device_id}
257 ... and expects flow count == ${flow_count}
258 Validate Device Flows ${olt_device_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400259
260Validate ONU Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000261 [Arguments] ${List_ONU_Serial} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400262 [Documentation] Parses the output of voltctl device flows for each ONU SN listed in ${List_ONU_Serial}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000263 ... and expects flow count == ${flow_count}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700264 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400265 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000266 Validate Device Flows ${onu_dev_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400267 END
268
269Validate Logical Device
270 [Documentation] Validate Logical Device is listed
271 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl logicaldevice list -o json
272 Should Be Equal As Integers ${rc} 0
273 ${jsondata}= To Json ${output}
274 Log ${jsondata}
275 ${length}= Get Length ${jsondata}
276 FOR ${INDEX} IN RANGE 0 ${length}
277 ${value}= Get From List ${jsondata} ${INDEX}
278 ${devid}= Get From Dictionary ${value} id
279 ${rootdev}= Get From Dictionary ${value} rootdeviceid
280 ${sn}= Get From Dictionary ${value} serialnumber
281 Exit For Loop
282 END
283 Should Be Equal '${rootdev}' '${olt_device_id}' Root Device does not match ${olt_device_id} values=False
284 Should Be Equal '${sn}' '${BBSIM_OLT_SN}' Logical Device ${sn} does not match ${BBSIM_OLT_SN}
285 ... values=False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700286 [Return] ${devid}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400287
288Validate Logical Device Ports
289 [Arguments] ${logical_device_id}
290 [Documentation] Validate Logical Device Ports are listed and are > 0
291 ${rc} ${output}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800292 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice port list ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400293 Should Be Equal As Integers ${rc} 0
294 ${jsondata}= To Json ${output}
295 Log ${jsondata}
296 ${length}= Get Length ${jsondata}
297 Should Be True ${length} > 0 Number of ports for ${logical_device_id} was 0
298
299Validate Logical Device Flows
300 [Arguments] ${logical_device_id}
301 [Documentation] Validate Logical Device Flows are listed and are > 0
302 ${rc} ${output}= Run and Return Rc and Output
303 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${logical_device_id} -o json
304 Should Be Equal As Integers ${rc} 0
305 ${jsondata}= To Json ${output}
306 Log ${jsondata}
307 ${length}= Get Length ${jsondata}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700308 Should Be True ${length} > 0 Number of flows for ${logical_device_id} was 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400309
310Retrieve Peer List From OLT
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700311 [Arguments] ${olt_peer_list}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400312 [Documentation] Retrieve the list of peer device id list from port list
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700313 ${rc} ${output}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800314 ... ${VOLTCTL_CONFIG}; voltctl device port list ${olt_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400315 Should Be Equal As Integers ${rc} 0
316 ${jsondata}= To Json ${output}
317 Log ${jsondata}
318 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700319 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400320 FOR ${INDEX} IN RANGE 0 ${length}
321 ${value}= Get From List ${jsondata} ${INDEX}
322 ${type}= Get From Dictionary ${value} type
323 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700324 ${matched}= Set Variable If '${type}' == 'PON_OLT' True False
325 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400326 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700327 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400328 ${length}= Get Length ${peers}
329 FOR ${INDEX} IN RANGE 0 ${length}
330 ${value}= Get From List ${peers} ${INDEX}
331 ${peer_id}= Get From Dictionary ${value} deviceid
332 Append To List ${olt_peer_list} ${peer_id}
333 END
334
335Validate OLT Peer Id List
336 [Arguments] ${olt_peer_id_list}
337 [Documentation] Match each entry in the ${olt_peer_id_list} against ONU device ids.
338 FOR ${peer_id} IN @{olt_peer_id_list}
339 Match OLT Peer Id ${peer_id}
340 END
341
342Match OLT Peer Id
343 [Arguments] ${olt_peer_id}
344 [Documentation] Lookup the OLT Peer Id in against the list of ONU device Ids
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700345 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400346 Should Be Equal As Integers ${rc} 0
347 ${jsondata}= To Json ${output}
348 Log ${jsondata}
349 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700350 ${matched}= Set Variable False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700351 FOR ${INDEX} IN RANGE 0 ${length}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400352 ${value}= Get From List ${jsondata} ${INDEX}
353 ${devid}= Get From Dictionary ${value} id
Andy Bavierb63f6d22020-03-12 15:34:37 -0700354 ${matched}= Set Variable If '${devid}' == '${olt_peer_id}' True False
355 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400356 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700357 Should Be True ${matched} Peer id ${olt_peer_id} does not match any ONU device id
Gilles Depatieb5682f82019-10-31 10:39:45 -0400358
359Validate ONU Peer Id
360 [Arguments] ${olt_device_id} ${List_ONU_Serial}
361 [Documentation] Match each ONU peer to that of the OLT device id
362 FOR ${onu_serial} IN @{List_ONU_Serial}
363 ${onu_dev_id}= Get Device ID From SN ${onu_serial}
364 Match ONU Peer Id ${onu_dev_id}
365 END
366
367Match ONU Peer Id
368 [Arguments] ${onu_dev_id}
369 [Documentation] Match an ONU peer to that of the OLT device id
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800370 ${rc} ${output}= Run and Return Rc and Output
371 ... ${VOLTCTL_CONFIG}; voltctl device port list ${onu_dev_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400372 Should Be Equal As Integers ${rc} 0
373 ${jsondata}= To Json ${output}
374 Log ${jsondata}
375 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700376 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400377 FOR ${INDEX} IN RANGE 0 ${length}
378 ${value}= Get From List ${jsondata} ${INDEX}
379 ${type}= Get From Dictionary ${value} type
380 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700381 ${matched}= Set Variable If '${type}' == 'PON_ONU' True False
382 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400383 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700384 Should Be True ${matched} No PON port found for ONU ${onu_dev_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400385 ${length}= Get Length ${peers}
386 FOR ${INDEX} IN RANGE 0 ${length}
387 ${value}= Get From List ${peers} ${INDEX}
388 ${peer_id}= Get From Dictionary ${value} deviceid
389 END
390 Should Be Equal '${peer_id}' '${olt_device_id}'
391 ... Mismatch between ONU peer ${peer_id} and OLT device id ${olt_device_id} values=False
Kailash6f5acb62019-08-28 14:38:45 -0700392
Kailash6f5acb62019-08-28 14:38:45 -0700393Get Device ID From SN
394 [Arguments] ${serial_number}
395 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700396 ${rc} ${id}= Run and Return Rc and Output
Andy Bavier8fca0452019-12-16 15:30:11 -0700397 ... ${VOLTCTL_CONFIG}; voltctl device list --filter=SerialNumber=${serial_number} --format='{{.Id}}'
398 Should Be Equal As Integers ${rc} 0
399 Log ${id}
Kailash6f5acb62019-08-28 14:38:45 -0700400 [Return] ${id}
401
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700402Get Logical Device ID From SN
403 [Arguments] ${serial_number}
404 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700405 ${rc} ${id}= Run and Return Rc and Output
Andy Bavier8fca0452019-12-16 15:30:11 -0700406 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice list --filter=SerialNumber=${serial_number} --format='{{.Id}}'
407 Should Be Equal As Integers ${rc} 0
408 Log ${id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700409 [Return] ${id}
410
Gilles Depatieb5682f82019-10-31 10:39:45 -0400411Build ONU SN List
412 [Arguments] ${serial_numbers}
413 [Documentation] Appends all ONU SNs to the ${serial_numbers} list
414 FOR ${INDEX} IN RANGE 0 ${num_onus}
415 Append To List ${serial_numbers} ${hosts.src[${INDEX}].onu}
416 END
417
418Get SN From Device ID
419 [Arguments] ${device_id}
420 [Documentation] Gets the device id by matching for ${device_id}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700421 ${rc} ${sn}= Run and Return Rc and Output
Andy Bavier8fca0452019-12-16 15:30:11 -0700422 ... ${VOLTCTL_CONFIG}; voltctl device list --filter=Id=${device_id} --format='{{.SerialNumber}}'
Gilles Depatieb5682f82019-10-31 10:39:45 -0400423 Should Be Equal As Integers ${rc} 0
Andy Bavier8fca0452019-12-16 15:30:11 -0700424 Log ${sn}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400425 [Return] ${sn}
426
Scott Baker60e570d2020-02-02 22:10:13 -0800427Get Parent ID From Device ID
428 [Arguments] ${device_id}
429 [Documentation] Gets the device id by matching for ${device_id}
430 ${rc} ${pid}= Run and Return Rc and Output
431 ... ${VOLTCTL_CONFIG}; voltctl device list --filter=Id=${device_id} --format='{{.ParentId}}'
432 Should Be Equal As Integers ${rc} 0
433 Log ${pid}
434 [Return] ${pid}
435
Kailash6f5acb62019-08-28 14:38:45 -0700436Validate Device Removed
437 [Arguments] ${id}
438 [Documentation] Verifys that device, ${serial_number}, has been removed
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700439 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
Andy Bavier8fca0452019-12-16 15:30:11 -0700440 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700441 ${jsondata}= To Json ${output}
442 Log ${jsondata}
443 ${length}= Get Length ${jsondata}
444 @{ids}= Create List
Zack Williamsec53a1b2019-09-16 15:50:52 -0700445 FOR ${INDEX} IN RANGE 0 ${length}
446 ${value}= Get From List ${jsondata} ${INDEX}
447 ${device_id}= Get From Dictionary ${value} id
448 Append To List ${ids} ${device_id}
449 END
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700450 List Should Not Contain Value ${ids} ${id}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800451
452Reboot ONU
453 [Arguments] ${onu_id} ${src} ${dst}
454 [Documentation] Using voltctl command reboot ONU and verify that ONU comes up to running state
455 ${rc} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device reboot ${onu_id}
456 Should Be Equal As Integers ${rc} 0
457 Run Keyword and Ignore Error Wait Until Keyword Succeeds 60s 1s Validate Device
458 ... ENABLED DISCOVERED UNREACHABLE ${onu_id} onu=True
Matteo Scandolo142e6272020-04-29 17:36:59 -0700459
460Assert ONUs in Voltha
461 [Arguments] ${count}
462 [Documentation] Check that a certain number of devices reached the ACTIVE/ENABLE state
463 ${rc1} ${devices}= Run and Return Rc and Output
464 ... ${VOLTCTL_CONFIG}; voltctl device list | grep -v OLT | grep ACTIVE | wc -l
465 Should Be Equal As Integers ${rc1} 0
466 Should Be Equal As Integers ${devices} ${count}
467
468Wait for ONUs in VOLTHA
469 [Arguments] ${count}
470 [Documentation] Waits until a certain number of devices reached the ACTIVE/ENABLE state
471 Wait Until Keyword Succeeds 10m 5s Assert ONUs In Voltha ${count}
472
473Count Logical Devices flows
474 [Documentation] Count the flows across logical devices in VOLTHA
475 [Arguments] ${targetFlows}
476 ${output}= Get Logical Device List From Voltha
477 ${logical_devices}= To Json ${output}
478 ${total_flows}= Set Variable 0
479 FOR ${device} IN @{logical_devices}
480 ${rc} ${flows}= Run and Return Rc and Output
481 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${device['id']} | grep -v ID | wc -l
482 Should Be Equal As Integers ${rc} 0
483 ${total_flows}= Evaluate ${total_flows} + ${flows}
484 END
485 Should Be Equal As Integers ${targetFlows} ${total_flows}
486
487Wait for Logical Devices flows
488 [Documentation] Waits until the flows have been provisioned in the logical device
489 [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned}
Matteo Scandoloeb26a842020-05-08 10:06:24 -0700490 ... ${withEapol} ${withDhcp} ${withIgmp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700491 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Matteo Scandoloeb26a842020-05-08 10:06:24 -0700492 ... ${withEapol} ${withDhcp} ${withIgmp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700493 Log ${targetFlows}
494 # TODO extend Validate Logical Device Flows to check the correct number of flows
495 Wait Until Keyword Succeeds 10m 5s Count Logical Devices flows ${targetFlows}
496