blob: 48316d1f0375d3d01c445a05cb2891cabe4017dc [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
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000018
TorstenThiemed4f48962020-12-08 12:17:19 +000019
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000020*** Keywords ***
TorstenThieme440b7c02020-12-18 15:42:57 +000021Calculate Timeout
22 [Documentation] Calculates the timeout regarding num-onus in case of more than 4 onus
23 [Arguments] ${basetimeout}=60s
24 ${new_timeout} Fetch From Left ${basetimeout} s
25 ${new_timeout}= evaluate ${new_timeout}+((${num_all_onus}-4)*10)
26 ${new_timeout}= Set Variable If (not ${debugmode}) and (${new_timeout}>300)
27 ... 300 ${new_timeout}
28 ${new_timeout}= Catenate SEPARATOR= ${new_timeout} s
29 [Return] ${new_timeout}
30
TorstenThieme3494ceb2021-07-19 09:47:24 +000031Get Logical Id of OLT
32 [Documentation] Fills the logical id of OLT(s) if missing
33 FOR ${I} IN RANGE 0 ${num_olts}
34 # exit loop if logical id already known
35 Exit For Loop IF "${olt_ids}[${I}][logical_id]" != "${EMPTY}"
36 #read current device values
37 ${olt}= Get From List ${olt_ids} ${I}
38 ${olt_serial_number}= Get From Dictionary ${olt} sn
39 # read logical id and store it
40 ${logical_id}= Get Logical Device ID From SN ${olt_serial_number}
41 Set To Dictionary ${olt} logical_id ${logical_id}
42 Set List Value ${olt_ids} ${I} ${olt}
43 END
44 Set Global Variable ${olt_ids}
45
TorstenThieme440b7c02020-12-18 15:42:57 +000046Power On ONU Device
47 [Documentation] This keyword turns on the power for all onus.
48 [Arguments] ${namespace}
TorstenThiemefe7099e2021-01-29 08:41:04 +000049 FOR ${J} IN RANGE 0 ${num_olts}
50 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
51 ${bbsim}= Catenate SEPARATOR= bbsim ${J}
52 ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
53 Power On ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
54 END
55
56Power On ONU Device per OLT
57 [Documentation] This keyword turns on the power for all onus.
58 [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000059 FOR ${I} IN RANGE 0 ${num_all_onus}
60 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThiemefe7099e2021-01-29 08:41:04 +000061 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
62 Power On ONU ${namespace} ${bbsim_pod} ${src['onu']}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000063 END
64
TorstenThieme440b7c02020-12-18 15:42:57 +000065Power Off ONU Device
TorstenThiemefe7099e2021-01-29 08:41:04 +000066 [Documentation] This keyword turns off the power for all onus per olt.
TorstenThieme440b7c02020-12-18 15:42:57 +000067 [Arguments] ${namespace}
TorstenThiemefe7099e2021-01-29 08:41:04 +000068 FOR ${J} IN RANGE 0 ${num_olts}
69 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
70 ${bbsim}= Catenate SEPARATOR= bbsim ${J}
71 ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
72 Power Off ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
73 END
74
75Power Off ONU Device per OLT
76 [Documentation] This keyword turns off the power for all onus per olt.
77 [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
TorstenThieme440b7c02020-12-18 15:42:57 +000078 FOR ${I} IN RANGE 0 ${num_all_onus}
79 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThiemefe7099e2021-01-29 08:41:04 +000080 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
81 Power Off ONU ${namespace} ${bbsim_pod} ${src['onu']}
TorstenThieme440b7c02020-12-18 15:42:57 +000082 END
83
84Current State Test
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000085 [Documentation] This keyword checks the passed state of the given onu.
86 [Arguments] ${state} ${onu} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY}
87 ... ${reqconnectstatus}=${EMPTY}
88 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
89 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
90 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
91 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
92 ... ${connect_status}
93 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
94 ... Validate Device ${admin_state} ${oper_status} ${connect_status}
95 ... ${onu} onu=True onu_reason=${onu_state}
96
TorstenThieme440b7c02020-12-18 15:42:57 +000097Current State Test All Onus
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000098 [Documentation] This keyword checks the passed state of all onus.
99 ... Hint: ${timeStart} will be not evaluated here!
100 [Arguments] ${state} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY} ${reqconnectstatus}=${EMPTY}
TorstenThieme53450ff2021-05-11 09:44:33 +0000101 ... ${alternativeonustate}=${EMPTY} ${timeout}=${timeout}
TorstenThieme440b7c02020-12-18 15:42:57 +0000102 ${timeStart}= Get Current Date
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000103 ${list_onus} Create List
104 Build ONU SN List ${list_onus}
105 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
106 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
107 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
108 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
109 ... ${connect_status}
110 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
111 ... Validate ONU Devices With Duration
112 ... ${admin_state} ${oper_status} ${connect_status}
TorstenThieme52ef8392020-11-10 13:42:26 +0000113 ... ${onu_state} ${list_onus} ${timeStart} alternate_reason=${alternativeonustate}
TorstenThieme53450ff2021-05-11 09:44:33 +0000114 # teardown is used as 'return' for result of Validate ONU Devices With Duration (used for ONUNegativeStateTests)
115 [Teardown] Run Keyword If "${KEYWORD STATUS}"=="FAIL" Set Suite Variable ${StateTestAllONUs} False
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000116
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000117Reconcile Onu Adapter
118 [Documentation] Restarts the openonu adapter and waits for reconciling is finished and expected oper-state is reached
119 [Arguments] ${namespace} ${usekill2restart} ${oper_status}
120 # get time of restart of openonu adapter
121 ${restart_ts}= Get Current Date
122 # restart OpenONU adapter
123 Run Keyword If ${usekill2restart} Kill And Check Onu Adaptor ${namespace}
124 ... ELSE Restart And Check Onu Adaptor ${namespace}
125 #check ready timestamp of openonu adapter, should be younger than restart timestamp
126 ${openonu_ready_ts}= Get Pod Ready Timestamp by Label ${namespace} app adapter-open-onu
127 ${restart_duration}= Subtract Date From Date ${openonu_ready_ts} ${restart_ts}
128 Should Be True ${restart_duration}>0
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700129 # wait for the reconcile to complete
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000130 # - we check that communication to openonu-adapter is established again
131 # - we check that all ONUs leave reconcile state by validate a simple voltctl request will not responds with error
132 Wait Until Keyword Succeeds ${timeout} 1s Validate Last ONU Communication
133 Wait Until Keyword Succeeds ${timeout} 1s Operation Of Onu Adaptor Finished reconciling
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700134 # - then we wait that all ONU move to the next state
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000135 ${list_onus} Create List
136 Build ONU SN List ${list_onus}
137 Run Keyword And Ignore Error Wait Until Keyword Succeeds ${timeout}
138 ... 1s Check all ONU OperStatus ${list_onus} ${oper_status}
139
140Operation Of Onu Adaptor Finished
141 [Documentation] This keyword checks onu adaptor finished named operation with help of a simple voltctl request.
142 ... It is an implicit check. Possible operations are (device) 'deletion' or 'reconciling'.
143 ... As long as one of the named operations still running we've got an rc!=0 and we will find our
144 ... 'operation' as part of output of get request.
145 ... As get request Onu image list is used, any other get command could be used for this check.
146 [Arguments] ${operation}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700147 ${onu_list} Create List
148 FOR ${I} IN RANGE 0 ${num_all_onus}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000149 ${src}= Set Variable ${hosts.src[${I}]}
150 ${onu_device_id}= Get Device ID From SN ${src['onu']}
151 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700152 Continue For Loop If -1 != ${onu_id}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000153 Append To List ${onu_list} ${onu_device_id}
154 ${rc} ${output}= Get Onu Image List ${onu_device_id}
155 Run Keyword If ${rc}!=0 Should Not Contain ${output} ${operation}
156 ... Onu adaptor operation ${operation} still in progress.
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700157 END
158
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000159Log Ports
160 [Documentation] This keyword logs all port data available in ONOS of first port per ONU
161 [Arguments] ${onlyenabled}=False
162 ${cmd} Set Variable If ${onlyenabled} ports -e ports
TorstenThieme731a7592021-07-01 14:26:54 +0000163 ${onu_ports}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${cmd}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000164 ${lines} = Get Lines Matching Regexp ${onu_ports} .*portName=BBSM[0-9]{8}-1
165 Log ${lines}
166
167Kill Adaptor
168 [Documentation] This keyword kills the passed adaptor.
169 [Arguments] ${namespace} ${name}
170 ${cmd} Catenate
171 ... kubectl exec -it -n voltha $(kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}')
172 ... -- /bin/sh -c "kill 1"
173 ${rc} ${output}= Run and Return Rc and Output ${cmd}
174 Log ${output}
175
TorstenThieme440b7c02020-12-18 15:42:57 +0000176Kill And Check Onu Adaptor
177 [Documentation] This keyword kills ONU Adaptor and waits for it to come up again
178 ... Following steps will be executed:
179 ... - kill openonu adaptor
180 ... - check openonu adaptor is ready again
181 [Arguments] ${namespace}
182 ${list_openonu_apps} Create List adapter-open-onu
183 ${adaptorname}= Set Variable open-onu
184 Kill Adaptor ${namespace} ${adaptorname}
185 Sleep 5s
186 Wait For Pods Ready ${namespace} ${list_openonu_apps}
187
188Restart And Check Onu Adaptor
189 [Documentation] This keyword restarts ONU Adaptor and waits for it to come up again
190 ... Following steps will be executed:
191 ... - restart openonu adaptor
192 ... - check openonu adaptor is ready again
193 [Arguments] ${namespace}
194 ${list_openonu_apps} Create List adapter-open-onu
Matteo Scandolo6f24ea92021-04-29 11:55:50 -0700195 ${openonu_label_key} Set Variable app
196 ${openonu_label_value} Set Variable adapter-open-onu
197 Restart Pod By Label ${namespace} ${openonu_label_key} ${openonu_label_value}
TorstenThieme440b7c02020-12-18 15:42:57 +0000198 Sleep 5s
199 Wait For Pods Ready ${namespace} ${list_openonu_apps}
200
201Disable Onu Device
202 [Documentation] This keyword disables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000203 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000204 FOR ${I} IN RANGE 0 ${num_all_onus}
205 ${src}= Set Variable ${hosts.src[${I}]}
206 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000207 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
208 Continue For Loop If -1 != ${onu_id}
209 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000210 Disable Device ${onu_device_id}
211 Wait Until Keyword Succeeds 20s 2s Test Devices Disabled in VOLTHA Id=${onu_device_id}
212 END
213
214Enable Onu Device
215 [Documentation] This keyword enables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000216 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000217 FOR ${I} IN RANGE 0 ${num_all_onus}
218 ${src}= Set Variable ${hosts.src[${I}]}
219 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000220 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
221 Continue For Loop If -1 != ${onu_id}
222 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000223 Enable Device ${onu_device_id}
224 END
225
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000226Verify MIB Template Data Available
227 [Documentation] This keyword verifies MIB Template Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000228 [Arguments] ${namespace}=default
TorstenThiemed4f48962020-12-08 12:17:19 +0000229 ${podname}= Set Variable etcd
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000230 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800231 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000232 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000233 Should Not Be Empty ${result} No MIB Template Data stored in etcd!
234
235Delete MIB Template Data
236 [Documentation] This keyword deletes MIB Template Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000237 [Arguments] ${namespace}=default
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000238 ${podname}= Set Variable etcd
239 ${commanddel} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800240 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000241 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commanddel}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000242 Sleep 3s
243 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800244 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000245 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000246 Should Be Empty ${result} Could not delete MIB Template Data stored in etcd!
247
TorstenThieme440b7c02020-12-18 15:42:57 +0000248Set Tech Profile
249 [Documentation] This keyword sets the passed TechProfile for the test
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000250 [Arguments] ${TechProfile} ${namespace}=default
TorstenThieme440b7c02020-12-18 15:42:57 +0000251 Log To Console \nTechProfile:${TechProfile}
TorstenThieme440b7c02020-12-18 15:42:57 +0000252 ${podname}= Set Variable etcd
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200253 ${label}= Set Variable app.kubernetes.io/name=${podname}
TorstenThieme440b7c02020-12-18 15:42:57 +0000254 ${src}= Set Variable ${data_dir}/TechProfile-${TechProfile}.json
255 ${dest}= Set Variable /tmp/flexpod.json
256 ${command} Catenate
257 ... /bin/sh -c 'cat ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64'
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200258 Copy File To Pod ${namespace} ${label} ${src} ${dest}
TorstenThieme440b7c02020-12-18 15:42:57 +0000259 Exec Pod In Kube ${namespace} ${podname} ${command}
260 ${commandget} Catenate
261 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200262 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
263 Should Not Be Empty ${result} No Tech Profile stored in etcd!
TorstenThieme440b7c02020-12-18 15:42:57 +0000264
265Remove Tech Profile
266 [Documentation] This keyword removes TechProfile
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000267 [Arguments] ${namespace}=default
TorstenThieme440b7c02020-12-18 15:42:57 +0000268 Log To Console \nTechProfile:${TechProfile}
TorstenThieme440b7c02020-12-18 15:42:57 +0000269 ${podname}= Set Variable etcd
270 ${command} Catenate
271 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/64'
272 Exec Pod In Kube ${namespace} ${podname} ${command}
273 ${commandget} Catenate
274 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
275 Exec Pod In Kube ${namespace} ${podname} ${commandget}
276
TorstenThiemea7315f12021-07-23 11:56:34 +0000277Do Onu Subscriber Add Per OLT
278 [Documentation] Add Subscriber per OLT
279 [Arguments] ${of_id} ${olt_serial_number} ${print2console}=False
280 FOR ${I} IN RANGE 0 ${num_all_onus}
281 ${src}= Set Variable ${hosts.src[${I}]}
282 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
283 ${onu_device_id}= Get Device ID From SN ${src['onu']}
284 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
285 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
286 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
287 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
288 ... volt-add-subscriber-access ${of_id} ${onu_port}
289 Run Keyword If ${print2console} Log \r\n[${I}] volt-add-subscriber-access ${of_id} ${onu_port}.
290 ... console=yes
291 END
292
293Do Onu Flow Check Per OLT
294 [Documentation] Checks all ONU flows show up in ONOS and Voltha
295 [Arguments] ${of_id} ${nni_port} ${olt_serial_number} ${print2console}=False
296 FOR ${I} IN RANGE 0 ${num_all_onus}
297 ${src}= Set Variable ${hosts.src[${I}]}
298 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
299 ${onu_device_id}= Get Device ID From SN ${src['onu']}
300 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
301 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
302 # Verify subscriber access flows are added for the ONU port
303 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
304 ... Verify Subscriber Access Flows Added For ONU ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${of_id}
305 ... ${onu_port} ${nni_port} ${src['c_tag']} ${src['s_tag']}
306 ${logoutput} Catenate \r\n[${I}] Verify Subscriber Access Flows Added For
307 ... ONU ${of_id} ${onu_port} ${src['c_tag']} ${src['s_tag']}.
308 Run Keyword If ${print2console} Log ${logoutput} console=yes
309 END
310
311Do Onu Subscriber Remove Per OLT
312 [Documentation] Removes per OLT subscribers in ONOS and Voltha
313 [Arguments] ${of_id} ${olt_serial_number} ${print2console}=False
314 FOR ${I} IN RANGE 0 ${num_all_onus}
315 ${src}= Set Variable ${hosts.src[${I}]}
316 ${dst}= Set Variable ${hosts.dst[${I}]}
317 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
318 ${onu_device_id}= Get Device ID From SN ${src['onu']}
319 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
320 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
321 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
322 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
323 ... volt-remove-subscriber-access ${of_id} ${onu_port}
324 Run Keyword If ${print2console} Log \r\n[${I}] volt-remove-subscriber-access ${of_id} ${onu_port}.
325 ... console=yes
326 END
327
TorstenThieme7c397d72021-07-14 11:51:09 +0000328Validate Resource Instances Used Gem Ports
329 [Documentation] This keyword validates resource instances data stored in etcd.
330 ... It checks checks the number of gemport-ids which has matched with used Tech Profile
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000331 [Arguments] ${nbofgemports} ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha
TorstenThieme7c397d72021-07-14 11:51:09 +0000332 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000333 ${etcddata}= Get ONU Go Adapter ETCD Data namespace=${namespace} defaultkvstoreprefix=${kvstoreprefix}
TorstenThieme7c397d72021-07-14 11:51:09 +0000334 #prepare result for json convert
335 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
336 ${jsondata}= To Json ${result}
337 ${length}= Get Length ${jsondata}
338 log ${jsondata}
339 FOR ${INDEX} IN RANGE 0 ${length}
340 ${value}= Get From List ${jsondata} ${INDEX}
341 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
342 # When testing multi-tcont this may need some adjustment.
343 Exit For Loop If not ('uni_config' in $value)
344 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000345 ${resourcedata}= Get Resource Instances ETCD Data ${tp_path} namespace=${namespace}
346 ... defaultkvstoreprefix=${kvstoreprefix}
TorstenThieme7c397d72021-07-14 11:51:09 +0000347 log ${resourcedata}
348 ${decoderesult}= volthatools.Tech Profile Decode Resource Instance ${resourcedata} return_default=true
349 log ${decoderesult}
350 ${gemportids}= Get From Dictionary ${decoderesult} gemport_ids
351 ${length}= Get Length ${gemportids}
352 Should Be Equal As Integers ${nbofgemports} ${length}
353 ... msg=Number of gem ports (${length}) does not match with techprofile ${techprofile}/${nbofgemports}
354 END
355
356Get Resource Instances ETCD Data
357 [Documentation] This keyword delivers Resource Instances Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000358 [Arguments] ${tppath} ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha
TorstenThieme7c397d72021-07-14 11:51:09 +0000359 ${podname}= Set Variable etcd
360 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
361 ${commandget}= Catenate
362 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/resource_instances/${tppath}
363 ... --print-value-only --hex'
364 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
365 log ${result}
366 [Return] ${result}
367
368
TorstenThieme17756ea2020-11-11 14:09:47 +0000369Validate Onu Data In Etcd
370 [Documentation] This keyword validates openonu-go-adapter Data stored in etcd.
371 ... It checks unique of serial_number and combination of pon, onu and uni in tp_path.
372 ... Furthermore it evaluates the values of onu_id and uni_id with values read from tp_path.
373 ... Number of etcd entries has to match with the passed number.
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000374 [Arguments] ${namespace}=default ${nbofetcddata}=${num_all_onus} ${defaultkvstoreprefix}=voltha_voltha
TorstenThiemefa29a892021-03-11 14:11:29 +0000375 ... ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000376 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000377 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme17756ea2020-11-11 14:09:47 +0000378 #prepare result for json convert
379 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
380 ${jsondata}= To Json ${result}
381 ${length}= Get Length ${jsondata}
382 log ${jsondata}
383 Run Keyword And Continue On Failure Should Be Equal As Integers ${length} ${nbofetcddata}
384 ... msg=Number etcd data (${length}) does not match required (${nbofetcddata})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000385 ${oltpononuuniidlist}= Create List
TorstenThieme17756ea2020-11-11 14:09:47 +0000386 ${serialnumberlist}= Create List
387 FOR ${INDEX} IN RANGE 0 ${length}
388 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra97f8d062020-11-17 15:48:23 -0800389 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
390 # When testing multi-tcont this may need some adjustment.
TorstenThieme45071602021-03-16 12:14:37 +0000391 Exit For Loop If not ('uni_config' in $value)
Girish Gowdra97f8d062020-11-17 15:48:23 -0800392 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000393 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
394 ${list_id}= Get Index From List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000395 Should Be Equal As Integers ${list_id} -1
TorstenThiemefe7099e2021-01-29 08:41:04 +0000396 ... msg=Combination of Pon, Onu and Uni (${oltpononuuniid}) exist multiple in etcd data!
397 Append To List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000398 Validate Onu Id ${value}
399 Validate Uni Id ${value}
400 ${serial_number}= Get From Dictionary ${value} serial_number
401 ${list_id}= Get Index From List ${serialnumberlist} ${serial_number}
402 Should Be Equal As Integers ${list_id} -1
403 ... msg=Serial number (${serial_number}) exists multiple in etcd data!
404 Append To List ${serialnumberlist} ${serial_number}
405 END
406
TorstenThieme52ef8392020-11-10 13:42:26 +0000407Validate Vlan Rules In Etcd
408 [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd.
409 ... It checks the given number of cookie_slice, match_vid (=4096) and set_vid.
410 ... Furthermore it returns a list of all set_vid.
411 ... In case of a passed dictionary containing set_vids these will be checked for to
412 ... current set-vid depending on setvidequal (True=equal, False=not equal).
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000413 [Arguments] ${namespace}=default ${nbofcookieslice}=1 ${reqmatchvid}=4096 ${prevvlanrules}=${NONE}
414 ... ${setvidequal}=False ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000415 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000416 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme52ef8392020-11-10 13:42:26 +0000417 #prepare result for json convert
418 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
419 ${jsondata}= To Json ${result}
420 ${length}= Get Length ${jsondata}
421 log ${jsondata}
422 ${vlan_rules}= Create Dictionary
423 FOR ${INDEX} IN RANGE 0 ${length}
424 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra295c1692020-11-19 10:51:53 -0800425 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
426 # When testing multi-tcont this may need some adjustment.
427 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000428 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000429 ${cookieslice}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]} cookie_slice
430 #@{cookieslicelist}= Split String ${cookieslice} ,
431 ${foundcookieslices}= Get Length ${cookieslice}
432 Should Be Equal As Integers ${foundcookieslices} ${nbofcookieslice}
433 ${matchvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
434 ... match_vid
435 Should Be Equal As Integers ${matchvid} ${reqmatchvid}
436 ${setvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
437 ... set_vid
438 ${evalresult}= Evaluate 2 <= ${setvid} <= 4095
439 Should Be True ${evalresult} msg=set_vid out of range (${setvid})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000440 Set To Dictionary ${vlan_rules} ${oltpononuuniid} ${setvid}
TorstenThieme52ef8392020-11-10 13:42:26 +0000441 ${oldsetvidvalid} Set Variable If ${prevvlanrules} is ${NONE} False True
TorstenThiemefe7099e2021-01-29 08:41:04 +0000442 ${prevsetvid}= Set Variable If ${oldsetvidvalid} ${prevvlanrules['${oltpononuuniid}']}
TorstenThieme52ef8392020-11-10 13:42:26 +0000443 Run Keyword If ${oldsetvidvalid} and ${setvidequal}
444 ... Should Be Equal As Integers ${prevsetvid} ${setvid}
445 ... ELSE IF ${oldsetvidvalid} and not ${setvidequal}
446 ... Should Not Be Equal As Integers ${prevsetvid} ${setvid}
447 END
TorstenThieme440b7c02020-12-18 15:42:57 +0000448 log Many ${vlan_rules}
TorstenThieme52ef8392020-11-10 13:42:26 +0000449 [Return] ${vlan_rules}
450
451Get ONU Go Adapter ETCD Data
452 [Documentation] This keyword delivers openonu-go-adapter Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000453 [Arguments] ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True
454 ... ${without_pm_data}=True
TorstenThieme52ef8392020-11-10 13:42:26 +0000455 ${podname}= Set Variable etcd
TorstenThieme3385cdc2021-02-04 13:50:50 +0000456 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
TorstenThieme3af12312021-03-10 16:15:24 +0000457 ${commandget}= Catenate
458 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/openonu'
459 ${commandget}= Run Keyword If ${without_prefix} Catenate ${commandget}
460 ... | grep -v service/${kvstoreprefix}/openonu
TorstenThiemefa29a892021-03-11 14:11:29 +0000461 ... ELSE Set Variable ${commandget}
TorstenThieme3af12312021-03-10 16:15:24 +0000462 ${commandget}= Run Keyword If ${without_pm_data} Catenate ${commandget} | grep -v instances_active
TorstenThiemefa29a892021-03-11 14:11:29 +0000463 ... ELSE Set Variable ${commandget}
Holger Hildebrandt23147742020-11-16 10:13:21 +0000464 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThieme52ef8392020-11-10 13:42:26 +0000465 log ${result}
466 [Return] ${result}
467
468Prepare ONU Go Adapter ETCD Data For Json
469 [Documentation] This keyword prepares openonu-go-adapter Data stored in etcd for converting
470 ... to json
471 [Arguments] ${etcddata}
472 #prepare result for json convert
473 ${prepresult}= Replace String ${etcddata} \n ,
474 ${prepresult}= Strip String ${prepresult} mode=right characters=,
475 ${prepresult}= Set Variable [${prepresult}]
476 log ${prepresult}
477 [Return] ${prepresult}
478
TorstenThieme52ef8392020-11-10 13:42:26 +0000479Read Pon Onu Uni String
TorstenThiemefe7099e2021-01-29 08:41:04 +0000480 [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 +0000481 ... taken from etcd data of onu go adapter
482 [Arguments] ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000483 ${tppathlines}= Replace String ${tp_path} / \n
TorstenThiemefe7099e2021-01-29 08:41:04 +0000484 ${olt}= Get Value Of Tp Path Element ${tppathlines} olt
TorstenThieme52ef8392020-11-10 13:42:26 +0000485 ${pon}= Get Value Of Tp Path Element ${tppathlines} pon
486 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
487 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
TorstenThiemefe7099e2021-01-29 08:41:04 +0000488 ${valuesid}= Set Variable ${olt}/${pon}/${onu}/${uni}
TorstenThieme52ef8392020-11-10 13:42:26 +0000489 log ${valuesid}
490 [Return] ${valuesid}
491
492Get Value Of Tp Path Element
TorstenThieme17756ea2020-11-11 14:09:47 +0000493 [Documentation] This keyword delivers numeric value of given tp path element.
TorstenThieme52ef8392020-11-10 13:42:26 +0000494 [Arguments] ${tp_path_lines} ${element}
495 ${value}= Get Lines Containing String ${tp_path_lines} ${element}-\{
496 ${value}= Remove String ${value} ${element}-\{
497 ${value}= Remove String ${value} \}
498 log ${value}
499 [Return] ${value}
500
TorstenThieme17756ea2020-11-11 14:09:47 +0000501Validate Onu Id
502 [Documentation] This keyword validates ONU Id of passed etcd data.
503 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800504 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
505 # When testing multi-tcont this may need some adjustment.
506 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000507 ${tppathlines}= Replace String ${tp_path} / \n
508 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
509 ${onu_id}= Get From Dictionary ${value} onu_id
510 Should Be Equal As Integers ${onu} ${onu_id}
511 ... msg=Onu-Id (${onu_id}) does not match onu (${onu}) from tp_path in etcd data!
512 Should Be True ${onu_id}>=1
513
514Validate Uni Id
515 [Documentation] This keyword validates UNI Id of passed etcd data.
516 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800517 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
518 # When testing multi-tcont this may need some adjustment.
519 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000520 ${tppathlines}= Replace String ${tp_path} / \n
521 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
522 ${uni_id}= Get From Dictionary ${value['uni_config'][0]} uni_id
523 Should Be Equal As Integers ${uni} ${uni_id}
524 ... msg=Uni-Id (${uni_id}) does not match onu (${uni}) from tp_path in etcd data!
TorstenThieme52ef8392020-11-10 13:42:26 +0000525
TorstenThieme45071602021-03-16 12:14:37 +0000526Delete ONU Go Adapter ETCD Data
527 [Documentation] This keyword deletes openonu-go-adapter Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000528 [Arguments] ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha ${validate}=False
TorstenThieme45071602021-03-16 12:14:37 +0000529 ${podname}= Set Variable etcd
530 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
531 ${commandget}= Catenate
532 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/${kvstoreprefix}/openonu'
533 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
534 log ${result}
535 Run Keyword If ${validate} Wait Until Keyword Succeeds ${timeout} 1s
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000536 ... Validate Onu Data In Etcd namespace=${namespace} nbofetcddata=0 without_pm_data=False
TorstenThieme45071602021-03-16 12:14:37 +0000537 [Return] ${result}
538
TorstenThiemed4f48962020-12-08 12:17:19 +0000539Wait for Ports in ONOS for all OLTs
TorstenThieme440b7c02020-12-18 15:42:57 +0000540 [Documentation] Waits untill a certain number of ports are enabled in all OLTs
TorstenThieme731a7592021-07-01 14:26:54 +0000541 [Arguments] ${host} ${port} ${count} ${filter} ${max_wait_time}=10m ${determine_number}=False
TorstenThiemed4f48962020-12-08 12:17:19 +0000542 FOR ${J} IN RANGE 0 ${num_olts}
543 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
544 ${onu_count}= Set Variable ${list_olts}[${J}][onucount]
545 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
546 ... ${olt_serial_number}
547 Set Global Variable ${of_id}
TorstenThiemeff9c9142021-04-08 07:21:34 +0000548 ${count2check}= Set Variable If ${count}==${num_all_onus} ${onu_count} ${count}
549 # if flag determine_number is set to True, always determine the number of real ONUs (overwrite previous value)
550 ${count2check}= Run Keyword If ${determine_number} Determine Number Of ONU ${olt_serial_number}
551 ... ELSE Set Variable ${count2check}
TorstenThieme731a7592021-07-01 14:26:54 +0000552 Wait for Ports in ONOS ${host} ${port} ${count2check} ${of_id} BBSM ${max_wait_time}
TorstenThiemed4f48962020-12-08 12:17:19 +0000553 END
554
TorstenThieme440b7c02020-12-18 15:42:57 +0000555Wait for all ONU Ports in ONOS Disabled
556 [Documentation] Waits untill a all ONU ports are disabled in all ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000557 [Arguments] ${host} ${port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000558 FOR ${I} IN RANGE 0 ${num_all_onus}
559 ${src}= Set Variable ${hosts.src[${I}]}
560 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
561 ... ${src['olt']}
562 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']} ${of_id}
TorstenThieme731a7592021-07-01 14:26:54 +0000563 Wait Until Keyword Succeeds ${timeout} 2s Assert ONU Port Is Disabled ${host} ${port} ${of_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000564 ... ${onu_port}
565 END
566
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000567Map State
568 [Documentation] This keyword converts the passed numeric value or name of a onu state to its state values.
569 [Arguments] ${state}
570 # create state lists with corresponding return values
571 # ADMIN-STATE OPER-STATUS CONNECT-STATUS ONU-STATE (number/name)
572 ${state1} Create List ENABLED ACTIVATING REACHABLE 1 activating-onu
573 ${state2} Create List ENABLED ACTIVATING REACHABLE 2 starting-openomci
574 ${state3} Create List ENABLED ACTIVATING REACHABLE 3 discovery-mibsync-complete
575 ${state4} Create List ENABLED ACTIVE REACHABLE 4 initial-mib-downloaded
576 ${state5} Create List ENABLED ACTIVE REACHABLE 5 tech-profile-config-download-success
577 ${state6} Create List ENABLED ACTIVE REACHABLE 6 omci-flows-pushed
578 ${state7} Create List DISABLED UNKNOWN REACHABLE 7 omci-admin-lock
579 ${state8} Create List ENABLED ACTIVE REACHABLE 8 onu-reenabled
580 ${state9} Create List ENABLED DISCOVERED UNREACHABLE 9 stopping-openomci
581 ${state10} Create List ENABLED DISCOVERED REACHABLE 10 rebooting
582 ${state11} Create List ENABLED DISCOVERED REACHABLE 11 omci-flows-deleted
583 ${state12} Create List DISABLED UNKNOWN REACHABLE 12 tech-profile-config-delete-success
584 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Set Variable If
585 ... '${state}'=='1' or '${state}'=='activating-onu' ${state1}
586 ... '${state}'=='2' or '${state}'=='starting-openomci' ${state2}
587 ... '${state}'=='3' or '${state}'=='discovery-mibsync-complete' ${state3}
588 ... '${state}'=='4' or '${state}'=='initial-mib-downloaded' ${state4}
589 ... '${state}'=='5' or '${state}'=='tech-profile-config-download-success' ${state5}
590 ... '${state}'=='6' or '${state}'=='omci-flows-pushed' ${state6}
591 ... '${state}'=='7' or '${state}'=='omci-admin-lock' ${state7}
592 ... '${state}'=='8' or '${state}'=='onu-reenabled' ${state8}
593 ... '${state}'=='9' or '${state}'=='stopping-openomci' ${state9}
594 ... '${state}'=='10' or '${state}'=='rebooting' ${state10}
595 ... '${state}'=='11' or '${state}'=='omci-flows-deleted' ${state11}
596 ... '${state}'=='12' or '${state}'=='tech-profile-config-delete-success' ${state12}
597 [Return] ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}