blob: 3c755c3f40f72976b94355974f6d786982034b09 [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# onos 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 Scandoloeb26a842020-05-08 10:06:24 -070025Resource ./flows.robot
Kailash6f5acb62019-08-28 14:38:45 -070026
TorstenThiemeb198c482020-12-14 19:45:23 +000027*** Variables ***
28@{connection_list}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000029${alias} ONOS_SSH
TorstenThieme1f58cac2022-02-10 15:58:38 +000030${ssh_read_timeout} 60s
TorstenThieme2ddb6e82022-02-08 14:44:24 +000031${ssh_prompt} karaf@root >
32${ssh_regexp_prompt} REGEXP:k.*a.*r.*a.*f.*@.*r.*o.*o.*t.* .*>.*
33${regexp_prompt} k.*a.*r.*a.*f.*@.*r.*o.*o.*t.* .*>.*
34${ssh_width} 400
35${disable_highlighter} setopt disable-highlighter
TorstenThieme36a38a82022-02-09 15:51:30 +000036# ${keep_alive_interval} is set to 0s means sending the keepalive packet is disabled!
37${keep_alive_interval} 0s
TorstenThiemeb198c482020-12-14 19:45:23 +000038
Kailash6f5acb62019-08-28 14:38:45 -070039*** Keywords ***
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070040
41Open ONOS SSH Connection
42 [Documentation] Establishes an ssh connection to ONOS contoller
43 [Arguments] ${host} ${port} ${user}=karaf ${pass}=karaf
TorstenThieme2ddb6e82022-02-08 14:44:24 +000044 ${conn_id}= SSHLibrary.Open Connection ${host} port=${port} timeout=${ssh_read_timeout} alias=${alias}
TorstenThieme36a38a82022-02-09 15:51:30 +000045 SSHLibrary.Login username=${user} password=${pass} keep_alive_interval=${keep_alive_interval}
TorstenThieme1d1413b2022-02-04 12:41:01 +000046 # set excepted prompt and terminal width to suppress unwanted line feeds
TorstenThieme2ddb6e82022-02-08 14:44:24 +000047 SSHLibrary.Set Client Configuration prompt=${ssh_prompt} width=${ssh_width}
TorstenThiemeb198c482020-12-14 19:45:23 +000048 ${conn_list_entry}= Create Dictionary conn_id=${conn_id} user=${user} pass=${pass}
TorstenThieme1d1413b2022-02-04 12:41:01 +000049 ... host=${host} port=${port} alias=${alias}
TorstenThiemeb198c482020-12-14 19:45:23 +000050 Append To List ${connection_list} ${conn_list_entry}
51 ${conn_list_id}= Get Index From List ${connection_list} ${conn_list_entry}
52 Set Global Variable ${connection_list}
TorstenThieme1d1413b2022-02-04 12:41:01 +000053 # disable highlighting to suppress control sequences
TorstenThieme2ddb6e82022-02-08 14:44:24 +000054 ${output}= Execute Single ONOS CLI Command ${conn_id} ${disable_highlighter} do_reconnect=False
TorstenThiemeb198c482020-12-14 19:45:23 +000055 [Return] ${conn_list_id}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070056
TorstenThieme4e2168e2021-06-22 14:01:47 +000057Execute ONOS CLI Command use single connection
58 [Documentation] Execute ONOS CLI Command use an Open Connection
59 ... In case no connection is open a connection will be opened
TorstenThieme1d1413b2022-02-04 12:41:01 +000060 ... Using Write and Read instead of Execute Command to keep connection alive.
TorstenThieme4e2168e2021-06-22 14:01:47 +000061 [Arguments] ${host} ${port} ${cmd}
62 ${connection_list_id}= Get Conn List Id ${host} ${port}
63 ${connection_list_id}= Run Keyword If "${connection_list_id}"=="${EMPTY}"
64 ... Open ONOS SSH Connection ${host} ${port}
65 ... ELSE Set Variable ${connection_list_id}
66 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000067 ${output}= Execute Single ONOS CLI Command ${connection_entry.conn_id} ${cmd}
TorstenThieme36a38a82022-02-09 15:51:30 +000068 ... connection_list_id=${connection_list_id}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000069 [Return] ${output}
70
71Execute Single ONOS CLI Command
72 [Documentation] Executes ONOS CLI Command on current connection
73 ... Using Write and Read instead of Execute Command to keep connection alive.
TorstenThieme36a38a82022-02-09 15:51:30 +000074 [Arguments] ${conn_id} ${cmd} ${do_reconnect}=True ${connection_list_id}=${EMPTY}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000075 Log Command: ${cmd}
76 SSHLibrary.Switch Connection ${conn_id}
77 # get connection settings, has no functional reason, only for info
TorstenThieme1d1413b2022-02-04 12:41:01 +000078 ${connection_info}= SSHLibrary.Get Connection
79 ${PassOrFail} ${Written}= Run Keyword And Ignore Error Write ${cmd}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000080 Run Keyword If '${PassOrFail}'=='FAIL' and ${do_reconnect} Reconnect ONOS SSH Connection ${connection_list_id}
TorstenThieme1d1413b2022-02-04 12:41:01 +000081 ${Written}= Run Keyword If '${PassOrFail}'=='FAIL' Write ${cmd} ELSE Set Variable ${Written}
82 Log pass_write: ${Written}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000083 ${PassOrFail} ${output}= Run Keyword And Ignore Error Read Until Prompt strip_prompt=True
TorstenThieme1d1413b2022-02-04 12:41:01 +000084 Log Result_values: ${output}
TorstenThieme1f58cac2022-02-10 15:58:38 +000085 # remove error printout from ssh library in case of failure
86 ${output}= Run Keyword If '${PassOrFail}'=='FAIL' Fetch From Right ${output} Output:
87 ... ELSE Set Variable ${output}
88 ${output}= Run Keyword If '${PassOrFail}'=='FAIL' Get Substring ${output} 1
89 ... ELSE Set Variable ${output}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000090 ${output_length}= Get Length ${output}
91 # remove regexp-prompt if available
92 ${output}= Remove String Using Regexp ${output} ${regexp_prompt}
93 ${output_after}= Get Length ${output}
94 Run Keyword If '${PassOrFail}'=='FAIL' and ${output_length}== ${output_after} FAIL SSH access failed for '${cmd}'!
TorstenThieme1d1413b2022-02-04 12:41:01 +000095 # we do not use strip of escape sequences integrated in ssh lib, we do it by ourself to have it under control
96 ${output}= Remove String Using Regexp ${output} \\x1b[>=]{0,1}(?:\\[[0-?]*(?:[hlm])[~]{0,1})*
97 # remove the endless spaces and two carrige returns at the end of output
98 ${output}= Remove String Using Regexp ${output} \\s*\\r \\r
99 # now we have the plain output text
100 Log Stripped Result_values: ${output}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000101 [Return] ${output}
102
103Get Conn List Id
104 [Documentation] Looks up for an Open Connection with passed host and port in conection list
105 ... First match connection will be used.
106 [Arguments] ${host} ${port}
107 ${connection_list_id}= Set Variable ${EMPTY}
108 ${match}= Set Variable False
109 ${length}= Get Length ${connection_list}
110 FOR ${INDEX} IN RANGE 0 ${length}
111 #${Item}= Get From List ${connection_list} ${INDEX}
112 ${conndata}= Get Connection ${connection_list[${INDEX}].conn_id}
113 ${match}= Set Variable If '${conndata.host}'=='${host}' and '${conndata.port}'=='${port}' True False
114 ${connection_list_id}= Set Variable If ${match} ${INDEX} ${EMPTY}
115 Exit For Loop If ${match}
116 END
117 [Return] ${connection_list_id}
118
TorstenThiemeb198c482020-12-14 19:45:23 +0000119Reconnect ONOS SSH Connection
120 [Documentation] Reconnect an SSH Connection
121 [Arguments] ${connection_list_id}
122 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
123 ${user}= Get From Dictionary ${connection_entry} user
124 ${pass}= Get From Dictionary ${connection_entry} pass
125 ${oldconndata}= Get Connection ${connection_entry.conn_id}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000126 ${match}= Set Variable If
127 ... "${oldconndata.host}"=="${connection_entry.host}" and "${oldconndata.port}"=="${connection_entry.port}"
128 ... True False
129 Run Keyword If ${match} SSHLibrary.Switch Connection ${connection_entry.conn_id}
130 Run Keyword If ${match} Run Keyword And Ignore Error SSHLibrary.Close Connection
131 ${conn_id}= SSHLibrary.Open Connection ${connection_entry.host} port=${connection_entry.port}
TorstenThieme2ddb6e82022-02-08 14:44:24 +0000132 ... timeout=${ssh_read_timeout} alias=${alias}
TorstenThieme36a38a82022-02-09 15:51:30 +0000133 SSHLibrary.Login username=${user} password=${pass} keep_alive_interval=${keep_alive_interval}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000134 # set excepted prompt and terminal width to suppress unwanted line feeds
TorstenThieme2ddb6e82022-02-08 14:44:24 +0000135 SSHLibrary.Set Client Configuration prompt=${ssh_prompt} width=${ssh_width}
TorstenThiemeb198c482020-12-14 19:45:23 +0000136 ${conn_list_entry}= Create Dictionary conn_id=${conn_id} user=${user} pass=${pass}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000137 ... host=${connection_entry.host} port=${connection_entry.port} alias=${alias}
TorstenThiemeb198c482020-12-14 19:45:23 +0000138 Set List Value ${connection_list} ${connection_list_id} ${conn_list_entry}
139 Set Global Variable ${connection_list}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000140 # disable highlighting to suppress control sequences
TorstenThieme2ddb6e82022-02-08 14:44:24 +0000141 ${output}= Execute Single ONOS CLI Command ${conn_id} ${disable_highlighter} do_reconnect=False
TorstenThiemeb198c482020-12-14 19:45:23 +0000142
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700143Close ONOS SSH Connection
144 [Documentation] Close an SSH Connection
TorstenThiemeb198c482020-12-14 19:45:23 +0000145 [Arguments] ${connection_list_id}
146 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
147 ${connection_alias}= Get From Dictionary ${connection_entry} conn_id
148 ${oldconndata}= Get Connection ${connection_entry.conn_id}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700149 SSHLibrary.Switch Connection ${connection_alias}
TorstenThiemebcf14612021-01-27 10:19:18 +0000150 Run Keyword And Ignore Error SSHLibrary.Close Connection
TorstenThiemeb198c482020-12-14 19:45:23 +0000151 Remove From List ${connection_list} ${connection_list_id}
152 Set Global Variable ${connection_list}
153
154Close All ONOS SSH Connections
155 [Documentation] Close all SSH Connection and clear connection list.
156 SSHLibrary.Close All Connections
157 @{connection_list} Create List
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700158
Kailash6f5acb62019-08-28 14:38:45 -0700159Validate OLT Device in ONOS
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700160 # FIXME use volt-olts to check that the OLT is ONOS
Kailash6f5acb62019-08-28 14:38:45 -0700161 [Arguments] ${serial_number}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700162 [Documentation] Checks if olt has been connected to ONOS
Kailash6f5acb62019-08-28 14:38:45 -0700163 ${resp}= Get Request ONOS onos/v1/devices
164 ${jsondata}= To Json ${resp.content}
165 Should Not Be Empty ${jsondata['devices']}
166 ${length}= Get Length ${jsondata['devices']}
167 @{serial_numbers}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -0700168 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700169 FOR ${INDEX} IN RANGE 0 ${length}
170 ${value}= Get From List ${jsondata['devices']} ${INDEX}
171 ${of_id}= Get From Dictionary ${value} id
172 ${sn}= Get From Dictionary ${value} serial
Andy Bavierb63f6d22020-03-12 15:34:37 -0700173 ${matched}= Set Variable If '${sn}' == '${serial_number}' True False
174 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700175 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700176 Should Be True ${matched} No match for ${serial_number} found
Kailash57210eb2019-08-30 13:27:19 -0700177 [Return] ${of_id}
Kailash6f5acb62019-08-28 14:38:45 -0700178
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700179Get ONU Port in ONOS
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000180 [Arguments] ${onu_serial_number} ${olt_of_id} ${onu_uni_id}=1
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700181 [Documentation] Retrieves ONU port for the ONU in ONOS
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000182 ${onu_serial_number}= Catenate SEPARATOR=- ${onu_serial_number} ${onu_uni_id}
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700183 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
184 ${jsondata}= To Json ${resp.content}
185 Should Not Be Empty ${jsondata['ports']}
186 ${length}= Get Length ${jsondata['ports']}
187 @{ports}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -0700188 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700189 FOR ${INDEX} IN RANGE 0 ${length}
190 ${value}= Get From List ${jsondata['ports']} ${INDEX}
191 ${annotations}= Get From Dictionary ${value} annotations
192 ${onu_port}= Get From Dictionary ${value} port
193 ${portName}= Get From Dictionary ${annotations} portName
Andy Bavierb63f6d22020-03-12 15:34:37 -0700194 ${matched}= Set Variable If '${portName}' == '${onu_serial_number}' True False
195 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700196 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700197 Should Be True ${matched} No match for ${onu_serial_number} found
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700198 [Return] ${onu_port}
199
TorstenThieme9b25aab2021-12-16 15:59:45 +0000200Get Onu Ports in ONOS For ALL UNI per ONU
201 [Documentation] Retrieves ONU port(s) for the ONU in ONOS for all UNI-IDs, list of ports will return!
202 [Arguments] ${onu_serial_number} ${olt_of_id}
203 @{uni_id_list}= Create List
204 @{port_list}= Create List
205 FOR ${I} IN RANGE 0 ${num_all_onus}
206 ${src}= Set Variable ${hosts.src[${I}]}
207 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
208 ${uni_id}= Set Variable ${src['uni_id']}
209 # make sure all actions do only once per uni_id
210 ${id}= Get Index From List ${uni_id_list} ${uni_id}
211 Continue For Loop If -1 != ${id}
212 Append To List ${uni_id_list} ${uni_id}
213 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${onu_serial_number}
214 ... ${olt_of_id} ${uni_id}
215 Append To List ${port_list} ${onu_port}
216 END
217 [return] ${port_list}
218
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530219Get NNI Port in ONOS
220 [Arguments] ${olt_of_id}
221 [Documentation] Retrieves NNI port for the OLT in ONOS
222 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
223 ${jsondata}= To Json ${resp.content}
224 Should Not Be Empty ${jsondata['ports']}
225 ${length}= Get Length ${jsondata['ports']}
226 @{ports}= Create List
227 ${matched}= Set Variable False
228 FOR ${INDEX} IN RANGE 0 ${length}
229 ${value}= Get From List ${jsondata['ports']} ${INDEX}
230 ${annotations}= Get From Dictionary ${value} annotations
231 ${nni_port}= Get From Dictionary ${value} port
232 ${nniPortName}= Catenate SEPARATOR= nni- ${nni_port}
233 ${portName}= Get From Dictionary ${annotations} portName
234 ${matched}= Set Variable If '${portName}' == '${nniPortName}' True False
235 Exit For Loop If ${matched}
236 END
237 Should Be True ${matched} No match for NNI found for ${olt_of_id}
238 [Return] ${nni_port}
239
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700240Get FabricSwitch in ONOS
241 [Documentation] Returns of_id of the Fabric Switch in ONOS
242 ${resp}= Get Request ONOS onos/v1/devices
243 ${jsondata}= To Json ${resp.content}
244 Should Not Be Empty ${jsondata['devices']}
245 ${length}= Get Length ${jsondata['devices']}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700246 ${matched}= Set Variable False
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700247 FOR ${INDEX} IN RANGE 0 ${length}
248 ${value}= Get From List ${jsondata['devices']} ${INDEX}
249 ${of_id}= Get From Dictionary ${value} id
250 ${type}= Get From Dictionary ${value} type
Andy Bavierb63f6d22020-03-12 15:34:37 -0700251 ${matched}= Set Variable If '${type}' == "SWITCH" True False
252 Exit For Loop If ${matched}
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700253 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700254 Should Be True ${matched} No fabric switch found
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700255 [Return] ${of_id}
256
Andrea Campanella4c404632020-08-26 14:41:36 +0200257Get Master Instace in ONOS
258 [Arguments] ${of_id}
259 [Documentation] Returns nodeId of the Master instace for a giver device in ONOS
260 ${resp}= Get Request ONOS onos/v1/mastership/${of_id}/master
261 ${jsondata}= To Json ${resp.content}
262 Should Not Be Empty ${jsondata['nodeId']}
263 ${master_node}= Get From Dictionary ${jsondata} nodeId
264 [Return] ${master_node}
265
Matteo Scandolo7bdbe2d2021-11-29 15:48:25 -0800266Verify LLDP Flow Added
267 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
268 [Documentation] Matches for total number of LLDP flows added for one OLT
269 ${lldp_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
270 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep ETH_TYPE:lldp | grep -v ETH_TYPE:arp
271 ${lldp_flows_added_count}= Get Line Count ${lldp_flows_added}
272 Should Be Equal As Integers ${lldp_flows_added_count} ${expected_flows}
273
Hardik Windlass21807632020-04-14 16:24:55 +0530274Verify Subscriber Access Flows Added for ONU
275 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${c_tag} ${s_tag}
276 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
277 # Verify upstream table=0 flow
278 ${upstream_flow_0_cmd}= Catenate SEPARATOR=
279 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:0 |
280 ... grep VLAN_ID:${c_tag} | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000281 ${upstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530282 ... ${upstream_flow_0_cmd}
283 Should Not Be Empty ${upstream_flow_0_added}
284 # Verify upstream table=1 flow
285 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
286 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
287 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000288 ${upstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530289 ... ${flow_vlan_push_cmd}
290 Should Not Be Empty ${upstream_flow_1_added}
291 # Verify downstream table=0 flow
292 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
293 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
294 ... grep VLAN_POP | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000295 ${downstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530296 ... ${flow_vlan_pop_cmd}
297 Should Not Be Empty ${downstream_flow_0_added}
298 # Verify downstream table=1 flow
299 ${downstream_flow_1_cmd}= Catenate SEPARATOR=
300 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${c_tag} |
301 ... grep VLAN_ID:0 | grep OUTPUT:${onu_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000302 ${downstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530303 ... ${downstream_flow_1_cmd}
304 Should Not Be Empty ${downstream_flow_1_added}
305 # Verify ipv4 dhcp upstream flow
306 ${upstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200307 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:ipv4 |
Andrea Campanella08678e12020-09-18 17:40:22 +0200308 ... grep IP_PROTO:17 | grep UDP_SRC:68 | grep UDP_DST:67 | grep VLAN_ID:${c_tag} |
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200309 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000310 ${upstream_flow_ipv4_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530311 ... ${upstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200312 Should Not Be Empty ${upstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530313 # Verify ipv4 dhcp downstream flow
314 # Note: This flow will be one per nni per olt
315 ${downstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200316 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep ETH_TYPE:ipv4 |
317 ... grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 | grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000318 ${downstream_flow_ipv4_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530319 ... ${downstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200320 Should Not Be Empty ${downstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530321
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530322Verify Subscriber Access Flows Added for ONU DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530323 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530324 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
325 # Verify upstream table=0 flow
TorstenThieme4e2168e2021-06-22 14:01:47 +0000326 ${upstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530327 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:Any | grep transition=TABLE:1
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530328 Should Not Be Empty ${upstream_flow_0_added}
329 # Verify upstream table=1 flow
330 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530331 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:Any |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530332 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000333 ${upstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530334 ... ${flow_vlan_push_cmd}
335 Should Not Be Empty ${upstream_flow_1_added}
336 # Verify downstream table=0 flow
337 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530338 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530339 ... grep VLAN_POP | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000340 ${downstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530341 ... ${flow_vlan_pop_cmd}
342 Should Not Be Empty ${downstream_flow_0_added}
343 # Verify downstream table=1 flow
TorstenThieme4e2168e2021-06-22 14:01:47 +0000344 ${downstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530345 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:Any | grep OUTPUT:${onu_port}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530346 Should Not Be Empty ${downstream_flow_1_added}
347
348Verify Subscriber Access Flows Added Count DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530349 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530350 [Documentation] Matches for total number of subscriber access flows added for all onus
TorstenThieme4e2168e2021-06-22 14:01:47 +0000351 ${access_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700352 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep -v ETH_TYPE:lldp | grep -v ETH_TYPE:arp
353 ${access_flows_added_count}= Get Line Count ${access_flows_added}
354 Should Be Equal As Integers ${access_flows_added_count} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530355
Huseyin Ahmet AYDIN45922c82021-05-27 12:37:32 +0000356Verify Added Flow Count for OLT TT
357 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
358 [Documentation] Total number of added flows given OLT with subscriber flows
TorstenThieme4e2168e2021-06-22 14:01:47 +0000359 ${access_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700360 ... flows -s ADDED ${olt_of_id} | grep -v deviceId
361 ${access_flows_added_count}= Get Line Count ${access_flows_added}
362 Should Be Equal As Integers ${access_flows_added_count} ${expected_flows}
Huseyin Ahmet AYDIN45922c82021-05-27 12:37:32 +0000363
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000364Verify Default Downstream Flows are added in ONOS for OLT TT
365 [Arguments] ${ip} ${port} ${olt_of_id} ${nni_port}
366 [Documentation] Verifies if the Default Downstream Flows are added in ONOS for the OLT
367 # Verify lldp flow
368 ${downstream_flow_lldp_cmd}= Catenate SEPARATOR=
369 ... flows -s ADDED ${olt_of_id} | grep lldp |
370 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000371 ${downstream_flow_lldp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000372 ... ${downstream_flow_lldp_cmd}
373 Should Not Be Empty ${downstream_flow_lldp_added}
374 # Verify downstream dhcp flow
375 ${downstream_flow_dhcp_cmd}= Catenate SEPARATOR=
376 ... flows -s ADDED ${olt_of_id} | grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 |
377 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000378 ${downstream_flow_dhcp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000379 ... ${downstream_flow_dhcp_cmd}
380 Should Not Be Empty ${downstream_flow_dhcp_added}
381 # Verify downstream igmp flow
382 ${downstream_flow_igmp_cmd}= Catenate SEPARATOR=
383 ... flows -s ADDED ${olt_of_id} | grep IP_PROTO:2 |
384 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000385 ${downstream_flow_igmp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000386 ... ${downstream_flow_igmp_cmd}
387 Should Not Be Empty ${downstream_flow_igmp_added}
388
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530389Get Programmed Subscribers
390 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
391 [Documentation] Retrieves the subscriber details at a given location
392 ${sub_location}= Catenate SEPARATOR=/ ${olt_of_id} ${onu_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000393 ${programmed_sub}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530394 ... volt-programmed-subscribers | grep ${sub_location}
395 [Return] ${programmed_sub}
396
397Get Upstream and Downstream Bandwidth Profile Name
398 [Arguments] ${programmed_sub}
399 [Documentation] Retrieves the upstream and downstream bandwidth profile name
400 ... from the programmed subscriber
401 @{programmed_sub_array}= Split String ${programmed_sub} ,
402 # Get upstream bandwidth profile name for the subscriber
403 @{param_val_pair}= Split String ${programmed_sub_array[9]} =
404 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
405 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
406 ${us_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' upstreamBandwidthProfile'
407 ... Set Variable ${programmed_sub_val}
408 Log ${us_bw_profile}
409 # Get downstream bandwidth profile name for the subscriber
410 @{param_val_pair}= Split String ${programmed_sub_array[10]} =
411 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
412 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
413 ${ds_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' downstreamBandwidthProfile'
414 ... Set Variable ${programmed_sub_val}
415 Log ${ds_bw_profile}
416 [Return] ${us_bw_profile} ${ds_bw_profile}
417
418Get Bandwidth Profile Details
419 [Arguments] ${ip} ${port} ${bw_profile}
420 [Documentation] Retrieves the details of the given bandwidth profile
TorstenThieme4e2168e2021-06-22 14:01:47 +0000421 ${bw_profile_values}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530422 ... bandwidthprofile ${bw_profile}
423 @{bw_profile_array}= Split String ${bw_profile_values} ,
424 @{param_val_pair}= Split String ${bw_profile_array[1]} =
425 ${bw_param}= Set Variable ${param_val_pair[0]}
426 ${bw_val}= Set Variable ${param_val_pair[1]}
427 ${cir} Run Keyword If '${bw_param}' == ' committedInformationRate'
428 ... Set Variable ${bw_val}
429 @{param_val_pair}= Split String ${bw_profile_array[2]} =
430 ${bw_param}= Set Variable ${param_val_pair[0]}
431 ${bw_val}= Set Variable ${param_val_pair[1]}
432 ${cbs} Run Keyword If '${bw_param}' == ' committedBurstSize'
433 ... Set Variable ${bw_val}
434 @{param_val_pair}= Split String ${bw_profile_array[3]} =
435 ${bw_param}= Set Variable ${param_val_pair[0]}
436 ${bw_val}= Set Variable ${param_val_pair[1]}
437 ${eir} Run Keyword If '${bw_param}' == ' exceededInformationRate'
438 ... Set Variable ${bw_val}
439 @{param_val_pair}= Split String ${bw_profile_array[4]} =
440 ${bw_param}= Set Variable ${param_val_pair[0]}
441 ${bw_val}= Set Variable ${param_val_pair[1]}
442 ${ebs} Run Keyword If '${bw_param}' == ' exceededBurstSize'
443 ... Set Variable ${bw_val}
444 @{param_val_pair}= Split String ${bw_profile_array[5]} =
445 ${bw_param}= Set Variable ${param_val_pair[0]}
446 ${bw_val}= Set Variable ${param_val_pair[1]}
447 @{bw_val_air}= Split String ${bw_val} }
448 ${air} Run Keyword If '${bw_param}' == ' assuredInformationRate'
449 ... Set Variable ${bw_val_air[0]}
450 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
451
Hardik Windlassba5add42021-05-04 12:41:29 +0000452Get Bandwidth Profile Details Rest
453 [Arguments] ${bw_profile_id}
454 [Documentation] Retrieves the details of the given bandwidth profile using REST API
Girish Gowdracb8482a2021-05-27 09:06:13 -0700455 ${bw_profile_id}= Remove String ${bw_profile_id} ' "
Hardik Windlassba5add42021-05-04 12:41:29 +0000456 ${resp}= Get Request ONOS onos/sadis/bandwidthprofile/${bw_profile_id}
457 ${jsondata}= To Json ${resp.content}
458 Should Not Be Empty ${jsondata['entry']}
459 ${length}= Get Length ${jsondata['entry']}
460 ${matched}= Set Variable False
461 FOR ${INDEX} IN RANGE 0 ${length}
462 ${value}= Get From List ${jsondata['entry']} ${INDEX}
463 ${bw_id}= Get From Dictionary ${value} id
464 ${matched}= Set Variable If '${bw_id}' == '${bw_profile_id}' True False
465 ${eir}= Get From Dictionary ${value} eir
466 ${ebs}= Get From Dictionary ${value} ebs
467 ${cir}= Get From Dictionary ${value} cir
468 ${cbs}= Get From Dictionary ${value} cbs
469 ${air}= Get From Dictionary ${value} air
470 Exit For Loop If ${matched}
471 END
472 Should Be True ${matched} No bandwidth profile found for id: ${bw_profile_id}
473 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
474
Hardik Windlass841979a2021-05-25 05:30:27 +0000475Get Bandwidth Profile Details Ietf Rest
476 [Arguments] ${bw_profile_id}
477 [Documentation] Retrieves the details of the given Ietf standard based bandwidth profile using REST API
478 ${bw_profile_id}= Remove String ${bw_profile_id} ' "
479 ${resp}= Get Request ONOS onos/sadis/bandwidthprofile/${bw_profile_id}
480 ${jsondata}= To Json ${resp.content}
481 Should Not Be Empty ${jsondata['entry']}
482 ${length}= Get Length ${jsondata['entry']}
483 ${matched}= Set Variable False
484 FOR ${INDEX} IN RANGE 0 ${length}
485 ${value}= Get From List ${jsondata['entry']} ${INDEX}
486 ${bw_id}= Get From Dictionary ${value} id
487 ${matched}= Set Variable If '${bw_id}' == '${bw_profile_id}' True False
488 ${pir}= Get From Dictionary ${value} pir
489 ${pbs}= Get From Dictionary ${value} pbs
490 ${cir}= Get From Dictionary ${value} cir
491 ${cbs}= Get From Dictionary ${value} cbs
492 ${gir}= Get From Dictionary ${value} gir
493 Exit For Loop If ${matched}
494 END
495 Should Be True ${matched} No bandwidth profile found for id: ${bw_profile_id}
496 [Return] ${cir} ${cbs} ${pir} ${pbs} ${gir}
497
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700498Verify Meters in ONOS Ietf
499 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
500 [Documentation] Verifies the meters with BW Ietf format (currently, DT workflow uses this format)
501 # Get programmed subscriber
502 ${programmed_sub}= Get Programmed Subscribers ${ip} ${port}
503 ... ${olt_of_id} ${onu_port}
504 Log ${programmed_sub}
505 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
506 ... ${programmed_sub}
507 # Get upstream bandwidth profile details
508 ${us_cir} ${us_cbs} ${us_pir} ${us_pbs} ${us_gir} Get Bandwidth Profile Details Ietf Rest
509 ... ${us_bw_profile}
510 # Verify meter for upstream bandwidth profile
511 ${us_meter_cmd}= Run Keyword If ${us_gir} != 0 Catenate SEPARATOR=
512 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
513 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | grep "rate=${us_gir}, burst-size=0" | wc -l
514 ... ELSE Catenate SEPARATOR=
515 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
516 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000517 ${upstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700518 ... ${us_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700519 Should Be Equal As Integers ${upstream_meter_added} 1 Upstream meter is missing
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700520 # Get downstream bandwidth profile details
521 ${ds_cir} ${ds_cbs} ${ds_pir} ${ds_pbs} ${ds_gir} Get Bandwidth Profile Details Ietf Rest
522 ... ${ds_bw_profile}
523 # Verify meter for downstream bandwidth profile
524 ${ds_meter_cmd}= Run Keyword If ${ds_gir} != 0 Catenate SEPARATOR=
525 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
526 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | grep "rate=${ds_gir}, burst-size=0" | wc -l
527 ... ELSE Catenate SEPARATOR=
528 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
529 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000530 ${downstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700531 ... ${ds_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700532 Should Be Equal As Integers ${downstream_meter_added} 1 Downstream meter is missing
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700533
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530534Verify Meters in ONOS
535 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
536 [Documentation] Verifies the meters
537 # Get programmed subscriber
538 ${programmed_sub}= Get Programmed Subscribers ${ip} ${port}
539 ... ${olt_of_id} ${onu_port}
540 Log ${programmed_sub}
541 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
542 ... ${programmed_sub}
Matteo Scandolo2056ed72021-11-02 17:38:03 -0700543 # logging all meters to facilitate debug
544 ${all_meters}= Execute ONOS CLI Command use single connection ${ip} ${port} meters
545 Log ${all_meters}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530546 # Get upstream bandwidth profile details
547 ${us_cir} ${us_cbs} ${us_eir} ${us_ebs} ${us_air} Get Bandwidth Profile Details
548 ... ${ip} ${port} ${us_bw_profile}
549 Sleep 1s
Andrea Campanella2b367102021-05-04 19:33:46 +0200550 ${us_pbs}= Evaluate ${us_cbs}+${us_ebs}
551 ${us_pir}= Evaluate ${us_eir}+${us_cir}+${us_air}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530552 # Verify meter for upstream bandwidth profile
553 ${us_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530554 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200555 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | grep "rate=${us_air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000556 ${upstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530557 ... ${us_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700558 Should Be Equal As Integers ${upstream_meter_added} 1 Upstream meter is missing
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530559 Sleep 1s
560 # Get downstream bandwidth profile details
561 ${ds_cir} ${ds_cbs} ${ds_eir} ${ds_ebs} ${ds_air} Get Bandwidth Profile Details
562 ... ${ip} ${port} ${ds_bw_profile}
563 Sleep 1s
564 # Verify meter for downstream bandwidth profile
Andrea Campanella2b367102021-05-04 19:33:46 +0200565 ${ds_pbs}= Evaluate ${ds_cbs}+${ds_ebs}
566 ${ds_pir}= Evaluate ${ds_eir}+${ds_cir}+${ds_air}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530567 ${ds_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530568 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200569 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | grep "rate=${ds_air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000570 ${downstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530571 ... ${ds_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700572 Should Be Equal As Integers ${downstream_meter_added} 1 Downstream meter is missing
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530573
574Verify Default Meter Present in ONOS
575 [Arguments] ${ip} ${port} ${olt_of_id}
576 [Documentation] Verifies the single default meter entry is present
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530577 # Get default bandwidth profile details
578 ${cir} ${cbs} ${eir} ${ebs} ${air} Get Bandwidth Profile Details
579 ... ${ip} ${port} 'Default'
580 Sleep 1s
Andrea Campanella2b367102021-05-04 19:33:46 +0200581 ${pbs}= Evaluate ${cbs}+${ebs}
582 ${pir}= Evaluate ${eir}+${cir}+${air}
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530583 # Verify meter for default bandwidth profile
584 ${meter_cmd}= Catenate SEPARATOR=
585 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${cir}, burst-size=${cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200586 ... | grep "rate=${pir}, burst-size=${pbs}" | grep "rate=${air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000587 ${default_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530588 ... ${meter_cmd}
Matteo Scandolo2056ed72021-11-02 17:38:03 -0700589 # logging all meters to facilitate debug
590 ${all_meters}= Execute ONOS CLI Command use single connection ${ip} ${port} meters
591 Log ${all_meters}
592 # done logging all meters to facilitate debug
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700593 Should Be Equal As Integers ${default_meter_added} 1 Default Meter not present
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530594
Hardik Windlass480f3e22020-04-02 20:14:14 +0530595Verify Device Flows Removed
596 [Arguments] ${ip} ${port} ${olt_of_id}
597 [Documentation] Verifies all flows are removed from the device
TorstenThieme4e2168e2021-06-22 14:01:47 +0000598 ${device_flows}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700599 ... flows -s -f ${olt_of_id} | grep -v deviceId
600 ${flow_count}= Get Line Count ${device_flows}
601 Should Be Equal As Integers ${flow_count} 0 Flows not removed
Hardik Windlass480f3e22020-04-02 20:14:14 +0530602
Kailash6f5acb62019-08-28 14:38:45 -0700603Verify Eapol Flows Added
Andy Bavierb0c06232019-08-29 12:58:53 -0700604 [Arguments] ${ip} ${port} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700605 [Documentation] Matches for number of eapol flows based on number of onus
TorstenThieme4e2168e2021-06-22 14:01:47 +0000606 ${eapol_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Gilles Depatie675a2062019-10-22 12:44:42 -0400607 ... flows -s -f ADDED | grep eapol | grep IN_PORT | wc -l
Andy Bavierb0c06232019-08-29 12:58:53 -0700608 Should Contain ${eapol_flows_added} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700609
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800610Verify No Pending Flows For ONU
611 [Arguments] ${ip} ${port} ${onu_port}
612 [Documentation] Verifies that there are no flows "PENDING" state for the ONU in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000613 ${pending_flows}= Execute ONOS CLI Command use single connection ${ip} ${port}
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800614 ... flows -s | grep IN_PORT:${onu_port} | grep PENDING
615 Should Be Empty ${pending_flows}
616
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700617Verify Eapol Flows Added For ONU
Matteo Scandolo7e519fb2021-08-13 11:35:16 -0700618 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${c_tag}=4091
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700619 [Documentation] Verifies if the Eapol Flows are added in ONOS for the ONU
Matteo Scandolo7e519fb2021-08-13 11:35:16 -0700620 ${eapol_flow_cmd}= Catenate SEPARATOR=
621 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:eapol |
622 ... grep VLAN_ID:${c_tag} | grep OUTPUT:CONTROLLER
623 ${eapol_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port} ${eapol_flow_cmd}
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700624 Should Not Be Empty ${eapol_flows_added}
625
Hardik Windlass39015672021-07-05 05:48:08 +0000626Verify UNI Port Is Enabled
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000627 [Arguments] ${ip} ${port} ${onu_name} ${onu_uni_id}=1
Hardik Windlass39015672021-07-05 05:48:08 +0000628 [Documentation] Verifies if the ONU's UNI port is enabled in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000629 ${onu_port_enabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000630 ... ports -e | grep portName=${onu_name}-${onu_uni_id}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800631 Log ${onu_port_enabled}
632 Should Not Be Empty ${onu_port_enabled}
633
Hardik Windlass39015672021-07-05 05:48:08 +0000634Verify UNI Port Is Disabled
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000635 [Arguments] ${ip} ${port} ${onu_name} ${onu_uni_id}=1
Hardik Windlass39015672021-07-05 05:48:08 +0000636 [Documentation] Verifies if the ONU's UNI port is disabled in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000637 ${onu_port_disabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo02768532021-10-21 15:14:12 -0700638 ... ports | grep portName=${onu_name}-${onu_uni_id} | grep state=disabled
Hardik Windlass63d5e002020-03-06 21:07:09 +0530639 Log ${onu_port_disabled}
Matteo Scandolo02768532021-10-21 15:14:12 -0700640 Should Not Be Empty ${onu_port_disabled}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530641
TorstenThieme9b25aab2021-12-16 15:59:45 +0000642Wait For All UNI Ports Are Disabled per ONU
643 [Documentation] Verifies all UNI Ports of passed ONU are disabled
644 [Arguments] ${ip} ${port} ${onu_serial_number}
645 @{uni_id_list}= Create List
646 FOR ${I} IN RANGE 0 ${num_all_onus}
647 ${src}= Set Variable ${hosts.src[${I}]}
648 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
649 ${uni_id}= Set Variable ${src['uni_id']}
650 # make sure all actions do only once per uni_id
651 ${id}= Get Index From List ${uni_id_list} ${uni_id}
652 Continue For Loop If -1 != ${id}
653 Append To List ${uni_id_list} ${uni_id}
654 Wait Until Keyword Succeeds ${timeout} 2s
655 ... Verify UNI Port Is Disabled ${ip} ${port} ${onu_serial_number} ${uni_id}
656 END
657
658Wait For All UNI Ports Are Enabled per ONU
659 [Documentation] Verifies all UNI Ports of passed ONU are enabled
660 [Arguments] ${ip} ${port} ${onu_serial_number}
661 @{uni_id_list}= Create List
662 FOR ${I} IN RANGE 0 ${num_all_onus}
663 ${src}= Set Variable ${hosts.src[${I}]}
664 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
665 ${uni_id}= Set Variable ${src['uni_id']}
666 # make sure all actions do only once per uni_id
667 ${id}= Get Index From List ${uni_id_list} ${uni_id}
668 Continue For Loop If -1 != ${id}
669 Append To List ${uni_id_list} ${uni_id}
670 Wait Until Keyword Succeeds ${timeout} 2s
671 ... Verify UNI Port Is Enabled ${ip} ${port} ${onu_serial_number} ${uni_id}
672 END
673
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700674Verify ONU in AAA-Users
675 [Arguments] ${ip} ${port} ${onu_port}
676 [Documentation] Verifies that the specified onu_port exists in aaa-users output
TorstenThieme4e2168e2021-06-22 14:01:47 +0000677 ${aaa_users}= Execute ONOS CLI Command use single connection ${ip} ${port}
678 ... aaa-users | grep AUTHORIZED | grep ${onu_port}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700679 Should Not Be Empty ${aaa_users} ONU port ${onu_port} not found in aaa-users
680
Hardik Windlass513afd12021-02-03 15:19:46 +0000681Verify Empty Group in ONOS
682 [Documentation] Verifies zero group count on the device
TorstenThieme731a7592021-07-01 14:26:54 +0000683 [Arguments] ${ip} ${port} ${deviceId}
684 ${groups}= Execute ONOS CLI Command use single connection ${ip} ${port} groups | grep ${deviceId}
Hardik Windlass513afd12021-02-03 15:19:46 +0000685 @{groups_arr}= Split String ${groups} ,
686 @{group_count_arr}= Split String ${groups_arr[1]} =
687 ${group_count}= Set Variable ${group_count_arr[1]}
688 Should Be Equal As Integers ${group_count} 0
689
690Verify ONUs in Group Count in ONOS
691 [Documentation] Verifies there exists a group bucket list with certain entries/count
692 ... Note: Currently, this validates only if all ONUs of an OLT joined the same igmp group
TorstenThieme731a7592021-07-01 14:26:54 +0000693 [Arguments] ${ip} ${port} ${count} ${deviceId}
694 ${result}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolofd36e212021-03-02 11:36:10 -0800695 ... groups added ${deviceId} | grep bucket | wc -l
696 Should Be Equal As Integers ${result} ${count} Bucket list count for a group: Found=${result} Expected=${count}
Hardik Windlass513afd12021-02-03 15:19:46 +0000697
698Verify ONU in Group Bucket
699 [Documentation] Matches if ONU port in Group Bucket
700 [Arguments] ${group_bucket_values} ${onu_port}
701 ${len}= Get Length ${group_bucket_values}
702 ${matched}= Set Variable False
703 FOR ${INDEX} IN RANGE 0 ${len}
704 ${value_bucket}= Get From List ${group_bucket_values} ${INDEX}
705 ${treatment}= Get From Dictionary ${value_bucket} treatment
706 ${instructions}= Get From Dictionary ${treatment} instructions
707 ${instructions_val}= Get From List ${instructions} 0
708 ${port}= Get From Dictionary ${instructions_val} port
709 ${matched}= Set Variable If '${port}'=='${onu_port}' True False
710 Exit For Loop If ${matched}
711 END
712 [Return] ${matched}
713
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700714Verify ONU in Groups
715 [Arguments] ${ip_onos} ${port_onos} ${deviceId} ${onu_port} ${group_exist}=True
716 [Documentation] Verifies that the specified onu_port exists in groups output
TorstenThieme4e2168e2021-06-22 14:01:47 +0000717 ${result}= Execute ONOS CLI Command use single connection ${ip_onos} ${port_onos} groups -j
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700718 Log Groups: ${result}
719 ${groups}= To Json ${result}
720 ${length}= Get Length ${groups}
721 ${buckets}= Create List
722 ${matched}= Set Variable False
723 FOR ${INDEX} IN RANGE 0 ${length}
724 ${value}= Get From List ${groups} ${INDEX}
725 ${devId}= Get From Dictionary ${value} deviceId
726 ${bucket}= Get From Dictionary ${value} buckets
727 Run Keyword If '${devId}'=='${deviceId}'
728 ... Append To List ${buckets} ${bucket}
729 END
730 ${bucket_len}= Get Length ${buckets}
Hardik Windlass513afd12021-02-03 15:19:46 +0000731 FOR ${INDEX_1} IN RANGE 0 ${bucket_len}
732 ${value}= Get From List ${buckets} ${INDEX_1}
733 ${matched}= Verify ONU in Group Bucket ${value} ${onu_port}
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700734 Exit For Loop If ${matched}
735 END
736 Run Keyword If ${group_exist}
737 ... Should Be True ${matched} No match for ${deviceId} and ${onu_port} found in ONOS groups
738 ... ELSE
739 ... Should Be True '${matched}'=='False' Match for ${deviceId} and ${onu_port} found in ONOS groups
740
Matteo Scandolo142e6272020-04-29 17:36:59 -0700741Assert Number of AAA-Users
TorstenThieme731a7592021-07-01 14:26:54 +0000742 [Arguments] ${ip} ${port} ${expected_onus} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700743 [Documentation] Matches for number of aaa-users authorized based on number of onus
TorstenThieme731a7592021-07-01 14:26:54 +0000744 ${aaa_users}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800745 ... aaa-users | grep ${deviceId} | grep AUTHORIZED | wc -l
746 Log Found ${aaa_users} of ${expected_onus} expected authenticated users on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700747 Should Be Equal As Integers ${aaa_users} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700748
749Validate DHCP Allocations
TorstenThieme731a7592021-07-01 14:26:54 +0000750 [Arguments] ${ip} ${port} ${count} ${workflow} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700751 [Documentation] Matches for number of dhcpacks based on number of onus
TorstenThieme731a7592021-07-01 14:26:54 +0000752 ${allocations}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800753 ... dhcpl2relay-allocations | grep ${deviceId} | grep DHCPACK | wc -l
Matteo Scandoloda854b02020-09-01 16:20:51 -0700754 # if the workflow is TT we'll have 2 allocations for each ONU
755 ${ttAllocations}= Evaluate (${count} * 2)
756 ${count}= Set Variable If $workflow=='tt' ${ttAllocations} ${count}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800757 Log Found ${allocations} of ${count} expected DHCPACK on device ${deviceId}
Matteo Scandoloda854b02020-09-01 16:20:51 -0700758 Should Be Equal As Integers ${allocations} ${count}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700759
760Validate Subscriber DHCP Allocation
Suchitra Vemuri42819412020-10-01 17:45:43 -0700761 [Arguments] ${ip} ${port} ${onu_port} ${vlan}=''
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700762 [Documentation] Verifies that the specified subscriber is found in DHCP allocations
763 ##TODO: Enhance the keyword to include DHCP allocated address is not 0.0.0.0
TorstenThieme4e2168e2021-06-22 14:01:47 +0000764 ${allocations}= Execute ONOS CLI Command use single connection ${ip} ${port}
Suchitra Vemuri42819412020-10-01 17:45:43 -0700765 ... dhcpl2relay-allocations | grep DHCPACK | grep ${onu_port} | grep ${vlan}
Gilles Depatie675a2062019-10-22 12:44:42 -0400766 Should Not Be Empty ${allocations} ONU port ${onu_port} not found in dhcpl2relay-allocations
David Bainbridgef81cd642019-11-20 00:14:47 +0000767
768Device Is Available In ONOS
Matteo Scandolo3218d5b2021-05-26 11:50:10 -0700769 [Arguments] ${url} ${dpid} ${available}=true
770 [Documentation] Validates the device exists and it has the expected availability in ONOS
David Bainbridgef81cd642019-11-20 00:14:47 +0000771 ${rc} ${json} Run And Return Rc And Output curl --fail -sSL ${url}/onos/v1/devices/${dpid}
772 Should Be Equal As Integers 0 ${rc}
773 ${rc} ${value} Run And Return Rc And Output echo '${json}' | jq -r .available
774 Should Be Equal As Integers 0 ${rc}
Matteo Scandolo3218d5b2021-05-26 11:50:10 -0700775 Should Be Equal ${available} ${value}
David Bainbridgef81cd642019-11-20 00:14:47 +0000776
777Remove All Devices From ONOS
778 [Arguments] ${url}
779 [Documentation] Executes the device-remove command on each device in ONOS
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000780 ${rc} ${output} Run And Return Rc And Output
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700781 ... curl --fail -sSL ${url}/onos/v1/devices | jq -r '.devices[].id'
David Bainbridgef81cd642019-11-20 00:14:47 +0000782 Should Be Equal As Integers ${rc} 0
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000783 @{dpids} Split String ${output}
David Bainbridgef81cd642019-11-20 00:14:47 +0000784 ${count}= Get length ${dpids}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700785 FOR ${dpid} IN @{dpids}
786 ${rc}= Run Keyword If '${dpid}' != ''
787 ... Run And Return Rc curl -XDELETE --fail -sSL ${url}/onos/v1/devices/${dpid}
788 Run Keyword If '${dpid}' != ''
789 ... Should Be Equal As Integers ${rc} 0
790 END
Matteo Scandolo142e6272020-04-29 17:36:59 -0700791
TorstenThieme440b7c02020-12-18 15:42:57 +0000792Assert ONU Port Is Disabled
TorstenThieme731a7592021-07-01 14:26:54 +0000793 [Arguments] ${ip} ${port} ${deviceId} ${onu_port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000794 [Documentation] Verifies if the ONU port is disabled in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000795 ${onu_port_disabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000796 ... ports -d ${deviceId} | grep port=${onu_port}
797 Log ${onu_port_disabled}
798 Should Not Be Empty ${onu_port_disabled}
799
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700800Assert Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000801 [Arguments] ${ip} ${port} ${count}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700802 [Documentation] DEPRECATED use Assert Olt in ONOS
803 ... Check that a certain number of olts are known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000804 ${olts}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700805 ... volt-olts | wc -l
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700806 Log Found ${olts} of ${count} expected Olts
807 Should Be Equal As Integers ${olts} ${count}
808
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700809Assert Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000810 [Arguments] ${ip} ${port} ${deviceId}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700811 [Documentation] Check that a particular olt is known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000812 ${olts}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700813 ... volt-olts | grep ${deviceId} | wc -l
814 Should Be Equal As Integers ${olts} 1 "Device ${deviceId} is not recognized as an OLT"
815
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700816Wait for Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000817 [Arguments] ${ip} ${port} ${count} ${max_wait_time}=10m
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700818 [Documentation] DEPRECATED use Wait for Olt in ONOS
819 ... Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700820 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000821 ... ${ip} ${port} ${count}
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700822
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700823Wait for Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000824 [Arguments] ${ip} ${port} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700825 [Documentation] Waits until a particular deviceId is recognized by ONOS as an OLT
826 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000827 ... ${ip} ${port} ${deviceId}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700828
Matteo Scandolo142e6272020-04-29 17:36:59 -0700829Assert Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000830 [Arguments] ${ip} ${port} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700831 [Documentation] Check that a certain number of ports are enabled in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000832 ${ports}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800833 ... ports -e ${deviceId} | grep ${filter} | wc -l
834 Log Found ${ports} of ${count} expected ports on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700835 Should Be Equal As Integers ${ports} ${count}
836
837Wait for Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000838 [Arguments] ${ip} ${port} ${count} ${deviceId} ${filter} ${max_wait_time}=10m
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800839 [Documentation] Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
TorstenThiemed4f48962020-12-08 12:17:19 +0000840 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000841 ... ${ip} ${port} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700842
843Wait for AAA Authentication
TorstenThieme731a7592021-07-01 14:26:54 +0000844 [Arguments] ${ip} ${port} ${count} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700845 [Documentation] Waits untill a certain number of subscribers are authenticated in ONOS
TorstenThiemed4f48962020-12-08 12:17:19 +0000846 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Number of AAA-Users
TorstenThieme731a7592021-07-01 14:26:54 +0000847 ... ${ip} ${port} ${count} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700848
849Wait for DHCP Ack
TorstenThieme731a7592021-07-01 14:26:54 +0000850 [Arguments] ${ip} ${port} ${count} ${workflow} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700851 [Documentation] Waits untill a certain number of subscribers have received a DHCP_ACK
TorstenThiemed4f48962020-12-08 12:17:19 +0000852 Wait Until Keyword Succeeds ${max_wait_time} 5s Validate DHCP Allocations
TorstenThieme731a7592021-07-01 14:26:54 +0000853 ... ${ip} ${port} ${count} ${workflow} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700854
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700855Provision subscriber REST
856 [Documentation] Uses the rest APIs to provision a subscriber
TorstenThieme731a7592021-07-01 14:26:54 +0000857 [Arguments] ${of_id} ${onu_port}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700858 ${resp}= Post Request ONOS
859 ... /onos/olt/oltapp/${of_id}/${onu_port}
860 Should Be Equal As Strings ${resp.status_code} 200
861
Hardik Windlassea4caf72021-07-30 07:22:12 +0000862Count Enabled UNI Ports
863 [Documentation] Count all the UNI Ports on a Device
864 [Arguments] ${ip} ${port} ${of_id}
865 ${count}= Execute ONOS CLI Command use single connection ${ip} ${port}
866 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni | wc -l
867 Log ${count}
868 [Return] ${count}
869
Matteo Scandolo142e6272020-04-29 17:36:59 -0700870List Enabled UNI Ports
871 [Documentation] List all the UNI Ports, the only way we have is to filter out the one called NNI
872 ... Creates a list of dictionaries
TorstenThieme731a7592021-07-01 14:26:54 +0000873 [Arguments] ${ip} ${port} ${of_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700874 [Return] [{'port': '16', 'of_id': 'of:00000a0a0a0a0a00'}, {'port': '32', 'of_id': 'of:00000a0a0a0a0a00'}]
875 ${result}= Create List
TorstenThieme731a7592021-07-01 14:26:54 +0000876 ${out}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700877 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000878 @{unis}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700879 FOR ${uni} IN @{unis}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000880 ${matches} = Get Regexp Matches ${uni} .*port=([0-9]+),.* 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700881 &{portDict} Create Dictionary of_id=${of_id} port=${matches[0]}
882 Append To List ${result} ${portDict}
883 END
884 Log ${result}
885 Return From Keyword ${result}
886
887Provision all subscribers on device
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700888 [Documentation] Provisions a subscriber in ONOS for all the enabled UNI ports on a particular device
TorstenThieme731a7592021-07-01 14:26:54 +0000889 [Arguments] ${ip} ${port} ${onos_ip} ${onos_rest_port} ${of_id}
890 ${unis}= List Enabled UNI Ports ${ip} ${port} ${of_id}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700891 ${onos_auth}= Create List karaf karaf
892 Create Session ONOS http://${onos_ip}:${onos_rest_port} auth=${onos_auth}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700893 FOR ${uni} IN @{unis}
TorstenThieme731a7592021-07-01 14:26:54 +0000894 Provision Subscriber REST ${uni['of_id']} ${uni['port']}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700895 END
896
897List OLTs
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800898 # NOTE this method is not currently used but it can come useful in the future
899 [Documentation] Returns a list of all OLTs known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000900 [Arguments] ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700901 [Return] ['of:00000a0a0a0a0a00', 'of:00000a0a0a0a0a01']
902 ${result}= Create List
TorstenThieme731a7592021-07-01 14:26:54 +0000903 ${out}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700904 ... volt-olts
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000905 @{olts}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700906 FOR ${olt} IN @{olts}
907 Log ${olt}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000908 ${matches} = Get Regexp Matches ${olt} ^OLT (.+)$ 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700909 # there may be some logs mixed with the output so only append if we have a match
910 ${matches_length}= Get Length ${matches}
911 Run Keyword If ${matches_length}==1
912 ... Append To List ${result} ${matches[0]}
913 END
914 Return From Keyword ${result}
915
Matteo Scandolo75911092021-11-16 17:05:36 -0800916Count flows
917 [Documentation] Count flows in a particular ${state} in ONOS
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000918 ... Optionally for a certain onu-port.
919 [Arguments] ${ip} ${port} ${deviceId} ${state} ${onu_port}=${EMPTY}
920 ${cmd}= Catenate SEPARATOR= flows -s ${state} ${deviceId} | grep -v deviceId
921 ${cmd}= Run Keyword If "${onu_port}"!="${EMPTY}" Catenate SEPARATOR= ${cmd} | grep ${onu_port}
922 ... ELSE Set Variable ${cmd}
923 ${cmd}= Catenate SEPARATOR= ${cmd} | wc -l
924 ${flows}= Execute ONOS CLI Command use single connection ${ip} ${port} ${cmd}
925 [return] ${flows}
926
927Validate number of flows
928 [Documentation] Validates number of flows in a particular ${state} in ONOS
929 ... Optionally for a certain onu-port.
930 [Arguments] ${ip} ${port} ${targetFlows} ${deviceId} ${state} ${onu_port}=${EMPTY}
931 ${flows}= Count flows ${ip} ${port} ${deviceId} ${state} ${onu_port}
Matteo Scandolo75911092021-11-16 17:05:36 -0800932 Log Found ${state} ${flows} of ${targetFlows} expected flows on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700933 Should Be Equal As Integers ${targetFlows} ${flows}
934
935Wait for all flows to in ADDED state
936 [Documentation] Waits until the flows have been provisioned
TorstenThieme731a7592021-07-01 14:26:54 +0000937 [Arguments] ${ip} ${port} ${deviceId} ${workflow} ${uni_count} ${olt_count}
TorstenThiemeb198c482020-12-14 19:45:23 +0000938 ... ${provisioned} ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700939 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200940 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000941 Wait Until Keyword Succeeds 10m 5s Validate number of flows
Matteo Scandolo75911092021-11-16 17:05:36 -0800942 ... ${ip} ${port} ${targetFlows} ${deviceId} added
943
944Wait for all flows to be removed
945 [Documentation] Wait for all flows to be removed from a particular device
946 [Arguments] ${ip} ${port} ${deviceId}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000947 Wait Until Keyword Succeeds 10m 5s Validate number of flows
Matteo Scandolo75911092021-11-16 17:05:36 -0800948 ... ${ip} ${port} 0 ${deviceId} any
949
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000950
Girish Gowdrad769b412021-05-16 11:09:46 -0700951Get Limiting Bandwidth Details
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000952 [Arguments] ${bandwidth_profile_name}
953 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
954 ... returns the limiting bandwidth
Girish Gowdracb8482a2021-05-27 09:06:13 -0700955 ${cir} ${cbs} ${eir} ${ebs} ${air}= Get Bandwidth Profile Details Rest
956 ... ${bandwidth_profile_name}
Girish Gowdrad769b412021-05-16 11:09:46 -0700957 ${limiting_BW}= Evaluate ${eir}+${cir}+${air}
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000958 [Return] ${limiting_BW}
Hardik Windlasse8b99222021-01-25 10:03:14 +0000959
Emrehan UZUNd6f85892021-07-01 13:54:26 +0000960Get Limiting Bandwidth Details for Fixed and Committed
961 [Arguments] ${bandwidth_profile_name}
962 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
963 ... returns the limiting bandwidth for fixed and committed
964 ${cir} ${cbs} ${eir} ${ebs} ${air}= Get Bandwidth Profile Details Rest
965 ... ${bandwidth_profile_name}
966 ${limiting_BW}= Evaluate ${cir}+${air}
967 [Return] ${limiting_BW}
968
Hardik Windlasse8b99222021-01-25 10:03:14 +0000969Validate Deleted Device Cleanup In ONOS
970 [Arguments] ${ip} ${port} ${olt_serial_number}
971 [Documentation] The keyword verifies that ports, flows, meters, subscribers, dhcp are all cleared in ONOS
972 # Fetch OF Id for OLT
973 ${olt_of_id}= Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device in ONOS ${olt_serial_number}
Hardik Windlasse8b99222021-01-25 10:03:14 +0000974 # Verify Ports are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700975 ${ports}= Execute ONOS CLI Command use single connection ${ip} ${port}
976 ... ports ${olt_of_id} | grep -v ${olt_of_id}
977 ${port_count}= Get Line Count ${ports}
978 Should Be Equal As Integers ${port_count} 0 Ports have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000979 # Verify Subscribers are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700980 ${sub}= Execute ONOS CLI Command use single connection ${ip} ${port}
981 ... volt-programmed-subscribers | grep ${olt_of_id}
982 ${sub_count}= Get Line Count ${sub}
983 Should Be Equal As Integers ${sub_count} 0 Subscribers have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000984 # Verify Flows are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700985 ${flow}= Execute ONOS CLI Command use single connection ${ip} ${port}
986 ... flows -s -f ${olt_of_id} | grep -v deviceId
987 ${flow_count}= Get Line Count ${flow}
988 Should Be Equal As Integers ${flow_count} 0 Flows have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000989 # Verify Meters are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700990 ${meter}= Execute ONOS CLI Command use single connection ${ip} ${port}
991 ... meters ${olt_of_id}
992 ${meter_count}= Get Line Count ${meter}
993 Should Be Equal As Integers ${meter_count} 0 Meters have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000994 # Verify AAA-Users are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700995 ${aaa}= Execute ONOS CLI Command use single connection ${ip} ${port}
996 ... aaa-users ${olt_of_id}
997 ${aaa_count}= Get Line Count ${aaa}
998 Should Be Equal As Integers ${aaa_count} 0 AAA Users have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000999 # Verify Dhcp-Allocations are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -07001000 ${dhcp}= Execute ONOS CLI Command use single connection ${ip} ${port}
1001 ... dhcpl2relay-allocations ${olt_of_id}
1002 ${dhcp_count}= Get Line Count ${dhcp}
1003 Should Be Equal As Integers ${dhcp_count} 0 DHCP Allocations have not been removed from ONOS after cleanup
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001004
1005Delete ONOS App
1006 [Arguments] ${url} ${app_name}
1007 [Documentation] This keyword deactivates and uninstalls the given ONOS App
1008 ${rc}= Run And Return Rc curl --fail -sSL -X DELETE ${url}/onos/v1/applications/${app_name}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001009 Should Be Equal As Integers ${rc} 0 Can't delete ${app_name} from ONOS
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001010
1011Verify ONOS App Active
1012 [Arguments] ${url} ${app_name} ${app_version}=${EMPTY}
1013 [Documentation] This keyword verifies that the given ONOS App status is Active
1014 ${rc} ${output} Run And Return Rc And Output
1015 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name} | jq -r .state
1016 Should Be Equal As Integers ${rc} 0
1017 Should Be Equal '${output}' 'ACTIVE'
1018 ${rc1} ${output1} Run And Return Rc And Output
1019 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name} | jq -r .version
1020 Run Keyword If '${app_version}'!='${EMPTY}'
1021 ... Run Keywords
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001022 ... Should Be Equal As Integers ${rc1} 0 Can't read app ${app_name} status from ONOS
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001023 ... AND Should Be Equal '${output1}' '${app_version}'
1024
1025Install And Activate ONOS App
1026 [Arguments] ${url} ${app_oar_file}
1027 [Documentation] This keyword installs and activates the given ONOS App
1028 ${cmd}= Catenate SEPARATOR=
1029 ... curl --fail -sSL -H Content-Type:application/octet-stream -
1030 ... X POST ${url}/onos/v1/applications?activate=true --data-binary \@${app_oar_file}
1031 ${rc} ${output} Run And Return Rc And Output ${cmd}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001032 Should Be Equal As Integers ${rc} 0 Can't load onos app ${app_oar_file} to ONOS"
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001033 Log ${output}
Hardik Windlassdc2610f2021-03-09 07:33:51 +00001034
1035Get ONOS App Details
1036 [Arguments] ${url} ${app_name}
1037 [Documentation] Retrieves ONOS App Details
1038 ${rc} ${output} Run And Return Rc And Output
1039 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001040 Should Be Equal As Integers ${rc} 0 Can't read app ${app_name} details from ONOS
Hardik Windlassdc2610f2021-03-09 07:33:51 +00001041 [Return] ${output}
Hardik Windlass88075f92022-01-25 12:19:45 +00001042
1043Verify UniTag Subscriber
1044 [Documentation] Verifies the unitag subscriber is provisioned/un-provisioned
1045 [Arguments] ${ip} ${port} ${dev_id} ${onu_port} ${stag} ${ctag} ${tpid} ${sub_added}=True
1046 ${cmd}= Catenate SEPARATOR=
1047 ... volt-programmed-subscribers ${dev_id} ${onu_port} | grep "ponCTag=${ctag}, ponSTag=${stag}" | grep technologyProfileId
1048 ... =${tpid} --color=none
1049 ${subscriber}= Execute ONOS CLI Command use single connection ${ip} ${port} ${cmd}
1050 Log ${subscriber}
1051 ${sub_count}= Get Line Count ${subscriber}
1052 Run Keyword If ${sub_added}
1053 ... Should Be Equal As Integers ${sub_count} 1 UniTag Subscriber Not Added
1054 ... ELSE
1055 ... Should Be Equal As Integers ${sub_count} 0 UniTag Subscriber Not Removed