blob: fb0e92a8f36c96f286a6295267516866474a24a5 [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
TorstenThiemee512b1d2021-11-12 10:52:29 +0000133 Wait Until Keyword Succeeds ${timeout} 1s Validate All Onus Accessible
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
TorstenThiemee512b1d2021-11-12 10:52:29 +0000140Validate All Onus Accessible
141 [Documentation] This keyword checks all onus accessible (again) with help of a simple voltctl request.
142 ... As long we've got an rc!=0 keyword will fail -> onu is not accessible.
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000143 ... As get request Onu image list is used, any other get command could be used for this check.
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700144 ${onu_list} Create List
145 FOR ${I} IN RANGE 0 ${num_all_onus}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000146 ${src}= Set Variable ${hosts.src[${I}]}
147 ${onu_device_id}= Get Device ID From SN ${src['onu']}
148 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700149 Continue For Loop If -1 != ${onu_id}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000150 Append To List ${onu_list} ${onu_device_id}
151 ${rc} ${output}= Get Onu Image List ${onu_device_id}
TorstenThiemee512b1d2021-11-12 10:52:29 +0000152 Should Be True ${rc}==0 Onu ${src['onu']} (${onu_device_id}) still not accessable.
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700153 END
154
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000155Log Ports
156 [Documentation] This keyword logs all port data available in ONOS of first port per ONU
157 [Arguments] ${onlyenabled}=False
158 ${cmd} Set Variable If ${onlyenabled} ports -e ports
TorstenThieme731a7592021-07-01 14:26:54 +0000159 ${onu_ports}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${cmd}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000160 ${lines} = Get Lines Matching Regexp ${onu_ports} .*portName=BBSM[0-9]{8}-1
161 Log ${lines}
162
163Kill Adaptor
164 [Documentation] This keyword kills the passed adaptor.
165 [Arguments] ${namespace} ${name}
166 ${cmd} Catenate
167 ... kubectl exec -it -n voltha $(kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}')
168 ... -- /bin/sh -c "kill 1"
169 ${rc} ${output}= Run and Return Rc and Output ${cmd}
170 Log ${output}
171
TorstenThieme440b7c02020-12-18 15:42:57 +0000172Kill And Check Onu Adaptor
173 [Documentation] This keyword kills ONU Adaptor and waits for it to come up again
174 ... Following steps will be executed:
175 ... - kill openonu adaptor
176 ... - check openonu adaptor is ready again
177 [Arguments] ${namespace}
178 ${list_openonu_apps} Create List adapter-open-onu
179 ${adaptorname}= Set Variable open-onu
180 Kill Adaptor ${namespace} ${adaptorname}
181 Sleep 5s
182 Wait For Pods Ready ${namespace} ${list_openonu_apps}
183
184Restart And Check Onu Adaptor
185 [Documentation] This keyword restarts ONU Adaptor and waits for it to come up again
186 ... Following steps will be executed:
187 ... - restart openonu adaptor
188 ... - check openonu adaptor is ready again
189 [Arguments] ${namespace}
190 ${list_openonu_apps} Create List adapter-open-onu
Matteo Scandolo6f24ea92021-04-29 11:55:50 -0700191 ${openonu_label_key} Set Variable app
192 ${openonu_label_value} Set Variable adapter-open-onu
193 Restart Pod By Label ${namespace} ${openonu_label_key} ${openonu_label_value}
TorstenThieme440b7c02020-12-18 15:42:57 +0000194 Sleep 5s
195 Wait For Pods Ready ${namespace} ${list_openonu_apps}
196
197Disable Onu Device
198 [Documentation] This keyword disables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000199 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000200 FOR ${I} IN RANGE 0 ${num_all_onus}
201 ${src}= Set Variable ${hosts.src[${I}]}
202 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000203 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
204 Continue For Loop If -1 != ${onu_id}
205 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000206 Disable Device ${onu_device_id}
207 Wait Until Keyword Succeeds 20s 2s Test Devices Disabled in VOLTHA Id=${onu_device_id}
208 END
209
210Enable Onu Device
211 [Documentation] This keyword enables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000212 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000213 FOR ${I} IN RANGE 0 ${num_all_onus}
214 ${src}= Set Variable ${hosts.src[${I}]}
215 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000216 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
217 Continue For Loop If -1 != ${onu_id}
218 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000219 Enable Device ${onu_device_id}
220 END
221
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000222Verify MIB Template Data Available
223 [Documentation] This keyword verifies MIB Template Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000224 [Arguments] ${namespace}=default
TorstenThiemed4f48962020-12-08 12:17:19 +0000225 ${podname}= Set Variable etcd
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000226 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800227 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000228 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000229 Should Not Be Empty ${result} No MIB Template Data stored in etcd!
230
231Delete MIB Template Data
232 [Documentation] This keyword deletes MIB Template Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000233 [Arguments] ${namespace}=default
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000234 ${podname}= Set Variable etcd
235 ${commanddel} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800236 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000237 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commanddel}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000238 Sleep 3s
239 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800240 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000241 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000242 Should Be Empty ${result} Could not delete MIB Template Data stored in etcd!
243
TorstenThieme440b7c02020-12-18 15:42:57 +0000244Set Tech Profile
245 [Documentation] This keyword sets the passed TechProfile for the test
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000246 [Arguments] ${TechProfile} ${namespace}=default
TorstenThieme440b7c02020-12-18 15:42:57 +0000247 Log To Console \nTechProfile:${TechProfile}
TorstenThieme440b7c02020-12-18 15:42:57 +0000248 ${podname}= Set Variable etcd
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200249 ${label}= Set Variable app.kubernetes.io/name=${podname}
TorstenThieme440b7c02020-12-18 15:42:57 +0000250 ${src}= Set Variable ${data_dir}/TechProfile-${TechProfile}.json
251 ${dest}= Set Variable /tmp/flexpod.json
252 ${command} Catenate
253 ... /bin/sh -c 'cat ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64'
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200254 Copy File To Pod ${namespace} ${label} ${src} ${dest}
TorstenThieme440b7c02020-12-18 15:42:57 +0000255 Exec Pod In Kube ${namespace} ${podname} ${command}
256 ${commandget} Catenate
257 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200258 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
259 Should Not Be Empty ${result} No Tech Profile stored in etcd!
TorstenThieme440b7c02020-12-18 15:42:57 +0000260
261Remove Tech Profile
262 [Documentation] This keyword removes TechProfile
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000263 [Arguments] ${namespace}=default
TorstenThieme440b7c02020-12-18 15:42:57 +0000264 Log To Console \nTechProfile:${TechProfile}
TorstenThieme440b7c02020-12-18 15:42:57 +0000265 ${podname}= Set Variable etcd
266 ${command} Catenate
267 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/64'
268 Exec Pod In Kube ${namespace} ${podname} ${command}
269 ${commandget} Catenate
270 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
271 Exec Pod In Kube ${namespace} ${podname} ${commandget}
272
TorstenThiemea7315f12021-07-23 11:56:34 +0000273Do Onu Subscriber Add Per OLT
274 [Documentation] Add Subscriber per OLT
275 [Arguments] ${of_id} ${olt_serial_number} ${print2console}=False
276 FOR ${I} IN RANGE 0 ${num_all_onus}
277 ${src}= Set Variable ${hosts.src[${I}]}
278 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
279 ${onu_device_id}= Get Device ID From SN ${src['onu']}
280 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
281 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
282 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
283 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
284 ... volt-add-subscriber-access ${of_id} ${onu_port}
285 Run Keyword If ${print2console} Log \r\n[${I}] volt-add-subscriber-access ${of_id} ${onu_port}.
286 ... console=yes
287 END
288
289Do Onu Flow Check Per OLT
290 [Documentation] Checks all ONU flows show up in ONOS and Voltha
291 [Arguments] ${of_id} ${nni_port} ${olt_serial_number} ${print2console}=False
292 FOR ${I} IN RANGE 0 ${num_all_onus}
293 ${src}= Set Variable ${hosts.src[${I}]}
294 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
295 ${onu_device_id}= Get Device ID From SN ${src['onu']}
296 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
297 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
298 # Verify subscriber access flows are added for the ONU port
299 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
300 ... Verify Subscriber Access Flows Added For ONU ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${of_id}
301 ... ${onu_port} ${nni_port} ${src['c_tag']} ${src['s_tag']}
302 ${logoutput} Catenate \r\n[${I}] Verify Subscriber Access Flows Added For
303 ... ONU ${of_id} ${onu_port} ${src['c_tag']} ${src['s_tag']}.
304 Run Keyword If ${print2console} Log ${logoutput} console=yes
305 END
306
307Do Onu Subscriber Remove Per OLT
308 [Documentation] Removes per OLT subscribers in ONOS and Voltha
309 [Arguments] ${of_id} ${olt_serial_number} ${print2console}=False
310 FOR ${I} IN RANGE 0 ${num_all_onus}
311 ${src}= Set Variable ${hosts.src[${I}]}
312 ${dst}= Set Variable ${hosts.dst[${I}]}
313 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
314 ${onu_device_id}= Get Device ID From SN ${src['onu']}
315 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
316 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
317 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
318 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
319 ... volt-remove-subscriber-access ${of_id} ${onu_port}
320 Run Keyword If ${print2console} Log \r\n[${I}] volt-remove-subscriber-access ${of_id} ${onu_port}.
321 ... console=yes
322 END
323
TorstenThieme7c397d72021-07-14 11:51:09 +0000324Validate Resource Instances Used Gem Ports
325 [Documentation] This keyword validates resource instances data stored in etcd.
326 ... It checks checks the number of gemport-ids which has matched with used Tech Profile
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000327 [Arguments] ${nbofgemports} ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha
TorstenThieme7c397d72021-07-14 11:51:09 +0000328 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000329 ${etcddata}= Get ONU Go Adapter ETCD Data namespace=${namespace} defaultkvstoreprefix=${kvstoreprefix}
TorstenThieme7c397d72021-07-14 11:51:09 +0000330 #prepare result for json convert
331 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
332 ${jsondata}= To Json ${result}
333 ${length}= Get Length ${jsondata}
334 log ${jsondata}
335 FOR ${INDEX} IN RANGE 0 ${length}
336 ${value}= Get From List ${jsondata} ${INDEX}
337 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
338 # When testing multi-tcont this may need some adjustment.
339 Exit For Loop If not ('uni_config' in $value)
340 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000341 ${resourcedata}= Get Resource Instances ETCD Data ${tp_path} namespace=${namespace}
342 ... defaultkvstoreprefix=${kvstoreprefix}
TorstenThieme7c397d72021-07-14 11:51:09 +0000343 log ${resourcedata}
344 ${decoderesult}= volthatools.Tech Profile Decode Resource Instance ${resourcedata} return_default=true
345 log ${decoderesult}
346 ${gemportids}= Get From Dictionary ${decoderesult} gemport_ids
347 ${length}= Get Length ${gemportids}
348 Should Be Equal As Integers ${nbofgemports} ${length}
349 ... msg=Number of gem ports (${length}) does not match with techprofile ${techprofile}/${nbofgemports}
350 END
351
352Get Resource Instances ETCD Data
353 [Documentation] This keyword delivers Resource Instances Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000354 [Arguments] ${tppath} ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha
TorstenThieme7c397d72021-07-14 11:51:09 +0000355 ${podname}= Set Variable etcd
356 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
357 ${commandget}= Catenate
358 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/resource_instances/${tppath}
359 ... --print-value-only --hex'
360 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
361 log ${result}
362 [Return] ${result}
363
364
TorstenThieme17756ea2020-11-11 14:09:47 +0000365Validate Onu Data In Etcd
366 [Documentation] This keyword validates openonu-go-adapter Data stored in etcd.
367 ... It checks unique of serial_number and combination of pon, onu and uni in tp_path.
368 ... Furthermore it evaluates the values of onu_id and uni_id with values read from tp_path.
369 ... Number of etcd entries has to match with the passed number.
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000370 [Arguments] ${namespace}=default ${nbofetcddata}=${num_all_onus} ${defaultkvstoreprefix}=voltha_voltha
TorstenThiemefa29a892021-03-11 14:11:29 +0000371 ... ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000372 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000373 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme17756ea2020-11-11 14:09:47 +0000374 #prepare result for json convert
375 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
376 ${jsondata}= To Json ${result}
377 ${length}= Get Length ${jsondata}
378 log ${jsondata}
379 Run Keyword And Continue On Failure Should Be Equal As Integers ${length} ${nbofetcddata}
380 ... msg=Number etcd data (${length}) does not match required (${nbofetcddata})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000381 ${oltpononuuniidlist}= Create List
TorstenThieme17756ea2020-11-11 14:09:47 +0000382 ${serialnumberlist}= Create List
383 FOR ${INDEX} IN RANGE 0 ${length}
384 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra97f8d062020-11-17 15:48:23 -0800385 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
386 # When testing multi-tcont this may need some adjustment.
TorstenThieme45071602021-03-16 12:14:37 +0000387 Exit For Loop If not ('uni_config' in $value)
Girish Gowdra97f8d062020-11-17 15:48:23 -0800388 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000389 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
390 ${list_id}= Get Index From List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000391 Should Be Equal As Integers ${list_id} -1
TorstenThiemefe7099e2021-01-29 08:41:04 +0000392 ... msg=Combination of Pon, Onu and Uni (${oltpononuuniid}) exist multiple in etcd data!
393 Append To List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000394 Validate Onu Id ${value}
395 Validate Uni Id ${value}
396 ${serial_number}= Get From Dictionary ${value} serial_number
397 ${list_id}= Get Index From List ${serialnumberlist} ${serial_number}
398 Should Be Equal As Integers ${list_id} -1
399 ... msg=Serial number (${serial_number}) exists multiple in etcd data!
400 Append To List ${serialnumberlist} ${serial_number}
401 END
402
TorstenThieme52ef8392020-11-10 13:42:26 +0000403Validate Vlan Rules In Etcd
404 [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd.
405 ... It checks the given number of cookie_slice, match_vid (=4096) and set_vid.
406 ... Furthermore it returns a list of all set_vid.
407 ... In case of a passed dictionary containing set_vids these will be checked for to
408 ... current set-vid depending on setvidequal (True=equal, False=not equal).
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000409 [Arguments] ${namespace}=default ${nbofcookieslice}=1 ${reqmatchvid}=4096 ${prevvlanrules}=${NONE}
410 ... ${setvidequal}=False ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000411 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000412 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme52ef8392020-11-10 13:42:26 +0000413 #prepare result for json convert
414 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
415 ${jsondata}= To Json ${result}
416 ${length}= Get Length ${jsondata}
417 log ${jsondata}
418 ${vlan_rules}= Create Dictionary
419 FOR ${INDEX} IN RANGE 0 ${length}
420 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra295c1692020-11-19 10:51:53 -0800421 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
422 # When testing multi-tcont this may need some adjustment.
423 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000424 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000425 ${cookieslice}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]} cookie_slice
426 #@{cookieslicelist}= Split String ${cookieslice} ,
427 ${foundcookieslices}= Get Length ${cookieslice}
428 Should Be Equal As Integers ${foundcookieslices} ${nbofcookieslice}
429 ${matchvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
430 ... match_vid
431 Should Be Equal As Integers ${matchvid} ${reqmatchvid}
432 ${setvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
433 ... set_vid
434 ${evalresult}= Evaluate 2 <= ${setvid} <= 4095
435 Should Be True ${evalresult} msg=set_vid out of range (${setvid})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000436 Set To Dictionary ${vlan_rules} ${oltpononuuniid} ${setvid}
TorstenThieme52ef8392020-11-10 13:42:26 +0000437 ${oldsetvidvalid} Set Variable If ${prevvlanrules} is ${NONE} False True
TorstenThiemefe7099e2021-01-29 08:41:04 +0000438 ${prevsetvid}= Set Variable If ${oldsetvidvalid} ${prevvlanrules['${oltpononuuniid}']}
TorstenThieme52ef8392020-11-10 13:42:26 +0000439 Run Keyword If ${oldsetvidvalid} and ${setvidequal}
440 ... Should Be Equal As Integers ${prevsetvid} ${setvid}
441 ... ELSE IF ${oldsetvidvalid} and not ${setvidequal}
442 ... Should Not Be Equal As Integers ${prevsetvid} ${setvid}
443 END
TorstenThieme440b7c02020-12-18 15:42:57 +0000444 log Many ${vlan_rules}
TorstenThieme52ef8392020-11-10 13:42:26 +0000445 [Return] ${vlan_rules}
446
447Get ONU Go Adapter ETCD Data
448 [Documentation] This keyword delivers openonu-go-adapter Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000449 [Arguments] ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True
450 ... ${without_pm_data}=True
TorstenThieme52ef8392020-11-10 13:42:26 +0000451 ${podname}= Set Variable etcd
TorstenThieme3385cdc2021-02-04 13:50:50 +0000452 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
TorstenThieme3af12312021-03-10 16:15:24 +0000453 ${commandget}= Catenate
454 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/openonu'
455 ${commandget}= Run Keyword If ${without_prefix} Catenate ${commandget}
456 ... | grep -v service/${kvstoreprefix}/openonu
TorstenThiemefa29a892021-03-11 14:11:29 +0000457 ... ELSE Set Variable ${commandget}
TorstenThieme3af12312021-03-10 16:15:24 +0000458 ${commandget}= Run Keyword If ${without_pm_data} Catenate ${commandget} | grep -v instances_active
TorstenThiemefa29a892021-03-11 14:11:29 +0000459 ... ELSE Set Variable ${commandget}
Holger Hildebrandt23147742020-11-16 10:13:21 +0000460 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThieme52ef8392020-11-10 13:42:26 +0000461 log ${result}
462 [Return] ${result}
463
464Prepare ONU Go Adapter ETCD Data For Json
465 [Documentation] This keyword prepares openonu-go-adapter Data stored in etcd for converting
466 ... to json
467 [Arguments] ${etcddata}
468 #prepare result for json convert
469 ${prepresult}= Replace String ${etcddata} \n ,
470 ${prepresult}= Strip String ${prepresult} mode=right characters=,
471 ${prepresult}= Set Variable [${prepresult}]
472 log ${prepresult}
473 [Return] ${prepresult}
474
TorstenThieme52ef8392020-11-10 13:42:26 +0000475Read Pon Onu Uni String
TorstenThiemefe7099e2021-01-29 08:41:04 +0000476 [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 +0000477 ... taken from etcd data of onu go adapter
478 [Arguments] ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000479 ${tppathlines}= Replace String ${tp_path} / \n
TorstenThiemefe7099e2021-01-29 08:41:04 +0000480 ${olt}= Get Value Of Tp Path Element ${tppathlines} olt
TorstenThieme52ef8392020-11-10 13:42:26 +0000481 ${pon}= Get Value Of Tp Path Element ${tppathlines} pon
482 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
483 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
TorstenThiemefe7099e2021-01-29 08:41:04 +0000484 ${valuesid}= Set Variable ${olt}/${pon}/${onu}/${uni}
TorstenThieme52ef8392020-11-10 13:42:26 +0000485 log ${valuesid}
486 [Return] ${valuesid}
487
488Get Value Of Tp Path Element
TorstenThieme17756ea2020-11-11 14:09:47 +0000489 [Documentation] This keyword delivers numeric value of given tp path element.
TorstenThieme52ef8392020-11-10 13:42:26 +0000490 [Arguments] ${tp_path_lines} ${element}
491 ${value}= Get Lines Containing String ${tp_path_lines} ${element}-\{
492 ${value}= Remove String ${value} ${element}-\{
493 ${value}= Remove String ${value} \}
494 log ${value}
495 [Return] ${value}
496
TorstenThieme17756ea2020-11-11 14:09:47 +0000497Validate Onu Id
498 [Documentation] This keyword validates ONU Id of passed etcd data.
499 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800500 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
501 # When testing multi-tcont this may need some adjustment.
502 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000503 ${tppathlines}= Replace String ${tp_path} / \n
504 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
505 ${onu_id}= Get From Dictionary ${value} onu_id
506 Should Be Equal As Integers ${onu} ${onu_id}
507 ... msg=Onu-Id (${onu_id}) does not match onu (${onu}) from tp_path in etcd data!
508 Should Be True ${onu_id}>=1
509
510Validate Uni Id
511 [Documentation] This keyword validates UNI Id of passed etcd data.
512 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800513 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
514 # When testing multi-tcont this may need some adjustment.
515 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000516 ${tppathlines}= Replace String ${tp_path} / \n
517 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
518 ${uni_id}= Get From Dictionary ${value['uni_config'][0]} uni_id
519 Should Be Equal As Integers ${uni} ${uni_id}
520 ... msg=Uni-Id (${uni_id}) does not match onu (${uni}) from tp_path in etcd data!
TorstenThieme52ef8392020-11-10 13:42:26 +0000521
TorstenThieme45071602021-03-16 12:14:37 +0000522Delete ONU Go Adapter ETCD Data
523 [Documentation] This keyword deletes openonu-go-adapter Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000524 [Arguments] ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha ${validate}=False
TorstenThieme45071602021-03-16 12:14:37 +0000525 ${podname}= Set Variable etcd
526 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
527 ${commandget}= Catenate
528 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/${kvstoreprefix}/openonu'
529 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
530 log ${result}
531 Run Keyword If ${validate} Wait Until Keyword Succeeds ${timeout} 1s
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000532 ... Validate Onu Data In Etcd namespace=${namespace} nbofetcddata=0 without_pm_data=False
TorstenThieme45071602021-03-16 12:14:37 +0000533 [Return] ${result}
534
TorstenThiemed4f48962020-12-08 12:17:19 +0000535Wait for Ports in ONOS for all OLTs
TorstenThieme440b7c02020-12-18 15:42:57 +0000536 [Documentation] Waits untill a certain number of ports are enabled in all OLTs
TorstenThieme731a7592021-07-01 14:26:54 +0000537 [Arguments] ${host} ${port} ${count} ${filter} ${max_wait_time}=10m ${determine_number}=False
TorstenThiemed4f48962020-12-08 12:17:19 +0000538 FOR ${J} IN RANGE 0 ${num_olts}
539 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
540 ${onu_count}= Set Variable ${list_olts}[${J}][onucount]
541 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
542 ... ${olt_serial_number}
543 Set Global Variable ${of_id}
TorstenThiemeff9c9142021-04-08 07:21:34 +0000544 ${count2check}= Set Variable If ${count}==${num_all_onus} ${onu_count} ${count}
545 # if flag determine_number is set to True, always determine the number of real ONUs (overwrite previous value)
546 ${count2check}= Run Keyword If ${determine_number} Determine Number Of ONU ${olt_serial_number}
547 ... ELSE Set Variable ${count2check}
TorstenThieme731a7592021-07-01 14:26:54 +0000548 Wait for Ports in ONOS ${host} ${port} ${count2check} ${of_id} BBSM ${max_wait_time}
TorstenThiemed4f48962020-12-08 12:17:19 +0000549 END
550
TorstenThieme440b7c02020-12-18 15:42:57 +0000551Wait for all ONU Ports in ONOS Disabled
552 [Documentation] Waits untill a all ONU ports are disabled in all ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000553 [Arguments] ${host} ${port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000554 FOR ${I} IN RANGE 0 ${num_all_onus}
555 ${src}= Set Variable ${hosts.src[${I}]}
556 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
557 ... ${src['olt']}
558 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']} ${of_id}
TorstenThieme731a7592021-07-01 14:26:54 +0000559 Wait Until Keyword Succeeds ${timeout} 2s Assert ONU Port Is Disabled ${host} ${port} ${of_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000560 ... ${onu_port}
561 END
562
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000563Map State
564 [Documentation] This keyword converts the passed numeric value or name of a onu state to its state values.
565 [Arguments] ${state}
566 # create state lists with corresponding return values
567 # ADMIN-STATE OPER-STATUS CONNECT-STATUS ONU-STATE (number/name)
568 ${state1} Create List ENABLED ACTIVATING REACHABLE 1 activating-onu
569 ${state2} Create List ENABLED ACTIVATING REACHABLE 2 starting-openomci
570 ${state3} Create List ENABLED ACTIVATING REACHABLE 3 discovery-mibsync-complete
571 ${state4} Create List ENABLED ACTIVE REACHABLE 4 initial-mib-downloaded
572 ${state5} Create List ENABLED ACTIVE REACHABLE 5 tech-profile-config-download-success
573 ${state6} Create List ENABLED ACTIVE REACHABLE 6 omci-flows-pushed
574 ${state7} Create List DISABLED UNKNOWN REACHABLE 7 omci-admin-lock
575 ${state8} Create List ENABLED ACTIVE REACHABLE 8 onu-reenabled
576 ${state9} Create List ENABLED DISCOVERED UNREACHABLE 9 stopping-openomci
577 ${state10} Create List ENABLED DISCOVERED REACHABLE 10 rebooting
578 ${state11} Create List ENABLED DISCOVERED REACHABLE 11 omci-flows-deleted
579 ${state12} Create List DISABLED UNKNOWN REACHABLE 12 tech-profile-config-delete-success
580 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Set Variable If
581 ... '${state}'=='1' or '${state}'=='activating-onu' ${state1}
582 ... '${state}'=='2' or '${state}'=='starting-openomci' ${state2}
583 ... '${state}'=='3' or '${state}'=='discovery-mibsync-complete' ${state3}
584 ... '${state}'=='4' or '${state}'=='initial-mib-downloaded' ${state4}
585 ... '${state}'=='5' or '${state}'=='tech-profile-config-download-success' ${state5}
586 ... '${state}'=='6' or '${state}'=='omci-flows-pushed' ${state6}
587 ... '${state}'=='7' or '${state}'=='omci-admin-lock' ${state7}
588 ... '${state}'=='8' or '${state}'=='onu-reenabled' ${state8}
589 ... '${state}'=='9' or '${state}'=='stopping-openomci' ${state9}
590 ... '${state}'=='10' or '${state}'=='rebooting' ${state10}
591 ... '${state}'=='11' or '${state}'=='omci-flows-deleted' ${state11}
592 ... '${state}'=='12' or '${state}'=='tech-profile-config-delete-success' ${state12}
593 [Return] ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}