blob: f45518c1bea4c1e5cf390d2e6c83ae715d3213fa [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
Andrea Campanella80655eb2020-07-10 15:49:22 +020081 ... ${VOLTCTL_CONFIG}; voltctl device list -m 8MB ${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
Andrea Campanella80655eb2020-07-10 15:49:22 +020091 ... ${VOLTCTL_CONFIG}; voltctl device list -m 8MB --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
Andrea Campanella80655eb2020-07-10 15:49:22 +0200101 ... ${VOLTCTL_CONFIG}; voltctl device list ${arg} -m 8MB --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
Andrea Campanella80655eb2020-07-10 15:49:22 +0200111 ... ${VOLTCTL_CONFIG}; voltctl device flows ${device_id} -m 8MB
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
Andrea Campanella80655eb2020-07-10 15:49:22 +0200131 ... ${VOLTCTL_CONFIG}; voltctl device flows ${device_id} -m 8MB
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700132 ${rc2} ${ports}= Run and Return Rc and Output
Andrea Campanella80655eb2020-07-10 15:49:22 +0200133 ... ${VOLTCTL_CONFIG}; voltctl device port list ${device_id} -m 8MB
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
Andrea Campanella80655eb2020-07-10 15:49:22 +0200141 ${rc1} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -m 8MB
Suchitra Vemuri1a970a62019-11-26 12:52:16 -0800142 Log ${devices}
143 Should Be Equal As Integers ${rc1} 0
144
Matteo Scandolo616daab2020-05-13 11:49:24 -0700145Get Device List from Voltha by type
146 [Documentation] Gets Device List Output from Voltha applying filtering by device type
147 [Arguments] ${type}
148 ${rc1} ${devices}= Run and Return Rc and Output
Andrea Campanella80655eb2020-07-10 15:49:22 +0200149 ... ${VOLTCTL_CONFIG}; voltctl device list -m 8MB -f Type=${type} -o json
Matteo Scandolo616daab2020-05-13 11:49:24 -0700150 Log ${devices}
151 Should Be Equal As Integers ${rc1} 0
152 Return From Keyword ${devices}
153
Matteo Scandolo142e6272020-04-29 17:36:59 -0700154Get Logical Device List from Voltha
155 [Documentation] Gets Logical Device List Output from Voltha (in json format)
Andrea Campanella80655eb2020-07-10 15:49:22 +0200156 ${rc1} ${devices}= Run and Return Rc and Output
157 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice list -m 8MB -o json
Matteo Scandolo142e6272020-04-29 17:36:59 -0700158 Log ${devices}
159 Should Be Equal As Integers ${rc1} 0
160 Return From Keyword ${devices}
161
Kailash6f5acb62019-08-28 14:38:45 -0700162Validate Device
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700163 [Documentation]
ubuntu6b6e7d42020-03-02 12:35:42 -0800164 ... Parses the output of "voltctl device list" and inspects a device ${id}, specified as either
165 ... the serial number or device ID. Arguments are matched for device states of: "admin_state",
166 ... "oper_status", and "connect_status"
167 [Arguments] ${admin_state} ${oper_status} ${connect_status}
168 ... ${id}=${EMPTY} ${onu_reason}=${EMPTY} ${onu}=False
Andrea Campanella80655eb2020-07-10 15:49:22 +0200169 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -m 8MB -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400170 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700171 ${jsondata}= To Json ${output}
Kailash6f5acb62019-08-28 14:38:45 -0700172 ${length}= Get Length ${jsondata}
ubuntu6b6e7d42020-03-02 12:35:42 -0800173 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700174 FOR ${INDEX} IN RANGE 0 ${length}
175 ${value}= Get From List ${jsondata} ${INDEX}
Scott Baker780b65f2020-05-22 14:03:15 -0700176 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
177 ... Dictionary Should Contain Key ${value} adminState
178 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
179 ... Get From Dictionary ${value} adminState
180 ... ELSE
181 ... Get From Dictionary ${value} adminstate
182 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
183 ... Get From Dictionary ${value} operStatus
184 ... ELSE
185 ... Get From Dictionary ${value} operstatus
186 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
187 ... Get From Dictionary ${value} connectStatus
188 ... ELSE
189 ... Get From Dictionary ${value} connectstatus
190 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
191 ... Get From Dictionary ${value} serialNumber
192 ... ELSE
193 ... Get From Dictionary ${value} serialnumber
Gilles Depatieb5682f82019-10-31 10:39:45 -0400194 ${devId}= Get From Dictionary ${value} id
Zack Williamsec53a1b2019-09-16 15:50:52 -0700195 ${mib_state}= Get From Dictionary ${value} reason
ubuntu6b6e7d42020-03-02 12:35:42 -0800196 ${matched}= Set Variable If '${sn}' == '${id}' or '${devId}' == '${id}' True False
Andy Bavierb63f6d22020-03-12 15:34:37 -0700197 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700198 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700199 Should Be True ${matched} No match found for ${id} to validate device
Matteo Scandolo5e10b282019-11-25 10:54:32 -0700200 Log ${value}
ubuntu6b6e7d42020-03-02 12:35:42 -0800201 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
Gilles Depatie675a2062019-10-22 12:44:42 -0400202 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800203 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400204 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800205 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400206 ... values=False
207 Run Keyword If '${onu}' == 'True' Should Be Equal '${mib_state}' '${onu_reason}'
ubuntu6b6e7d42020-03-02 12:35:42 -0800208 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400209
210Validate OLT Device
ubuntu6b6e7d42020-03-02 12:35:42 -0800211 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${id}=${EMPTY}
212 [Documentation] Parses the output of "voltctl device list" and inspects device ${id}, specified
213 ... as either its serial numbner or device ID. Match on OLT Serial number or Device Id and inspect states
214 Validate Device ${admin_state} ${oper_status} ${connect_status} ${id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400215
216Validate ONU Devices
217 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${List_ONU_Serial}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700218 ... ${onu_reason}=omci-flows-pushed
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700219 [Documentation] Parses the output of "voltctl device list" and inspects device ${List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400220 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
221 ... states including MIB state
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700222 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400223 Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700224 ... onu_reason=${onu_reason} onu=True
Debasish28130d02020-03-16 11:05:26 +0000225 END
226
Gilles Depatieb5682f82019-10-31 10:39:45 -0400227Validate Device Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700228 [Documentation]
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800229 ... Parses the output of voltctl device port list <device_id> and matches the port types listed
Andy Bavier90eb1a12020-03-26 11:54:35 -0700230 [Arguments] ${device_id} ${pon_type} ${ethernet_type} ${all_active}=True
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700231 ${rc} ${output}= Run and Return Rc and Output
Andrea Campanella80655eb2020-07-10 15:49:22 +0200232 ... ${VOLTCTL_CONFIG}; voltctl device port list ${device_id} -m 8MB -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400233 Should Be Equal As Integers ${rc} 0
234 ${jsondata}= To Json ${output}
235 Log ${jsondata}
236 ${length}= Get Length ${jsondata}
237 FOR ${INDEX} IN RANGE 0 ${length}
238 ${value}= Get From List ${jsondata} ${INDEX}
Scott Baker780b65f2020-05-22 14:03:15 -0700239 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
240 ... Dictionary Should Contain Key ${value} adminState
241 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
Hardik Windlass2b37e712020-06-12 02:13:17 +0530242 ... Get From Dictionary ${value} adminState
Scott Baker780b65f2020-05-22 14:03:15 -0700243 ... ELSE
Hardik Windlass2b37e712020-06-12 02:13:17 +0530244 ... Get From Dictionary ${value} adminstate
Scott Baker780b65f2020-05-22 14:03:15 -0700245 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
246 ... Get From Dictionary ${value} operStatus
247 ... ELSE
Hardik Windlass2b37e712020-06-12 02:13:17 +0530248 ... Get From Dictionary ${value} operstatus
Gilles Depatieb5682f82019-10-31 10:39:45 -0400249 ${type}= Get From Dictionary ${value} type
Hemaf64d34c2020-03-25 00:40:17 +0530250 Should Be Equal '${astate}' 'ENABLED' Device ${device_id} port admin_state != ENABLED values=False
Andy Bavier90eb1a12020-03-26 11:54:35 -0700251 Run Keyword If ${all_active} Should Be Equal '${opstatus}' 'ACTIVE'
252 ... Device ${device_id} port oper_status != ACTIVE values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400253 Should Be True '${type}' == '${pon_type}' or '${type}' == '${ethernet_type}'
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700254 ... Device ${device_id} port type is neither ${pon_type} or ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400255 END
256
257Validate OLT Port Types
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800258 [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 -0700259 [Arguments] ${pon_type} ${ethernet_type}
260 Validate Device Port Types ${olt_device_id} ${pon_type} ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400261
262Validate ONU Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700263 [Arguments] ${List_ONU_Serial} ${pon_type} ${ethernet_type}
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800264 [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 -0700265 ... and matches the port types listed
Gilles Depatieb5682f82019-10-31 10:39:45 -0400266 FOR ${serial_number} IN @{List_ONU_Serial}
267 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Andy Bavier90eb1a12020-03-26 11:54:35 -0700268 # Only first UNI port is ACTIVE; the rest are in DISCOVERED operstatus
269 Validate Device Port Types ${onu_dev_id} ${pon_type} ${ethernet_type} all_active=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400270 END
271
272Validate Device Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000273 [Arguments] ${device_id} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400274 [Documentation] Parses the output of voltctl device flows <device_id> and expects flow count > 0
Andrea Campanella80655eb2020-07-10 15:49:22 +0200275 ${rc} ${output}= Run and Return Rc and Output
276 ... ${VOLTCTL_CONFIG}; voltctl device flows ${device_id} -m 8MB -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400277 Should Be Equal As Integers ${rc} 0
278 ${jsondata}= To Json ${output}
279 Log ${jsondata}
280 ${length}= Get Length ${jsondata}
281 Log 'Number of flows = ' ${length}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000282 Run Keyword If '${flow_count}' == '${EMPTY}' Should Be True ${length} > 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400283 ... Number of flows for ${device_id} was 0
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000284 ... ELSE Should Be True ${length} == ${flow_count}
285 ... Number of flows for ${device_id} was not ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400286
287Validate OLT Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000288 [Arguments] ${flow_count}=${EMPTY}
289 [Documentation] Parses the output of voltctl device flows ${olt_device_id}
290 ... and expects flow count == ${flow_count}
291 Validate Device Flows ${olt_device_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400292
293Validate ONU Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000294 [Arguments] ${List_ONU_Serial} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400295 [Documentation] Parses the output of voltctl device flows for each ONU SN listed in ${List_ONU_Serial}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000296 ... and expects flow count == ${flow_count}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700297 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400298 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000299 Validate Device Flows ${onu_dev_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400300 END
301
TorstenThieme401af432020-06-11 15:53:53 +0000302Validate ONU Devices With Duration
303 [Documentation]
304 ... Parses the output of "voltctl device list" and inspects all devices ${List_ONU_Serial},
305 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
306 ... states including MIB state.
307 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${onu_reason}
308 ... ${List_ONU_Serial} ${startTime} ${print2console}=False ${output_file}=${EMPTY}
Andrea Campanella80655eb2020-07-10 15:49:22 +0200309 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -m 8MB -o json
TorstenThieme401af432020-06-11 15:53:53 +0000310 Should Be Equal As Integers ${rc} 0
311 ${timeCurrent} = Get Current Date
312 ${timeTotalMs} = Subtract Date From Date ${timeCurrent} ${startTime} result_format=number
313 ${jsondata}= To Json ${output}
314 ${length}= Get Length ${jsondata}
315 FOR ${INDEX} IN RANGE 0 ${length}
316 ${matched}= Set Variable False
317 ${value}= Get From List ${jsondata} ${INDEX}
318 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
319 ... Dictionary Should Contain Key ${value} adminState
320 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
321 ... Get From Dictionary ${value} adminState
322 ... ELSE
323 ... Get From Dictionary ${value} adminstate
324 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
325 ... Get From Dictionary ${value} operStatus
326 ... ELSE
327 ... Get From Dictionary ${value} operstatus
328 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
329 ... Get From Dictionary ${value} connectStatus
330 ... ELSE
331 ... Get From Dictionary ${value} connectstatus
332 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
333 ... Get From Dictionary ${value} serialNumber
334 ... ELSE
335 ... Get From Dictionary ${value} serialnumber
336 ${mib_state}= Get From Dictionary ${value} reason
337 ${onu_id}= Get Index From List ${List_ONU_Serial} ${sn}
338 ${matched}= Set Variable If -1 != ${onu_id} True False
339 ${matched}= Set Variable If '${astate}' == '${admin_state}' ${matched} False
340 ${matched}= Set Variable If '${opstatus}' == '${oper_status}' ${matched} False
341 ${matched}= Set Variable If '${cstatus}' == '${connect_status}' ${matched} False
342 ${matched}= Set Variable If '${mib_state}' == '${onu_reason}' ${matched} False
343 Run Keyword If ${matched} and ${print2console} Log
344 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec. console=yes
345 Run Keyword If ${matched} and ('${output_file}'!='${EMPTY}') Append To File ${output_file}
346 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec.
347 Run Keyword If ${matched} Remove Values From List ${List_ONU_Serial} ${sn}
348 END
349 Should Be Empty ${List_ONU_Serial} List ${List_ONU_Serial} not empty
350
TorstenThieme9949b172020-06-16 10:00:15 +0000351Validate ONU Devices MIB State With Duration
352 [Documentation]
353 ... Parses the output of "voltctl device list" and inspects all devices ${List_ONU_Serial},
354 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect MIB state.
355 [Arguments] ${onu_reason}
356 ... ${List_ONU_Serial} ${startTime} ${print2console}=False ${output_file}=${EMPTY}
357 ${type} = Set Variable brcm_openomci_onu
Andrea Campanella80655eb2020-07-10 15:49:22 +0200358 ${voltctl_commad} = Catenate SEPARATOR=
359 ... voltctl device list -m 8MB -f Type=${type} -f Reason=${onu_reason} --format '{{.SerialNumber}}'
360 ${rc} ${output}= Run and Return Rc and Output ${voltctl_commad}
TorstenThieme9949b172020-06-16 10:00:15 +0000361 Should Be Equal As Integers ${rc} 0
362 ${timeCurrent} = Get Current Date
363 ${timeTotalMs} = Subtract Date From Date ${timeCurrent} ${startTime} result_format=number
364 @{outputdata} = Split String ${output}
365 ${outputlength} = Get Length ${outputdata}
366 ${onulength} = Get Length ${List_ONU_Serial}
367 ${Matches} = Run Keyword If ${outputlength}<=${onulength}
368 ... Compare Lists ${outputdata} ${List_ONU_Serial}
369 ... ELSE Compare Lists ${List_ONU_Serial} ${outputdata}
370 ${length} = Get Length ${Matches}
371 FOR ${INDEX} IN RANGE 0 ${length}
372 ${sn}= Get From List ${Matches} ${INDEX}
373 Run Keyword If ${print2console} Log
374 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec. console=yes
375 Run Keyword If ('${output_file}'!='${EMPTY}') Append To File ${output_file}
376 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec.
377 Remove Values From List ${List_ONU_Serial} ${sn}
378 END
379 Should Be Empty ${List_ONU_Serial} List ${List_ONU_Serial} not empty
380
TorstenThieme1fbe8082020-10-21 13:27:59 +0000381Validate ONU Device By Device Id
382 [Documentation]
383 ... Parses the output of "voltctl device list" filtered by device id and inspects states including reason.
384 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${onu_reason} ${onu_id}
385 ${cmd} Catenate ${VOLTCTL_CONFIG}; voltctl device list --filter=Id=${onu_id} -m 8MB -o json
386 ${rc} ${output}= Run and Return Rc and Output ${cmd}
387 Should Be Equal As Integers ${rc} 0
388 ${jsondata}= To Json ${output}
389 ${length}= Get Length ${jsondata}
390 Should Be Equal As Integers ${length} 1 No match found for ${onu_id} to validate device
391 ${value}= Get From List ${jsondata} 0
392 Log ${value}
393 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
394 ... Dictionary Should Contain Key ${value} adminState
395 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
396 ... Get From Dictionary ${value} adminState
397 ... ELSE
398 ... Get From Dictionary ${value} adminstate
399 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
400 ... Get From Dictionary ${value} operStatus
401 ... ELSE
402 ... Get From Dictionary ${value} operstatus
403 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
404 ... Get From Dictionary ${value} connectStatus
405 ... ELSE
406 ... Get From Dictionary ${value} connectstatus
407 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
408 ... Get From Dictionary ${value} serialNumber
409 ... ELSE
410 ... Get From Dictionary ${value} serialnumber
411 ${devId}= Get From Dictionary ${value} id
412 ${mib_state}= Get From Dictionary ${value} reason
413 Should Be Equal '${devId}' '${onu_id}' No match found for ${onu_id} to validate device
414 ... values=False
415 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
416 ... values=False
417 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
418 ... values=False
419 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
420 ... values=False
421 Should Be Equal '${mib_state}' '${onu_reason}'
422 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
423
424
TorstenThieme9949b172020-06-16 10:00:15 +0000425Compare Lists
426 [Documentation]
427 ... Compares both lists and put all matches in the returned list
428 [Arguments] ${ListIterate} ${ListCompare}
429 @{list} = Create List
430 ${length} = Get Length ${ListIterate}
431 FOR ${INDEX} IN RANGE 0 ${length}
432 ${sn}= Get From List ${ListIterate} ${INDEX}
433 ${onu_id}= Get Index From List ${ListCompare} ${sn}
434 Run Keyword If -1 != ${onu_id} Append To List ${list} ${sn}
435 END
436 [Return] ${list}
437
Gilles Depatieb5682f82019-10-31 10:39:45 -0400438Validate Logical Device
439 [Documentation] Validate Logical Device is listed
440 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl logicaldevice list -o json
441 Should Be Equal As Integers ${rc} 0
442 ${jsondata}= To Json ${output}
443 Log ${jsondata}
444 ${length}= Get Length ${jsondata}
445 FOR ${INDEX} IN RANGE 0 ${length}
446 ${value}= Get From List ${jsondata} ${INDEX}
447 ${devid}= Get From Dictionary ${value} id
Scott Baker2ab2a0c2020-06-05 12:51:47 -0700448 ${rootdev}= Get From Dictionary ${value} rootDeviceId
449 ${desc}= Get From Dictionary ${value} desc
450 ${sn}= Get From Dictionary ${desc} serialNum
Gilles Depatieb5682f82019-10-31 10:39:45 -0400451 Exit For Loop
452 END
453 Should Be Equal '${rootdev}' '${olt_device_id}' Root Device does not match ${olt_device_id} values=False
454 Should Be Equal '${sn}' '${BBSIM_OLT_SN}' Logical Device ${sn} does not match ${BBSIM_OLT_SN}
455 ... values=False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700456 [Return] ${devid}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400457
458Validate Logical Device Ports
459 [Arguments] ${logical_device_id}
460 [Documentation] Validate Logical Device Ports are listed and are > 0
461 ${rc} ${output}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800462 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice port list ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400463 Should Be Equal As Integers ${rc} 0
464 ${jsondata}= To Json ${output}
465 Log ${jsondata}
466 ${length}= Get Length ${jsondata}
467 Should Be True ${length} > 0 Number of ports for ${logical_device_id} was 0
468
469Validate Logical Device Flows
470 [Arguments] ${logical_device_id}
471 [Documentation] Validate Logical Device Flows are listed and are > 0
472 ${rc} ${output}= Run and Return Rc and Output
473 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${logical_device_id} -o json
474 Should Be Equal As Integers ${rc} 0
475 ${jsondata}= To Json ${output}
476 Log ${jsondata}
477 ${length}= Get Length ${jsondata}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700478 Should Be True ${length} > 0 Number of flows for ${logical_device_id} was 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400479
Hardik Windlass16cdf962020-04-29 15:26:50 +0530480Retrieve OLT PON Ports
481 [Arguments] ${olt_device_id}
482 [Documentation] Retrieves the list of PON ports from the OLT device
483 ${rc} ${output}= Run and Return Rc and Output
484 ... ${VOLTCTL_CONFIG}; voltctl device port list ${olt_device_id} -o json
485 Should Be Equal As Integers ${rc} 0
486 ${jsondata}= To Json ${output}
487 Log ${jsondata}
488 ${length}= Get Length ${jsondata}
489 ${olt_pon_list}= Create List
490 FOR ${INDEX} IN RANGE 0 ${length}
491 ${value}= Get From List ${jsondata} ${INDEX}
492 ${type}= Get From Dictionary ${value} type
493 ${portno}= Get From Dictionary ${value} portNo
494 ${peers}= Get From Dictionary ${value} peers
495 ${len_peers}= Get Length ${peers}
496 Run Keyword If '${type}' == 'PON_OLT' and ${len_peers} > 0
497 ... Append To List ${olt_pon_list} ${portno}
498 END
499 [Return] ${olt_pon_list}
500
501Retrieve Peer List From OLT PON Port
502 [Arguments] ${olt_device_id} ${pon_port}
503 [Documentation] Retrieves the list of peer device ids list from the OLT PON port
504 ${rc} ${output}= Run and Return Rc and Output
505 ... ${VOLTCTL_CONFIG}; voltctl device port list ${olt_device_id} -o json
506 Should Be Equal As Integers ${rc} 0
507 ${jsondata}= To Json ${output}
508 Log ${jsondata}
509 ${length}= Get Length ${jsondata}
510 ${matched}= Set Variable False
511 FOR ${INDEX} IN RANGE 0 ${length}
512 ${value}= Get From List ${jsondata} ${INDEX}
513 ${type}= Get From Dictionary ${value} type
514 ${portno}= Get From Dictionary ${value} portNo
515 ${peers}= Get From Dictionary ${value} peers
516 ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
517 Exit For Loop If ${matched}
518 END
519 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
520 ${length}= Get Length ${peers}
521 ${olt_peer_list}= Create List
522 FOR ${INDEX} IN RANGE 0 ${length}
523 ${value}= Get From List ${peers} ${INDEX}
524 ${peer_id}= Get From Dictionary ${value} deviceId
525 Append To List ${olt_peer_list} ${peer_id}
526 END
527 [Return] ${olt_peer_list}
528
529Validate OLT PON Port Status
530 [Arguments] ${olt_device_id} ${pon_port} ${admin_state} ${oper_status}
531 [Documentation] Verifies the state of the PON port of the OLT
532 ${rc} ${output}= Run and Return Rc and Output
533 ... ${VOLTCTL_CONFIG}; voltctl device port list ${olt_device_id} -o json
534 Should Be Equal As Integers ${rc} 0
535 ${jsondata}= To Json ${output}
536 Log ${jsondata}
537 ${length}= Get Length ${jsondata}
538 ${matched}= Set Variable False
539 FOR ${INDEX} IN RANGE 0 ${length}
540 ${value}= Get From List ${jsondata} ${INDEX}
541 ${type}= Get From Dictionary ${value} type
542 ${portno}= Get From Dictionary ${value} portNo
543 ${astate}= Get From Dictionary ${value} adminState
544 ${opstatus}= Get From Dictionary ${value} operStatus
545 ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
546 Exit For Loop If ${matched}
547 END
548 Should Be True ${matched} No PON port found for OLT ${olt_device_id} ${pon_port}
549 Log ${value}
550 Should Be Equal '${astate}' '${admin_state}' OLT PON Port admin_state != ${admin_state}
551 ... values=False
552 Should Be Equal '${opstatus}' '${oper_status}' OLT PON Port oper_status != ${oper_status}
553 ... values=False
554
555DisableOrEnable OLT PON Port
556 [Arguments] ${operation} ${olt_device_id} ${portno}
557 [Documentation] Disables or Enables the PON port of the OLT
558 ${rc} ${output}= Run and Return Rc and Output
559 ... ${VOLTCTL_CONFIG}; voltctl device port ${operation} ${olt_device_id} ${portno}
560 Should Be Equal As Integers ${rc} 0
561
Gilles Depatieb5682f82019-10-31 10:39:45 -0400562Retrieve Peer List From OLT
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700563 [Arguments] ${olt_peer_list}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400564 [Documentation] Retrieve the list of peer device id list from port list
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700565 ${rc} ${output}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800566 ... ${VOLTCTL_CONFIG}; voltctl device port list ${olt_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400567 Should Be Equal As Integers ${rc} 0
568 ${jsondata}= To Json ${output}
569 Log ${jsondata}
570 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700571 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400572 FOR ${INDEX} IN RANGE 0 ${length}
573 ${value}= Get From List ${jsondata} ${INDEX}
574 ${type}= Get From Dictionary ${value} type
575 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700576 ${matched}= Set Variable If '${type}' == 'PON_OLT' True False
577 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400578 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700579 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400580 ${length}= Get Length ${peers}
581 FOR ${INDEX} IN RANGE 0 ${length}
582 ${value}= Get From List ${peers} ${INDEX}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530583 ${peer_id}= Get From Dictionary ${value} deviceId
Gilles Depatieb5682f82019-10-31 10:39:45 -0400584 Append To List ${olt_peer_list} ${peer_id}
585 END
586
587Validate OLT Peer Id List
588 [Arguments] ${olt_peer_id_list}
589 [Documentation] Match each entry in the ${olt_peer_id_list} against ONU device ids.
590 FOR ${peer_id} IN @{olt_peer_id_list}
591 Match OLT Peer Id ${peer_id}
592 END
593
594Match OLT Peer Id
595 [Arguments] ${olt_peer_id}
596 [Documentation] Lookup the OLT Peer Id in against the list of ONU device Ids
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700597 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400598 Should Be Equal As Integers ${rc} 0
599 ${jsondata}= To Json ${output}
600 Log ${jsondata}
601 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700602 ${matched}= Set Variable False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700603 FOR ${INDEX} IN RANGE 0 ${length}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400604 ${value}= Get From List ${jsondata} ${INDEX}
605 ${devid}= Get From Dictionary ${value} id
Andy Bavierb63f6d22020-03-12 15:34:37 -0700606 ${matched}= Set Variable If '${devid}' == '${olt_peer_id}' True False
607 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400608 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700609 Should Be True ${matched} Peer id ${olt_peer_id} does not match any ONU device id
Gilles Depatieb5682f82019-10-31 10:39:45 -0400610
611Validate ONU Peer Id
612 [Arguments] ${olt_device_id} ${List_ONU_Serial}
613 [Documentation] Match each ONU peer to that of the OLT device id
614 FOR ${onu_serial} IN @{List_ONU_Serial}
615 ${onu_dev_id}= Get Device ID From SN ${onu_serial}
616 Match ONU Peer Id ${onu_dev_id}
617 END
618
619Match ONU Peer Id
620 [Arguments] ${onu_dev_id}
621 [Documentation] Match an ONU peer to that of the OLT device id
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800622 ${rc} ${output}= Run and Return Rc and Output
623 ... ${VOLTCTL_CONFIG}; voltctl device port list ${onu_dev_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400624 Should Be Equal As Integers ${rc} 0
625 ${jsondata}= To Json ${output}
626 Log ${jsondata}
627 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700628 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400629 FOR ${INDEX} IN RANGE 0 ${length}
630 ${value}= Get From List ${jsondata} ${INDEX}
631 ${type}= Get From Dictionary ${value} type
632 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700633 ${matched}= Set Variable If '${type}' == 'PON_ONU' True False
634 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400635 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700636 Should Be True ${matched} No PON port found for ONU ${onu_dev_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400637 ${length}= Get Length ${peers}
638 FOR ${INDEX} IN RANGE 0 ${length}
639 ${value}= Get From List ${peers} ${INDEX}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530640 ${peer_id}= Get From Dictionary ${value} deviceId
Gilles Depatieb5682f82019-10-31 10:39:45 -0400641 END
642 Should Be Equal '${peer_id}' '${olt_device_id}'
643 ... Mismatch between ONU peer ${peer_id} and OLT device id ${olt_device_id} values=False
Kailash6f5acb62019-08-28 14:38:45 -0700644
Kailash6f5acb62019-08-28 14:38:45 -0700645Get Device ID From SN
646 [Arguments] ${serial_number}
647 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700648 ${rc} ${id}= Run and Return Rc and Output
Andy Bavier8fca0452019-12-16 15:30:11 -0700649 ... ${VOLTCTL_CONFIG}; voltctl device list --filter=SerialNumber=${serial_number} --format='{{.Id}}'
650 Should Be Equal As Integers ${rc} 0
651 Log ${id}
Kailash6f5acb62019-08-28 14:38:45 -0700652 [Return] ${id}
653
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700654Get Logical Device ID From SN
655 [Arguments] ${serial_number}
656 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700657 ${rc} ${id}= Run and Return Rc and Output
Scott Baker2ab2a0c2020-06-05 12:51:47 -0700658 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice list --filter=Desc.SerialNum=${serial_number} --format='{{.Id}}'
Andy Bavier8fca0452019-12-16 15:30:11 -0700659 Should Be Equal As Integers ${rc} 0
660 Log ${id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700661 [Return] ${id}
662
Gilles Depatieb5682f82019-10-31 10:39:45 -0400663Build ONU SN List
664 [Arguments] ${serial_numbers}
665 [Documentation] Appends all ONU SNs to the ${serial_numbers} list
666 FOR ${INDEX} IN RANGE 0 ${num_onus}
667 Append To List ${serial_numbers} ${hosts.src[${INDEX}].onu}
668 END
669
670Get SN From Device ID
671 [Arguments] ${device_id}
672 [Documentation] Gets the device id by matching for ${device_id}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700673 ${rc} ${sn}= Run and Return Rc and Output
Andy Bavier8fca0452019-12-16 15:30:11 -0700674 ... ${VOLTCTL_CONFIG}; voltctl device list --filter=Id=${device_id} --format='{{.SerialNumber}}'
Gilles Depatieb5682f82019-10-31 10:39:45 -0400675 Should Be Equal As Integers ${rc} 0
Andy Bavier8fca0452019-12-16 15:30:11 -0700676 Log ${sn}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400677 [Return] ${sn}
678
Scott Baker60e570d2020-02-02 22:10:13 -0800679Get Parent ID From Device ID
680 [Arguments] ${device_id}
681 [Documentation] Gets the device id by matching for ${device_id}
682 ${rc} ${pid}= Run and Return Rc and Output
683 ... ${VOLTCTL_CONFIG}; voltctl device list --filter=Id=${device_id} --format='{{.ParentId}}'
684 Should Be Equal As Integers ${rc} 0
685 Log ${pid}
686 [Return] ${pid}
687
Kailash6f5acb62019-08-28 14:38:45 -0700688Validate Device Removed
689 [Arguments] ${id}
690 [Documentation] Verifys that device, ${serial_number}, has been removed
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700691 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
Andy Bavier8fca0452019-12-16 15:30:11 -0700692 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700693 ${jsondata}= To Json ${output}
694 Log ${jsondata}
695 ${length}= Get Length ${jsondata}
696 @{ids}= Create List
Zack Williamsec53a1b2019-09-16 15:50:52 -0700697 FOR ${INDEX} IN RANGE 0 ${length}
698 ${value}= Get From List ${jsondata} ${INDEX}
699 ${device_id}= Get From Dictionary ${value} id
700 Append To List ${ids} ${device_id}
701 END
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700702 List Should Not Contain Value ${ids} ${id}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800703
704Reboot ONU
TorstenThieme1fbe8082020-10-21 13:27:59 +0000705 [Arguments] ${onu_id}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800706 [Documentation] Using voltctl command reboot ONU and verify that ONU comes up to running state
707 ${rc} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device reboot ${onu_id}
708 Should Be Equal As Integers ${rc} 0
TorstenThieme1fbe8082020-10-21 13:27:59 +0000709 Run Keyword And Continue On Failure Wait Until Keyword Succeeds 60s 1s Validate ONU Device By Device Id
710 ... ENABLED DISCOVERED REACHABLE rebooting ${onu_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700711
712Assert ONUs in Voltha
713 [Arguments] ${count}
714 [Documentation] Check that a certain number of devices reached the ACTIVE/ENABLE state
715 ${rc1} ${devices}= Run and Return Rc and Output
Matteo Scandolof831b0e2020-06-26 11:57:17 -0700716 ... ${VOLTCTL_CONFIG}; voltctl -m 8M device list | grep -v OLT | grep ACTIVE | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700717 Should Be Equal As Integers ${rc1} 0
718 Should Be Equal As Integers ${devices} ${count}
719
720Wait for ONUs in VOLTHA
721 [Arguments] ${count}
722 [Documentation] Waits until a certain number of devices reached the ACTIVE/ENABLE state
723 Wait Until Keyword Succeeds 10m 5s Assert ONUs In Voltha ${count}
724
725Count Logical Devices flows
726 [Documentation] Count the flows across logical devices in VOLTHA
727 [Arguments] ${targetFlows}
728 ${output}= Get Logical Device List From Voltha
729 ${logical_devices}= To Json ${output}
730 ${total_flows}= Set Variable 0
731 FOR ${device} IN @{logical_devices}
732 ${rc} ${flows}= Run and Return Rc and Output
733 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${device['id']} | grep -v ID | wc -l
734 Should Be Equal As Integers ${rc} 0
735 ${total_flows}= Evaluate ${total_flows} + ${flows}
736 END
Matteo Scandolo616daab2020-05-13 11:49:24 -0700737 ${msg}= Format String Found {total_flows} flows of {targetFlows} expected
738 ... total_flows=${total_flows} targetFlows=${targetFlows}
739 Log ${msg}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700740 Should Be Equal As Integers ${targetFlows} ${total_flows}
741
742Wait for Logical Devices flows
743 [Documentation] Waits until the flows have been provisioned in the logical device
744 [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200745 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700746 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200747 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700748 Log ${targetFlows}
749 # TODO extend Validate Logical Device Flows to check the correct number of flows
750 Wait Until Keyword Succeeds 10m 5s Count Logical Devices flows ${targetFlows}
751
Matteo Scandolo616daab2020-05-13 11:49:24 -0700752Count OpenOLT Device Flows
753 [Documentation] Count the flows across openolt devices in VOLTHA
754 [Arguments] ${targetFlows}
755 ${output}= Get Device List from Voltha by type openolt
756 ${devices}= To Json ${output}
757 ${total_flows}= Set Variable 0
758 FOR ${device} IN @{devices}
759 ${rc} ${flows}= Run and Return Rc and Output
760 ... ${VOLTCTL_CONFIG}; voltctl device flows ${device['id']} | grep -v ID | wc -l
761 Should Be Equal As Integers ${rc} 0
762 ${total_flows}= Evaluate ${total_flows} + ${flows}
763 END
764 ${msg}= Format String Found {total_flows} flows of {targetFlows} expected
765 ... total_flows=${total_flows} targetFlows=${targetFlows}
766 Log ${msg}
767 Should Be Equal As Integers ${targetFlows} ${total_flows}
768
769Wait for OpenOLT Devices flows
770 [Documentation] Waits until the flows have been provisioned in the openolt devices
771 [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200772 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700773 ${beforeFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
774 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandoloda854b02020-09-01 16:20:51 -0700775 # In the physical device we only have 2 data plane flows (on the PON) instead of 4
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700776 ${afterFlows}= Evaluate ${beforeFlows} - (${uni_count} * 2)
Matteo Scandoloda854b02020-09-01 16:20:51 -0700777 # In the TT workflow we have multiple service,
778 # so we need to remove 6 flows per each UNI that are only on the ONU device
779 ${ttFlows}= Evaluate ${beforeFlows} - (${uni_count} * 6)
780 ${afterFlows}= Set Variable If $workflow=='tt' ${ttFlows} ${afterFlows}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700781 ${targetFlows}= Set Variable If $provisioned=='true' ${afterFlows} ${beforeFlows}
Matteo Scandolo616daab2020-05-13 11:49:24 -0700782 Log ${targetFlows}
Hardik Windlass2b37e712020-06-12 02:13:17 +0530783 Wait Until Keyword Succeeds 10m 5s Count OpenOLT Device Flows ${targetFlows}