blob: d07db5046ba14240667d92cd0d108db418f3579c [file] [log] [blame]
TorstenThiemed4f48962020-12-08 12:17:19 +00001# Copyright 2020 - present Open Networking Foundation
TorstenThiemefd7e7ba2020-11-06 13:57:57 +00002#
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.
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000014
15*** Settings ***
16Documentation Library for various openonu-go-adpter utilities
TorstenThieme7c397d72021-07-14 11:51:09 +000017Library grpc_robot.VolthaTools WITH NAME volthatools
TorstenThieme00fe8262022-01-19 10:43:07 +000018Resource ./bbsim.robot
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000019
TorstenThiemed4f48962020-12-08 12:17:19 +000020
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000021*** Keywords ***
TorstenThieme373adfe2021-12-16 13:03:04 +000022Printout ONU Serial Number and Device Id
23 [Documentation] Printouts the ONU serial number and corresponding device id.
24 [Arguments] ${onu_sn}=${EMPTY} ${print2console}=False
25 ${output}= Set Variable \r\n
26 ${onu_sn_list} Create List
27 Run Keyword If "${onu_sn}"=="${EMPTY}" Build ONU SN List ${onu_sn_list}
28 ... ELSE Append To List ${onu_sn_list} ${onu_sn}
29 FOR ${sn} IN @{onu_sn_list}
30 ${device_id}= Get Device ID From SN ${sn}
31 ${output}= Catenate ${output} ONU Serial Number: ${sn} ONU Device ID: ${device_id}\r\n
32 END
33 Log ${output}
34 Run Keyword If ${print2console} Log ${output} console=yes
35
TorstenThieme440b7c02020-12-18 15:42:57 +000036Calculate Timeout
37 [Documentation] Calculates the timeout regarding num-onus in case of more than 4 onus
38 [Arguments] ${basetimeout}=60s
39 ${new_timeout} Fetch From Left ${basetimeout} s
40 ${new_timeout}= evaluate ${new_timeout}+((${num_all_onus}-4)*10)
41 ${new_timeout}= Set Variable If (not ${debugmode}) and (${new_timeout}>300)
42 ... 300 ${new_timeout}
43 ${new_timeout}= Catenate SEPARATOR= ${new_timeout} s
44 [Return] ${new_timeout}
45
TorstenThieme3494ceb2021-07-19 09:47:24 +000046Get Logical Id of OLT
47 [Documentation] Fills the logical id of OLT(s) if missing
48 FOR ${I} IN RANGE 0 ${num_olts}
49 # exit loop if logical id already known
50 Exit For Loop IF "${olt_ids}[${I}][logical_id]" != "${EMPTY}"
51 #read current device values
52 ${olt}= Get From List ${olt_ids} ${I}
53 ${olt_serial_number}= Get From Dictionary ${olt} sn
54 # read logical id and store it
55 ${logical_id}= Get Logical Device ID From SN ${olt_serial_number}
56 Set To Dictionary ${olt} logical_id ${logical_id}
57 Set List Value ${olt_ids} ${I} ${olt}
58 END
59 Set Global Variable ${olt_ids}
60
TorstenThieme440b7c02020-12-18 15:42:57 +000061Power On ONU Device
62 [Documentation] This keyword turns on the power for all onus.
63 [Arguments] ${namespace}
TorstenThiemefe7099e2021-01-29 08:41:04 +000064 FOR ${J} IN RANGE 0 ${num_olts}
65 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
66 ${bbsim}= Catenate SEPARATOR= bbsim ${J}
67 ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
68 Power On ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
69 END
70
71Power On ONU Device per OLT
72 [Documentation] This keyword turns on the power for all onus.
73 [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
TorstenThieme00fe8262022-01-19 10:43:07 +000074 @{onu_list}= Create List
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000075 FOR ${I} IN RANGE 0 ${num_all_onus}
76 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThiemefe7099e2021-01-29 08:41:04 +000077 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
TorstenThieme00fe8262022-01-19 10:43:07 +000078 ${sn}= Set Variable ${src['onu']}
79 # make sure all actions are done only once per onu
80 ${onu_id}= Get Index From List ${onu_list} ${sn}
81 Continue For Loop If -1 != ${onu_id}
82 Append To List ${onu_list} ${sn}
83 Power On ONU ${namespace} ${bbsim_pod} ${sn}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000084 END
85
TorstenThieme440b7c02020-12-18 15:42:57 +000086Power Off ONU Device
TorstenThiemefe7099e2021-01-29 08:41:04 +000087 [Documentation] This keyword turns off the power for all onus per olt.
TorstenThieme440b7c02020-12-18 15:42:57 +000088 [Arguments] ${namespace}
TorstenThiemefe7099e2021-01-29 08:41:04 +000089 FOR ${J} IN RANGE 0 ${num_olts}
90 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
91 ${bbsim}= Catenate SEPARATOR= bbsim ${J}
92 ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
93 Power Off ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
94 END
95
96Power Off ONU Device per OLT
97 [Documentation] This keyword turns off the power for all onus per olt.
98 [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
TorstenThieme00fe8262022-01-19 10:43:07 +000099 @{onu_list}= Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000100 FOR ${I} IN RANGE 0 ${num_all_onus}
101 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThiemefe7099e2021-01-29 08:41:04 +0000102 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
TorstenThieme00fe8262022-01-19 10:43:07 +0000103 ${sn}= Set Variable ${src['onu']}
104 # make sure all actions are done only once per onu
105 ${onu_id}= Get Index From List ${onu_list} ${sn}
106 Continue For Loop If -1 != ${onu_id}
107 Append To List ${onu_list} ${sn}
108 Power Off ONU ${namespace} ${bbsim_pod} ${sn}
109 END
110
111Set Wrong MDS Counter All ONUs
112 [Documentation] This keyword sets wrong MDS counter for all onus.
113 [Arguments] ${namespace}
114 FOR ${J} IN RANGE 0 ${num_olts}
115 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
116 ${bbsim}= Catenate SEPARATOR= bbsim ${J}
117 ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
118 Set Wrong MDS Counter per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
119 END
120
121Set Wrong MDS Counter per OLT
122 [Documentation] This keyword sets wrong MDS counter for all onus per olt.
123 [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
124 @{onu_list}= Create List
125 FOR ${I} IN RANGE 0 ${num_all_onus}
126 ${src}= Set Variable ${hosts.src[${I}]}
127 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
128 ${sn}= Set Variable ${src['onu']}
129 # make sure all actions are done only once per onu
130 ${onu_id}= Get Index From List ${onu_list} ${sn}
131 Continue For Loop If -1 != ${onu_id}
132 Append To List ${onu_list} ${sn}
133 Set Wrong MDS Counter ONU ${namespace} ${bbsim_pod} ${sn}
TorstenThieme440b7c02020-12-18 15:42:57 +0000134 END
135
136Current State Test
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000137 [Documentation] This keyword checks the passed state of the given onu.
138 [Arguments] ${state} ${onu} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY}
139 ... ${reqconnectstatus}=${EMPTY}
140 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
141 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
142 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
143 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
144 ... ${connect_status}
145 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
146 ... Validate Device ${admin_state} ${oper_status} ${connect_status}
147 ... ${onu} onu=True onu_reason=${onu_state}
148
TorstenThieme440b7c02020-12-18 15:42:57 +0000149Current State Test All Onus
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000150 [Documentation] This keyword checks the passed state of all onus.
151 ... Hint: ${timeStart} will be not evaluated here!
152 [Arguments] ${state} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY} ${reqconnectstatus}=${EMPTY}
TorstenThieme53450ff2021-05-11 09:44:33 +0000153 ... ${alternativeonustate}=${EMPTY} ${timeout}=${timeout}
TorstenThieme440b7c02020-12-18 15:42:57 +0000154 ${timeStart}= Get Current Date
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000155 ${list_onus} Create List
156 Build ONU SN List ${list_onus}
157 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
158 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
159 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
160 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
161 ... ${connect_status}
162 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
163 ... Validate ONU Devices With Duration
164 ... ${admin_state} ${oper_status} ${connect_status}
TorstenThieme52ef8392020-11-10 13:42:26 +0000165 ... ${onu_state} ${list_onus} ${timeStart} alternate_reason=${alternativeonustate}
TorstenThieme53450ff2021-05-11 09:44:33 +0000166 # teardown is used as 'return' for result of Validate ONU Devices With Duration (used for ONUNegativeStateTests)
167 [Teardown] Run Keyword If "${KEYWORD STATUS}"=="FAIL" Set Suite Variable ${StateTestAllONUs} False
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000168
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000169Reconcile Onu Adapter
170 [Documentation] Restarts the openonu adapter and waits for reconciling is finished and expected oper-state is reached
TorstenThieme712b2962021-11-17 14:16:15 +0000171 [Arguments] ${namespace} ${usekill2restart} ${oper_status} ${olt_to_be_deleted_sn}=${EMPTY}
TorstenThieme00fe8262022-01-19 10:43:07 +0000172 ... ${flow_delete_params}=&{EMPTY} ${wrong_MDS_counter}=False
TorstenThieme7e9f1252022-01-05 13:43:59 +0000173 # get last ready timestamp of openonu adapter
174 ${previous_ready_ts}= Get Pod Ready Timestamp by Label ${namespace} app adapter-open-onu
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000175 # restart OpenONU adapter
176 Run Keyword If ${usekill2restart} Kill And Check Onu Adaptor ${namespace}
177 ... ELSE Restart And Check Onu Adaptor ${namespace}
TorstenThieme7e9f1252022-01-05 13:43:59 +0000178 #check ready timestamp of openonu adapter, should be younger than the previous ready timestamp
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000179 ${openonu_ready_ts}= Get Pod Ready Timestamp by Label ${namespace} app adapter-open-onu
TorstenThieme7e9f1252022-01-05 13:43:59 +0000180 ${restart_duration}= Subtract Date From Date ${openonu_ready_ts} ${previous_ready_ts}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000181 Should Be True ${restart_duration}>0
TorstenThieme712b2962021-11-17 14:16:15 +0000182 # delete the olt passed, if available (special feature)
183 ${olt_to_be_deleted_device_id}= Run Keyword IF "${olt_to_be_deleted_sn}"!="${EMPTY}"
184 ... Get OLTDeviceID From OLT List ${olt_to_be_deleted_sn}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000185 Run Keyword If "${olt_to_be_deleted_sn}"!="${EMPTY}" Delete Device ${olt_to_be_deleted_device_id}
186 # remove flows if params passed for it (special feature II)
TorstenThieme00fe8262022-01-19 10:43:07 +0000187 Run Keyword If ${flow_delete_params}!=&{EMPTY} Remove Flows Conditional ${flow_delete_params['unitag']}
188 ... ${flow_delete_params['onu_sn']} ${flow_delete_params['of_id']} ${flow_delete_params['onu_port']}
189 # Set wrong MDS counter (for all ONUs) if required (special feature III)
190 Run Keyword If ${wrong_MDS_counter} Set Wrong MDS Counter All ONUs ${namespace}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700191 # wait for the reconcile to complete
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000192 # - we check that communication to openonu-adapter is established again
193 # - we check that all ONUs leave reconcile state by validate a simple voltctl request will not responds with error
194 Wait Until Keyword Succeeds ${timeout} 1s Validate Last ONU Communication
TorstenThieme712b2962021-11-17 14:16:15 +0000195 Wait Until Keyword Succeeds ${timeout} 1s Validate All Onus Accessible ${olt_to_be_deleted_sn}
196 # - then we wait that all ONU move to the next state, except ONU belonging to deleted OLT (special feature)
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000197 ${list_onus} Create List
TorstenThieme712b2962021-11-17 14:16:15 +0000198 FOR ${J} IN RANGE 0 ${num_olts}
199 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
200 Continue For Loop If "${olt_to_be_deleted_sn}"=="${olt_serial_number}"
201 Build ONU SN List ${list_onus} ${olt_serial_number}
202 END
203 Log ${list_onus}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000204 Run Keyword And Ignore Error Wait Until Keyword Succeeds ${timeout}
205 ... 1s Check all ONU OperStatus ${list_onus} ${oper_status}
206
TorstenThiemee512b1d2021-11-12 10:52:29 +0000207Validate All Onus Accessible
208 [Documentation] This keyword checks all onus accessible (again) with help of a simple voltctl request.
209 ... As long we've got an rc!=0 keyword will fail -> onu is not accessible.
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000210 ... As get request Onu image list is used, any other get command could be used for this check.
TorstenThieme712b2962021-11-17 14:16:15 +0000211 ... Will not check ONUs of passed deleted OLT (special feature)
212 [Arguments] ${deleted_olt}=${EMPTY}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700213 ${onu_list} Create List
214 FOR ${I} IN RANGE 0 ${num_all_onus}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000215 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThieme712b2962021-11-17 14:16:15 +0000216 ${olt_serial_number}= Set Variable ${src['olt']}
217 Continue For Loop If "${deleted_olt}"=="${olt_serial_number}"
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000218 ${onu_device_id}= Get Device ID From SN ${src['onu']}
219 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700220 Continue For Loop If -1 != ${onu_id}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000221 Append To List ${onu_list} ${onu_device_id}
222 ${rc} ${output}= Get Onu Image List ${onu_device_id}
TorstenThieme712b2962021-11-17 14:16:15 +0000223 Should Be True ${rc}==0 Onu ${src['onu']} (${onu_device_id}) still not accessible.
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700224 END
225
TorstenThieme00fe8262022-01-19 10:43:07 +0000226Remove Flows Conditional
227 [Documentation] This keyword removes the flows (subscriber) conditional depending on unitag.
228 ... In case of unitagsub==False (normal case) single subscriber remove will be executed.
229 ... In case of multi uni each uni id will be deleted.
230 [Arguments] ${unitagsub} ${onu_sn} ${of_id} ${onu_port}
231 # first handle 'normal' case without uni ports
232 Run Keyword If ${unitagsub}==False Wait Until Keyword Succeeds ${timeout} 2s
233 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
234 ... volt-remove-subscriber-access ${of_id} ${onu_port}
235 Return From Keyword If ${unitagsub}==False
236 # handle multi uni case
237 FOR ${I} IN RANGE 0 ${num_all_onus}
238 ${src}= Set Variable ${hosts.src[${I}]}
239 Continue For Loop If "${onu_sn}"!="${src['onu']}"
240 ${add_sub_cmd}= Catenate volt-remove-subscriber-unitag --tpId ${src['tp_id']} --sTag ${src['s_tag']}
241 ... --cTag ${src['c_tag']} ${src['onu']}-${src['uni_id']}
242 Wait Until Keyword Succeeds ${timeout} 2s Execute ONOS CLI Command use single connection
243 ... ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${add_sub_cmd}
244 END
245
TorstenThieme700ccbf2022-02-11 10:24:05 +0000246Remove Flows all ONUs
247 [Documentation] Remove all Flows from all onus
248 FOR ${I} IN RANGE 0 ${num_all_onus}
249 # Collect data for remove flow(s)
250 ${src}= Set Variable ${hosts.src[${I}]}
251 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS ${src['olt']}
252 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']}
253 ... ${of_id} ${src['uni_id']}
254 ${onu_sn}= Set Variable ${src['onu']}
255 # Remove Flows
256 Remove Flows Conditional ${unitag_sub} ${onu_sn} ${of_id} ${onu_port}
257 END
258
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000259Log Ports
260 [Documentation] This keyword logs all port data available in ONOS of first port per ONU
261 [Arguments] ${onlyenabled}=False
262 ${cmd} Set Variable If ${onlyenabled} ports -e ports
TorstenThieme731a7592021-07-01 14:26:54 +0000263 ${onu_ports}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${cmd}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000264 ${lines} = Get Lines Matching Regexp ${onu_ports} .*portName=BBSM[0-9]{8}-1
265 Log ${lines}
266
267Kill Adaptor
268 [Documentation] This keyword kills the passed adaptor.
269 [Arguments] ${namespace} ${name}
270 ${cmd} Catenate
Matteo Scandolo6b524122021-10-22 14:34:29 -0700271 ... kubectl exec -it -n ${namespace} $(kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}')
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000272 ... -- /bin/sh -c "kill 1"
273 ${rc} ${output}= Run and Return Rc and Output ${cmd}
274 Log ${output}
275
TorstenThieme440b7c02020-12-18 15:42:57 +0000276Kill And Check Onu Adaptor
277 [Documentation] This keyword kills ONU Adaptor and waits for it to come up again
278 ... Following steps will be executed:
279 ... - kill openonu adaptor
280 ... - check openonu adaptor is ready again
281 [Arguments] ${namespace}
282 ${list_openonu_apps} Create List adapter-open-onu
283 ${adaptorname}= Set Variable open-onu
284 Kill Adaptor ${namespace} ${adaptorname}
285 Sleep 5s
286 Wait For Pods Ready ${namespace} ${list_openonu_apps}
287
288Restart And Check Onu Adaptor
289 [Documentation] This keyword restarts ONU Adaptor and waits for it to come up again
290 ... Following steps will be executed:
291 ... - restart openonu adaptor
292 ... - check openonu adaptor is ready again
293 [Arguments] ${namespace}
294 ${list_openonu_apps} Create List adapter-open-onu
Matteo Scandolo6f24ea92021-04-29 11:55:50 -0700295 ${openonu_label_key} Set Variable app
296 ${openonu_label_value} Set Variable adapter-open-onu
297 Restart Pod By Label ${namespace} ${openonu_label_key} ${openonu_label_value}
TorstenThieme440b7c02020-12-18 15:42:57 +0000298 Sleep 5s
299 Wait For Pods Ready ${namespace} ${list_openonu_apps}
300
301Disable Onu Device
302 [Documentation] This keyword disables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000303 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000304 FOR ${I} IN RANGE 0 ${num_all_onus}
305 ${src}= Set Variable ${hosts.src[${I}]}
306 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000307 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
308 Continue For Loop If -1 != ${onu_id}
309 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000310 Disable Device ${onu_device_id}
311 Wait Until Keyword Succeeds 20s 2s Test Devices Disabled in VOLTHA Id=${onu_device_id}
312 END
313
314Enable Onu Device
315 [Documentation] This keyword enables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000316 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000317 FOR ${I} IN RANGE 0 ${num_all_onus}
318 ${src}= Set Variable ${hosts.src[${I}]}
319 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000320 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
321 Continue For Loop If -1 != ${onu_id}
322 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000323 Enable Device ${onu_device_id}
324 END
325
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000326Verify MIB Template Data Available
327 [Documentation] This keyword verifies MIB Template Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000328 [Arguments] ${namespace}=default
TorstenThiemed4f48962020-12-08 12:17:19 +0000329 ${podname}= Set Variable etcd
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000330 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800331 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000332 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000333 Should Not Be Empty ${result} No MIB Template Data stored in etcd!
334
335Delete MIB Template Data
336 [Documentation] This keyword deletes MIB Template Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000337 [Arguments] ${namespace}=default
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000338 ${podname}= Set Variable etcd
339 ${commanddel} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800340 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000341 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commanddel}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000342 Sleep 3s
343 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800344 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000345 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000346 Should Be Empty ${result} Could not delete MIB Template Data stored in etcd!
347
TorstenThieme440b7c02020-12-18 15:42:57 +0000348Set Tech Profile
349 [Documentation] This keyword sets the passed TechProfile for the test
TorstenThieme00fe8262022-01-19 10:43:07 +0000350 [Arguments] ${TechProfile} ${namespace}=default ${tp_id}=64
351 Log To Console \nSet TechProfile:${TechProfile} tp_id:${tp_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000352 ${podname}= Set Variable etcd
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200353 ${label}= Set Variable app.kubernetes.io/name=${podname}
TorstenThieme440b7c02020-12-18 15:42:57 +0000354 ${src}= Set Variable ${data_dir}/TechProfile-${TechProfile}.json
355 ${dest}= Set Variable /tmp/flexpod.json
356 ${command} Catenate
TorstenThieme00fe8262022-01-19 10:43:07 +0000357 ... /bin/sh -c 'cat ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/${tp_id}'
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200358 Copy File To Pod ${namespace} ${label} ${src} ${dest}
TorstenThieme440b7c02020-12-18 15:42:57 +0000359 Exec Pod In Kube ${namespace} ${podname} ${command}
360 ${commandget} Catenate
TorstenThieme00fe8262022-01-19 10:43:07 +0000361 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/${tp_id}'
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200362 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
363 Should Not Be Empty ${result} No Tech Profile stored in etcd!
TorstenThieme440b7c02020-12-18 15:42:57 +0000364
365Remove Tech Profile
366 [Documentation] This keyword removes TechProfile
TorstenThieme00fe8262022-01-19 10:43:07 +0000367 [Arguments] ${namespace}=default ${tp_id}=64
368 Run Keyword If "${TechProfile}"!="${EMPTY}" Log To Console \nRemove TechProfile:${TechProfile} tp_id:${tp_id}
369 ... ELSE Log To Console \nRemove Tech Profile template at tp_id:${tp_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000370 ${podname}= Set Variable etcd
371 ${command} Catenate
TorstenThieme00fe8262022-01-19 10:43:07 +0000372 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/${tp_id}'
TorstenThieme440b7c02020-12-18 15:42:57 +0000373 Exec Pod In Kube ${namespace} ${podname} ${command}
374 ${commandget} Catenate
TorstenThieme00fe8262022-01-19 10:43:07 +0000375 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/${tp_id}'
TorstenThieme440b7c02020-12-18 15:42:57 +0000376 Exec Pod In Kube ${namespace} ${podname} ${commandget}
377
TorstenThiemea7315f12021-07-23 11:56:34 +0000378Do Onu Subscriber Add Per OLT
379 [Documentation] Add Subscriber per OLT
380 [Arguments] ${of_id} ${olt_serial_number} ${print2console}=False
381 FOR ${I} IN RANGE 0 ${num_all_onus}
382 ${src}= Set Variable ${hosts.src[${I}]}
383 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
384 ${onu_device_id}= Get Device ID From SN ${src['onu']}
385 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
386 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
387 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
388 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
389 ... volt-add-subscriber-access ${of_id} ${onu_port}
390 Run Keyword If ${print2console} Log \r\n[${I}] volt-add-subscriber-access ${of_id} ${onu_port}.
391 ... console=yes
392 END
393
394Do Onu Flow Check Per OLT
395 [Documentation] Checks all ONU flows show up in ONOS and Voltha
396 [Arguments] ${of_id} ${nni_port} ${olt_serial_number} ${print2console}=False
397 FOR ${I} IN RANGE 0 ${num_all_onus}
398 ${src}= Set Variable ${hosts.src[${I}]}
399 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
400 ${onu_device_id}= Get Device ID From SN ${src['onu']}
401 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
402 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
403 # Verify subscriber access flows are added for the ONU port
404 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
405 ... Verify Subscriber Access Flows Added For ONU ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${of_id}
406 ... ${onu_port} ${nni_port} ${src['c_tag']} ${src['s_tag']}
407 ${logoutput} Catenate \r\n[${I}] Verify Subscriber Access Flows Added For
408 ... ONU ${of_id} ${onu_port} ${src['c_tag']} ${src['s_tag']}.
409 Run Keyword If ${print2console} Log ${logoutput} console=yes
410 END
411
412Do Onu Subscriber Remove Per OLT
413 [Documentation] Removes per OLT subscribers in ONOS and Voltha
414 [Arguments] ${of_id} ${olt_serial_number} ${print2console}=False
415 FOR ${I} IN RANGE 0 ${num_all_onus}
416 ${src}= Set Variable ${hosts.src[${I}]}
417 ${dst}= Set Variable ${hosts.dst[${I}]}
418 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
419 ${onu_device_id}= Get Device ID From SN ${src['onu']}
420 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
421 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
422 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
423 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
424 ... volt-remove-subscriber-access ${of_id} ${onu_port}
425 Run Keyword If ${print2console} Log \r\n[${I}] volt-remove-subscriber-access ${of_id} ${onu_port}.
426 ... console=yes
427 END
428
TorstenThieme7c397d72021-07-14 11:51:09 +0000429Validate Resource Instances Used Gem Ports
430 [Documentation] This keyword validates resource instances data stored in etcd.
431 ... It checks checks the number of gemport-ids which has matched with used Tech Profile
Andrea Campanella388cd872022-02-10 09:11:39 +0100432 [Arguments] ${nbofgemports} ${namespace}=default ${defaultkvstoreprefix}=voltha/voltha_voltha
TorstenThieme7c397d72021-07-14 11:51:09 +0000433 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000434 ${etcddata}= Get ONU Go Adapter ETCD Data namespace=${namespace} defaultkvstoreprefix=${kvstoreprefix}
TorstenThieme7c397d72021-07-14 11:51:09 +0000435 #prepare result for json convert
436 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
437 ${jsondata}= To Json ${result}
438 ${length}= Get Length ${jsondata}
439 log ${jsondata}
440 FOR ${INDEX} IN RANGE 0 ${length}
441 ${value}= Get From List ${jsondata} ${INDEX}
442 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
443 # When testing multi-tcont this may need some adjustment.
444 Exit For Loop If not ('uni_config' in $value)
445 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000446 ${resourcedata}= Get Resource Instances ETCD Data ${tp_path} namespace=${namespace}
447 ... defaultkvstoreprefix=${kvstoreprefix}
TorstenThieme7c397d72021-07-14 11:51:09 +0000448 log ${resourcedata}
449 ${decoderesult}= volthatools.Tech Profile Decode Resource Instance ${resourcedata} return_default=true
450 log ${decoderesult}
451 ${gemportids}= Get From Dictionary ${decoderesult} gemport_ids
452 ${length}= Get Length ${gemportids}
453 Should Be Equal As Integers ${nbofgemports} ${length}
454 ... msg=Number of gem ports (${length}) does not match with techprofile ${techprofile}/${nbofgemports}
455 END
456
457Get Resource Instances ETCD Data
458 [Documentation] This keyword delivers Resource Instances Data stored in etcd
Andrea Campanella388cd872022-02-10 09:11:39 +0100459 [Arguments] ${tppath} ${namespace}=default ${defaultkvstoreprefix}=voltha/voltha_voltha
TorstenThieme7c397d72021-07-14 11:51:09 +0000460 ${podname}= Set Variable etcd
461 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
462 ${commandget}= Catenate
463 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/resource_instances/${tppath}
464 ... --print-value-only --hex'
465 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
466 log ${result}
467 [Return] ${result}
468
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000469Validate Tech Profiles and Flows in ETCD Data Per Onu
470 [Documentation] This keyword validates tech profiles and flows data stored in etcd per onu.
471 ... It checks checks presence/absence of tech profiles and flows depending on must_exist.
472 ... The values/content of tech profiles and flows will be not validated!
Andrea Campanella388cd872022-02-10 09:11:39 +0100473 [Arguments] ${onu_sn} ${namespace}=default ${defaultkvstoreprefix}=voltha/voltha_voltha ${must_exist}=True
TorstenThieme569ef452022-02-07 14:00:26 +0000474 ... ${check_tcont_map_empty}=False ${check_default_flow_att}=True
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000475 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
476 ${etcddata}= Get ONU Go Adapter ETCD Data namespace=${namespace} defaultkvstoreprefix=${kvstoreprefix}
477 #prepare result for json convert
478 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
479 ${jsondata}= To Json ${result}
480 ${length}= Get Length ${jsondata}
481 log ${jsondata}
482 ${matched}= Set Variable False
483 FOR ${INDEX} IN RANGE 0 ${length}
484 ${value}= Get From List ${jsondata} ${INDEX}
485 ${uni_config}= Get From Dictionary ${value} uni_config
486 ${uni_config}= Set Variable ${uni_config[0]}
487 ${sn}= Get From Dictionary ${value} serial_number
TorstenThieme00fe8262022-01-19 10:43:07 +0000488 ${tcont_map}= Get From Dictionary ${value} tcont_map
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000489 ${matched}= Set Variable If '${sn}'=='${onu_sn}' True False
490 Exit For Loop If ${matched}
491 END
492 Should Be True ${matched} No ETCD data found for ONU ${onu_sn}
493 Log ${uni_config}
494 ${tp_path}= Get From Dictionary ${uni_config} PersTpPathMap
495 Log ${tp_path}
496 ${flow_params}= Get From Dictionary ${uni_config} flow_params
497 Log ${flow_params}
498 # in case of ATT for ONU with removed flows there is default flow established
499 ${length}= Get Length ${flow_params}
500 ${cookieslice}= Run Keyword If ${length}>0 Run Keyword If 'cookie_slice' in ${flow_params[0]}
501 ... Get From Dictionary ${flow_params[0]} cookie_slice
502 ${setvid}= Run Keyword If ${length}>0 Run Keyword If 'set_vid' in ${flow_params[0]['vlan_rule_params']}
503 ... Get From Dictionary ${flow_params[0]['vlan_rule_params']} set_vid
504 ${cookie_slice_length}= Run Keyword If ${length}>0 Run Keyword If 'cookie_slice' in ${flow_params[0]}
505 ... Get Length ${cookieslice}
TorstenThieme569ef452022-02-07 14:00:26 +0000506 Run Keyword If "${workflow}"=="ATT" and not ${must_exist} and ${check_default_flow_att} Run Keywords
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000507 ... Should Be Equal As Numbers ${setvid} 4091 AND
508 ... Should Be Equal As Numbers ${cookie_slice_length} 1 AND
509 ... Should Not Be Empty ${tp_path} AND
510 ... Return From Keyword
511 ${tp_path_length}= Get Length ${tp_path}
512 # validate tp_path is not Empty for case must_exist, case not must_exist will be validated implicitly with FOR loop
513 Run Keyword If ${must_exist} Should Not Be Empty ${tp_path}
514 ${tp_path_keys}= Run Keyword If ${tp_path_length}==0 Create List
515 ... ELSE Get Dictionary Keys ${tp_path}
516 ${tp_path_values}= Run Keyword If ${tp_path_length}==0 Create List
517 ... ELSE Get Dictionary Values ${tp_path}
518 ${tp_path_empty}= Set Variable True
519 Log ${tp_path_values}
520 Log ${tp_path_keys}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000521 # In case of not empty tp_path each value will be checked depending on must_exist
522 FOR ${key} IN @{tp_path_keys}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000523 ${value}= Get From Dictionary ${tp_path} ${key}
524 Run Keyword If ${must_exist} Should Not Be Empty ${value}
525 ... ELSE Should Be Empty ${value}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000526 END
527 Run Keyword If ${must_exist} Should Not Be Empty ${flow_params}
528 ... ELSE Should Be Empty ${flow_params}
TorstenThieme00fe8262022-01-19 10:43:07 +0000529 Run Keyword If ${check_tcont_map_empty} Log ${tcont_map}
530 Run Keyword If ${check_tcont_map_empty} Should Be Empty ${tcont_map}
TorstenThieme7c397d72021-07-14 11:51:09 +0000531
TorstenThieme17756ea2020-11-11 14:09:47 +0000532Validate Onu Data In Etcd
533 [Documentation] This keyword validates openonu-go-adapter Data stored in etcd.
534 ... It checks unique of serial_number and combination of pon, onu and uni in tp_path.
535 ... Furthermore it evaluates the values of onu_id and uni_id with values read from tp_path.
536 ... Number of etcd entries has to match with the passed number.
Andrea Campanella388cd872022-02-10 09:11:39 +0100537 [Arguments] ${namespace}=default ${nbofetcddata}=${num_all_onus} ${defaultkvstoreprefix}=voltha/voltha_voltha
TorstenThiemefa29a892021-03-11 14:11:29 +0000538 ... ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000539 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000540 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme17756ea2020-11-11 14:09:47 +0000541 #prepare result for json convert
542 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
543 ${jsondata}= To Json ${result}
544 ${length}= Get Length ${jsondata}
545 log ${jsondata}
546 Run Keyword And Continue On Failure Should Be Equal As Integers ${length} ${nbofetcddata}
547 ... msg=Number etcd data (${length}) does not match required (${nbofetcddata})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000548 ${oltpononuuniidlist}= Create List
TorstenThieme17756ea2020-11-11 14:09:47 +0000549 ${serialnumberlist}= Create List
550 FOR ${INDEX} IN RANGE 0 ${length}
551 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra97f8d062020-11-17 15:48:23 -0800552 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
553 # When testing multi-tcont this may need some adjustment.
TorstenThieme45071602021-03-16 12:14:37 +0000554 Exit For Loop If not ('uni_config' in $value)
Girish Gowdra97f8d062020-11-17 15:48:23 -0800555 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000556 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
557 ${list_id}= Get Index From List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000558 Should Be Equal As Integers ${list_id} -1
TorstenThiemefe7099e2021-01-29 08:41:04 +0000559 ... msg=Combination of Pon, Onu and Uni (${oltpononuuniid}) exist multiple in etcd data!
560 Append To List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000561 Validate Onu Id ${value}
562 Validate Uni Id ${value}
563 ${serial_number}= Get From Dictionary ${value} serial_number
564 ${list_id}= Get Index From List ${serialnumberlist} ${serial_number}
565 Should Be Equal As Integers ${list_id} -1
566 ... msg=Serial number (${serial_number}) exists multiple in etcd data!
567 Append To List ${serialnumberlist} ${serial_number}
568 END
569
TorstenThieme712b2962021-11-17 14:16:15 +0000570Validate Onu Data In Etcd Removed
571 [Documentation] This keyword validates openonu-go-adapter Data stored in etcd are removed.
572 ... In case of a device is passed, only this will be checked.
Andrea Campanella388cd872022-02-10 09:11:39 +0100573 [Arguments] ${namespace}=default ${device_id}=${EMPTY} ${defaultkvstoreprefix}=voltha/voltha_voltha
TorstenThieme712b2962021-11-17 14:16:15 +0000574 ... ${without_pm_data}=True
575 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
576 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} False ${without_pm_data}
577 ... ${device_id} True
578 Log ${etcddata}
579 Should Be Empty ${etcddata} Stale Openonu Data in Etcd (KV store) ${device_id}
580
TorstenThieme52ef8392020-11-10 13:42:26 +0000581Validate Vlan Rules In Etcd
582 [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd.
583 ... It checks the given number of cookie_slice, match_vid (=4096) and set_vid.
584 ... Furthermore it returns a list of all set_vid.
585 ... In case of a passed dictionary containing set_vids these will be checked for to
586 ... current set-vid depending on setvidequal (True=equal, False=not equal).
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000587 [Arguments] ${namespace}=default ${nbofcookieslice}=1 ${reqmatchvid}=4096 ${prevvlanrules}=${NONE}
Andrea Campanella388cd872022-02-10 09:11:39 +0100588 ... ${setvidequal}=False ${defaultkvstoreprefix}=voltha/voltha_voltha
589 ... ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000590 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000591 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme52ef8392020-11-10 13:42:26 +0000592 #prepare result for json convert
593 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
594 ${jsondata}= To Json ${result}
595 ${length}= Get Length ${jsondata}
596 log ${jsondata}
597 ${vlan_rules}= Create Dictionary
598 FOR ${INDEX} IN RANGE 0 ${length}
599 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra295c1692020-11-19 10:51:53 -0800600 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
601 # When testing multi-tcont this may need some adjustment.
602 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000603 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000604 ${cookieslice}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]} cookie_slice
605 #@{cookieslicelist}= Split String ${cookieslice} ,
606 ${foundcookieslices}= Get Length ${cookieslice}
607 Should Be Equal As Integers ${foundcookieslices} ${nbofcookieslice}
608 ${matchvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
609 ... match_vid
610 Should Be Equal As Integers ${matchvid} ${reqmatchvid}
611 ${setvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
612 ... set_vid
613 ${evalresult}= Evaluate 2 <= ${setvid} <= 4095
614 Should Be True ${evalresult} msg=set_vid out of range (${setvid})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000615 Set To Dictionary ${vlan_rules} ${oltpononuuniid} ${setvid}
TorstenThieme52ef8392020-11-10 13:42:26 +0000616 ${oldsetvidvalid} Set Variable If ${prevvlanrules} is ${NONE} False True
TorstenThiemefe7099e2021-01-29 08:41:04 +0000617 ${prevsetvid}= Set Variable If ${oldsetvidvalid} ${prevvlanrules['${oltpononuuniid}']}
TorstenThieme52ef8392020-11-10 13:42:26 +0000618 Run Keyword If ${oldsetvidvalid} and ${setvidequal}
619 ... Should Be Equal As Integers ${prevsetvid} ${setvid}
620 ... ELSE IF ${oldsetvidvalid} and not ${setvidequal}
621 ... Should Not Be Equal As Integers ${prevsetvid} ${setvid}
622 END
TorstenThieme440b7c02020-12-18 15:42:57 +0000623 log Many ${vlan_rules}
TorstenThieme52ef8392020-11-10 13:42:26 +0000624 [Return] ${vlan_rules}
625
626Get ONU Go Adapter ETCD Data
627 [Documentation] This keyword delivers openonu-go-adapter Data stored in etcd
Andrea Campanella388cd872022-02-10 09:11:39 +0100628 [Arguments] ${namespace}=default ${defaultkvstoreprefix}=voltha/voltha_voltha ${without_prefix}=True
TorstenThieme712b2962021-11-17 14:16:15 +0000629 ... ${without_pm_data}=True ${device_id}=${Empty} ${keys_only}=False
TorstenThieme52ef8392020-11-10 13:42:26 +0000630 ${podname}= Set Variable etcd
TorstenThieme3385cdc2021-02-04 13:50:50 +0000631 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
TorstenThieme3af12312021-03-10 16:15:24 +0000632 ${commandget}= Catenate
633 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/openonu'
TorstenThieme712b2962021-11-17 14:16:15 +0000634 ${commandget}= Run Keyword If ${keys_only} Catenate ${commandget} --keys-only
635 ... ELSE Set Variable ${commandget}
TorstenThieme3af12312021-03-10 16:15:24 +0000636 ${commandget}= Run Keyword If ${without_prefix} Catenate ${commandget}
637 ... | grep -v service/${kvstoreprefix}/openonu
TorstenThiemefa29a892021-03-11 14:11:29 +0000638 ... ELSE Set Variable ${commandget}
TorstenThieme3af12312021-03-10 16:15:24 +0000639 ${commandget}= Run Keyword If ${without_pm_data} Catenate ${commandget} | grep -v instances_active
TorstenThiemefa29a892021-03-11 14:11:29 +0000640 ... ELSE Set Variable ${commandget}
TorstenThieme712b2962021-11-17 14:16:15 +0000641 ${commandget}= Run Keyword If "${device_id}"!="${Empty}" Catenate ${commandget} | grep ${device_id}
642 ... ELSE Set Variable ${commandget}
Holger Hildebrandt23147742020-11-16 10:13:21 +0000643 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThieme52ef8392020-11-10 13:42:26 +0000644 log ${result}
645 [Return] ${result}
646
647Prepare ONU Go Adapter ETCD Data For Json
648 [Documentation] This keyword prepares openonu-go-adapter Data stored in etcd for converting
649 ... to json
650 [Arguments] ${etcddata}
651 #prepare result for json convert
652 ${prepresult}= Replace String ${etcddata} \n ,
653 ${prepresult}= Strip String ${prepresult} mode=right characters=,
654 ${prepresult}= Set Variable [${prepresult}]
655 log ${prepresult}
656 [Return] ${prepresult}
657
TorstenThieme52ef8392020-11-10 13:42:26 +0000658Read Pon Onu Uni String
TorstenThiemefe7099e2021-01-29 08:41:04 +0000659 [Documentation] This keyword builds a four digit string using Olt, Pon, Onu and Uni value of given tp-path taken
TorstenThieme52ef8392020-11-10 13:42:26 +0000660 ... taken from etcd data of onu go adapter
661 [Arguments] ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000662 ${tppathlines}= Replace String ${tp_path} / \n
TorstenThiemefe7099e2021-01-29 08:41:04 +0000663 ${olt}= Get Value Of Tp Path Element ${tppathlines} olt
TorstenThieme52ef8392020-11-10 13:42:26 +0000664 ${pon}= Get Value Of Tp Path Element ${tppathlines} pon
665 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
666 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
TorstenThiemefe7099e2021-01-29 08:41:04 +0000667 ${valuesid}= Set Variable ${olt}/${pon}/${onu}/${uni}
TorstenThieme52ef8392020-11-10 13:42:26 +0000668 log ${valuesid}
669 [Return] ${valuesid}
670
671Get Value Of Tp Path Element
TorstenThieme17756ea2020-11-11 14:09:47 +0000672 [Documentation] This keyword delivers numeric value of given tp path element.
TorstenThieme52ef8392020-11-10 13:42:26 +0000673 [Arguments] ${tp_path_lines} ${element}
674 ${value}= Get Lines Containing String ${tp_path_lines} ${element}-\{
675 ${value}= Remove String ${value} ${element}-\{
676 ${value}= Remove String ${value} \}
677 log ${value}
678 [Return] ${value}
679
TorstenThieme17756ea2020-11-11 14:09:47 +0000680Validate Onu Id
681 [Documentation] This keyword validates ONU Id of passed etcd data.
682 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800683 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
684 # When testing multi-tcont this may need some adjustment.
685 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000686 ${tppathlines}= Replace String ${tp_path} / \n
687 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
688 ${onu_id}= Get From Dictionary ${value} onu_id
689 Should Be Equal As Integers ${onu} ${onu_id}
690 ... msg=Onu-Id (${onu_id}) does not match onu (${onu}) from tp_path in etcd data!
691 Should Be True ${onu_id}>=1
692
693Validate Uni Id
694 [Documentation] This keyword validates UNI Id of passed etcd data.
695 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800696 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
697 # When testing multi-tcont this may need some adjustment.
698 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000699 ${tppathlines}= Replace String ${tp_path} / \n
700 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
701 ${uni_id}= Get From Dictionary ${value['uni_config'][0]} uni_id
702 Should Be Equal As Integers ${uni} ${uni_id}
703 ... msg=Uni-Id (${uni_id}) does not match onu (${uni}) from tp_path in etcd data!
TorstenThieme52ef8392020-11-10 13:42:26 +0000704
TorstenThieme45071602021-03-16 12:14:37 +0000705Delete ONU Go Adapter ETCD Data
706 [Documentation] This keyword deletes openonu-go-adapter Data stored in etcd
Andrea Campanella388cd872022-02-10 09:11:39 +0100707 [Arguments] ${namespace}=default ${defaultkvstoreprefix}=voltha/voltha_voltha ${validate}=False
TorstenThieme45071602021-03-16 12:14:37 +0000708 ${podname}= Set Variable etcd
709 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
710 ${commandget}= Catenate
711 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/${kvstoreprefix}/openonu'
712 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
713 log ${result}
714 Run Keyword If ${validate} Wait Until Keyword Succeeds ${timeout} 1s
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000715 ... Validate Onu Data In Etcd namespace=${namespace} nbofetcddata=0 without_pm_data=False
TorstenThieme45071602021-03-16 12:14:37 +0000716 [Return] ${result}
717
TorstenThiemed6492882021-12-16 08:10:02 +0000718Validate ONOS Flows per OLT
719 [Documentation] This keyword validates onos flows per olt
720 [Arguments] ${olt_sn} ${expected_flows}
721 ${olt_of_id} Validate OLT Device in ONOS ${olt_sn}
722 ${flows}= Count flows ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${olt_of_id} added
723 Log Found added ${flows} of ${expected_flows} expected flows on device ${olt_sn}
724 Should Be Equal As Integers ${expected_flows} ${flows}
725
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000726Validate OLT Flows Per Onu
727 [Documentation] This keyword validates olt flows per onu
728 ... It checks checks presence/absence of olt flows depending on must_exist.
729 ... The values/content of olt flows will be not validated!
730 [Arguments] ${onu_device_id} ${must_exist}
731 ${rc} ${output}= Run and Return Rc and Output
Andrea Campanella28989d12022-01-11 09:49:21 +0100732 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${onu_device_id} -m 32MB -o json
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000733 Should Be Equal As Integers ${rc} 0
734 ${jsondata}= To Json ${output}
735 Log ${jsondata}
736 # in case of ATT for ONU with removed flows there is default flow established
737 ${length}= Get Length ${jsondata}
738 ${value}= Run Keyword If ${length}>0 Get From List ${jsondata} 0
739 ${setvid}= Run Keyword If ${length}>0 Run Keyword If 'setvlanid' in ${value}
740 ... Get From Dictionary ${value} setvlanid
741 Run Keyword If "${workflow}"=="ATT" and not ${must_exist} Run Keywords
742 ... Should Be Equal As Numbers ${setvid} 4091 AND
743 ... Should Be Equal As Numbers ${length} 1 AND
744 ... Return From Keyword
745 Run Keyword If ${must_exist} Should Not Be Empty ${jsondata}
746 ... ELSE Should Be Empty ${jsondata}
747
TorstenThiemed4f48962020-12-08 12:17:19 +0000748Wait for Ports in ONOS for all OLTs
TorstenThieme440b7c02020-12-18 15:42:57 +0000749 [Documentation] Waits untill a certain number of ports are enabled in all OLTs
TorstenThieme731a7592021-07-01 14:26:54 +0000750 [Arguments] ${host} ${port} ${count} ${filter} ${max_wait_time}=10m ${determine_number}=False
TorstenThiemed4f48962020-12-08 12:17:19 +0000751 FOR ${J} IN RANGE 0 ${num_olts}
752 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
753 ${onu_count}= Set Variable ${list_olts}[${J}][onucount]
754 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
755 ... ${olt_serial_number}
756 Set Global Variable ${of_id}
TorstenThiemeff9c9142021-04-08 07:21:34 +0000757 ${count2check}= Set Variable If ${count}==${num_all_onus} ${onu_count} ${count}
758 # if flag determine_number is set to True, always determine the number of real ONUs (overwrite previous value)
759 ${count2check}= Run Keyword If ${determine_number} Determine Number Of ONU ${olt_serial_number}
760 ... ELSE Set Variable ${count2check}
TorstenThieme731a7592021-07-01 14:26:54 +0000761 Wait for Ports in ONOS ${host} ${port} ${count2check} ${of_id} BBSM ${max_wait_time}
TorstenThiemed4f48962020-12-08 12:17:19 +0000762 END
763
TorstenThieme440b7c02020-12-18 15:42:57 +0000764Wait for all ONU Ports in ONOS Disabled
765 [Documentation] Waits untill a all ONU ports are disabled in all ONOS
TorstenThieme00fe8262022-01-19 10:43:07 +0000766 [Arguments] ${host} ${port} ${unitag}=False
TorstenThieme440b7c02020-12-18 15:42:57 +0000767 FOR ${I} IN RANGE 0 ${num_all_onus}
768 ${src}= Set Variable ${hosts.src[${I}]}
769 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
770 ... ${src['olt']}
TorstenThieme00fe8262022-01-19 10:43:07 +0000771 ${onu_uni_id}= Set Variable If ${unitag} ${src['uni_id']} 1
772 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']} ${of_id}
773 ... ${onu_uni_id}
TorstenThieme731a7592021-07-01 14:26:54 +0000774 Wait Until Keyword Succeeds ${timeout} 2s Assert ONU Port Is Disabled ${host} ${port} ${of_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000775 ... ${onu_port}
776 END
777
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000778Map State
779 [Documentation] This keyword converts the passed numeric value or name of a onu state to its state values.
780 [Arguments] ${state}
781 # create state lists with corresponding return values
782 # ADMIN-STATE OPER-STATUS CONNECT-STATUS ONU-STATE (number/name)
783 ${state1} Create List ENABLED ACTIVATING REACHABLE 1 activating-onu
784 ${state2} Create List ENABLED ACTIVATING REACHABLE 2 starting-openomci
785 ${state3} Create List ENABLED ACTIVATING REACHABLE 3 discovery-mibsync-complete
786 ${state4} Create List ENABLED ACTIVE REACHABLE 4 initial-mib-downloaded
787 ${state5} Create List ENABLED ACTIVE REACHABLE 5 tech-profile-config-download-success
788 ${state6} Create List ENABLED ACTIVE REACHABLE 6 omci-flows-pushed
789 ${state7} Create List DISABLED UNKNOWN REACHABLE 7 omci-admin-lock
790 ${state8} Create List ENABLED ACTIVE REACHABLE 8 onu-reenabled
791 ${state9} Create List ENABLED DISCOVERED UNREACHABLE 9 stopping-openomci
792 ${state10} Create List ENABLED DISCOVERED REACHABLE 10 rebooting
793 ${state11} Create List ENABLED DISCOVERED REACHABLE 11 omci-flows-deleted
794 ${state12} Create List DISABLED UNKNOWN REACHABLE 12 tech-profile-config-delete-success
795 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Set Variable If
796 ... '${state}'=='1' or '${state}'=='activating-onu' ${state1}
797 ... '${state}'=='2' or '${state}'=='starting-openomci' ${state2}
798 ... '${state}'=='3' or '${state}'=='discovery-mibsync-complete' ${state3}
799 ... '${state}'=='4' or '${state}'=='initial-mib-downloaded' ${state4}
800 ... '${state}'=='5' or '${state}'=='tech-profile-config-download-success' ${state5}
801 ... '${state}'=='6' or '${state}'=='omci-flows-pushed' ${state6}
802 ... '${state}'=='7' or '${state}'=='omci-admin-lock' ${state7}
803 ... '${state}'=='8' or '${state}'=='onu-reenabled' ${state8}
804 ... '${state}'=='9' or '${state}'=='stopping-openomci' ${state9}
805 ... '${state}'=='10' or '${state}'=='rebooting' ${state10}
806 ... '${state}'=='11' or '${state}'=='omci-flows-deleted' ${state11}
807 ... '${state}'=='12' or '${state}'=='tech-profile-config-delete-success' ${state12}
808 [Return] ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}