blob: 650c289f0c117f63375d3f9ce6d73cad82fdb984 [file] [log] [blame]
Joey Armstrong888f1ee2023-01-11 17:14:30 -05001# Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors
Kailash6f5acb62019-08-28 14:38:45 -07002#
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
Matteo Scandoloc2a19e32022-03-11 08:05:55 -080028*** Variables ***
29${voltctlGrpcLimit} 32M
30
Kailash6f5acb62019-08-28 14:38:45 -070031*** Keywords ***
Gilles Depatieb5682f82019-10-31 10:39:45 -040032Test Empty Device List
Zack Williamsa8fe75a2020-01-10 14:25:27 -070033 [Documentation] Verify that there are no devices in the system
Matteo Scandolo5899be12020-11-11 15:38:07 -080034 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -040035 Should Be Equal As Integers ${rc} 0
36 ${jsondata}= To Json ${output}
37 Log ${jsondata}
38 ${length}= Get Length ${jsondata}
David Bainbridgef81cd642019-11-20 00:14:47 +000039 Should Be Equal As Integers ${length} 0
Gilles Depatieb5682f82019-10-31 10:39:45 -040040
Kailash6f5acb62019-08-28 14:38:45 -070041Create Device
Matteo Scandolo142e6272020-04-29 17:36:59 -070042 [Arguments] ${ip} ${port} ${type}=openolt
You Wang2b550642019-10-07 14:39:48 -070043 [Documentation] Creates a device in VOLTHA
Kailash6f5acb62019-08-28 14:38:45 -070044 #create/preprovision device
Gilles Depatie675a2062019-10-22 12:44:42 -040045 ${rc} ${device_id}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080046 ... voltctl -c ${VOLTCTL_CONFIG} device create -t ${type} -H ${ip}:${port}
47 Log ${device_id}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -070048 Should Be Equal As Integers ${rc} 0 Failed to Create Device beause of ${device_id}
Kailash6f5acb62019-08-28 14:38:45 -070049 [Return] ${device_id}
50
51Enable Device
52 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -070053 [Documentation] Enables a device in VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -070054 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080055 ... voltctl -c ${VOLTCTL_CONFIG} device enable ${device_id}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -070056 Should Be Equal As Integers ${rc} 0 Failed to Enable Device beause of ${output}
Kailash6f5acb62019-08-28 14:38:45 -070057
Suchitra Vemuri6db89412019-11-14 14:52:54 -080058Disable Device
59 [Arguments] ${device_id}
Hardik Windlassaaea3402020-03-10 19:45:45 +053060 [Documentation] Disables a device in VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -070061 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080062 ... voltctl -c ${VOLTCTL_CONFIG} device disable ${device_id}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -070063 Should Be Equal As Integers ${rc} 0 Failed to Disable Device beause of ${output}
Suchitra Vemuri6db89412019-11-14 14:52:54 -080064
Hardik Windlassaaea3402020-03-10 19:45:45 +053065Delete Device
66 [Arguments] ${device_id}
67 [Documentation] Deletes a device in VOLTHA
68 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080069 ... voltctl -c ${VOLTCTL_CONFIG} device delete ${device_id}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -070070 Should Be Equal As Integers ${rc} 0 Failed to Delete Device beause of ${output}
Hardik Windlassaaea3402020-03-10 19:45:45 +053071
Hemadf003682020-04-28 21:22:22 +053072Reboot Device
73 [Arguments] ${device_id}
74 [Documentation] Reboot the OLT using voltctl command
75 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080076 ... voltctl -c ${VOLTCTL_CONFIG} device reboot ${device_id}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -070077 Should Be Equal As Integers ${rc} 0 Failed to Reboot Device beause of ${output}
Hemadf003682020-04-28 21:22:22 +053078
David Bainbridgef81cd642019-11-20 00:14:47 +000079Disable Devices In Voltha
80 [Documentation] Disables all the known devices in voltha
81 [Arguments] ${filter}
82 ${arg}= Set Variable ${EMPTY}
83 ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070084 ${rc} ${devices}= Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -080085 ... voltctl -c ${VOLTCTL_CONFIG} device list -m ${voltctlGrpcLimit} ${arg} --orderby Root -q | xargs echo -n
David Bainbridgef81cd642019-11-20 00:14:47 +000086 Should Be Equal As Integers ${rc} 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -070087 ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080088 ... voltctl -c ${VOLTCTL_CONFIG} device disable ${devices}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -070089 Run Keyword If len('${devices}') != 0
90 ... Should Be Equal As Integers ${rc} 0 Failed to Disable Devices beause of ${output}
David Bainbridgef81cd642019-11-20 00:14:47 +000091
92Test Devices Disabled In Voltha
93 [Documentation] Tests to verify that all devices in VOLTHA are disabled
94 [Arguments] ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070095 ${rc} ${count}= Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -080096 ... voltctl -c ${VOLTCTL_CONFIG} device list -m ${voltctlGrpcLimit} --filter '${filter},AdminState!=DISABLED' -q | wc -l
David Bainbridgef81cd642019-11-20 00:14:47 +000097 Should Be Equal As Integers ${rc} 0
98 Should Be Equal As Integers ${count} 0
99
100Delete Devices In Voltha
101 [Documentation] Disables all the known devices in voltha
102 [Arguments] ${filter}
103 ${arg}= Set Variable ${EMPTY}
104 ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700105 ${rc} ${devices}= Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800106 ... voltctl -c ${VOLTCTL_CONFIG} device list ${arg} -m ${voltctlGrpcLimit} --orderby Root -q | xargs echo -n
David Bainbridgef81cd642019-11-20 00:14:47 +0000107 Should Be Equal As Integers ${rc} 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700108 ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800109 ... voltctl -c ${VOLTCTL_CONFIG} device delete ${devices}
David Bainbridgef81cd642019-11-20 00:14:47 +0000110 Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0
111
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700112Get Device Flows from Voltha
113 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700114 [Documentation] Gets device flows from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700115 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800116 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m ${voltctlGrpcLimit}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700117 Should Be Equal As Integers ${rc} 0
118 [Return] ${output}
119
120Get Logical Device Output from Voltha
121 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700122 [Documentation] Gets logicaldevice flows and ports from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700123 ${rc1} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800124 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice flows ${device_id}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700125 ${rc2} ${ports}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800126 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice port list ${device_id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700127 Log ${flows}
128 Log ${ports}
129 Should Be Equal As Integers ${rc1} 0
130 Should Be Equal As Integers ${rc2} 0
131
132Get Device Output from Voltha
133 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700134 [Documentation] Gets device flows and ports from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700135 ${rc1} ${flows}= Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800136 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m ${voltctlGrpcLimit}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700137 ${rc2} ${ports}= Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800138 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${device_id} -m ${voltctlGrpcLimit}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700139 Log ${flows}
140 Log ${ports}
141 Should Be Equal As Integers ${rc1} 0
142 Should Be Equal As Integers ${rc2} 0
143
Suchitra Vemuri1a970a62019-11-26 12:52:16 -0800144Get Device List from Voltha
145 [Documentation] Gets Device List Output from Voltha
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800146 ${rc1} ${devices}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -m ${voltctlGrpcLimit}
Suchitra Vemuri1a970a62019-11-26 12:52:16 -0800147 Log ${devices}
148 Should Be Equal As Integers ${rc1} 0
149
Hardik Windlassf8b3ee62022-01-24 16:36:32 +0000150Get ONUs Device IDs from Voltha
151 [Documentation] Fetches the ONU Device Ids from Voltha
152 ${rc} ${onus}= Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800153 ... voltctl -c ${VOLTCTL_CONFIG} device list -m ${voltctlGrpcLimit} -f Type=brcm_openomci_onu -q
Hardik Windlassf8b3ee62022-01-24 16:36:32 +0000154 Should Be Equal as Integers ${rc} 0
155 @{onuDevList}= Split To Lines ${onus}
156 [Return] ${onuDevList}
157
Matteo Scandolo616daab2020-05-13 11:49:24 -0700158Get Device List from Voltha by type
159 [Documentation] Gets Device List Output from Voltha applying filtering by device type
160 [Arguments] ${type}
161 ${rc1} ${devices}= Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800162 ... voltctl -c ${VOLTCTL_CONFIG} device list -m ${voltctlGrpcLimit} -f Type=${type} -o json
Matteo Scandolo616daab2020-05-13 11:49:24 -0700163 Log ${devices}
164 Should Be Equal As Integers ${rc1} 0
165 Return From Keyword ${devices}
166
Matteo Scandolo142e6272020-04-29 17:36:59 -0700167Get Logical Device List from Voltha
168 [Documentation] Gets Logical Device List Output from Voltha (in json format)
Andrea Campanella80655eb2020-07-10 15:49:22 +0200169 ${rc1} ${devices}= Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800170 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice list -m ${voltctlGrpcLimit} -o json
Matteo Scandolo142e6272020-04-29 17:36:59 -0700171 Log ${devices}
172 Should Be Equal As Integers ${rc1} 0
173 Return From Keyword ${devices}
174
Kailash6f5acb62019-08-28 14:38:45 -0700175Validate Device
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700176 [Documentation]
ubuntu6b6e7d42020-03-02 12:35:42 -0800177 ... Parses the output of "voltctl device list" and inspects a device ${id}, specified as either
178 ... the serial number or device ID. Arguments are matched for device states of: "admin_state",
179 ... "oper_status", and "connect_status"
Hardik Windlass8b446492021-06-10 06:25:23 +0000180 ... Note: Set "by_dev_id" to True if Device Id is passed for validation
181 ... otherwise look up will be based on Device Serial Number
ubuntu6b6e7d42020-03-02 12:35:42 -0800182 [Arguments] ${admin_state} ${oper_status} ${connect_status}
Hardik Windlass8b446492021-06-10 06:25:23 +0000183 ... ${id} ${onu_reason}=${EMPTY} ${onu}=False ${by_dev_id}=False
184 ${rc} ${output}= Run Keyword If ${by_dev_id} Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800185 ... voltctl -c ${VOLTCTL_CONFIG} device list -m ${voltctlGrpcLimit} -f Id=${id} -o json
Hardik Windlass8b446492021-06-10 06:25:23 +0000186 ... ELSE Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800187 ... voltctl -c ${VOLTCTL_CONFIG} device list -m ${voltctlGrpcLimit} -f SerialNumber=${id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400188 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700189 ${jsondata}= To Json ${output}
Matteo Scandolobfb74382021-05-10 15:45:16 -0700190 Log ${output}
Kailash6f5acb62019-08-28 14:38:45 -0700191 ${length}= Get Length ${jsondata}
ubuntu6b6e7d42020-03-02 12:35:42 -0800192 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700193 FOR ${INDEX} IN RANGE 0 ${length}
194 ${value}= Get From List ${jsondata} ${INDEX}
Scott Baker780b65f2020-05-22 14:03:15 -0700195 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
196 ... Dictionary Should Contain Key ${value} adminState
197 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
198 ... Get From Dictionary ${value} adminState
199 ... ELSE
200 ... Get From Dictionary ${value} adminstate
201 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
202 ... Get From Dictionary ${value} operStatus
203 ... ELSE
204 ... Get From Dictionary ${value} operstatus
205 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
206 ... Get From Dictionary ${value} connectStatus
207 ... ELSE
208 ... Get From Dictionary ${value} connectstatus
209 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
210 ... Get From Dictionary ${value} serialNumber
211 ... ELSE
212 ... Get From Dictionary ${value} serialnumber
Gilles Depatieb5682f82019-10-31 10:39:45 -0400213 ${devId}= Get From Dictionary ${value} id
Zack Williamsec53a1b2019-09-16 15:50:52 -0700214 ${mib_state}= Get From Dictionary ${value} reason
ubuntu6b6e7d42020-03-02 12:35:42 -0800215 ${matched}= Set Variable If '${sn}' == '${id}' or '${devId}' == '${id}' True False
Andy Bavierb63f6d22020-03-12 15:34:37 -0700216 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700217 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700218 Should Be True ${matched} No match found for ${id} to validate device
Matteo Scandolo5e10b282019-11-25 10:54:32 -0700219 Log ${value}
ubuntu6b6e7d42020-03-02 12:35:42 -0800220 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
Gilles Depatie675a2062019-10-22 12:44:42 -0400221 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800222 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400223 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800224 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400225 ... values=False
Matteo Scandolo74bd5c32020-12-08 09:52:19 -0800226 Run Keyword If '${onu}' == 'True' Should Contain '${onu_reason}' '${mib_state}'
ubuntu6b6e7d42020-03-02 12:35:42 -0800227 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400228
229Validate OLT Device
Hardik Windlass8b446492021-06-10 06:25:23 +0000230 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${id} ${by_dev_id}=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800231 [Documentation] Parses the output of "voltctl device list" and inspects device ${id}, specified
232 ... as either its serial numbner or device ID. Match on OLT Serial number or Device Id and inspect states
Hardik Windlass8b446492021-06-10 06:25:23 +0000233 ... Note: Set "by_dev_id" to True if Device Id is passed for validation
234 ... otherwise look up will be based on Device Serial Number
235 Validate Device ${admin_state} ${oper_status} ${connect_status} ${id} by_dev_id=${by_dev_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400236
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800237Validate OLT Devices
238 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${ids}=${EMPTY}
239 [Documentation] Parses the output of "voltctl device list" and inspects device ${id}, specified
240 ... as either its serial numbner or device ID. Match on OLT Serial number or Device Id and inspect states
241 FOR ${I} IN RANGE 0 ${olt_count}
242 ${olt_serial_number}= Get From Dictionary ${olt_ids}[${I}] sn
243 ${olt_device_id}= Get OLTDeviceID From OLT List ${olt_serial_number}
Hardik Windlass8b446492021-06-10 06:25:23 +0000244 Validate Device ${admin_state} ${oper_status} ${connect_status} ${olt_device_id} by_dev_id=True
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800245 END
246
Gilles Depatieb5682f82019-10-31 10:39:45 -0400247Validate ONU Devices
248 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${List_ONU_Serial}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700249 ... ${onu_reason}=omci-flows-pushed
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700250 [Documentation] Parses the output of "voltctl device list" and inspects device ${List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400251 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
252 ... states including MIB state
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700253 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400254 Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700255 ... onu_reason=${onu_reason} onu=True
Debasish28130d02020-03-16 11:05:26 +0000256 END
257
Gilles Depatieb5682f82019-10-31 10:39:45 -0400258Validate Device Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700259 [Documentation]
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800260 ... Parses the output of voltctl device port list <device_id> and matches the port types listed
Andy Bavier90eb1a12020-03-26 11:54:35 -0700261 [Arguments] ${device_id} ${pon_type} ${ethernet_type} ${all_active}=True
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700262 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800263 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${device_id} -m ${voltctlGrpcLimit} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400264 Should Be Equal As Integers ${rc} 0
265 ${jsondata}= To Json ${output}
266 Log ${jsondata}
267 ${length}= Get Length ${jsondata}
268 FOR ${INDEX} IN RANGE 0 ${length}
269 ${value}= Get From List ${jsondata} ${INDEX}
Scott Baker780b65f2020-05-22 14:03:15 -0700270 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
271 ... Dictionary Should Contain Key ${value} adminState
272 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
Hardik Windlass2b37e712020-06-12 02:13:17 +0530273 ... Get From Dictionary ${value} adminState
Scott Baker780b65f2020-05-22 14:03:15 -0700274 ... ELSE
Hardik Windlass2b37e712020-06-12 02:13:17 +0530275 ... Get From Dictionary ${value} adminstate
Scott Baker780b65f2020-05-22 14:03:15 -0700276 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
277 ... Get From Dictionary ${value} operStatus
278 ... ELSE
Hardik Windlass2b37e712020-06-12 02:13:17 +0530279 ... Get From Dictionary ${value} operstatus
Gilles Depatieb5682f82019-10-31 10:39:45 -0400280 ${type}= Get From Dictionary ${value} type
Hemaf64d34c2020-03-25 00:40:17 +0530281 Should Be Equal '${astate}' 'ENABLED' Device ${device_id} port admin_state != ENABLED values=False
Andy Bavier90eb1a12020-03-26 11:54:35 -0700282 Run Keyword If ${all_active} Should Be Equal '${opstatus}' 'ACTIVE'
283 ... Device ${device_id} port oper_status != ACTIVE values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400284 Should Be True '${type}' == '${pon_type}' or '${type}' == '${ethernet_type}'
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700285 ... Device ${device_id} port type is neither ${pon_type} or ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400286 END
287
288Validate OLT Port Types
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800289 [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 -0700290 [Arguments] ${pon_type} ${ethernet_type}
291 Validate Device Port Types ${olt_device_id} ${pon_type} ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400292
293Validate ONU Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700294 [Arguments] ${List_ONU_Serial} ${pon_type} ${ethernet_type}
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800295 [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 -0700296 ... and matches the port types listed
Gilles Depatieb5682f82019-10-31 10:39:45 -0400297 FOR ${serial_number} IN @{List_ONU_Serial}
298 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Andy Bavier90eb1a12020-03-26 11:54:35 -0700299 # Only first UNI port is ACTIVE; the rest are in DISCOVERED operstatus
300 Validate Device Port Types ${onu_dev_id} ${pon_type} ${ethernet_type} all_active=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400301 END
302
303Validate Device Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000304 [Arguments] ${device_id} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400305 [Documentation] Parses the output of voltctl device flows <device_id> and expects flow count > 0
Andrea Campanella80655eb2020-07-10 15:49:22 +0200306 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800307 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m ${voltctlGrpcLimit} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400308 Should Be Equal As Integers ${rc} 0
309 ${jsondata}= To Json ${output}
310 Log ${jsondata}
311 ${length}= Get Length ${jsondata}
312 Log 'Number of flows = ' ${length}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000313 Run Keyword If '${flow_count}' == '${EMPTY}' Should Be True ${length} > 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400314 ... Number of flows for ${device_id} was 0
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000315 ... ELSE Should Be True ${length} == ${flow_count}
316 ... Number of flows for ${device_id} was not ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400317
318Validate OLT Flows
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800319 [Arguments] ${flow_count}=${EMPTY} ${olt_device_id}=${EMPTY}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000320 [Documentation] Parses the output of voltctl device flows ${olt_device_id}
321 ... and expects flow count == ${flow_count}
322 Validate Device Flows ${olt_device_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400323
324Validate ONU Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000325 [Arguments] ${List_ONU_Serial} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400326 [Documentation] Parses the output of voltctl device flows for each ONU SN listed in ${List_ONU_Serial}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000327 ... and expects flow count == ${flow_count}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700328 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400329 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000330 Validate Device Flows ${onu_dev_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400331 END
332
TorstenThieme401af432020-06-11 15:53:53 +0000333Validate ONU Devices With Duration
334 [Documentation]
335 ... Parses the output of "voltctl device list" and inspects all devices ${List_ONU_Serial},
336 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
337 ... states including MIB state.
338 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${onu_reason}
339 ... ${List_ONU_Serial} ${startTime} ${print2console}=False ${output_file}=${EMPTY}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000340 ... ${alternate_reason}=${EMPTY}
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800341 ${cmd}= Catenate voltctl -c ${VOLTCTL_CONFIG} device list -m ${voltctlGrpcLimit} -f Type=brcm_openomci_onu
Matteo Scandolo6f24ea92021-04-29 11:55:50 -0700342 ... --format "{{.SerialNumber}}\t{{.AdminState}}\t{{.OperStatus}}\t{{.ConnectStatus}}\t{{.Reason}}" | grep -v SERIALNUMBER
TorstenThiemef78a9d82021-03-05 13:42:09 +0000343 ${rc} ${output}= Run and Return Rc and Output ${cmd}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700344 Should Be Equal As Integers ${rc} 0 Failed Validate ONU Devices because of ${output}
345 Log ${output}
TorstenThieme401af432020-06-11 15:53:53 +0000346 ${timeCurrent} = Get Current Date
347 ${timeTotalMs} = Subtract Date From Date ${timeCurrent} ${startTime} result_format=number
TorstenThiemef78a9d82021-03-05 13:42:09 +0000348 @{Results}= Split String ${output} \n
349 FOR ${Line} IN @{Results}
TorstenThieme401af432020-06-11 15:53:53 +0000350 ${matched}= Set Variable False
TorstenThiemef78a9d82021-03-05 13:42:09 +0000351 @{words}= Split String ${Line} \t
352 ${sn}= Set Variable ${words[0]}
353 ${astate}= Set Variable ${words[1]}
354 ${opstatus}= Set Variable ${words[2]}
355 ${cstatus}= Set Variable ${words[3]}
356 ${mib_state}= Set Variable ${words[4]}
TorstenThieme401af432020-06-11 15:53:53 +0000357 ${onu_id}= Get Index From List ${List_ONU_Serial} ${sn}
358 ${matched}= Set Variable If -1 != ${onu_id} True False
359 ${matched}= Set Variable If '${astate}' == '${admin_state}' ${matched} False
360 ${matched}= Set Variable If '${opstatus}' == '${oper_status}' ${matched} False
361 ${matched}= Set Variable If '${cstatus}' == '${connect_status}' ${matched} False
TorstenThiemec3c23232021-01-13 13:06:31 +0000362 ${len}= Get Length ${alternate_reason}
TorstenThieme105c5982021-01-21 09:50:27 +0000363 ${matches}= Run Keyword If ${len} >= 1 Get Match Count ${alternate_reason} ${mib_state}
364 ... ELSE Set Variable 0
TorstenThiemec3c23232021-01-13 13:06:31 +0000365 ${matched}= Set Variable If '${mib_state}' == '${onu_reason}' or ${matches} >= 1
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000366 ... ${matched} False
TorstenThieme401af432020-06-11 15:53:53 +0000367 Run Keyword If ${matched} and ${print2console} Log
368 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec. console=yes
369 Run Keyword If ${matched} and ('${output_file}'!='${EMPTY}') Append To File ${output_file}
370 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec.
371 Run Keyword If ${matched} Remove Values From List ${List_ONU_Serial} ${sn}
372 END
373 Should Be Empty ${List_ONU_Serial} List ${List_ONU_Serial} not empty
374
TorstenThieme9949b172020-06-16 10:00:15 +0000375Validate ONU Devices MIB State With Duration
376 [Documentation]
377 ... Parses the output of "voltctl device list" and inspects all devices ${List_ONU_Serial},
378 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect MIB state.
379 [Arguments] ${onu_reason}
380 ... ${List_ONU_Serial} ${startTime} ${print2console}=False ${output_file}=${EMPTY}
381 ${type} = Set Variable brcm_openomci_onu
Andrea Campanella80655eb2020-07-10 15:49:22 +0200382 ${voltctl_commad} = Catenate SEPARATOR=
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800383 ... voltctl device list -m ${voltctlGrpcLimit} -f Type=${type} -f Reason=${onu_reason} --format '{{.SerialNumber}}'
Andrea Campanella80655eb2020-07-10 15:49:22 +0200384 ${rc} ${output}= Run and Return Rc and Output ${voltctl_commad}
TorstenThieme9949b172020-06-16 10:00:15 +0000385 Should Be Equal As Integers ${rc} 0
386 ${timeCurrent} = Get Current Date
387 ${timeTotalMs} = Subtract Date From Date ${timeCurrent} ${startTime} result_format=number
388 @{outputdata} = Split String ${output}
389 ${outputlength} = Get Length ${outputdata}
390 ${onulength} = Get Length ${List_ONU_Serial}
391 ${Matches} = Run Keyword If ${outputlength}<=${onulength}
392 ... Compare Lists ${outputdata} ${List_ONU_Serial}
393 ... ELSE Compare Lists ${List_ONU_Serial} ${outputdata}
394 ${length} = Get Length ${Matches}
395 FOR ${INDEX} IN RANGE 0 ${length}
396 ${sn}= Get From List ${Matches} ${INDEX}
397 Run Keyword If ${print2console} Log
398 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec. console=yes
399 Run Keyword If ('${output_file}'!='${EMPTY}') Append To File ${output_file}
400 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec.
401 Remove Values From List ${List_ONU_Serial} ${sn}
402 END
403 Should Be Empty ${List_ONU_Serial} List ${List_ONU_Serial} not empty
404
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000405Validate ONU Device By Device Id
406 [Documentation]
407 ... Parses the output of "voltctl device list" filtered by device id and inspects states including reason.
408 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${onu_reason} ${onu_id}
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800409 ${cmd} Catenate voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${onu_id} -m ${voltctlGrpcLimit} -o json
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000410 ${rc} ${output}= Run and Return Rc and Output ${cmd}
411 Should Be Equal As Integers ${rc} 0
412 ${jsondata}= To Json ${output}
413 ${length}= Get Length ${jsondata}
414 Should Be Equal As Integers ${length} 1 No match found for ${onu_id} to validate device
415 ${value}= Get From List ${jsondata} 0
416 Log ${value}
417 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
418 ... Dictionary Should Contain Key ${value} adminState
419 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
420 ... Get From Dictionary ${value} adminState
421 ... ELSE
422 ... Get From Dictionary ${value} adminstate
423 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
424 ... Get From Dictionary ${value} operStatus
425 ... ELSE
426 ... Get From Dictionary ${value} operstatus
427 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
428 ... Get From Dictionary ${value} connectStatus
429 ... ELSE
430 ... Get From Dictionary ${value} connectstatus
431 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
432 ... Get From Dictionary ${value} serialNumber
433 ... ELSE
434 ... Get From Dictionary ${value} serialnumber
435 ${devId}= Get From Dictionary ${value} id
436 ${mib_state}= Get From Dictionary ${value} reason
437 Should Be Equal '${devId}' '${onu_id}' No match found for ${onu_id} to validate device
438 ... values=False
439 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
440 ... values=False
441 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
442 ... values=False
443 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
444 ... values=False
445 Should Be Equal '${mib_state}' '${onu_reason}'
446 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
447
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000448Check all ONU OperStatus
449 [Documentation] Checks that all ONUs OperStatus is the required one.
450 [Arguments] ${List_ONU_Serial} ${oper_status}
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800451 ${cmd}= Catenate voltctl -c ${VOLTCTL_CONFIG} device list -m ${voltctlGrpcLimit} -f Type=brcm_openomci_onu
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000452 ... --format "{{.SerialNumber}}\t{{.AdminState}}\t{{.OperStatus}}\t{{.ConnectStatus}}\t{{.Reason}}"
453 ... | grep -v SERIALNUMBER | grep ${oper_status}
454 ${rc} ${output}= Run and Return Rc and Output ${cmd}
455 Should Be Equal As Integers ${rc} 0
456 @{Results}= Split String ${output} \n
457 FOR ${Line} IN @{Results}
458 @{words}= Split String ${Line} \t
459 ${sn}= Set Variable ${words[0]}
460 Remove Values From List ${List_ONU_Serial} ${sn}
461 END
462 Should Be Empty ${List_ONU_Serial} For ONUs ${List_ONU_Serial} OperStatus ${oper_status} not matched!
463
464Validate Last ONU Communication
465 [Documentation] Validates last communication with ONU.
466 [Arguments] ${validation_duration}=5s
467 ${cmd}= Catenate voltctl -c ${VOLTCTL_CONFIG} adapter list -f Type=brcm_openomci_onu
468 ... --format '{{gosince .LastCommunication}}'
469 ${rc} ${output}= Run and Return Rc and Output ${cmd}
470 Should Be Equal As Integers ${rc} 0
TorstenThieme70790282021-11-19 10:26:25 +0000471 ${lastcomm}= Convert Time ${output}
472 ${validduration}= Convert Time ${validation_duration}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000473 Should Be True ${lastcomm}<=${validduration}
474
475Get Onu Image List
476 [Documentation] Delivers the ONU device image list
477 [Arguments] ${dev_id}
478 ${rc} ${output}= Run and Return Rc and Output
479 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage list ${dev_id}
480 [return] ${rc} ${output}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000481
TorstenThieme9949b172020-06-16 10:00:15 +0000482Compare Lists
483 [Documentation]
484 ... Compares both lists and put all matches in the returned list
485 [Arguments] ${ListIterate} ${ListCompare}
486 @{list} = Create List
487 ${length} = Get Length ${ListIterate}
488 FOR ${INDEX} IN RANGE 0 ${length}
489 ${sn}= Get From List ${ListIterate} ${INDEX}
490 ${onu_id}= Get Index From List ${ListCompare} ${sn}
491 Run Keyword If -1 != ${onu_id} Append To List ${list} ${sn}
492 END
493 [Return] ${list}
494
Gilles Depatieb5682f82019-10-31 10:39:45 -0400495Validate Logical Device
496 [Documentation] Validate Logical Device is listed
Matteo Scandolo5899be12020-11-11 15:38:07 -0800497 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} logicaldevice list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400498 Should Be Equal As Integers ${rc} 0
499 ${jsondata}= To Json ${output}
500 Log ${jsondata}
501 ${length}= Get Length ${jsondata}
502 FOR ${INDEX} IN RANGE 0 ${length}
503 ${value}= Get From List ${jsondata} ${INDEX}
504 ${devid}= Get From Dictionary ${value} id
Scott Baker2ab2a0c2020-06-05 12:51:47 -0700505 ${rootdev}= Get From Dictionary ${value} rootDeviceId
506 ${desc}= Get From Dictionary ${value} desc
507 ${sn}= Get From Dictionary ${desc} serialNum
Gilles Depatieb5682f82019-10-31 10:39:45 -0400508 Exit For Loop
509 END
510 Should Be Equal '${rootdev}' '${olt_device_id}' Root Device does not match ${olt_device_id} values=False
511 Should Be Equal '${sn}' '${BBSIM_OLT_SN}' Logical Device ${sn} does not match ${BBSIM_OLT_SN}
512 ... values=False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700513 [Return] ${devid}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400514
515Validate Logical Device Ports
516 [Arguments] ${logical_device_id}
517 [Documentation] Validate Logical Device Ports are listed and are > 0
518 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800519 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice port list ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400520 Should Be Equal As Integers ${rc} 0
521 ${jsondata}= To Json ${output}
522 Log ${jsondata}
523 ${length}= Get Length ${jsondata}
524 Should Be True ${length} > 0 Number of ports for ${logical_device_id} was 0
525
526Validate Logical Device Flows
527 [Arguments] ${logical_device_id}
528 [Documentation] Validate Logical Device Flows are listed and are > 0
529 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800530 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice flows ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400531 Should Be Equal As Integers ${rc} 0
532 ${jsondata}= To Json ${output}
533 Log ${jsondata}
534 ${length}= Get Length ${jsondata}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700535 Should Be True ${length} > 0 Number of flows for ${logical_device_id} was 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400536
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000537Retrieve ONU UNI Ports
538 [Arguments] ${onu_device_id}
539 [Documentation] Retrieves the list of Active and Enabled UNI ports from the ONU device
540 ${rc} ${output}= Run and Return Rc and Output
541 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${onu_device_id} -o json
542 Should Be Equal As Integers ${rc} 0
543 ${jsondata}= To Json ${output}
544 Log ${jsondata}
545 ${length}= Get Length ${jsondata}
546 ${onu_uni_list}= Create List
547 FOR ${INDEX} IN RANGE 0 ${length}
548 ${value}= Get From List ${jsondata} ${INDEX}
549 ${type}= Get From Dictionary ${value} type
550 ${portno}= Get From Dictionary ${value} portNo
551 ${adminstate}= Get From Dictionary ${value} adminState
552 ${operstate}= Get From Dictionary ${value} operStatus
553 Run Keyword If '${type}'=='ETHERNET_UNI' and '${adminstate}'=='ENABLED' and '${operstate}'=='ACTIVE'
554 ... Append To List ${onu_uni_list} ${portno}
555 END
556 [Return] ${onu_uni_list}
557
Hardik Windlass16cdf962020-04-29 15:26:50 +0530558Retrieve OLT PON Ports
559 [Arguments] ${olt_device_id}
560 [Documentation] Retrieves the list of PON ports from the OLT device
561 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800562 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530563 Should Be Equal As Integers ${rc} 0
564 ${jsondata}= To Json ${output}
565 Log ${jsondata}
566 ${length}= Get Length ${jsondata}
567 ${olt_pon_list}= Create List
568 FOR ${INDEX} IN RANGE 0 ${length}
569 ${value}= Get From List ${jsondata} ${INDEX}
570 ${type}= Get From Dictionary ${value} type
571 ${portno}= Get From Dictionary ${value} portNo
572 ${peers}= Get From Dictionary ${value} peers
573 ${len_peers}= Get Length ${peers}
574 Run Keyword If '${type}' == 'PON_OLT' and ${len_peers} > 0
575 ... Append To List ${olt_pon_list} ${portno}
576 END
577 [Return] ${olt_pon_list}
578
579Retrieve Peer List From OLT PON Port
TorstenThieme17d6fd22021-09-23 10:00:08 +0000580 [Arguments] ${olt_device_id} ${pon_port} ${expected_num_peers}=0
Hardik Windlass16cdf962020-04-29 15:26:50 +0530581 [Documentation] Retrieves the list of peer device ids list from the OLT PON port
582 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800583 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530584 Should Be Equal As Integers ${rc} 0
585 ${jsondata}= To Json ${output}
586 Log ${jsondata}
587 ${length}= Get Length ${jsondata}
588 ${matched}= Set Variable False
589 FOR ${INDEX} IN RANGE 0 ${length}
590 ${value}= Get From List ${jsondata} ${INDEX}
591 ${type}= Get From Dictionary ${value} type
592 ${portno}= Get From Dictionary ${value} portNo
593 ${peers}= Get From Dictionary ${value} peers
594 ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
595 Exit For Loop If ${matched}
596 END
597 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
598 ${length}= Get Length ${peers}
TorstenThieme17d6fd22021-09-23 10:00:08 +0000599 Run Keyword If ${expected_num_peers}>0 Should Be Equal As Integers ${length} ${expected_num_peers}
600 ... Number of found peers does not match expected number ${length}:${expected_num_peers}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530601 ${olt_peer_list}= Create List
602 FOR ${INDEX} IN RANGE 0 ${length}
603 ${value}= Get From List ${peers} ${INDEX}
604 ${peer_id}= Get From Dictionary ${value} deviceId
605 Append To List ${olt_peer_list} ${peer_id}
606 END
607 [Return] ${olt_peer_list}
608
609Validate OLT PON Port Status
610 [Arguments] ${olt_device_id} ${pon_port} ${admin_state} ${oper_status}
611 [Documentation] Verifies the state of the PON port of the OLT
612 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800613 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530614 Should Be Equal As Integers ${rc} 0
615 ${jsondata}= To Json ${output}
616 Log ${jsondata}
617 ${length}= Get Length ${jsondata}
618 ${matched}= Set Variable False
619 FOR ${INDEX} IN RANGE 0 ${length}
620 ${value}= Get From List ${jsondata} ${INDEX}
621 ${type}= Get From Dictionary ${value} type
622 ${portno}= Get From Dictionary ${value} portNo
623 ${astate}= Get From Dictionary ${value} adminState
624 ${opstatus}= Get From Dictionary ${value} operStatus
625 ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
626 Exit For Loop If ${matched}
627 END
628 Should Be True ${matched} No PON port found for OLT ${olt_device_id} ${pon_port}
629 Log ${value}
630 Should Be Equal '${astate}' '${admin_state}' OLT PON Port admin_state != ${admin_state}
631 ... values=False
632 Should Be Equal '${opstatus}' '${oper_status}' OLT PON Port oper_status != ${oper_status}
633 ... values=False
634
635DisableOrEnable OLT PON Port
636 [Arguments] ${operation} ${olt_device_id} ${portno}
637 [Documentation] Disables or Enables the PON port of the OLT
638 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800639 ... voltctl -c ${VOLTCTL_CONFIG} device port ${operation} ${olt_device_id} ${portno}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530640 Should Be Equal As Integers ${rc} 0
641
Gilles Depatieb5682f82019-10-31 10:39:45 -0400642Retrieve Peer List From OLT
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700643 [Arguments] ${olt_peer_list}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400644 [Documentation] Retrieve the list of peer device id list from port list
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700645 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800646 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400647 Should Be Equal As Integers ${rc} 0
648 ${jsondata}= To Json ${output}
649 Log ${jsondata}
650 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700651 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400652 FOR ${INDEX} IN RANGE 0 ${length}
653 ${value}= Get From List ${jsondata} ${INDEX}
654 ${type}= Get From Dictionary ${value} type
655 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700656 ${matched}= Set Variable If '${type}' == 'PON_OLT' True False
657 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400658 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700659 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400660 ${length}= Get Length ${peers}
661 FOR ${INDEX} IN RANGE 0 ${length}
662 ${value}= Get From List ${peers} ${INDEX}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530663 ${peer_id}= Get From Dictionary ${value} deviceId
Gilles Depatieb5682f82019-10-31 10:39:45 -0400664 Append To List ${olt_peer_list} ${peer_id}
665 END
666
667Validate OLT Peer Id List
668 [Arguments] ${olt_peer_id_list}
669 [Documentation] Match each entry in the ${olt_peer_id_list} against ONU device ids.
670 FOR ${peer_id} IN @{olt_peer_id_list}
671 Match OLT Peer Id ${peer_id}
672 END
673
674Match OLT Peer Id
675 [Arguments] ${olt_peer_id}
676 [Documentation] Lookup the OLT Peer Id in against the list of ONU device Ids
Matteo Scandolo5899be12020-11-11 15:38:07 -0800677 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400678 Should Be Equal As Integers ${rc} 0
679 ${jsondata}= To Json ${output}
680 Log ${jsondata}
681 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700682 ${matched}= Set Variable False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700683 FOR ${INDEX} IN RANGE 0 ${length}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400684 ${value}= Get From List ${jsondata} ${INDEX}
685 ${devid}= Get From Dictionary ${value} id
Andy Bavierb63f6d22020-03-12 15:34:37 -0700686 ${matched}= Set Variable If '${devid}' == '${olt_peer_id}' True False
687 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400688 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700689 Should Be True ${matched} Peer id ${olt_peer_id} does not match any ONU device id
Gilles Depatieb5682f82019-10-31 10:39:45 -0400690
691Validate ONU Peer Id
692 [Arguments] ${olt_device_id} ${List_ONU_Serial}
693 [Documentation] Match each ONU peer to that of the OLT device id
694 FOR ${onu_serial} IN @{List_ONU_Serial}
695 ${onu_dev_id}= Get Device ID From SN ${onu_serial}
696 Match ONU Peer Id ${onu_dev_id}
697 END
698
699Match ONU Peer Id
700 [Arguments] ${onu_dev_id}
701 [Documentation] Match an ONU peer to that of the OLT device id
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800702 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800703 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${onu_dev_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400704 Should Be Equal As Integers ${rc} 0
705 ${jsondata}= To Json ${output}
706 Log ${jsondata}
707 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700708 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400709 FOR ${INDEX} IN RANGE 0 ${length}
710 ${value}= Get From List ${jsondata} ${INDEX}
711 ${type}= Get From Dictionary ${value} type
712 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700713 ${matched}= Set Variable If '${type}' == 'PON_ONU' True False
714 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400715 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700716 Should Be True ${matched} No PON port found for ONU ${onu_dev_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400717 ${length}= Get Length ${peers}
718 FOR ${INDEX} IN RANGE 0 ${length}
719 ${value}= Get From List ${peers} ${INDEX}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530720 ${peer_id}= Get From Dictionary ${value} deviceId
Gilles Depatieb5682f82019-10-31 10:39:45 -0400721 END
722 Should Be Equal '${peer_id}' '${olt_device_id}'
723 ... Mismatch between ONU peer ${peer_id} and OLT device id ${olt_device_id} values=False
Kailash6f5acb62019-08-28 14:38:45 -0700724
Kailash6f5acb62019-08-28 14:38:45 -0700725Get Device ID From SN
726 [Arguments] ${serial_number}
727 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700728 ${rc} ${id}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800729 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=SerialNumber=${serial_number} --format='{{.Id}}'
Matteo Scandolo2769d2b2021-04-14 10:29:24 -0700730 Should Be Equal As Integers ${rc} 0 "Error while fetching device list from VOLTHA"
Andy Bavier8fca0452019-12-16 15:30:11 -0700731 Log ${id}
Kailash6f5acb62019-08-28 14:38:45 -0700732 [Return] ${id}
733
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700734Get Logical Device ID From SN
735 [Arguments] ${serial_number}
736 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700737 ${rc} ${id}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800738 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice list --filter=Desc.SerialNum=${serial_number} --format='{{.Id}}'
Andy Bavier8fca0452019-12-16 15:30:11 -0700739 Should Be Equal As Integers ${rc} 0
740 Log ${id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700741 [Return] ${id}
742
Gilles Depatieb5682f82019-10-31 10:39:45 -0400743Build ONU SN List
Andrea Campanella6391f842020-11-16 10:01:18 +0100744 [Arguments] ${serial_numbers} ${olt_serial_number}=${EMPTY} ${num_onus}=${num_all_onus}
745 [Documentation] Appends all ONU SNs for the given OLT to the ${serial_numbers} list
Gilles Depatieb5682f82019-10-31 10:39:45 -0400746 FOR ${INDEX} IN RANGE 0 ${num_onus}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000747 ${onu_sn}= Set Variable ${hosts.src[${INDEX}]['onu']}
748 # skip if we have already append this ONU
749 ${onu_id}= Get Index From List ${serial_numbers} ${onu_sn}
750 Continue For Loop If -1 != ${onu_id}
751 Run Keyword IF "${olt_serial_number}"=="${hosts.src[${INDEX}].olt}" or "${olt_serial_number}"=="${EMPTY}"
752 ... Append To List ${serial_numbers} ${onu_sn}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400753 END
754
TorstenThiemef3e492c2021-11-08 15:25:48 +0000755Build ONU Device Id List
756 [Arguments] ${device_ids} ${olt_serial_number}=${EMPTY} ${num_onus}=${num_all_onus}
757 [Documentation] Appends all ONU Device IDs for the given OLT to the ${serial_numbers} list
758 FOR ${INDEX} IN RANGE 0 ${num_onus}
759 ${onu_device_id}= Get Device ID From SN ${hosts.src[${INDEX}]['onu']}
760 # skip if we have already append this ONU
761 ${onu_id}= Get Index From List ${device_ids} ${onu_device_id}
762 Continue For Loop If -1 != ${onu_id}
763 Run Keyword IF "${olt_serial_number}"=="${hosts.src[${INDEX}].olt}" or "${olt_serial_number}"=="${EMPTY}"
764 ... Append To List ${device_ids} ${onu_device_id}
765 END
766
Gilles Depatieb5682f82019-10-31 10:39:45 -0400767Get SN From Device ID
768 [Arguments] ${device_id}
769 [Documentation] Gets the device id by matching for ${device_id}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700770 ${rc} ${sn}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800771 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${device_id} --format='{{.SerialNumber}}'
Gilles Depatieb5682f82019-10-31 10:39:45 -0400772 Should Be Equal As Integers ${rc} 0
Andy Bavier8fca0452019-12-16 15:30:11 -0700773 Log ${sn}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400774 [Return] ${sn}
775
Scott Baker60e570d2020-02-02 22:10:13 -0800776Get Parent ID From Device ID
777 [Arguments] ${device_id}
778 [Documentation] Gets the device id by matching for ${device_id}
779 ${rc} ${pid}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800780 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${device_id} --format='{{.ParentId}}'
Scott Baker60e570d2020-02-02 22:10:13 -0800781 Should Be Equal As Integers ${rc} 0
782 Log ${pid}
783 [Return] ${pid}
784
Kailash6f5acb62019-08-28 14:38:45 -0700785Validate Device Removed
TorstenThieme4489b512021-12-16 09:41:50 +0000786 [Arguments] ${serialNumber}
Kailash6f5acb62019-08-28 14:38:45 -0700787 [Documentation] Verifys that device, ${serial_number}, has been removed
Matteo Scandolo5899be12020-11-11 15:38:07 -0800788 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -o json
Andy Bavier8fca0452019-12-16 15:30:11 -0700789 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700790 ${jsondata}= To Json ${output}
791 Log ${jsondata}
792 ${length}= Get Length ${jsondata}
TorstenThieme4489b512021-12-16 09:41:50 +0000793 @{sns}= Create List
Zack Williamsec53a1b2019-09-16 15:50:52 -0700794 FOR ${INDEX} IN RANGE 0 ${length}
795 ${value}= Get From List ${jsondata} ${INDEX}
TorstenThieme4489b512021-12-16 09:41:50 +0000796 ${device_sn}= Get From Dictionary ${value} serialNumber
797 Append To List ${sns} ${device_sn}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700798 END
TorstenThieme4489b512021-12-16 09:41:50 +0000799 List Should Not Contain Value ${sns} ${serialNumber}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800800
Andrea Campanella4e507882020-11-26 11:33:11 +0100801Validate all ONUS for OLT Removed
802 [Arguments] ${num_all_onus} ${hosts} ${olt_serial_number} ${timeout}
803 [Documentation] Verifys that all the ONUS for OLT ${serial_number}, has been removed
TorstenThieme4489b512021-12-16 09:41:50 +0000804 @{onu_list}= Create List
Andrea Campanella4e507882020-11-26 11:33:11 +0100805 FOR ${J} IN RANGE 0 ${num_all_onus}
806 ${src}= Set Variable ${hosts.src[${J}]}
807 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
TorstenThieme4489b512021-12-16 09:41:50 +0000808 ${sn}= Set Variable ${src['onu']}
809 ${onu_id}= Get Index From List ${onu_list} ${sn}
810 Continue For Loop If -1 != ${onu_id}
811 Append To List ${onu_list} ${sn}
812 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s Validate Device Removed ${sn}
Andrea Campanella4e507882020-11-26 11:33:11 +0100813 END
814
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800815Reboot ONU
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000816 [Arguments] ${onu_id} ${validate_device}=True
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800817 [Documentation] Using voltctl command reboot ONU and verify that ONU comes up to running state
Matteo Scandolo5899be12020-11-11 15:38:07 -0800818 ${rc} ${devices}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device reboot ${onu_id}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800819 Should Be Equal As Integers ${rc} 0
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000820 Run Keyword If ${validate_device} Run Keyword And Continue On Failure Wait Until Keyword Succeeds
821 ... 60s 1s Validate ONU Device By Device Id ENABLED DISCOVERED REACHABLE rebooting ${onu_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700822
823Assert ONUs in Voltha
824 [Arguments] ${count}
825 [Documentation] Check that a certain number of devices reached the ACTIVE/ENABLE state
826 ${rc1} ${devices}= Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800827 ... voltctl -c ${VOLTCTL_CONFIG} -m ${voltctlGrpcLimit} device list | grep -v OLT | grep ACTIVE | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700828 Should Be Equal As Integers ${rc1} 0
829 Should Be Equal As Integers ${devices} ${count}
830
831Wait for ONUs in VOLTHA
Andrea Campanella4ec9b832022-02-09 13:21:54 +0100832 [Arguments] ${count} ${timeout}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700833 [Documentation] Waits until a certain number of devices reached the ACTIVE/ENABLE state
Andrea Campanella4ec9b832022-02-09 13:21:54 +0100834 Wait Until Keyword Succeeds ${timeout} 5s Assert ONUs In Voltha ${count}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700835
TorstenThiemea8bcec72022-06-13 12:01:30 +0000836Validate ONU Model
837 [Documentation]
838 ... Parses the output of "voltctl device list" and inspects onu model and optionally Vendor and Vendor-id
839 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect passed values
840 [Arguments] ${List_ONU_Serial} ${onu_model} ${onu_vendor}=${EMPTY} ${onu_vendor_id}=${EMPTY}
841 ${cmd}= Catenate voltctl -c ${VOLTCTL_CONFIG} device list -m ${voltctlGrpcLimit} -f Type=brcm_openomci_onu
842 ... --format "{{.Id}}\t{{.SerialNumber}}\t{{.Vendor}}\t{{.VendorId}}\t{{.Model}}" | grep -v SERIALNUMBER
843 ${rc} ${output}= Run and Return Rc and Output ${cmd}
844 Should Be Equal As Integers ${rc} 0 Failed Validate ONU model because of ${output}
845 Log ${output}
846 @{Results}= Split String ${output} \n
847 FOR ${Line} IN @{Results}
848 ${matched}= Set Variable False
849 @{words}= Split String ${Line} \t
850 ${id}= Set Variable ${words[0]}
851 ${sn}= Set Variable ${words[1]}
852 ${vendor}= Set Variable ${words[2]}
853 ${vendor_id}= Set Variable ${words[3]}
854 ${model}= Set Variable ${words[4]}
855 ${onu_id}= Get Index From List ${List_ONU_Serial} ${sn}
856 ${matched}= Set Variable If -1 != ${onu_id} True False
857 ${matched}= Set Variable If '${model}'=='${onu_model}' ${matched} False
858 ${matched}= Set Variable If '${onu_vendor}'=='${EMPTY}' or '${vendor}'=='${onu_vendor}' ${matched} False
859 ${matched}= Set Variable If '${onu_vendor_id}'=='${EMPTY}' or '${vendor_id}'=='${onu_vendor_id}' ${matched} False
860 Run Keyword If ${matched} Remove Values From List ${List_ONU_Serial} ${sn}
861 END
862 Should Be Empty ${List_ONU_Serial} No valid ONU model found for ${List_ONU_Serial}!
863
Matteo Scandolo142e6272020-04-29 17:36:59 -0700864Count Logical Devices flows
865 [Documentation] Count the flows across logical devices in VOLTHA
866 [Arguments] ${targetFlows}
867 ${output}= Get Logical Device List From Voltha
868 ${logical_devices}= To Json ${output}
869 ${total_flows}= Set Variable 0
870 FOR ${device} IN @{logical_devices}
871 ${rc} ${flows}= Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800872 ... voltctl -m ${voltctlGrpcLimit} -c ${VOLTCTL_CONFIG} logicaldevice flows ${device['id']} | grep -v ID | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700873 Should Be Equal As Integers ${rc} 0
874 ${total_flows}= Evaluate ${total_flows} + ${flows}
875 END
Matteo Scandolo616daab2020-05-13 11:49:24 -0700876 ${msg}= Format String Found {total_flows} flows of {targetFlows} expected
877 ... total_flows=${total_flows} targetFlows=${targetFlows}
878 Log ${msg}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700879 Should Be Equal As Integers ${targetFlows} ${total_flows}
880
881Wait for Logical Devices flows
882 [Documentation] Waits until the flows have been provisioned in the logical device
883 [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella4ec9b832022-02-09 13:21:54 +0100884 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp} ${timeout}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700885 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200886 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700887 Log ${targetFlows}
888 # TODO extend Validate Logical Device Flows to check the correct number of flows
Andrea Campanella4ec9b832022-02-09 13:21:54 +0100889 Wait Until Keyword Succeeds ${timeout} 5s Count Logical Devices flows ${targetFlows}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700890
Matteo Scandolo616daab2020-05-13 11:49:24 -0700891Count OpenOLT Device Flows
892 [Documentation] Count the flows across openolt devices in VOLTHA
893 [Arguments] ${targetFlows}
894 ${output}= Get Device List from Voltha by type openolt
895 ${devices}= To Json ${output}
896 ${total_flows}= Set Variable 0
897 FOR ${device} IN @{devices}
898 ${rc} ${flows}= Run and Return Rc and Output
Matteo Scandoloc2a19e32022-03-11 08:05:55 -0800899 ... voltctl -m ${voltctlGrpcLimit} -c ${VOLTCTL_CONFIG} device flows ${device['id']} | grep -v ID | wc -l
Matteo Scandolo616daab2020-05-13 11:49:24 -0700900 Should Be Equal As Integers ${rc} 0
901 ${total_flows}= Evaluate ${total_flows} + ${flows}
902 END
903 ${msg}= Format String Found {total_flows} flows of {targetFlows} expected
904 ... total_flows=${total_flows} targetFlows=${targetFlows}
905 Log ${msg}
906 Should Be Equal As Integers ${targetFlows} ${total_flows}
907
908Wait for OpenOLT Devices flows
909 [Documentation] Waits until the flows have been provisioned in the openolt devices
910 [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200911 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700912 ${beforeFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
913 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandoloda854b02020-09-01 16:20:51 -0700914 # In the physical device we only have 2 data plane flows (on the PON) instead of 4
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700915 ${afterFlows}= Evaluate ${beforeFlows} - (${uni_count} * 2)
Matteo Scandoloda854b02020-09-01 16:20:51 -0700916 # In the TT workflow we have multiple service,
917 # so we need to remove 6 flows per each UNI that are only on the ONU device
918 ${ttFlows}= Evaluate ${beforeFlows} - (${uni_count} * 6)
919 ${afterFlows}= Set Variable If $workflow=='tt' ${ttFlows} ${afterFlows}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700920 ${targetFlows}= Set Variable If $provisioned=='true' ${afterFlows} ${beforeFlows}
Matteo Scandolo616daab2020-05-13 11:49:24 -0700921 Log ${targetFlows}
Hardik Windlass2b37e712020-06-12 02:13:17 +0530922 Wait Until Keyword Succeeds 10m 5s Count OpenOLT Device Flows ${targetFlows}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000923
Hardik Windlassba1bd272021-06-22 08:29:33 +0000924Validate ONU Device Image
925 [Documentation] Validates the ONU device image
926 [Arguments] ${data} ${image_version} ${dev_id} ${download_state} ${expected_reason} ${image_status}
927 ${jsondata}= To Json ${data}
928 ${length}= Get Length ${jsondata}
TorstenThiemef3e492c2021-11-08 15:25:48 +0000929 Should Not Be Equal As Integers ${length} 0 No record to validate device image
930 FOR ${J} IN RANGE 0 ${length}
931 ${value}= Get From List ${jsondata} ${J}
932 Log ${value}
933 ${deviceId}= Get From Dictionary ${value} deviceId
934 Should Contain ${dev_id} ${deviceId} No match found for ${deviceId} to validate device image!
935 ${imageState}= Get From Dictionary ${value} imageState
936 ${version}= Get From Dictionary ${imageState} version
937 ${dwlState}= Get From Dictionary ${imageState} downloadState
938 ${reason}= Get From Dictionary ${imageState} reason
939 ${imgStatus}= Get From Dictionary ${imageState} imageState
Hardik Windlassca8ce7c2022-02-01 09:01:23 +0000940 Should Be Equal '${version}' '${image_version}' Device ${deviceId}: '${version}' != '${image_version}'
TorstenThiemef3e492c2021-11-08 15:25:48 +0000941 ... values=False
Hardik Windlassca8ce7c2022-02-01 09:01:23 +0000942 Should Be Equal '${dwlState}' '${download_state}' Device ${deviceId}: '${dwlState}' != '${download_state}'
TorstenThiemef3e492c2021-11-08 15:25:48 +0000943 ... values=False
Hardik Windlassca8ce7c2022-02-01 09:01:23 +0000944 Should Be Equal '${reason}' '${expected_reason}' Device ${deviceId}: '${reason}' != '${expected_reason}'
TorstenThiemef3e492c2021-11-08 15:25:48 +0000945 ... values=False
Hardik Windlassca8ce7c2022-02-01 09:01:23 +0000946 Should Be Equal '${imgStatus}' '${image_status}' Device ${deviceId}: '${imgStatus}' != '${image_status}'
TorstenThiemef3e492c2021-11-08 15:25:48 +0000947 ... values=False
948 END
Hardik Windlassba1bd272021-06-22 08:29:33 +0000949
Hardik Windlass17bd1142021-03-12 08:15:25 +0000950Download ONU Device Image
951 [Documentation] Downloads the given ONU software image
Hardik Windlassba1bd272021-06-22 08:29:33 +0000952 [Arguments] ${ver} ${url} ${vendor} ${active} ${commit} ${crc} ${id}
TorstenThieme7cb9de72021-08-24 09:40:57 +0000953 ... ${download_state}=DOWNLOAD_STARTED ${expected_reason}=NO_ERROR ${image_state}=IMAGE_UNKNOWN
Hardik Windlassba1bd272021-06-22 08:29:33 +0000954 ${rc} ${output}= Run and Return Rc and Output
955 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage download ${ver} ${url} ${vendor} ${active} ${commit} ${crc} ${id} -o json
956 Log ${output}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000957 Should Be Equal As Integers ${rc} 0
TorstenThieme7cb9de72021-08-24 09:40:57 +0000958 Validate ONU Device Image ${output} ${ver} ${id} ${download_state} ${expected_reason} ${image_state}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000959
960Activate ONU Device Image
Hardik Windlassba1bd272021-06-22 08:29:33 +0000961 [Documentation] Activates the given ONU software image
962 [Arguments] ${ver} ${commit} ${id}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000963 ${rc} ${output}= Run and Return Rc and Output
Hardik Windlassba1bd272021-06-22 08:29:33 +0000964 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage activate ${ver} ${commit} ${id} -o json
965 Log ${output}
966 Should Be Equal As Integers ${rc} 0
Andrea Campanellaf3b88f62021-10-01 18:43:03 +0200967 Validate ONU Device Image ${output} ${ver} ${id} DOWNLOAD_SUCCEEDED NO_ERROR IMAGE_ACTIVATING
Hardik Windlassba1bd272021-06-22 08:29:33 +0000968
969Commit ONU Device Image
970 [Documentation] Commits the given ONU software image
971 [Arguments] ${ver} ${id}
972 ${rc} ${output}= Run and Return Rc and Output
973 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage commit ${ver} ${id} -o json
974 Log ${output}
975 Should Be Equal As Integers ${rc} 0
Andrea Campanellaf3b88f62021-10-01 18:43:03 +0200976 Validate ONU Device Image ${output} ${ver} ${id} DOWNLOAD_SUCCEEDED NO_ERROR IMAGE_COMMITTING
Hardik Windlassba1bd272021-06-22 08:29:33 +0000977
TorstenThieme37165402021-09-03 11:39:40 +0000978Abort ONU Device Image
979 [Documentation] Aborts the given ONU software image
980 [Arguments] ${ver} ${id} ${download_state} ${expected_reason} ${image_state}
981 ${rc} ${output}= Run and Return Rc and Output
982 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage abort ${ver} ${id} -o json
983 Log ${output}
984 Should Be Equal As Integers ${rc} 0
985 Validate ONU Device Image ${output} ${ver} ${id} ${download_state} ${expected_reason} ${image_state}
986
Andrea Campanellaf3b88f62021-10-01 18:43:03 +0200987Remove Adapter Image
988 [Documentation] Aborts the upgrade processing for a given ONU software image and thus removes the image from adapter
989 [Arguments] ${ver} ${id}
990 ${rc} ${output}= Run and Return Rc and Output
991 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage abort ${ver} ${id} -o json
992 Log ${output}
993
TorstenThiemef3e492c2021-11-08 15:25:48 +0000994Remove Adapter Image from ONUs
995 [Documentation] Aborts the upgrade processing for a given ONU software image and thus removes the image from adapter
996 ... for the passed ONUs
997 [Arguments] ${ver} ${onu_id_list}
998 FOR ${onu_device_id} IN @{onu_id_list}
999 Remove Adapter Image ${ver} ${onu_device_id}
1000 END
1001
Hardik Windlassba1bd272021-06-22 08:29:33 +00001002Verify ONU Device Image Status
1003 [Documentation] Verfies the ONU device image state
1004 [Arguments] ${image_version} ${dev_id} ${download_state} ${expected_reason} ${image_state}
1005 ${rc} ${output}= Run and Return Rc and Output
1006 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage status ${image_version} ${dev_id} -o json
1007 Log ${output}
1008 Should Be Equal As Integers ${rc} 0
1009 Validate ONU Device Image ${output} ${image_version} ${dev_id} ${download_state} ${expected_reason}
1010 ... ${image_state}
1011
Hardik Windlass6fd3cae2022-03-03 08:35:33 +00001012Assert ONUs Image Status in Voltha
1013 [Arguments] ${onu_count} ${image_version} ${download_state} ${expected_reason} ${image_state}
1014 [Documentation] Check that a certain number of devices reached the given image status
Matteo Scandoloc2a19e32022-03-11 08:05:55 -08001015 ${cmd}= Catenate voltctl -c ${VOLTCTL_CONFIG} -m ${voltctlGrpcLimit} device onuimage status ${image_version}
Hardik Windlass6fd3cae2022-03-03 08:35:33 +00001016 ... | grep ${download_state} | grep ${expected_reason} | grep ${image_state} | wc -l
1017 ${rc} ${count}= Run and Return Rc and Output ${cmd}
1018 Should Be Equal As Integers ${rc} 0
1019 Should Be Equal As Integers ${count} ${onu_count}
1020
1021Wait for ONUs Image Status in VOLTHA
1022 [Arguments] ${onu_count} ${image_version} ${download_state} ${expected_reason} ${image_state}
1023 ... ${timeout}=10m
1024 [Documentation] Waits until a certain number of devices reached the given image status
1025 Wait Until Keyword Succeeds ${timeout} 5s Assert ONUs Image Status in Voltha ${onu_count}
1026 ... ${image_version} ${download_state} ${expected_reason} ${image_state}
1027
Hardik Windlassba1bd272021-06-22 08:29:33 +00001028Verify ONU Device Image List
1029 [Documentation] Verfies the ONU device image list
TorstenThieme70790282021-11-19 10:26:25 +00001030 [Arguments] ${dev_id} ${image_version} ${committed} ${activated} ${valid} ${image_should_not_in_list}=False
Hardik Windlassba1bd272021-06-22 08:29:33 +00001031 ${rc} ${output}= Run and Return Rc and Output
1032 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage list ${dev_id} -o json
Hardik Windlass17bd1142021-03-12 08:15:25 +00001033 Should Be Equal As Integers ${rc} 0
1034 ${jsondata}= To Json ${output}
1035 Log ${jsondata}
1036 ${length}= Get Length ${jsondata}
1037 ${matched}= Set Variable False
1038 FOR ${INDEX} IN RANGE 0 ${length}
1039 ${value}= Get From List ${jsondata} ${INDEX}
Hardik Windlassba1bd272021-06-22 08:29:33 +00001040 ${version}= Get From Dictionary ${value} version
1041 ${isCommited}= Get From Dictionary ${value} isCommited
1042 ${isActive}= Get From Dictionary ${value} isActive
1043 ${isValid}= Get From Dictionary ${value} isValid
1044 ${matched}= Set Variable If '${version}' == '${image_version}' True False
Hardik Windlass17bd1142021-03-12 08:15:25 +00001045 Exit For Loop If ${matched}
1046 END
TorstenThieme70790282021-11-19 10:26:25 +00001047 Run Keyword If ${image_should_not_in_list}
1048 ... Should Not Be True ${matched} ONU Image found unexpectedly with Version ${image_version}
1049 ... ELSE Should Be True ${matched} No ONU Image found with Version ${image_version}
1050 Run Keyword If ${matched} Should Be Equal '${isCommited}' '${committed}'
1051 ... Device ${dev_id}: '${isCommited}' != '${committed}' values=False
1052 Run Keyword If ${matched} Should Be Equal '${isActive}' '${activated}'
1053 ... Device ${dev_id}: '${isActive}' != '${activated}' values=False
1054 Run Keyword If ${matched} Should Be Equal '${isValid}' '${valid}'
1055 ... Device ${dev_id}: '${isValid}' != '${valid}' values=False
TorstenThiemeff9c9142021-04-08 07:21:34 +00001056
1057# pm-data relevant keywords
1058Read Default Interval From Pmconfig
1059 [Documentation] Reads default interval from pm config
1060 [Arguments] ${device_id}
1061 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig get ${device_id}
1062 Should Be Equal As Integers ${rc} 0
1063 log ${result}
1064 @{words}= Split String ${result}
1065 ${interval}= Get From List ${words} 3
1066 log ${interval}
1067 [return] ${interval}
1068
1069Read Group Interval From Pmconfig
1070 [Documentation] Reads default interval from pm config
1071 [Arguments] ${device_id} ${group}
1072 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group list ${device_id} | grep ${group}
1073 Should Be Equal As Integers ${rc} 0
1074 log ${result}
1075 @{words}= Split String ${result}
1076 ${interval}= Get From List ${words} -1
1077 log ${interval}
1078 [return] ${interval}
1079
1080Set and Validate Default Interval
1081 [Documentation] Sets and validates default interval of pm data
1082 [Arguments] ${device_id} ${interval}
1083 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig frequency set ${device_id} ${interval}
1084 Should Be Equal As Integers ${rc} 0
1085 log ${result}
1086 # workaround until unit will be printed out in voltctl - remove unit
1087 ${interval}= Get Substring ${interval} 0 -1
1088 Should Contain ${result} ${interval}
1089
1090Set and Validate Group Interval
1091 [Documentation] Sets and validates group interval of pm data
1092 [Arguments] ${device_id} ${interval} ${group}
1093 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group set ${device_id} ${group} ${interval}
1094 Should Be Equal As Integers ${rc} 0
1095 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group list ${device_id} | grep ${group}
1096 Should Be Equal As Integers ${rc} 0
1097 log ${result}
1098 # workaround until unit will be printed out in voltctl - remove unit
1099 ${interval}= Get Substring ${interval} 0 -1
1100 Should Contain ${result} ${interval}
1101
1102Read Group List
1103 [Documentation] Reads metric group list of given device
1104 [Arguments] ${device_id}
1105 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group list ${device_id} | grep -v GROUPNAME
1106 Should Be Equal As Integers ${rc} 0
1107 ${group_list} Create List
1108 ${interval_dict} Create Dictionary
1109 @{output}= Split String ${result} \n
1110 FOR ${Line} IN @{output}
1111 @{words}= Split String ${Line}
1112 ${group}= Set Variable ${words[0]}
1113 ${interval}= Set Variable ${words[2]}
1114 Append To List ${group_list} ${group}
1115 Set To Dictionary ${interval_dict} ${group}=${interval}
1116 END
1117 [return] ${group_list} ${interval_dict}
1118
1119Read Group Metric List
1120 [Documentation] Reads group metric list of given device and group
1121 [Arguments] ${device_id} ${group}
1122 ${cmd}= Catenate voltctl device pmconfig groupmetric list ${device_id} ${group} | grep -v SAMPLEFREQ
1123 ${rc} ${result}= Run and Return Rc and Output ${cmd}
1124 Should Be Equal As Integers ${rc} 0
1125 ${groupmetric_list} Create List
1126 @{output}= Split String ${result} \n
1127 FOR ${Line} IN @{output}
1128 @{words}= Split String ${Line}
1129 ${name}= Set Variable ${words[0]}
1130 ${type}= Set Variable ${words[1]}
1131 ${enabled}= Set Variable ${words[2]}
1132 ${subdict}= Create Dictionary type=${type} enabled=${enabled}
1133 ${dict}= Create Dictionary ${name}=${subdict}
1134 Append To List ${groupmetric_list} ${dict}
1135 END
1136 [return] ${groupmetric_list}
1137
1138Read Group Metric Dict
1139 [Documentation] Reads group metric list of given device and group
1140 [Arguments] ${device_id} ${group}
1141 ${cmd}= Catenate voltctl device pmconfig groupmetric list ${device_id} ${group} | grep -v SAMPLEFREQ
1142 ${rc} ${result}= Run and Return Rc and Output ${cmd}
1143 Should Be Equal As Integers ${rc} 0
1144 ${groupmetric_dict} Create Dictionary
1145 @{output}= Split String ${result} \n
1146 FOR ${Line} IN @{output}
1147 @{words}= Split String ${Line}
1148 ${name}= Set Variable ${words[0]}
1149 ${type}= Set Variable ${words[1]}
1150 ${enabled}= Set Variable ${words[2]}
1151 ${subdict}= Create Dictionary type=${type} enabled=${enabled}
1152 Set To Dictionary ${groupmetric_dict} ${name}=${subdict}
1153 END
1154 [return] ${groupmetric_dict}
TorstenThieme517b7ce2022-12-19 11:56:34 +00001155
1156# openonu-go-adapter OMCI counter statistics
1157Get OMCI counter statistics
1158 [Documentation] Delivers the openonu-go-adapter OMCI counter statistics
1159 [Arguments] ${dev_id}
1160 ${rc} ${output}= Run and Return Rc and Output
1161 ... voltctl -c ${VOLTCTL_CONFIG} device getextval onu_omci_stats ${dev_id}
1162 [return] ${rc} ${output}
1163
1164Get OMCI counter statistics dictionary
1165 [Documentation] Delivers the openonu-go-adapter OMCI counter statistics as dictionary
1166 [Arguments] ${dev_id}
1167 ${rc} ${output}= Get OMCI counter statistics ${dev_id}
1168 # check rc
1169 &{output_dict}= Create Dictionary
1170 Return From Keyword If ${rc} != 0 ${rc} ${output_dict}
1171 @{Results}= Split String ${output} \n
1172 FOR ${Line} IN @{Results}
1173 ${matched}= Set Variable False
1174 @{words}= Split String ${Line}
1175 ${name}= Set Variable ${words[0]}
1176 ${value}= Set Variable ${words[1]}
1177 ${name}= Remove String ${name} :
1178 Set To Dictionary ${output_dict} ${name} ${value}
1179 END
1180 [return] ${rc} ${output_dict}