blob: 43098990277c5f6cb91341a7a743294d10ef842a [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
TorstenThieme712b2962021-11-17 14:16:15 +0000119 [Arguments] ${namespace} ${usekill2restart} ${oper_status} ${olt_to_be_deleted_sn}=${EMPTY}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000120 ... ${flow_delete_params}=&{EMPTY}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000121 # get time of restart of openonu adapter
122 ${restart_ts}= Get Current Date
123 # restart OpenONU adapter
124 Run Keyword If ${usekill2restart} Kill And Check Onu Adaptor ${namespace}
125 ... ELSE Restart And Check Onu Adaptor ${namespace}
126 #check ready timestamp of openonu adapter, should be younger than restart timestamp
127 ${openonu_ready_ts}= Get Pod Ready Timestamp by Label ${namespace} app adapter-open-onu
128 ${restart_duration}= Subtract Date From Date ${openonu_ready_ts} ${restart_ts}
129 Should Be True ${restart_duration}>0
TorstenThieme712b2962021-11-17 14:16:15 +0000130 # delete the olt passed, if available (special feature)
131 ${olt_to_be_deleted_device_id}= Run Keyword IF "${olt_to_be_deleted_sn}"!="${EMPTY}"
132 ... Get OLTDeviceID From OLT List ${olt_to_be_deleted_sn}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000133 Run Keyword If "${olt_to_be_deleted_sn}"!="${EMPTY}" Delete Device ${olt_to_be_deleted_device_id}
134 # remove flows if params passed for it (special feature II)
135 Run Keyword If ${flow_delete_params}!=&{EMPTY} Wait Until Keyword Succeeds ${timeout} 2s
136 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
137 ... volt-remove-subscriber-access ${flow_delete_params['of_id']} ${flow_delete_params['onu_port']}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700138 # wait for the reconcile to complete
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000139 # - we check that communication to openonu-adapter is established again
140 # - we check that all ONUs leave reconcile state by validate a simple voltctl request will not responds with error
141 Wait Until Keyword Succeeds ${timeout} 1s Validate Last ONU Communication
TorstenThieme712b2962021-11-17 14:16:15 +0000142 Wait Until Keyword Succeeds ${timeout} 1s Validate All Onus Accessible ${olt_to_be_deleted_sn}
143 # - 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 +0000144 ${list_onus} Create List
TorstenThieme712b2962021-11-17 14:16:15 +0000145 FOR ${J} IN RANGE 0 ${num_olts}
146 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
147 Continue For Loop If "${olt_to_be_deleted_sn}"=="${olt_serial_number}"
148 Build ONU SN List ${list_onus} ${olt_serial_number}
149 END
150 Log ${list_onus}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000151 Run Keyword And Ignore Error Wait Until Keyword Succeeds ${timeout}
152 ... 1s Check all ONU OperStatus ${list_onus} ${oper_status}
153
TorstenThiemee512b1d2021-11-12 10:52:29 +0000154Validate All Onus Accessible
155 [Documentation] This keyword checks all onus accessible (again) with help of a simple voltctl request.
156 ... As long we've got an rc!=0 keyword will fail -> onu is not accessible.
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000157 ... As get request Onu image list is used, any other get command could be used for this check.
TorstenThieme712b2962021-11-17 14:16:15 +0000158 ... Will not check ONUs of passed deleted OLT (special feature)
159 [Arguments] ${deleted_olt}=${EMPTY}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700160 ${onu_list} Create List
161 FOR ${I} IN RANGE 0 ${num_all_onus}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000162 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThieme712b2962021-11-17 14:16:15 +0000163 ${olt_serial_number}= Set Variable ${src['olt']}
164 Continue For Loop If "${deleted_olt}"=="${olt_serial_number}"
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000165 ${onu_device_id}= Get Device ID From SN ${src['onu']}
166 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700167 Continue For Loop If -1 != ${onu_id}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000168 Append To List ${onu_list} ${onu_device_id}
169 ${rc} ${output}= Get Onu Image List ${onu_device_id}
TorstenThieme712b2962021-11-17 14:16:15 +0000170 Should Be True ${rc}==0 Onu ${src['onu']} (${onu_device_id}) still not accessible.
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700171 END
172
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000173Log Ports
174 [Documentation] This keyword logs all port data available in ONOS of first port per ONU
175 [Arguments] ${onlyenabled}=False
176 ${cmd} Set Variable If ${onlyenabled} ports -e ports
TorstenThieme731a7592021-07-01 14:26:54 +0000177 ${onu_ports}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${cmd}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000178 ${lines} = Get Lines Matching Regexp ${onu_ports} .*portName=BBSM[0-9]{8}-1
179 Log ${lines}
180
181Kill Adaptor
182 [Documentation] This keyword kills the passed adaptor.
183 [Arguments] ${namespace} ${name}
184 ${cmd} Catenate
Matteo Scandolo6b524122021-10-22 14:34:29 -0700185 ... kubectl exec -it -n ${namespace} $(kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}')
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000186 ... -- /bin/sh -c "kill 1"
187 ${rc} ${output}= Run and Return Rc and Output ${cmd}
188 Log ${output}
189
TorstenThieme440b7c02020-12-18 15:42:57 +0000190Kill And Check Onu Adaptor
191 [Documentation] This keyword kills ONU Adaptor and waits for it to come up again
192 ... Following steps will be executed:
193 ... - kill openonu adaptor
194 ... - check openonu adaptor is ready again
195 [Arguments] ${namespace}
196 ${list_openonu_apps} Create List adapter-open-onu
197 ${adaptorname}= Set Variable open-onu
198 Kill Adaptor ${namespace} ${adaptorname}
199 Sleep 5s
200 Wait For Pods Ready ${namespace} ${list_openonu_apps}
201
202Restart And Check Onu Adaptor
203 [Documentation] This keyword restarts ONU Adaptor and waits for it to come up again
204 ... Following steps will be executed:
205 ... - restart openonu adaptor
206 ... - check openonu adaptor is ready again
207 [Arguments] ${namespace}
208 ${list_openonu_apps} Create List adapter-open-onu
Matteo Scandolo6f24ea92021-04-29 11:55:50 -0700209 ${openonu_label_key} Set Variable app
210 ${openonu_label_value} Set Variable adapter-open-onu
211 Restart Pod By Label ${namespace} ${openonu_label_key} ${openonu_label_value}
TorstenThieme440b7c02020-12-18 15:42:57 +0000212 Sleep 5s
213 Wait For Pods Ready ${namespace} ${list_openonu_apps}
214
215Disable Onu Device
216 [Documentation] This keyword disables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000217 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000218 FOR ${I} IN RANGE 0 ${num_all_onus}
219 ${src}= Set Variable ${hosts.src[${I}]}
220 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000221 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
222 Continue For Loop If -1 != ${onu_id}
223 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000224 Disable Device ${onu_device_id}
225 Wait Until Keyword Succeeds 20s 2s Test Devices Disabled in VOLTHA Id=${onu_device_id}
226 END
227
228Enable Onu Device
229 [Documentation] This keyword enables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000230 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000231 FOR ${I} IN RANGE 0 ${num_all_onus}
232 ${src}= Set Variable ${hosts.src[${I}]}
233 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000234 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
235 Continue For Loop If -1 != ${onu_id}
236 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000237 Enable Device ${onu_device_id}
238 END
239
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000240Verify MIB Template Data Available
241 [Documentation] This keyword verifies MIB Template Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000242 [Arguments] ${namespace}=default
TorstenThiemed4f48962020-12-08 12:17:19 +0000243 ${podname}= Set Variable etcd
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000244 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800245 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000246 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000247 Should Not Be Empty ${result} No MIB Template Data stored in etcd!
248
249Delete MIB Template Data
250 [Documentation] This keyword deletes MIB Template Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000251 [Arguments] ${namespace}=default
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000252 ${podname}= Set Variable etcd
253 ${commanddel} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800254 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000255 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commanddel}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000256 Sleep 3s
257 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800258 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000259 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000260 Should Be Empty ${result} Could not delete MIB Template Data stored in etcd!
261
TorstenThieme440b7c02020-12-18 15:42:57 +0000262Set Tech Profile
263 [Documentation] This keyword sets the passed TechProfile for the test
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000264 [Arguments] ${TechProfile} ${namespace}=default
TorstenThieme440b7c02020-12-18 15:42:57 +0000265 Log To Console \nTechProfile:${TechProfile}
TorstenThieme440b7c02020-12-18 15:42:57 +0000266 ${podname}= Set Variable etcd
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200267 ${label}= Set Variable app.kubernetes.io/name=${podname}
TorstenThieme440b7c02020-12-18 15:42:57 +0000268 ${src}= Set Variable ${data_dir}/TechProfile-${TechProfile}.json
269 ${dest}= Set Variable /tmp/flexpod.json
270 ${command} Catenate
271 ... /bin/sh -c 'cat ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64'
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200272 Copy File To Pod ${namespace} ${label} ${src} ${dest}
TorstenThieme440b7c02020-12-18 15:42:57 +0000273 Exec Pod In Kube ${namespace} ${podname} ${command}
274 ${commandget} Catenate
275 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200276 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
277 Should Not Be Empty ${result} No Tech Profile stored in etcd!
TorstenThieme440b7c02020-12-18 15:42:57 +0000278
279Remove Tech Profile
280 [Documentation] This keyword removes TechProfile
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000281 [Arguments] ${namespace}=default
TorstenThieme440b7c02020-12-18 15:42:57 +0000282 Log To Console \nTechProfile:${TechProfile}
TorstenThieme440b7c02020-12-18 15:42:57 +0000283 ${podname}= Set Variable etcd
284 ${command} Catenate
285 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/64'
286 Exec Pod In Kube ${namespace} ${podname} ${command}
287 ${commandget} Catenate
288 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
289 Exec Pod In Kube ${namespace} ${podname} ${commandget}
290
TorstenThiemea7315f12021-07-23 11:56:34 +0000291Do Onu Subscriber Add Per OLT
292 [Documentation] Add Subscriber per OLT
293 [Arguments] ${of_id} ${olt_serial_number} ${print2console}=False
294 FOR ${I} IN RANGE 0 ${num_all_onus}
295 ${src}= Set Variable ${hosts.src[${I}]}
296 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
297 ${onu_device_id}= Get Device ID From SN ${src['onu']}
298 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
299 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
300 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
301 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
302 ... volt-add-subscriber-access ${of_id} ${onu_port}
303 Run Keyword If ${print2console} Log \r\n[${I}] volt-add-subscriber-access ${of_id} ${onu_port}.
304 ... console=yes
305 END
306
307Do Onu Flow Check Per OLT
308 [Documentation] Checks all ONU flows show up in ONOS and Voltha
309 [Arguments] ${of_id} ${nni_port} ${olt_serial_number} ${print2console}=False
310 FOR ${I} IN RANGE 0 ${num_all_onus}
311 ${src}= Set Variable ${hosts.src[${I}]}
312 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
313 ${onu_device_id}= Get Device ID From SN ${src['onu']}
314 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
315 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
316 # Verify subscriber access flows are added for the ONU port
317 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
318 ... Verify Subscriber Access Flows Added For ONU ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${of_id}
319 ... ${onu_port} ${nni_port} ${src['c_tag']} ${src['s_tag']}
320 ${logoutput} Catenate \r\n[${I}] Verify Subscriber Access Flows Added For
321 ... ONU ${of_id} ${onu_port} ${src['c_tag']} ${src['s_tag']}.
322 Run Keyword If ${print2console} Log ${logoutput} console=yes
323 END
324
325Do Onu Subscriber Remove Per OLT
326 [Documentation] Removes per OLT subscribers in ONOS and Voltha
327 [Arguments] ${of_id} ${olt_serial_number} ${print2console}=False
328 FOR ${I} IN RANGE 0 ${num_all_onus}
329 ${src}= Set Variable ${hosts.src[${I}]}
330 ${dst}= Set Variable ${hosts.dst[${I}]}
331 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
332 ${onu_device_id}= Get Device ID From SN ${src['onu']}
333 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
334 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
335 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
336 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
337 ... volt-remove-subscriber-access ${of_id} ${onu_port}
338 Run Keyword If ${print2console} Log \r\n[${I}] volt-remove-subscriber-access ${of_id} ${onu_port}.
339 ... console=yes
340 END
341
TorstenThieme7c397d72021-07-14 11:51:09 +0000342Validate Resource Instances Used Gem Ports
343 [Documentation] This keyword validates resource instances data stored in etcd.
344 ... It checks checks the number of gemport-ids which has matched with used Tech Profile
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000345 [Arguments] ${nbofgemports} ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha
TorstenThieme7c397d72021-07-14 11:51:09 +0000346 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000347 ${etcddata}= Get ONU Go Adapter ETCD Data namespace=${namespace} defaultkvstoreprefix=${kvstoreprefix}
TorstenThieme7c397d72021-07-14 11:51:09 +0000348 #prepare result for json convert
349 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
350 ${jsondata}= To Json ${result}
351 ${length}= Get Length ${jsondata}
352 log ${jsondata}
353 FOR ${INDEX} IN RANGE 0 ${length}
354 ${value}= Get From List ${jsondata} ${INDEX}
355 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
356 # When testing multi-tcont this may need some adjustment.
357 Exit For Loop If not ('uni_config' in $value)
358 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000359 ${resourcedata}= Get Resource Instances ETCD Data ${tp_path} namespace=${namespace}
360 ... defaultkvstoreprefix=${kvstoreprefix}
TorstenThieme7c397d72021-07-14 11:51:09 +0000361 log ${resourcedata}
362 ${decoderesult}= volthatools.Tech Profile Decode Resource Instance ${resourcedata} return_default=true
363 log ${decoderesult}
364 ${gemportids}= Get From Dictionary ${decoderesult} gemport_ids
365 ${length}= Get Length ${gemportids}
366 Should Be Equal As Integers ${nbofgemports} ${length}
367 ... msg=Number of gem ports (${length}) does not match with techprofile ${techprofile}/${nbofgemports}
368 END
369
370Get Resource Instances ETCD Data
371 [Documentation] This keyword delivers Resource Instances Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000372 [Arguments] ${tppath} ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha
TorstenThieme7c397d72021-07-14 11:51:09 +0000373 ${podname}= Set Variable etcd
374 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
375 ${commandget}= Catenate
376 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/resource_instances/${tppath}
377 ... --print-value-only --hex'
378 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
379 log ${result}
380 [Return] ${result}
381
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000382Validate Tech Profiles and Flows in ETCD Data Per Onu
383 [Documentation] This keyword validates tech profiles and flows data stored in etcd per onu.
384 ... It checks checks presence/absence of tech profiles and flows depending on must_exist.
385 ... The values/content of tech profiles and flows will be not validated!
386 [Arguments] ${onu_sn} ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha ${must_exist}=True
387 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
388 ${etcddata}= Get ONU Go Adapter ETCD Data namespace=${namespace} defaultkvstoreprefix=${kvstoreprefix}
389 #prepare result for json convert
390 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
391 ${jsondata}= To Json ${result}
392 ${length}= Get Length ${jsondata}
393 log ${jsondata}
394 ${matched}= Set Variable False
395 FOR ${INDEX} IN RANGE 0 ${length}
396 ${value}= Get From List ${jsondata} ${INDEX}
397 ${uni_config}= Get From Dictionary ${value} uni_config
398 ${uni_config}= Set Variable ${uni_config[0]}
399 ${sn}= Get From Dictionary ${value} serial_number
400 ${matched}= Set Variable If '${sn}'=='${onu_sn}' True False
401 Exit For Loop If ${matched}
402 END
403 Should Be True ${matched} No ETCD data found for ONU ${onu_sn}
404 Log ${uni_config}
405 ${tp_path}= Get From Dictionary ${uni_config} PersTpPathMap
406 Log ${tp_path}
407 ${flow_params}= Get From Dictionary ${uni_config} flow_params
408 Log ${flow_params}
409 # in case of ATT for ONU with removed flows there is default flow established
410 ${length}= Get Length ${flow_params}
411 ${cookieslice}= Run Keyword If ${length}>0 Run Keyword If 'cookie_slice' in ${flow_params[0]}
412 ... Get From Dictionary ${flow_params[0]} cookie_slice
413 ${setvid}= Run Keyword If ${length}>0 Run Keyword If 'set_vid' in ${flow_params[0]['vlan_rule_params']}
414 ... Get From Dictionary ${flow_params[0]['vlan_rule_params']} set_vid
415 ${cookie_slice_length}= Run Keyword If ${length}>0 Run Keyword If 'cookie_slice' in ${flow_params[0]}
416 ... Get Length ${cookieslice}
417 Run Keyword If "${workflow}"=="ATT" and not ${must_exist} Run Keywords
418 ... Should Be Equal As Numbers ${setvid} 4091 AND
419 ... Should Be Equal As Numbers ${cookie_slice_length} 1 AND
420 ... Should Not Be Empty ${tp_path} AND
421 ... Return From Keyword
422 ${tp_path_length}= Get Length ${tp_path}
423 # validate tp_path is not Empty for case must_exist, case not must_exist will be validated implicitly with FOR loop
424 Run Keyword If ${must_exist} Should Not Be Empty ${tp_path}
425 ${tp_path_keys}= Run Keyword If ${tp_path_length}==0 Create List
426 ... ELSE Get Dictionary Keys ${tp_path}
427 ${tp_path_values}= Run Keyword If ${tp_path_length}==0 Create List
428 ... ELSE Get Dictionary Values ${tp_path}
429 ${tp_path_empty}= Set Variable True
430 Log ${tp_path_values}
431 Log ${tp_path_keys}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000432 # In case of not empty tp_path each value will be checked depending on must_exist
433 FOR ${key} IN @{tp_path_keys}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000434 ${value}= Get From Dictionary ${tp_path} ${key}
435 Run Keyword If ${must_exist} Should Not Be Empty ${value}
436 ... ELSE Should Be Empty ${value}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000437 END
438 Run Keyword If ${must_exist} Should Not Be Empty ${flow_params}
439 ... ELSE Should Be Empty ${flow_params}
TorstenThieme7c397d72021-07-14 11:51:09 +0000440
TorstenThieme17756ea2020-11-11 14:09:47 +0000441Validate Onu Data In Etcd
442 [Documentation] This keyword validates openonu-go-adapter Data stored in etcd.
443 ... It checks unique of serial_number and combination of pon, onu and uni in tp_path.
444 ... Furthermore it evaluates the values of onu_id and uni_id with values read from tp_path.
445 ... Number of etcd entries has to match with the passed number.
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000446 [Arguments] ${namespace}=default ${nbofetcddata}=${num_all_onus} ${defaultkvstoreprefix}=voltha_voltha
TorstenThiemefa29a892021-03-11 14:11:29 +0000447 ... ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000448 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000449 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme17756ea2020-11-11 14:09:47 +0000450 #prepare result for json convert
451 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
452 ${jsondata}= To Json ${result}
453 ${length}= Get Length ${jsondata}
454 log ${jsondata}
455 Run Keyword And Continue On Failure Should Be Equal As Integers ${length} ${nbofetcddata}
456 ... msg=Number etcd data (${length}) does not match required (${nbofetcddata})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000457 ${oltpononuuniidlist}= Create List
TorstenThieme17756ea2020-11-11 14:09:47 +0000458 ${serialnumberlist}= Create List
459 FOR ${INDEX} IN RANGE 0 ${length}
460 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra97f8d062020-11-17 15:48:23 -0800461 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
462 # When testing multi-tcont this may need some adjustment.
TorstenThieme45071602021-03-16 12:14:37 +0000463 Exit For Loop If not ('uni_config' in $value)
Girish Gowdra97f8d062020-11-17 15:48:23 -0800464 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000465 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
466 ${list_id}= Get Index From List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000467 Should Be Equal As Integers ${list_id} -1
TorstenThiemefe7099e2021-01-29 08:41:04 +0000468 ... msg=Combination of Pon, Onu and Uni (${oltpononuuniid}) exist multiple in etcd data!
469 Append To List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000470 Validate Onu Id ${value}
471 Validate Uni Id ${value}
472 ${serial_number}= Get From Dictionary ${value} serial_number
473 ${list_id}= Get Index From List ${serialnumberlist} ${serial_number}
474 Should Be Equal As Integers ${list_id} -1
475 ... msg=Serial number (${serial_number}) exists multiple in etcd data!
476 Append To List ${serialnumberlist} ${serial_number}
477 END
478
TorstenThieme712b2962021-11-17 14:16:15 +0000479Validate Onu Data In Etcd Removed
480 [Documentation] This keyword validates openonu-go-adapter Data stored in etcd are removed.
481 ... In case of a device is passed, only this will be checked.
482 [Arguments] ${namespace}=default ${device_id}=${EMPTY} ${defaultkvstoreprefix}=voltha_voltha
483 ... ${without_pm_data}=True
484 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
485 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} False ${without_pm_data}
486 ... ${device_id} True
487 Log ${etcddata}
488 Should Be Empty ${etcddata} Stale Openonu Data in Etcd (KV store) ${device_id}
489
TorstenThieme52ef8392020-11-10 13:42:26 +0000490Validate Vlan Rules In Etcd
491 [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd.
492 ... It checks the given number of cookie_slice, match_vid (=4096) and set_vid.
493 ... Furthermore it returns a list of all set_vid.
494 ... In case of a passed dictionary containing set_vids these will be checked for to
495 ... current set-vid depending on setvidequal (True=equal, False=not equal).
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000496 [Arguments] ${namespace}=default ${nbofcookieslice}=1 ${reqmatchvid}=4096 ${prevvlanrules}=${NONE}
497 ... ${setvidequal}=False ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000498 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000499 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme52ef8392020-11-10 13:42:26 +0000500 #prepare result for json convert
501 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
502 ${jsondata}= To Json ${result}
503 ${length}= Get Length ${jsondata}
504 log ${jsondata}
505 ${vlan_rules}= Create Dictionary
506 FOR ${INDEX} IN RANGE 0 ${length}
507 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra295c1692020-11-19 10:51:53 -0800508 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
509 # When testing multi-tcont this may need some adjustment.
510 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000511 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000512 ${cookieslice}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]} cookie_slice
513 #@{cookieslicelist}= Split String ${cookieslice} ,
514 ${foundcookieslices}= Get Length ${cookieslice}
515 Should Be Equal As Integers ${foundcookieslices} ${nbofcookieslice}
516 ${matchvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
517 ... match_vid
518 Should Be Equal As Integers ${matchvid} ${reqmatchvid}
519 ${setvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
520 ... set_vid
521 ${evalresult}= Evaluate 2 <= ${setvid} <= 4095
522 Should Be True ${evalresult} msg=set_vid out of range (${setvid})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000523 Set To Dictionary ${vlan_rules} ${oltpononuuniid} ${setvid}
TorstenThieme52ef8392020-11-10 13:42:26 +0000524 ${oldsetvidvalid} Set Variable If ${prevvlanrules} is ${NONE} False True
TorstenThiemefe7099e2021-01-29 08:41:04 +0000525 ${prevsetvid}= Set Variable If ${oldsetvidvalid} ${prevvlanrules['${oltpononuuniid}']}
TorstenThieme52ef8392020-11-10 13:42:26 +0000526 Run Keyword If ${oldsetvidvalid} and ${setvidequal}
527 ... Should Be Equal As Integers ${prevsetvid} ${setvid}
528 ... ELSE IF ${oldsetvidvalid} and not ${setvidequal}
529 ... Should Not Be Equal As Integers ${prevsetvid} ${setvid}
530 END
TorstenThieme440b7c02020-12-18 15:42:57 +0000531 log Many ${vlan_rules}
TorstenThieme52ef8392020-11-10 13:42:26 +0000532 [Return] ${vlan_rules}
533
534Get ONU Go Adapter ETCD Data
535 [Documentation] This keyword delivers openonu-go-adapter Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000536 [Arguments] ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True
TorstenThieme712b2962021-11-17 14:16:15 +0000537 ... ${without_pm_data}=True ${device_id}=${Empty} ${keys_only}=False
TorstenThieme52ef8392020-11-10 13:42:26 +0000538 ${podname}= Set Variable etcd
TorstenThieme3385cdc2021-02-04 13:50:50 +0000539 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
TorstenThieme3af12312021-03-10 16:15:24 +0000540 ${commandget}= Catenate
541 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/openonu'
TorstenThieme712b2962021-11-17 14:16:15 +0000542 ${commandget}= Run Keyword If ${keys_only} Catenate ${commandget} --keys-only
543 ... ELSE Set Variable ${commandget}
TorstenThieme3af12312021-03-10 16:15:24 +0000544 ${commandget}= Run Keyword If ${without_prefix} Catenate ${commandget}
545 ... | grep -v service/${kvstoreprefix}/openonu
TorstenThiemefa29a892021-03-11 14:11:29 +0000546 ... ELSE Set Variable ${commandget}
TorstenThieme3af12312021-03-10 16:15:24 +0000547 ${commandget}= Run Keyword If ${without_pm_data} Catenate ${commandget} | grep -v instances_active
TorstenThiemefa29a892021-03-11 14:11:29 +0000548 ... ELSE Set Variable ${commandget}
TorstenThieme712b2962021-11-17 14:16:15 +0000549 ${commandget}= Run Keyword If "${device_id}"!="${Empty}" Catenate ${commandget} | grep ${device_id}
550 ... ELSE Set Variable ${commandget}
Holger Hildebrandt23147742020-11-16 10:13:21 +0000551 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThieme52ef8392020-11-10 13:42:26 +0000552 log ${result}
553 [Return] ${result}
554
555Prepare ONU Go Adapter ETCD Data For Json
556 [Documentation] This keyword prepares openonu-go-adapter Data stored in etcd for converting
557 ... to json
558 [Arguments] ${etcddata}
559 #prepare result for json convert
560 ${prepresult}= Replace String ${etcddata} \n ,
561 ${prepresult}= Strip String ${prepresult} mode=right characters=,
562 ${prepresult}= Set Variable [${prepresult}]
563 log ${prepresult}
564 [Return] ${prepresult}
565
TorstenThieme52ef8392020-11-10 13:42:26 +0000566Read Pon Onu Uni String
TorstenThiemefe7099e2021-01-29 08:41:04 +0000567 [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 +0000568 ... taken from etcd data of onu go adapter
569 [Arguments] ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000570 ${tppathlines}= Replace String ${tp_path} / \n
TorstenThiemefe7099e2021-01-29 08:41:04 +0000571 ${olt}= Get Value Of Tp Path Element ${tppathlines} olt
TorstenThieme52ef8392020-11-10 13:42:26 +0000572 ${pon}= Get Value Of Tp Path Element ${tppathlines} pon
573 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
574 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
TorstenThiemefe7099e2021-01-29 08:41:04 +0000575 ${valuesid}= Set Variable ${olt}/${pon}/${onu}/${uni}
TorstenThieme52ef8392020-11-10 13:42:26 +0000576 log ${valuesid}
577 [Return] ${valuesid}
578
579Get Value Of Tp Path Element
TorstenThieme17756ea2020-11-11 14:09:47 +0000580 [Documentation] This keyword delivers numeric value of given tp path element.
TorstenThieme52ef8392020-11-10 13:42:26 +0000581 [Arguments] ${tp_path_lines} ${element}
582 ${value}= Get Lines Containing String ${tp_path_lines} ${element}-\{
583 ${value}= Remove String ${value} ${element}-\{
584 ${value}= Remove String ${value} \}
585 log ${value}
586 [Return] ${value}
587
TorstenThieme17756ea2020-11-11 14:09:47 +0000588Validate Onu Id
589 [Documentation] This keyword validates ONU Id of passed etcd data.
590 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800591 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
592 # When testing multi-tcont this may need some adjustment.
593 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000594 ${tppathlines}= Replace String ${tp_path} / \n
595 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
596 ${onu_id}= Get From Dictionary ${value} onu_id
597 Should Be Equal As Integers ${onu} ${onu_id}
598 ... msg=Onu-Id (${onu_id}) does not match onu (${onu}) from tp_path in etcd data!
599 Should Be True ${onu_id}>=1
600
601Validate Uni Id
602 [Documentation] This keyword validates UNI Id of passed etcd data.
603 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800604 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
605 # When testing multi-tcont this may need some adjustment.
606 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000607 ${tppathlines}= Replace String ${tp_path} / \n
608 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
609 ${uni_id}= Get From Dictionary ${value['uni_config'][0]} uni_id
610 Should Be Equal As Integers ${uni} ${uni_id}
611 ... msg=Uni-Id (${uni_id}) does not match onu (${uni}) from tp_path in etcd data!
TorstenThieme52ef8392020-11-10 13:42:26 +0000612
TorstenThieme45071602021-03-16 12:14:37 +0000613Delete ONU Go Adapter ETCD Data
614 [Documentation] This keyword deletes openonu-go-adapter Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000615 [Arguments] ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha ${validate}=False
TorstenThieme45071602021-03-16 12:14:37 +0000616 ${podname}= Set Variable etcd
617 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
618 ${commandget}= Catenate
619 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/${kvstoreprefix}/openonu'
620 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
621 log ${result}
622 Run Keyword If ${validate} Wait Until Keyword Succeeds ${timeout} 1s
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000623 ... Validate Onu Data In Etcd namespace=${namespace} nbofetcddata=0 without_pm_data=False
TorstenThieme45071602021-03-16 12:14:37 +0000624 [Return] ${result}
625
TorstenThiemed6492882021-12-16 08:10:02 +0000626Validate ONOS Flows per OLT
627 [Documentation] This keyword validates onos flows per olt
628 [Arguments] ${olt_sn} ${expected_flows}
629 ${olt_of_id} Validate OLT Device in ONOS ${olt_sn}
630 ${flows}= Count flows ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${olt_of_id} added
631 Log Found added ${flows} of ${expected_flows} expected flows on device ${olt_sn}
632 Should Be Equal As Integers ${expected_flows} ${flows}
633
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000634Validate OLT Flows Per Onu
635 [Documentation] This keyword validates olt flows per onu
636 ... It checks checks presence/absence of olt flows depending on must_exist.
637 ... The values/content of olt flows will be not validated!
638 [Arguments] ${onu_device_id} ${must_exist}
639 ${rc} ${output}= Run and Return Rc and Output
640 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${onu_device_id} -m 8MB -o json
641 Should Be Equal As Integers ${rc} 0
642 ${jsondata}= To Json ${output}
643 Log ${jsondata}
644 # in case of ATT for ONU with removed flows there is default flow established
645 ${length}= Get Length ${jsondata}
646 ${value}= Run Keyword If ${length}>0 Get From List ${jsondata} 0
647 ${setvid}= Run Keyword If ${length}>0 Run Keyword If 'setvlanid' in ${value}
648 ... Get From Dictionary ${value} setvlanid
649 Run Keyword If "${workflow}"=="ATT" and not ${must_exist} Run Keywords
650 ... Should Be Equal As Numbers ${setvid} 4091 AND
651 ... Should Be Equal As Numbers ${length} 1 AND
652 ... Return From Keyword
653 Run Keyword If ${must_exist} Should Not Be Empty ${jsondata}
654 ... ELSE Should Be Empty ${jsondata}
655
TorstenThiemed4f48962020-12-08 12:17:19 +0000656Wait for Ports in ONOS for all OLTs
TorstenThieme440b7c02020-12-18 15:42:57 +0000657 [Documentation] Waits untill a certain number of ports are enabled in all OLTs
TorstenThieme731a7592021-07-01 14:26:54 +0000658 [Arguments] ${host} ${port} ${count} ${filter} ${max_wait_time}=10m ${determine_number}=False
TorstenThiemed4f48962020-12-08 12:17:19 +0000659 FOR ${J} IN RANGE 0 ${num_olts}
660 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
661 ${onu_count}= Set Variable ${list_olts}[${J}][onucount]
662 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
663 ... ${olt_serial_number}
664 Set Global Variable ${of_id}
TorstenThiemeff9c9142021-04-08 07:21:34 +0000665 ${count2check}= Set Variable If ${count}==${num_all_onus} ${onu_count} ${count}
666 # if flag determine_number is set to True, always determine the number of real ONUs (overwrite previous value)
667 ${count2check}= Run Keyword If ${determine_number} Determine Number Of ONU ${olt_serial_number}
668 ... ELSE Set Variable ${count2check}
TorstenThieme731a7592021-07-01 14:26:54 +0000669 Wait for Ports in ONOS ${host} ${port} ${count2check} ${of_id} BBSM ${max_wait_time}
TorstenThiemed4f48962020-12-08 12:17:19 +0000670 END
671
TorstenThieme440b7c02020-12-18 15:42:57 +0000672Wait for all ONU Ports in ONOS Disabled
673 [Documentation] Waits untill a all ONU ports are disabled in all ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000674 [Arguments] ${host} ${port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000675 FOR ${I} IN RANGE 0 ${num_all_onus}
676 ${src}= Set Variable ${hosts.src[${I}]}
677 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
678 ... ${src['olt']}
679 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']} ${of_id}
TorstenThieme731a7592021-07-01 14:26:54 +0000680 Wait Until Keyword Succeeds ${timeout} 2s Assert ONU Port Is Disabled ${host} ${port} ${of_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000681 ... ${onu_port}
682 END
683
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000684Map State
685 [Documentation] This keyword converts the passed numeric value or name of a onu state to its state values.
686 [Arguments] ${state}
687 # create state lists with corresponding return values
688 # ADMIN-STATE OPER-STATUS CONNECT-STATUS ONU-STATE (number/name)
689 ${state1} Create List ENABLED ACTIVATING REACHABLE 1 activating-onu
690 ${state2} Create List ENABLED ACTIVATING REACHABLE 2 starting-openomci
691 ${state3} Create List ENABLED ACTIVATING REACHABLE 3 discovery-mibsync-complete
692 ${state4} Create List ENABLED ACTIVE REACHABLE 4 initial-mib-downloaded
693 ${state5} Create List ENABLED ACTIVE REACHABLE 5 tech-profile-config-download-success
694 ${state6} Create List ENABLED ACTIVE REACHABLE 6 omci-flows-pushed
695 ${state7} Create List DISABLED UNKNOWN REACHABLE 7 omci-admin-lock
696 ${state8} Create List ENABLED ACTIVE REACHABLE 8 onu-reenabled
697 ${state9} Create List ENABLED DISCOVERED UNREACHABLE 9 stopping-openomci
698 ${state10} Create List ENABLED DISCOVERED REACHABLE 10 rebooting
699 ${state11} Create List ENABLED DISCOVERED REACHABLE 11 omci-flows-deleted
700 ${state12} Create List DISABLED UNKNOWN REACHABLE 12 tech-profile-config-delete-success
701 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Set Variable If
702 ... '${state}'=='1' or '${state}'=='activating-onu' ${state1}
703 ... '${state}'=='2' or '${state}'=='starting-openomci' ${state2}
704 ... '${state}'=='3' or '${state}'=='discovery-mibsync-complete' ${state3}
705 ... '${state}'=='4' or '${state}'=='initial-mib-downloaded' ${state4}
706 ... '${state}'=='5' or '${state}'=='tech-profile-config-download-success' ${state5}
707 ... '${state}'=='6' or '${state}'=='omci-flows-pushed' ${state6}
708 ... '${state}'=='7' or '${state}'=='omci-admin-lock' ${state7}
709 ... '${state}'=='8' or '${state}'=='onu-reenabled' ${state8}
710 ... '${state}'=='9' or '${state}'=='stopping-openomci' ${state9}
711 ... '${state}'=='10' or '${state}'=='rebooting' ${state10}
712 ... '${state}'=='11' or '${state}'=='omci-flows-deleted' ${state11}
713 ... '${state}'=='12' or '${state}'=='tech-profile-config-delete-success' ${state12}
714 [Return] ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}