blob: b9d68440b22b67c3a8bf8ad9dd3126890e377e61 [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}
Matteo Scandolobfb74382021-05-10 15:45:16 -0700173 Log ${output}
Kailash6f5acb62019-08-28 14:38:45 -0700174 ${length}= Get Length ${jsondata}
ubuntu6b6e7d42020-03-02 12:35:42 -0800175 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700176 FOR ${INDEX} IN RANGE 0 ${length}
177 ${value}= Get From List ${jsondata} ${INDEX}
Scott Baker780b65f2020-05-22 14:03:15 -0700178 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
179 ... Dictionary Should Contain Key ${value} adminState
180 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
181 ... Get From Dictionary ${value} adminState
182 ... ELSE
183 ... Get From Dictionary ${value} adminstate
184 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
185 ... Get From Dictionary ${value} operStatus
186 ... ELSE
187 ... Get From Dictionary ${value} operstatus
188 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
189 ... Get From Dictionary ${value} connectStatus
190 ... ELSE
191 ... Get From Dictionary ${value} connectstatus
192 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
193 ... Get From Dictionary ${value} serialNumber
194 ... ELSE
195 ... Get From Dictionary ${value} serialnumber
Gilles Depatieb5682f82019-10-31 10:39:45 -0400196 ${devId}= Get From Dictionary ${value} id
Zack Williamsec53a1b2019-09-16 15:50:52 -0700197 ${mib_state}= Get From Dictionary ${value} reason
ubuntu6b6e7d42020-03-02 12:35:42 -0800198 ${matched}= Set Variable If '${sn}' == '${id}' or '${devId}' == '${id}' True False
Andy Bavierb63f6d22020-03-12 15:34:37 -0700199 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700200 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700201 Should Be True ${matched} No match found for ${id} to validate device
Matteo Scandolo5e10b282019-11-25 10:54:32 -0700202 Log ${value}
ubuntu6b6e7d42020-03-02 12:35:42 -0800203 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
Gilles Depatie675a2062019-10-22 12:44:42 -0400204 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800205 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400206 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800207 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400208 ... values=False
Matteo Scandolo74bd5c32020-12-08 09:52:19 -0800209 Run Keyword If '${onu}' == 'True' Should Contain '${onu_reason}' '${mib_state}'
ubuntu6b6e7d42020-03-02 12:35:42 -0800210 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400211
212Validate OLT Device
ubuntu6b6e7d42020-03-02 12:35:42 -0800213 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${id}=${EMPTY}
214 [Documentation] Parses the output of "voltctl device list" and inspects device ${id}, specified
215 ... as either its serial numbner or device ID. Match on OLT Serial number or Device Id and inspect states
216 Validate Device ${admin_state} ${oper_status} ${connect_status} ${id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400217
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800218Validate OLT Devices
219 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${ids}=${EMPTY}
220 [Documentation] Parses the output of "voltctl device list" and inspects device ${id}, specified
221 ... as either its serial numbner or device ID. Match on OLT Serial number or Device Id and inspect states
222 FOR ${I} IN RANGE 0 ${olt_count}
223 ${olt_serial_number}= Get From Dictionary ${olt_ids}[${I}] sn
224 ${olt_device_id}= Get OLTDeviceID From OLT List ${olt_serial_number}
225 Validate Device ${admin_state} ${oper_status} ${connect_status} ${olt_device_id}
226 END
227
Gilles Depatieb5682f82019-10-31 10:39:45 -0400228Validate ONU Devices
229 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${List_ONU_Serial}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700230 ... ${onu_reason}=omci-flows-pushed
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700231 [Documentation] Parses the output of "voltctl device list" and inspects device ${List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400232 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
233 ... states including MIB state
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700234 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400235 Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700236 ... onu_reason=${onu_reason} onu=True
Debasish28130d02020-03-16 11:05:26 +0000237 END
238
Gilles Depatieb5682f82019-10-31 10:39:45 -0400239Validate Device Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700240 [Documentation]
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800241 ... Parses the output of voltctl device port list <device_id> and matches the port types listed
Andy Bavier90eb1a12020-03-26 11:54:35 -0700242 [Arguments] ${device_id} ${pon_type} ${ethernet_type} ${all_active}=True
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700243 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800244 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${device_id} -m 8MB -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400245 Should Be Equal As Integers ${rc} 0
246 ${jsondata}= To Json ${output}
247 Log ${jsondata}
248 ${length}= Get Length ${jsondata}
249 FOR ${INDEX} IN RANGE 0 ${length}
250 ${value}= Get From List ${jsondata} ${INDEX}
Scott Baker780b65f2020-05-22 14:03:15 -0700251 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
252 ... Dictionary Should Contain Key ${value} adminState
253 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
Hardik Windlass2b37e712020-06-12 02:13:17 +0530254 ... Get From Dictionary ${value} adminState
Scott Baker780b65f2020-05-22 14:03:15 -0700255 ... ELSE
Hardik Windlass2b37e712020-06-12 02:13:17 +0530256 ... Get From Dictionary ${value} adminstate
Scott Baker780b65f2020-05-22 14:03:15 -0700257 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
258 ... Get From Dictionary ${value} operStatus
259 ... ELSE
Hardik Windlass2b37e712020-06-12 02:13:17 +0530260 ... Get From Dictionary ${value} operstatus
Gilles Depatieb5682f82019-10-31 10:39:45 -0400261 ${type}= Get From Dictionary ${value} type
Hemaf64d34c2020-03-25 00:40:17 +0530262 Should Be Equal '${astate}' 'ENABLED' Device ${device_id} port admin_state != ENABLED values=False
Andy Bavier90eb1a12020-03-26 11:54:35 -0700263 Run Keyword If ${all_active} Should Be Equal '${opstatus}' 'ACTIVE'
264 ... Device ${device_id} port oper_status != ACTIVE values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400265 Should Be True '${type}' == '${pon_type}' or '${type}' == '${ethernet_type}'
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700266 ... Device ${device_id} port type is neither ${pon_type} or ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400267 END
268
269Validate OLT Port Types
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800270 [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 -0700271 [Arguments] ${pon_type} ${ethernet_type}
272 Validate Device Port Types ${olt_device_id} ${pon_type} ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400273
274Validate ONU Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700275 [Arguments] ${List_ONU_Serial} ${pon_type} ${ethernet_type}
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800276 [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 -0700277 ... and matches the port types listed
Gilles Depatieb5682f82019-10-31 10:39:45 -0400278 FOR ${serial_number} IN @{List_ONU_Serial}
279 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Andy Bavier90eb1a12020-03-26 11:54:35 -0700280 # Only first UNI port is ACTIVE; the rest are in DISCOVERED operstatus
281 Validate Device Port Types ${onu_dev_id} ${pon_type} ${ethernet_type} all_active=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400282 END
283
284Validate Device Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000285 [Arguments] ${device_id} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400286 [Documentation] Parses the output of voltctl device flows <device_id> and expects flow count > 0
Andrea Campanella80655eb2020-07-10 15:49:22 +0200287 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800288 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m 8MB -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400289 Should Be Equal As Integers ${rc} 0
290 ${jsondata}= To Json ${output}
291 Log ${jsondata}
292 ${length}= Get Length ${jsondata}
293 Log 'Number of flows = ' ${length}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000294 Run Keyword If '${flow_count}' == '${EMPTY}' Should Be True ${length} > 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400295 ... Number of flows for ${device_id} was 0
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000296 ... ELSE Should Be True ${length} == ${flow_count}
297 ... Number of flows for ${device_id} was not ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400298
299Validate OLT Flows
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800300 [Arguments] ${flow_count}=${EMPTY} ${olt_device_id}=${EMPTY}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000301 [Documentation] Parses the output of voltctl device flows ${olt_device_id}
302 ... and expects flow count == ${flow_count}
303 Validate Device Flows ${olt_device_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400304
305Validate ONU Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000306 [Arguments] ${List_ONU_Serial} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400307 [Documentation] Parses the output of voltctl device flows for each ONU SN listed in ${List_ONU_Serial}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000308 ... and expects flow count == ${flow_count}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700309 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400310 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000311 Validate Device Flows ${onu_dev_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400312 END
313
TorstenThieme401af432020-06-11 15:53:53 +0000314Validate ONU Devices With Duration
315 [Documentation]
316 ... Parses the output of "voltctl device list" and inspects all devices ${List_ONU_Serial},
317 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
318 ... states including MIB state.
319 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${onu_reason}
320 ... ${List_ONU_Serial} ${startTime} ${print2console}=False ${output_file}=${EMPTY}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000321 ... ${alternate_reason}=${EMPTY}
TorstenThiemef78a9d82021-03-05 13:42:09 +0000322 ${cmd}= Catenate voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -f Type=brcm_openomci_onu
Matteo Scandolo6f24ea92021-04-29 11:55:50 -0700323 ... --format "{{.SerialNumber}}\t{{.AdminState}}\t{{.OperStatus}}\t{{.ConnectStatus}}\t{{.Reason}}" | grep -v SERIALNUMBER
TorstenThiemef78a9d82021-03-05 13:42:09 +0000324 ${rc} ${output}= Run and Return Rc and Output ${cmd}
TorstenThieme401af432020-06-11 15:53:53 +0000325 Should Be Equal As Integers ${rc} 0
326 ${timeCurrent} = Get Current Date
327 ${timeTotalMs} = Subtract Date From Date ${timeCurrent} ${startTime} result_format=number
TorstenThiemef78a9d82021-03-05 13:42:09 +0000328 @{Results}= Split String ${output} \n
329 FOR ${Line} IN @{Results}
TorstenThieme401af432020-06-11 15:53:53 +0000330 ${matched}= Set Variable False
TorstenThiemef78a9d82021-03-05 13:42:09 +0000331 @{words}= Split String ${Line} \t
332 ${sn}= Set Variable ${words[0]}
333 ${astate}= Set Variable ${words[1]}
334 ${opstatus}= Set Variable ${words[2]}
335 ${cstatus}= Set Variable ${words[3]}
336 ${mib_state}= Set Variable ${words[4]}
TorstenThieme401af432020-06-11 15:53:53 +0000337 ${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
TorstenThiemec3c23232021-01-13 13:06:31 +0000342 ${len}= Get Length ${alternate_reason}
TorstenThieme105c5982021-01-21 09:50:27 +0000343 ${matches}= Run Keyword If ${len} >= 1 Get Match Count ${alternate_reason} ${mib_state}
344 ... ELSE Set Variable 0
TorstenThiemec3c23232021-01-13 13:06:31 +0000345 ${matched}= Set Variable If '${mib_state}' == '${onu_reason}' or ${matches} >= 1
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000346 ... ${matched} False
TorstenThieme401af432020-06-11 15:53:53 +0000347 Run Keyword If ${matched} and ${print2console} Log
348 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec. console=yes
349 Run Keyword If ${matched} and ('${output_file}'!='${EMPTY}') Append To File ${output_file}
350 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec.
351 Run Keyword If ${matched} Remove Values From List ${List_ONU_Serial} ${sn}
352 END
353 Should Be Empty ${List_ONU_Serial} List ${List_ONU_Serial} not empty
354
TorstenThieme9949b172020-06-16 10:00:15 +0000355Validate ONU Devices MIB State With Duration
356 [Documentation]
357 ... Parses the output of "voltctl device list" and inspects all devices ${List_ONU_Serial},
358 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect MIB state.
359 [Arguments] ${onu_reason}
360 ... ${List_ONU_Serial} ${startTime} ${print2console}=False ${output_file}=${EMPTY}
361 ${type} = Set Variable brcm_openomci_onu
Andrea Campanella80655eb2020-07-10 15:49:22 +0200362 ${voltctl_commad} = Catenate SEPARATOR=
363 ... voltctl device list -m 8MB -f Type=${type} -f Reason=${onu_reason} --format '{{.SerialNumber}}'
364 ${rc} ${output}= Run and Return Rc and Output ${voltctl_commad}
TorstenThieme9949b172020-06-16 10:00:15 +0000365 Should Be Equal As Integers ${rc} 0
366 ${timeCurrent} = Get Current Date
367 ${timeTotalMs} = Subtract Date From Date ${timeCurrent} ${startTime} result_format=number
368 @{outputdata} = Split String ${output}
369 ${outputlength} = Get Length ${outputdata}
370 ${onulength} = Get Length ${List_ONU_Serial}
371 ${Matches} = Run Keyword If ${outputlength}<=${onulength}
372 ... Compare Lists ${outputdata} ${List_ONU_Serial}
373 ... ELSE Compare Lists ${List_ONU_Serial} ${outputdata}
374 ${length} = Get Length ${Matches}
375 FOR ${INDEX} IN RANGE 0 ${length}
376 ${sn}= Get From List ${Matches} ${INDEX}
377 Run Keyword If ${print2console} Log
378 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec. console=yes
379 Run Keyword If ('${output_file}'!='${EMPTY}') Append To File ${output_file}
380 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec.
381 Remove Values From List ${List_ONU_Serial} ${sn}
382 END
383 Should Be Empty ${List_ONU_Serial} List ${List_ONU_Serial} not empty
384
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000385Validate ONU Device By Device Id
386 [Documentation]
387 ... Parses the output of "voltctl device list" filtered by device id and inspects states including reason.
388 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${onu_reason} ${onu_id}
Matteo Scandolo5899be12020-11-11 15:38:07 -0800389 ${cmd} Catenate voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${onu_id} -m 8MB -o json
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000390 ${rc} ${output}= Run and Return Rc and Output ${cmd}
391 Should Be Equal As Integers ${rc} 0
392 ${jsondata}= To Json ${output}
393 ${length}= Get Length ${jsondata}
394 Should Be Equal As Integers ${length} 1 No match found for ${onu_id} to validate device
395 ${value}= Get From List ${jsondata} 0
396 Log ${value}
397 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
398 ... Dictionary Should Contain Key ${value} adminState
399 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
400 ... Get From Dictionary ${value} adminState
401 ... ELSE
402 ... Get From Dictionary ${value} adminstate
403 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
404 ... Get From Dictionary ${value} operStatus
405 ... ELSE
406 ... Get From Dictionary ${value} operstatus
407 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
408 ... Get From Dictionary ${value} connectStatus
409 ... ELSE
410 ... Get From Dictionary ${value} connectstatus
411 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
412 ... Get From Dictionary ${value} serialNumber
413 ... ELSE
414 ... Get From Dictionary ${value} serialnumber
415 ${devId}= Get From Dictionary ${value} id
416 ${mib_state}= Get From Dictionary ${value} reason
417 Should Be Equal '${devId}' '${onu_id}' No match found for ${onu_id} to validate device
418 ... values=False
419 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
420 ... values=False
421 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
422 ... values=False
423 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
424 ... values=False
425 Should Be Equal '${mib_state}' '${onu_reason}'
426 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
427
428
TorstenThieme9949b172020-06-16 10:00:15 +0000429Compare Lists
430 [Documentation]
431 ... Compares both lists and put all matches in the returned list
432 [Arguments] ${ListIterate} ${ListCompare}
433 @{list} = Create List
434 ${length} = Get Length ${ListIterate}
435 FOR ${INDEX} IN RANGE 0 ${length}
436 ${sn}= Get From List ${ListIterate} ${INDEX}
437 ${onu_id}= Get Index From List ${ListCompare} ${sn}
438 Run Keyword If -1 != ${onu_id} Append To List ${list} ${sn}
439 END
440 [Return] ${list}
441
Gilles Depatieb5682f82019-10-31 10:39:45 -0400442Validate Logical Device
443 [Documentation] Validate Logical Device is listed
Matteo Scandolo5899be12020-11-11 15:38:07 -0800444 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} logicaldevice list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400445 Should Be Equal As Integers ${rc} 0
446 ${jsondata}= To Json ${output}
447 Log ${jsondata}
448 ${length}= Get Length ${jsondata}
449 FOR ${INDEX} IN RANGE 0 ${length}
450 ${value}= Get From List ${jsondata} ${INDEX}
451 ${devid}= Get From Dictionary ${value} id
Scott Baker2ab2a0c2020-06-05 12:51:47 -0700452 ${rootdev}= Get From Dictionary ${value} rootDeviceId
453 ${desc}= Get From Dictionary ${value} desc
454 ${sn}= Get From Dictionary ${desc} serialNum
Gilles Depatieb5682f82019-10-31 10:39:45 -0400455 Exit For Loop
456 END
457 Should Be Equal '${rootdev}' '${olt_device_id}' Root Device does not match ${olt_device_id} values=False
458 Should Be Equal '${sn}' '${BBSIM_OLT_SN}' Logical Device ${sn} does not match ${BBSIM_OLT_SN}
459 ... values=False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700460 [Return] ${devid}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400461
462Validate Logical Device Ports
463 [Arguments] ${logical_device_id}
464 [Documentation] Validate Logical Device Ports are listed and are > 0
465 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800466 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice port list ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400467 Should Be Equal As Integers ${rc} 0
468 ${jsondata}= To Json ${output}
469 Log ${jsondata}
470 ${length}= Get Length ${jsondata}
471 Should Be True ${length} > 0 Number of ports for ${logical_device_id} was 0
472
473Validate Logical Device Flows
474 [Arguments] ${logical_device_id}
475 [Documentation] Validate Logical Device Flows are listed and are > 0
476 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800477 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice flows ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400478 Should Be Equal As Integers ${rc} 0
479 ${jsondata}= To Json ${output}
480 Log ${jsondata}
481 ${length}= Get Length ${jsondata}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700482 Should Be True ${length} > 0 Number of flows for ${logical_device_id} was 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400483
Hardik Windlass16cdf962020-04-29 15:26:50 +0530484Retrieve OLT PON Ports
485 [Arguments] ${olt_device_id}
486 [Documentation] Retrieves the list of PON ports from the OLT device
487 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800488 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530489 Should Be Equal As Integers ${rc} 0
490 ${jsondata}= To Json ${output}
491 Log ${jsondata}
492 ${length}= Get Length ${jsondata}
493 ${olt_pon_list}= Create List
494 FOR ${INDEX} IN RANGE 0 ${length}
495 ${value}= Get From List ${jsondata} ${INDEX}
496 ${type}= Get From Dictionary ${value} type
497 ${portno}= Get From Dictionary ${value} portNo
498 ${peers}= Get From Dictionary ${value} peers
499 ${len_peers}= Get Length ${peers}
500 Run Keyword If '${type}' == 'PON_OLT' and ${len_peers} > 0
501 ... Append To List ${olt_pon_list} ${portno}
502 END
503 [Return] ${olt_pon_list}
504
505Retrieve Peer List From OLT PON Port
506 [Arguments] ${olt_device_id} ${pon_port}
507 [Documentation] Retrieves the list of peer device ids list from the OLT PON port
508 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800509 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530510 Should Be Equal As Integers ${rc} 0
511 ${jsondata}= To Json ${output}
512 Log ${jsondata}
513 ${length}= Get Length ${jsondata}
514 ${matched}= Set Variable False
515 FOR ${INDEX} IN RANGE 0 ${length}
516 ${value}= Get From List ${jsondata} ${INDEX}
517 ${type}= Get From Dictionary ${value} type
518 ${portno}= Get From Dictionary ${value} portNo
519 ${peers}= Get From Dictionary ${value} peers
520 ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
521 Exit For Loop If ${matched}
522 END
523 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
524 ${length}= Get Length ${peers}
525 ${olt_peer_list}= Create List
526 FOR ${INDEX} IN RANGE 0 ${length}
527 ${value}= Get From List ${peers} ${INDEX}
528 ${peer_id}= Get From Dictionary ${value} deviceId
529 Append To List ${olt_peer_list} ${peer_id}
530 END
531 [Return] ${olt_peer_list}
532
533Validate OLT PON Port Status
534 [Arguments] ${olt_device_id} ${pon_port} ${admin_state} ${oper_status}
535 [Documentation] Verifies the state of the PON port of the OLT
536 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800537 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530538 Should Be Equal As Integers ${rc} 0
539 ${jsondata}= To Json ${output}
540 Log ${jsondata}
541 ${length}= Get Length ${jsondata}
542 ${matched}= Set Variable False
543 FOR ${INDEX} IN RANGE 0 ${length}
544 ${value}= Get From List ${jsondata} ${INDEX}
545 ${type}= Get From Dictionary ${value} type
546 ${portno}= Get From Dictionary ${value} portNo
547 ${astate}= Get From Dictionary ${value} adminState
548 ${opstatus}= Get From Dictionary ${value} operStatus
549 ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
550 Exit For Loop If ${matched}
551 END
552 Should Be True ${matched} No PON port found for OLT ${olt_device_id} ${pon_port}
553 Log ${value}
554 Should Be Equal '${astate}' '${admin_state}' OLT PON Port admin_state != ${admin_state}
555 ... values=False
556 Should Be Equal '${opstatus}' '${oper_status}' OLT PON Port oper_status != ${oper_status}
557 ... values=False
558
559DisableOrEnable OLT PON Port
560 [Arguments] ${operation} ${olt_device_id} ${portno}
561 [Documentation] Disables or Enables the PON port of the OLT
562 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800563 ... voltctl -c ${VOLTCTL_CONFIG} device port ${operation} ${olt_device_id} ${portno}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530564 Should Be Equal As Integers ${rc} 0
565
Gilles Depatieb5682f82019-10-31 10:39:45 -0400566Retrieve Peer List From OLT
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700567 [Arguments] ${olt_peer_list}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400568 [Documentation] Retrieve the list of peer device id list from port list
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700569 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800570 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400571 Should Be Equal As Integers ${rc} 0
572 ${jsondata}= To Json ${output}
573 Log ${jsondata}
574 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700575 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400576 FOR ${INDEX} IN RANGE 0 ${length}
577 ${value}= Get From List ${jsondata} ${INDEX}
578 ${type}= Get From Dictionary ${value} type
579 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700580 ${matched}= Set Variable If '${type}' == 'PON_OLT' True False
581 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400582 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700583 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400584 ${length}= Get Length ${peers}
585 FOR ${INDEX} IN RANGE 0 ${length}
586 ${value}= Get From List ${peers} ${INDEX}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530587 ${peer_id}= Get From Dictionary ${value} deviceId
Gilles Depatieb5682f82019-10-31 10:39:45 -0400588 Append To List ${olt_peer_list} ${peer_id}
589 END
590
591Validate OLT Peer Id List
592 [Arguments] ${olt_peer_id_list}
593 [Documentation] Match each entry in the ${olt_peer_id_list} against ONU device ids.
594 FOR ${peer_id} IN @{olt_peer_id_list}
595 Match OLT Peer Id ${peer_id}
596 END
597
598Match OLT Peer Id
599 [Arguments] ${olt_peer_id}
600 [Documentation] Lookup the OLT Peer Id in against the list of ONU device Ids
Matteo Scandolo5899be12020-11-11 15:38:07 -0800601 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400602 Should Be Equal As Integers ${rc} 0
603 ${jsondata}= To Json ${output}
604 Log ${jsondata}
605 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700606 ${matched}= Set Variable False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700607 FOR ${INDEX} IN RANGE 0 ${length}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400608 ${value}= Get From List ${jsondata} ${INDEX}
609 ${devid}= Get From Dictionary ${value} id
Andy Bavierb63f6d22020-03-12 15:34:37 -0700610 ${matched}= Set Variable If '${devid}' == '${olt_peer_id}' True False
611 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400612 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700613 Should Be True ${matched} Peer id ${olt_peer_id} does not match any ONU device id
Gilles Depatieb5682f82019-10-31 10:39:45 -0400614
615Validate ONU Peer Id
616 [Arguments] ${olt_device_id} ${List_ONU_Serial}
617 [Documentation] Match each ONU peer to that of the OLT device id
618 FOR ${onu_serial} IN @{List_ONU_Serial}
619 ${onu_dev_id}= Get Device ID From SN ${onu_serial}
620 Match ONU Peer Id ${onu_dev_id}
621 END
622
623Match ONU Peer Id
624 [Arguments] ${onu_dev_id}
625 [Documentation] Match an ONU peer to that of the OLT device id
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800626 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800627 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${onu_dev_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400628 Should Be Equal As Integers ${rc} 0
629 ${jsondata}= To Json ${output}
630 Log ${jsondata}
631 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700632 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400633 FOR ${INDEX} IN RANGE 0 ${length}
634 ${value}= Get From List ${jsondata} ${INDEX}
635 ${type}= Get From Dictionary ${value} type
636 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700637 ${matched}= Set Variable If '${type}' == 'PON_ONU' True False
638 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400639 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700640 Should Be True ${matched} No PON port found for ONU ${onu_dev_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400641 ${length}= Get Length ${peers}
642 FOR ${INDEX} IN RANGE 0 ${length}
643 ${value}= Get From List ${peers} ${INDEX}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530644 ${peer_id}= Get From Dictionary ${value} deviceId
Gilles Depatieb5682f82019-10-31 10:39:45 -0400645 END
646 Should Be Equal '${peer_id}' '${olt_device_id}'
647 ... Mismatch between ONU peer ${peer_id} and OLT device id ${olt_device_id} values=False
Kailash6f5acb62019-08-28 14:38:45 -0700648
Kailash6f5acb62019-08-28 14:38:45 -0700649Get Device ID From SN
650 [Arguments] ${serial_number}
651 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700652 ${rc} ${id}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800653 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=SerialNumber=${serial_number} --format='{{.Id}}'
Matteo Scandolo2769d2b2021-04-14 10:29:24 -0700654 Should Be Equal As Integers ${rc} 0 "Error while fetching device list from VOLTHA"
Andy Bavier8fca0452019-12-16 15:30:11 -0700655 Log ${id}
Kailash6f5acb62019-08-28 14:38:45 -0700656 [Return] ${id}
657
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700658Get Logical Device ID From SN
659 [Arguments] ${serial_number}
660 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700661 ${rc} ${id}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800662 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice list --filter=Desc.SerialNum=${serial_number} --format='{{.Id}}'
Andy Bavier8fca0452019-12-16 15:30:11 -0700663 Should Be Equal As Integers ${rc} 0
664 Log ${id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700665 [Return] ${id}
666
Gilles Depatieb5682f82019-10-31 10:39:45 -0400667Build ONU SN List
Andrea Campanella6391f842020-11-16 10:01:18 +0100668 [Arguments] ${serial_numbers} ${olt_serial_number}=${EMPTY} ${num_onus}=${num_all_onus}
669 [Documentation] Appends all ONU SNs for the given OLT to the ${serial_numbers} list
Gilles Depatieb5682f82019-10-31 10:39:45 -0400670 FOR ${INDEX} IN RANGE 0 ${num_onus}
Andrea Campanella6391f842020-11-16 10:01:18 +0100671 Run Keyword IF "${olt_serial_number}"=="${hosts.src[${INDEX}].olt}" or "${olt_serial_number}"=="${EMPTY}"
672 ... Append To List ${serial_numbers} ${hosts.src[${INDEX}].onu}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400673 END
674
675Get SN From Device ID
676 [Arguments] ${device_id}
677 [Documentation] Gets the device id by matching for ${device_id}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700678 ${rc} ${sn}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800679 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${device_id} --format='{{.SerialNumber}}'
Gilles Depatieb5682f82019-10-31 10:39:45 -0400680 Should Be Equal As Integers ${rc} 0
Andy Bavier8fca0452019-12-16 15:30:11 -0700681 Log ${sn}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400682 [Return] ${sn}
683
Scott Baker60e570d2020-02-02 22:10:13 -0800684Get Parent ID From Device ID
685 [Arguments] ${device_id}
686 [Documentation] Gets the device id by matching for ${device_id}
687 ${rc} ${pid}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800688 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${device_id} --format='{{.ParentId}}'
Scott Baker60e570d2020-02-02 22:10:13 -0800689 Should Be Equal As Integers ${rc} 0
690 Log ${pid}
691 [Return] ${pid}
692
Kailash6f5acb62019-08-28 14:38:45 -0700693Validate Device Removed
694 [Arguments] ${id}
695 [Documentation] Verifys that device, ${serial_number}, has been removed
Matteo Scandolo5899be12020-11-11 15:38:07 -0800696 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -o json
Andy Bavier8fca0452019-12-16 15:30:11 -0700697 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700698 ${jsondata}= To Json ${output}
699 Log ${jsondata}
700 ${length}= Get Length ${jsondata}
701 @{ids}= Create List
Zack Williamsec53a1b2019-09-16 15:50:52 -0700702 FOR ${INDEX} IN RANGE 0 ${length}
703 ${value}= Get From List ${jsondata} ${INDEX}
704 ${device_id}= Get From Dictionary ${value} id
705 Append To List ${ids} ${device_id}
706 END
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700707 List Should Not Contain Value ${ids} ${id}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800708
Andrea Campanella4e507882020-11-26 11:33:11 +0100709Validate all ONUS for OLT Removed
710 [Arguments] ${num_all_onus} ${hosts} ${olt_serial_number} ${timeout}
711 [Documentation] Verifys that all the ONUS for OLT ${serial_number}, has been removed
712 FOR ${J} IN RANGE 0 ${num_all_onus}
713 ${src}= Set Variable ${hosts.src[${J}]}
714 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
715 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
716 ... Validate Device Removed ${src['onu']}
717 END
718
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800719Reboot ONU
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000720 [Arguments] ${onu_id} ${validate_device}=True
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800721 [Documentation] Using voltctl command reboot ONU and verify that ONU comes up to running state
Matteo Scandolo5899be12020-11-11 15:38:07 -0800722 ${rc} ${devices}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device reboot ${onu_id}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800723 Should Be Equal As Integers ${rc} 0
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000724 Run Keyword If ${validate_device} Run Keyword And Continue On Failure Wait Until Keyword Succeeds
725 ... 60s 1s Validate ONU Device By Device Id ENABLED DISCOVERED REACHABLE rebooting ${onu_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700726
727Assert ONUs in Voltha
728 [Arguments] ${count}
729 [Documentation] Check that a certain number of devices reached the ACTIVE/ENABLE state
730 ${rc1} ${devices}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800731 ... voltctl -c ${VOLTCTL_CONFIG} -m 8M device list | grep -v OLT | grep ACTIVE | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700732 Should Be Equal As Integers ${rc1} 0
733 Should Be Equal As Integers ${devices} ${count}
734
735Wait for ONUs in VOLTHA
736 [Arguments] ${count}
737 [Documentation] Waits until a certain number of devices reached the ACTIVE/ENABLE state
738 Wait Until Keyword Succeeds 10m 5s Assert ONUs In Voltha ${count}
739
740Count Logical Devices flows
741 [Documentation] Count the flows across logical devices in VOLTHA
742 [Arguments] ${targetFlows}
743 ${output}= Get Logical Device List From Voltha
744 ${logical_devices}= To Json ${output}
745 ${total_flows}= Set Variable 0
746 FOR ${device} IN @{logical_devices}
747 ${rc} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800748 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice flows ${device['id']} | grep -v ID | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700749 Should Be Equal As Integers ${rc} 0
750 ${total_flows}= Evaluate ${total_flows} + ${flows}
751 END
Matteo Scandolo616daab2020-05-13 11:49:24 -0700752 ${msg}= Format String Found {total_flows} flows of {targetFlows} expected
753 ... total_flows=${total_flows} targetFlows=${targetFlows}
754 Log ${msg}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700755 Should Be Equal As Integers ${targetFlows} ${total_flows}
756
757Wait for Logical Devices flows
758 [Documentation] Waits until the flows have been provisioned in the logical device
759 [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200760 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700761 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200762 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700763 Log ${targetFlows}
764 # TODO extend Validate Logical Device Flows to check the correct number of flows
765 Wait Until Keyword Succeeds 10m 5s Count Logical Devices flows ${targetFlows}
766
Matteo Scandolo616daab2020-05-13 11:49:24 -0700767Count OpenOLT Device Flows
768 [Documentation] Count the flows across openolt devices in VOLTHA
769 [Arguments] ${targetFlows}
770 ${output}= Get Device List from Voltha by type openolt
771 ${devices}= To Json ${output}
772 ${total_flows}= Set Variable 0
773 FOR ${device} IN @{devices}
774 ${rc} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800775 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device['id']} | grep -v ID | wc -l
Matteo Scandolo616daab2020-05-13 11:49:24 -0700776 Should Be Equal As Integers ${rc} 0
777 ${total_flows}= Evaluate ${total_flows} + ${flows}
778 END
779 ${msg}= Format String Found {total_flows} flows of {targetFlows} expected
780 ... total_flows=${total_flows} targetFlows=${targetFlows}
781 Log ${msg}
782 Should Be Equal As Integers ${targetFlows} ${total_flows}
783
784Wait for OpenOLT Devices flows
785 [Documentation] Waits until the flows have been provisioned in the openolt devices
786 [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200787 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700788 ${beforeFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
789 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandoloda854b02020-09-01 16:20:51 -0700790 # In the physical device we only have 2 data plane flows (on the PON) instead of 4
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700791 ${afterFlows}= Evaluate ${beforeFlows} - (${uni_count} * 2)
Matteo Scandoloda854b02020-09-01 16:20:51 -0700792 # In the TT workflow we have multiple service,
793 # so we need to remove 6 flows per each UNI that are only on the ONU device
794 ${ttFlows}= Evaluate ${beforeFlows} - (${uni_count} * 6)
795 ${afterFlows}= Set Variable If $workflow=='tt' ${ttFlows} ${afterFlows}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700796 ${targetFlows}= Set Variable If $provisioned=='true' ${afterFlows} ${beforeFlows}
Matteo Scandolo616daab2020-05-13 11:49:24 -0700797 Log ${targetFlows}
Hardik Windlass2b37e712020-06-12 02:13:17 +0530798 Wait Until Keyword Succeeds 10m 5s Count OpenOLT Device Flows ${targetFlows}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000799
800Download ONU Device Image
801 [Documentation] Downloads the given ONU software image
802 [Arguments] ${id} ${image} ${url} ${ver} ${crc} ${local_dir}
803 ${rc}= Run and Return Rc
804 ... voltctl -c ${VOLTCTL_CONFIG} device image download ${id} ${image} ${url} ${ver} ${crc} ${local_dir}
805 Should Be Equal As Integers ${rc} 0
806
807Activate ONU Device Image
808 [Documentation] Activatess the given ONU software image
809 [Arguments] ${id} ${image} ${ver} ${crc} ${local_dir}
810 ${rc}= Run and Return Rc
811 ... voltctl -c ${VOLTCTL_CONFIG} device image activate ${id} ${image} ${ver} ${crc} ${local_dir}
812 Should Be Equal As Integers ${rc} 0
813
814Verify ONU Device Image
815 [Documentation] Verfies the ONU device image state
816 [Arguments] ${dev_id} ${download_state} ${image_state} ${expected_reason}
817 ${rc} ${output}= Run and Return Rc and Output
818 ... voltctl -c ${VOLTCTL_CONFIG} device image list ${dev_id} -o json
819 Should Be Equal As Integers ${rc} 0
820 ${jsondata}= To Json ${output}
821 Log ${jsondata}
822 ${length}= Get Length ${jsondata}
823 ${matched}= Set Variable False
824 FOR ${INDEX} IN RANGE 0 ${length}
825 ${value}= Get From List ${jsondata} ${INDEX}
826 ${id}= Get From Dictionary ${value} id
827 ${downloadstate}= Get From Dictionary ${value} downloadState
828 ${imagestate}= Get From Dictionary ${value} imageState
829 ${reason}= Get From Dictionary ${value} reason
830 ${matched}= Set Variable If '${id}' == '${dev_id}' True False
831 Exit For Loop If ${matched}
832 END
833 Should Be True ${matched} No ONU Device Image for Id: ${dev_id}
834 Should Be Equal '${downloadstate}' '${download_state}' ONU Device ${id} Image downloadState does not match
835 Should Be Equal '${imagestate}' '${image_state}' ONU Device ${id} Image imageState does not match
836 Should Be Equal '${reason}' '${expected_reason}' ONU Device ${id} Image reason does not match
TorstenThiemeff9c9142021-04-08 07:21:34 +0000837
838
839# pm-data relevant keywords
840Read Default Interval From Pmconfig
841 [Documentation] Reads default interval from pm config
842 [Arguments] ${device_id}
843 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig get ${device_id}
844 Should Be Equal As Integers ${rc} 0
845 log ${result}
846 @{words}= Split String ${result}
847 ${interval}= Get From List ${words} 3
848 log ${interval}
849 [return] ${interval}
850
851Read Group Interval From Pmconfig
852 [Documentation] Reads default interval from pm config
853 [Arguments] ${device_id} ${group}
854 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group list ${device_id} | grep ${group}
855 Should Be Equal As Integers ${rc} 0
856 log ${result}
857 @{words}= Split String ${result}
858 ${interval}= Get From List ${words} -1
859 log ${interval}
860 [return] ${interval}
861
862Set and Validate Default Interval
863 [Documentation] Sets and validates default interval of pm data
864 [Arguments] ${device_id} ${interval}
865 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig frequency set ${device_id} ${interval}
866 Should Be Equal As Integers ${rc} 0
867 log ${result}
868 # workaround until unit will be printed out in voltctl - remove unit
869 ${interval}= Get Substring ${interval} 0 -1
870 Should Contain ${result} ${interval}
871
872Set and Validate Group Interval
873 [Documentation] Sets and validates group interval of pm data
874 [Arguments] ${device_id} ${interval} ${group}
875 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group set ${device_id} ${group} ${interval}
876 Should Be Equal As Integers ${rc} 0
877 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group list ${device_id} | grep ${group}
878 Should Be Equal As Integers ${rc} 0
879 log ${result}
880 # workaround until unit will be printed out in voltctl - remove unit
881 ${interval}= Get Substring ${interval} 0 -1
882 Should Contain ${result} ${interval}
883
884Read Group List
885 [Documentation] Reads metric group list of given device
886 [Arguments] ${device_id}
887 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group list ${device_id} | grep -v GROUPNAME
888 Should Be Equal As Integers ${rc} 0
889 ${group_list} Create List
890 ${interval_dict} Create Dictionary
891 @{output}= Split String ${result} \n
892 FOR ${Line} IN @{output}
893 @{words}= Split String ${Line}
894 ${group}= Set Variable ${words[0]}
895 ${interval}= Set Variable ${words[2]}
896 Append To List ${group_list} ${group}
897 Set To Dictionary ${interval_dict} ${group}=${interval}
898 END
899 [return] ${group_list} ${interval_dict}
900
901Read Group Metric List
902 [Documentation] Reads group metric list of given device and group
903 [Arguments] ${device_id} ${group}
904 ${cmd}= Catenate voltctl device pmconfig groupmetric list ${device_id} ${group} | grep -v SAMPLEFREQ
905 ${rc} ${result}= Run and Return Rc and Output ${cmd}
906 Should Be Equal As Integers ${rc} 0
907 ${groupmetric_list} Create List
908 @{output}= Split String ${result} \n
909 FOR ${Line} IN @{output}
910 @{words}= Split String ${Line}
911 ${name}= Set Variable ${words[0]}
912 ${type}= Set Variable ${words[1]}
913 ${enabled}= Set Variable ${words[2]}
914 ${subdict}= Create Dictionary type=${type} enabled=${enabled}
915 ${dict}= Create Dictionary ${name}=${subdict}
916 Append To List ${groupmetric_list} ${dict}
917 END
918 [return] ${groupmetric_list}
919
920Read Group Metric Dict
921 [Documentation] Reads group metric list of given device and group
922 [Arguments] ${device_id} ${group}
923 ${cmd}= Catenate voltctl device pmconfig groupmetric list ${device_id} ${group} | grep -v SAMPLEFREQ
924 ${rc} ${result}= Run and Return Rc and Output ${cmd}
925 Should Be Equal As Integers ${rc} 0
926 ${groupmetric_dict} Create Dictionary
927 @{output}= Split String ${result} \n
928 FOR ${Line} IN @{output}
929 @{words}= Split String ${Line}
930 ${name}= Set Variable ${words[0]}
931 ${type}= Set Variable ${words[1]}
932 ${enabled}= Set Variable ${words[2]}
933 ${subdict}= Create Dictionary type=${type} enabled=${enabled}
934 Set To Dictionary ${groupmetric_dict} ${name}=${subdict}
935 END
936 [return] ${groupmetric_dict}