blob: c3eda8a75870c1e7fa175089b2916242d187e028 [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 ***
TorstenThieme373adfe2021-12-16 13:03:04 +000021Printout ONU Serial Number and Device Id
22 [Documentation] Printouts the ONU serial number and corresponding device id.
23 [Arguments] ${onu_sn}=${EMPTY} ${print2console}=False
24 ${output}= Set Variable \r\n
25 ${onu_sn_list} Create List
26 Run Keyword If "${onu_sn}"=="${EMPTY}" Build ONU SN List ${onu_sn_list}
27 ... ELSE Append To List ${onu_sn_list} ${onu_sn}
28 FOR ${sn} IN @{onu_sn_list}
29 ${device_id}= Get Device ID From SN ${sn}
30 ${output}= Catenate ${output} ONU Serial Number: ${sn} ONU Device ID: ${device_id}\r\n
31 END
32 Log ${output}
33 Run Keyword If ${print2console} Log ${output} console=yes
34
TorstenThieme440b7c02020-12-18 15:42:57 +000035Calculate Timeout
36 [Documentation] Calculates the timeout regarding num-onus in case of more than 4 onus
37 [Arguments] ${basetimeout}=60s
38 ${new_timeout} Fetch From Left ${basetimeout} s
39 ${new_timeout}= evaluate ${new_timeout}+((${num_all_onus}-4)*10)
40 ${new_timeout}= Set Variable If (not ${debugmode}) and (${new_timeout}>300)
41 ... 300 ${new_timeout}
42 ${new_timeout}= Catenate SEPARATOR= ${new_timeout} s
43 [Return] ${new_timeout}
44
TorstenThieme3494ceb2021-07-19 09:47:24 +000045Get Logical Id of OLT
46 [Documentation] Fills the logical id of OLT(s) if missing
47 FOR ${I} IN RANGE 0 ${num_olts}
48 # exit loop if logical id already known
49 Exit For Loop IF "${olt_ids}[${I}][logical_id]" != "${EMPTY}"
50 #read current device values
51 ${olt}= Get From List ${olt_ids} ${I}
52 ${olt_serial_number}= Get From Dictionary ${olt} sn
53 # read logical id and store it
54 ${logical_id}= Get Logical Device ID From SN ${olt_serial_number}
55 Set To Dictionary ${olt} logical_id ${logical_id}
56 Set List Value ${olt_ids} ${I} ${olt}
57 END
58 Set Global Variable ${olt_ids}
59
TorstenThieme440b7c02020-12-18 15:42:57 +000060Power On ONU Device
61 [Documentation] This keyword turns on the power for all onus.
62 [Arguments] ${namespace}
TorstenThiemefe7099e2021-01-29 08:41:04 +000063 FOR ${J} IN RANGE 0 ${num_olts}
64 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
65 ${bbsim}= Catenate SEPARATOR= bbsim ${J}
66 ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
67 Power On ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
68 END
69
70Power On ONU Device per OLT
71 [Documentation] This keyword turns on the power for all onus.
72 [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000073 FOR ${I} IN RANGE 0 ${num_all_onus}
74 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThiemefe7099e2021-01-29 08:41:04 +000075 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
76 Power On ONU ${namespace} ${bbsim_pod} ${src['onu']}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000077 END
78
TorstenThieme440b7c02020-12-18 15:42:57 +000079Power Off ONU Device
TorstenThiemefe7099e2021-01-29 08:41:04 +000080 [Documentation] This keyword turns off the power for all onus per olt.
TorstenThieme440b7c02020-12-18 15:42:57 +000081 [Arguments] ${namespace}
TorstenThiemefe7099e2021-01-29 08:41:04 +000082 FOR ${J} IN RANGE 0 ${num_olts}
83 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
84 ${bbsim}= Catenate SEPARATOR= bbsim ${J}
85 ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
86 Power Off ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
87 END
88
89Power Off ONU Device per OLT
90 [Documentation] This keyword turns off the power for all onus per olt.
91 [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
TorstenThieme440b7c02020-12-18 15:42:57 +000092 FOR ${I} IN RANGE 0 ${num_all_onus}
93 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThiemefe7099e2021-01-29 08:41:04 +000094 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
95 Power Off ONU ${namespace} ${bbsim_pod} ${src['onu']}
TorstenThieme440b7c02020-12-18 15:42:57 +000096 END
97
98Current State Test
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000099 [Documentation] This keyword checks the passed state of the given onu.
100 [Arguments] ${state} ${onu} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY}
101 ... ${reqconnectstatus}=${EMPTY}
102 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
103 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
104 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
105 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
106 ... ${connect_status}
107 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
108 ... Validate Device ${admin_state} ${oper_status} ${connect_status}
109 ... ${onu} onu=True onu_reason=${onu_state}
110
TorstenThieme440b7c02020-12-18 15:42:57 +0000111Current State Test All Onus
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000112 [Documentation] This keyword checks the passed state of all onus.
113 ... Hint: ${timeStart} will be not evaluated here!
114 [Arguments] ${state} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY} ${reqconnectstatus}=${EMPTY}
TorstenThieme53450ff2021-05-11 09:44:33 +0000115 ... ${alternativeonustate}=${EMPTY} ${timeout}=${timeout}
TorstenThieme440b7c02020-12-18 15:42:57 +0000116 ${timeStart}= Get Current Date
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000117 ${list_onus} Create List
118 Build ONU SN List ${list_onus}
119 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
120 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
121 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
122 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
123 ... ${connect_status}
124 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
125 ... Validate ONU Devices With Duration
126 ... ${admin_state} ${oper_status} ${connect_status}
TorstenThieme52ef8392020-11-10 13:42:26 +0000127 ... ${onu_state} ${list_onus} ${timeStart} alternate_reason=${alternativeonustate}
TorstenThieme53450ff2021-05-11 09:44:33 +0000128 # teardown is used as 'return' for result of Validate ONU Devices With Duration (used for ONUNegativeStateTests)
129 [Teardown] Run Keyword If "${KEYWORD STATUS}"=="FAIL" Set Suite Variable ${StateTestAllONUs} False
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000130
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000131Reconcile Onu Adapter
132 [Documentation] Restarts the openonu adapter and waits for reconciling is finished and expected oper-state is reached
TorstenThieme712b2962021-11-17 14:16:15 +0000133 [Arguments] ${namespace} ${usekill2restart} ${oper_status} ${olt_to_be_deleted_sn}=${EMPTY}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000134 ... ${flow_delete_params}=&{EMPTY}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000135 # get time of restart of openonu adapter
136 ${restart_ts}= Get Current Date
137 # restart OpenONU adapter
138 Run Keyword If ${usekill2restart} Kill And Check Onu Adaptor ${namespace}
139 ... ELSE Restart And Check Onu Adaptor ${namespace}
140 #check ready timestamp of openonu adapter, should be younger than restart timestamp
141 ${openonu_ready_ts}= Get Pod Ready Timestamp by Label ${namespace} app adapter-open-onu
142 ${restart_duration}= Subtract Date From Date ${openonu_ready_ts} ${restart_ts}
143 Should Be True ${restart_duration}>0
TorstenThieme712b2962021-11-17 14:16:15 +0000144 # delete the olt passed, if available (special feature)
145 ${olt_to_be_deleted_device_id}= Run Keyword IF "${olt_to_be_deleted_sn}"!="${EMPTY}"
146 ... Get OLTDeviceID From OLT List ${olt_to_be_deleted_sn}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000147 Run Keyword If "${olt_to_be_deleted_sn}"!="${EMPTY}" Delete Device ${olt_to_be_deleted_device_id}
148 # remove flows if params passed for it (special feature II)
149 Run Keyword If ${flow_delete_params}!=&{EMPTY} Wait Until Keyword Succeeds ${timeout} 2s
150 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
151 ... volt-remove-subscriber-access ${flow_delete_params['of_id']} ${flow_delete_params['onu_port']}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700152 # wait for the reconcile to complete
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000153 # - we check that communication to openonu-adapter is established again
154 # - we check that all ONUs leave reconcile state by validate a simple voltctl request will not responds with error
155 Wait Until Keyword Succeeds ${timeout} 1s Validate Last ONU Communication
TorstenThieme712b2962021-11-17 14:16:15 +0000156 Wait Until Keyword Succeeds ${timeout} 1s Validate All Onus Accessible ${olt_to_be_deleted_sn}
157 # - 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 +0000158 ${list_onus} Create List
TorstenThieme712b2962021-11-17 14:16:15 +0000159 FOR ${J} IN RANGE 0 ${num_olts}
160 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
161 Continue For Loop If "${olt_to_be_deleted_sn}"=="${olt_serial_number}"
162 Build ONU SN List ${list_onus} ${olt_serial_number}
163 END
164 Log ${list_onus}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000165 Run Keyword And Ignore Error Wait Until Keyword Succeeds ${timeout}
166 ... 1s Check all ONU OperStatus ${list_onus} ${oper_status}
167
TorstenThiemee512b1d2021-11-12 10:52:29 +0000168Validate All Onus Accessible
169 [Documentation] This keyword checks all onus accessible (again) with help of a simple voltctl request.
170 ... As long we've got an rc!=0 keyword will fail -> onu is not accessible.
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000171 ... As get request Onu image list is used, any other get command could be used for this check.
TorstenThieme712b2962021-11-17 14:16:15 +0000172 ... Will not check ONUs of passed deleted OLT (special feature)
173 [Arguments] ${deleted_olt}=${EMPTY}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700174 ${onu_list} Create List
175 FOR ${I} IN RANGE 0 ${num_all_onus}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000176 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThieme712b2962021-11-17 14:16:15 +0000177 ${olt_serial_number}= Set Variable ${src['olt']}
178 Continue For Loop If "${deleted_olt}"=="${olt_serial_number}"
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000179 ${onu_device_id}= Get Device ID From SN ${src['onu']}
180 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700181 Continue For Loop If -1 != ${onu_id}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000182 Append To List ${onu_list} ${onu_device_id}
183 ${rc} ${output}= Get Onu Image List ${onu_device_id}
TorstenThieme712b2962021-11-17 14:16:15 +0000184 Should Be True ${rc}==0 Onu ${src['onu']} (${onu_device_id}) still not accessible.
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700185 END
186
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000187Log Ports
188 [Documentation] This keyword logs all port data available in ONOS of first port per ONU
189 [Arguments] ${onlyenabled}=False
190 ${cmd} Set Variable If ${onlyenabled} ports -e ports
TorstenThieme731a7592021-07-01 14:26:54 +0000191 ${onu_ports}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${cmd}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000192 ${lines} = Get Lines Matching Regexp ${onu_ports} .*portName=BBSM[0-9]{8}-1
193 Log ${lines}
194
195Kill Adaptor
196 [Documentation] This keyword kills the passed adaptor.
197 [Arguments] ${namespace} ${name}
198 ${cmd} Catenate
Matteo Scandolo6b524122021-10-22 14:34:29 -0700199 ... kubectl exec -it -n ${namespace} $(kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}')
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000200 ... -- /bin/sh -c "kill 1"
201 ${rc} ${output}= Run and Return Rc and Output ${cmd}
202 Log ${output}
203
TorstenThieme440b7c02020-12-18 15:42:57 +0000204Kill And Check Onu Adaptor
205 [Documentation] This keyword kills ONU Adaptor and waits for it to come up again
206 ... Following steps will be executed:
207 ... - kill openonu adaptor
208 ... - check openonu adaptor is ready again
209 [Arguments] ${namespace}
210 ${list_openonu_apps} Create List adapter-open-onu
211 ${adaptorname}= Set Variable open-onu
212 Kill Adaptor ${namespace} ${adaptorname}
213 Sleep 5s
214 Wait For Pods Ready ${namespace} ${list_openonu_apps}
215
216Restart And Check Onu Adaptor
217 [Documentation] This keyword restarts ONU Adaptor and waits for it to come up again
218 ... Following steps will be executed:
219 ... - restart openonu adaptor
220 ... - check openonu adaptor is ready again
221 [Arguments] ${namespace}
222 ${list_openonu_apps} Create List adapter-open-onu
Matteo Scandolo6f24ea92021-04-29 11:55:50 -0700223 ${openonu_label_key} Set Variable app
224 ${openonu_label_value} Set Variable adapter-open-onu
225 Restart Pod By Label ${namespace} ${openonu_label_key} ${openonu_label_value}
TorstenThieme440b7c02020-12-18 15:42:57 +0000226 Sleep 5s
227 Wait For Pods Ready ${namespace} ${list_openonu_apps}
228
229Disable Onu Device
230 [Documentation] This keyword disables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000231 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000232 FOR ${I} IN RANGE 0 ${num_all_onus}
233 ${src}= Set Variable ${hosts.src[${I}]}
234 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000235 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
236 Continue For Loop If -1 != ${onu_id}
237 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000238 Disable Device ${onu_device_id}
239 Wait Until Keyword Succeeds 20s 2s Test Devices Disabled in VOLTHA Id=${onu_device_id}
240 END
241
242Enable Onu Device
243 [Documentation] This keyword enables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000244 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000245 FOR ${I} IN RANGE 0 ${num_all_onus}
246 ${src}= Set Variable ${hosts.src[${I}]}
247 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000248 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
249 Continue For Loop If -1 != ${onu_id}
250 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000251 Enable Device ${onu_device_id}
252 END
253
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000254Verify MIB Template Data Available
255 [Documentation] This keyword verifies MIB Template Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000256 [Arguments] ${namespace}=default
TorstenThiemed4f48962020-12-08 12:17:19 +0000257 ${podname}= Set Variable etcd
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000258 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800259 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000260 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000261 Should Not Be Empty ${result} No MIB Template Data stored in etcd!
262
263Delete MIB Template Data
264 [Documentation] This keyword deletes MIB Template Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000265 [Arguments] ${namespace}=default
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000266 ${podname}= Set Variable etcd
267 ${commanddel} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800268 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000269 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commanddel}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000270 Sleep 3s
271 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800272 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000273 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000274 Should Be Empty ${result} Could not delete MIB Template Data stored in etcd!
275
TorstenThieme440b7c02020-12-18 15:42:57 +0000276Set Tech Profile
277 [Documentation] This keyword sets the passed TechProfile for the test
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000278 [Arguments] ${TechProfile} ${namespace}=default
TorstenThieme440b7c02020-12-18 15:42:57 +0000279 Log To Console \nTechProfile:${TechProfile}
TorstenThieme440b7c02020-12-18 15:42:57 +0000280 ${podname}= Set Variable etcd
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200281 ${label}= Set Variable app.kubernetes.io/name=${podname}
TorstenThieme440b7c02020-12-18 15:42:57 +0000282 ${src}= Set Variable ${data_dir}/TechProfile-${TechProfile}.json
283 ${dest}= Set Variable /tmp/flexpod.json
284 ${command} Catenate
285 ... /bin/sh -c 'cat ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64'
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200286 Copy File To Pod ${namespace} ${label} ${src} ${dest}
TorstenThieme440b7c02020-12-18 15:42:57 +0000287 Exec Pod In Kube ${namespace} ${podname} ${command}
288 ${commandget} Catenate
289 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200290 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
291 Should Not Be Empty ${result} No Tech Profile stored in etcd!
TorstenThieme440b7c02020-12-18 15:42:57 +0000292
293Remove Tech Profile
294 [Documentation] This keyword removes TechProfile
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000295 [Arguments] ${namespace}=default
TorstenThieme440b7c02020-12-18 15:42:57 +0000296 Log To Console \nTechProfile:${TechProfile}
TorstenThieme440b7c02020-12-18 15:42:57 +0000297 ${podname}= Set Variable etcd
298 ${command} Catenate
299 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/64'
300 Exec Pod In Kube ${namespace} ${podname} ${command}
301 ${commandget} Catenate
302 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
303 Exec Pod In Kube ${namespace} ${podname} ${commandget}
304
TorstenThiemea7315f12021-07-23 11:56:34 +0000305Do Onu Subscriber Add Per OLT
306 [Documentation] Add Subscriber per OLT
307 [Arguments] ${of_id} ${olt_serial_number} ${print2console}=False
308 FOR ${I} IN RANGE 0 ${num_all_onus}
309 ${src}= Set Variable ${hosts.src[${I}]}
310 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
311 ${onu_device_id}= Get Device ID From SN ${src['onu']}
312 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
313 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
314 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
315 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
316 ... volt-add-subscriber-access ${of_id} ${onu_port}
317 Run Keyword If ${print2console} Log \r\n[${I}] volt-add-subscriber-access ${of_id} ${onu_port}.
318 ... console=yes
319 END
320
321Do Onu Flow Check Per OLT
322 [Documentation] Checks all ONU flows show up in ONOS and Voltha
323 [Arguments] ${of_id} ${nni_port} ${olt_serial_number} ${print2console}=False
324 FOR ${I} IN RANGE 0 ${num_all_onus}
325 ${src}= Set Variable ${hosts.src[${I}]}
326 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
327 ${onu_device_id}= Get Device ID From SN ${src['onu']}
328 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
329 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
330 # Verify subscriber access flows are added for the ONU port
331 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
332 ... Verify Subscriber Access Flows Added For ONU ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${of_id}
333 ... ${onu_port} ${nni_port} ${src['c_tag']} ${src['s_tag']}
334 ${logoutput} Catenate \r\n[${I}] Verify Subscriber Access Flows Added For
335 ... ONU ${of_id} ${onu_port} ${src['c_tag']} ${src['s_tag']}.
336 Run Keyword If ${print2console} Log ${logoutput} console=yes
337 END
338
339Do Onu Subscriber Remove Per OLT
340 [Documentation] Removes per OLT subscribers in ONOS and Voltha
341 [Arguments] ${of_id} ${olt_serial_number} ${print2console}=False
342 FOR ${I} IN RANGE 0 ${num_all_onus}
343 ${src}= Set Variable ${hosts.src[${I}]}
344 ${dst}= Set Variable ${hosts.dst[${I}]}
345 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
346 ${onu_device_id}= Get Device ID From SN ${src['onu']}
347 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
348 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
349 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
350 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
351 ... volt-remove-subscriber-access ${of_id} ${onu_port}
352 Run Keyword If ${print2console} Log \r\n[${I}] volt-remove-subscriber-access ${of_id} ${onu_port}.
353 ... console=yes
354 END
355
TorstenThieme7c397d72021-07-14 11:51:09 +0000356Validate Resource Instances Used Gem Ports
357 [Documentation] This keyword validates resource instances data stored in etcd.
358 ... It checks checks the number of gemport-ids which has matched with used Tech Profile
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000359 [Arguments] ${nbofgemports} ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha
TorstenThieme7c397d72021-07-14 11:51:09 +0000360 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000361 ${etcddata}= Get ONU Go Adapter ETCD Data namespace=${namespace} defaultkvstoreprefix=${kvstoreprefix}
TorstenThieme7c397d72021-07-14 11:51:09 +0000362 #prepare result for json convert
363 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
364 ${jsondata}= To Json ${result}
365 ${length}= Get Length ${jsondata}
366 log ${jsondata}
367 FOR ${INDEX} IN RANGE 0 ${length}
368 ${value}= Get From List ${jsondata} ${INDEX}
369 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
370 # When testing multi-tcont this may need some adjustment.
371 Exit For Loop If not ('uni_config' in $value)
372 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000373 ${resourcedata}= Get Resource Instances ETCD Data ${tp_path} namespace=${namespace}
374 ... defaultkvstoreprefix=${kvstoreprefix}
TorstenThieme7c397d72021-07-14 11:51:09 +0000375 log ${resourcedata}
376 ${decoderesult}= volthatools.Tech Profile Decode Resource Instance ${resourcedata} return_default=true
377 log ${decoderesult}
378 ${gemportids}= Get From Dictionary ${decoderesult} gemport_ids
379 ${length}= Get Length ${gemportids}
380 Should Be Equal As Integers ${nbofgemports} ${length}
381 ... msg=Number of gem ports (${length}) does not match with techprofile ${techprofile}/${nbofgemports}
382 END
383
384Get Resource Instances ETCD Data
385 [Documentation] This keyword delivers Resource Instances Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000386 [Arguments] ${tppath} ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha
TorstenThieme7c397d72021-07-14 11:51:09 +0000387 ${podname}= Set Variable etcd
388 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
389 ${commandget}= Catenate
390 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/resource_instances/${tppath}
391 ... --print-value-only --hex'
392 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
393 log ${result}
394 [Return] ${result}
395
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000396Validate Tech Profiles and Flows in ETCD Data Per Onu
397 [Documentation] This keyword validates tech profiles and flows data stored in etcd per onu.
398 ... It checks checks presence/absence of tech profiles and flows depending on must_exist.
399 ... The values/content of tech profiles and flows will be not validated!
400 [Arguments] ${onu_sn} ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha ${must_exist}=True
401 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
402 ${etcddata}= Get ONU Go Adapter ETCD Data namespace=${namespace} defaultkvstoreprefix=${kvstoreprefix}
403 #prepare result for json convert
404 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
405 ${jsondata}= To Json ${result}
406 ${length}= Get Length ${jsondata}
407 log ${jsondata}
408 ${matched}= Set Variable False
409 FOR ${INDEX} IN RANGE 0 ${length}
410 ${value}= Get From List ${jsondata} ${INDEX}
411 ${uni_config}= Get From Dictionary ${value} uni_config
412 ${uni_config}= Set Variable ${uni_config[0]}
413 ${sn}= Get From Dictionary ${value} serial_number
414 ${matched}= Set Variable If '${sn}'=='${onu_sn}' True False
415 Exit For Loop If ${matched}
416 END
417 Should Be True ${matched} No ETCD data found for ONU ${onu_sn}
418 Log ${uni_config}
419 ${tp_path}= Get From Dictionary ${uni_config} PersTpPathMap
420 Log ${tp_path}
421 ${flow_params}= Get From Dictionary ${uni_config} flow_params
422 Log ${flow_params}
423 # in case of ATT for ONU with removed flows there is default flow established
424 ${length}= Get Length ${flow_params}
425 ${cookieslice}= Run Keyword If ${length}>0 Run Keyword If 'cookie_slice' in ${flow_params[0]}
426 ... Get From Dictionary ${flow_params[0]} cookie_slice
427 ${setvid}= Run Keyword If ${length}>0 Run Keyword If 'set_vid' in ${flow_params[0]['vlan_rule_params']}
428 ... Get From Dictionary ${flow_params[0]['vlan_rule_params']} set_vid
429 ${cookie_slice_length}= Run Keyword If ${length}>0 Run Keyword If 'cookie_slice' in ${flow_params[0]}
430 ... Get Length ${cookieslice}
431 Run Keyword If "${workflow}"=="ATT" and not ${must_exist} Run Keywords
432 ... Should Be Equal As Numbers ${setvid} 4091 AND
433 ... Should Be Equal As Numbers ${cookie_slice_length} 1 AND
434 ... Should Not Be Empty ${tp_path} AND
435 ... Return From Keyword
436 ${tp_path_length}= Get Length ${tp_path}
437 # validate tp_path is not Empty for case must_exist, case not must_exist will be validated implicitly with FOR loop
438 Run Keyword If ${must_exist} Should Not Be Empty ${tp_path}
439 ${tp_path_keys}= Run Keyword If ${tp_path_length}==0 Create List
440 ... ELSE Get Dictionary Keys ${tp_path}
441 ${tp_path_values}= Run Keyword If ${tp_path_length}==0 Create List
442 ... ELSE Get Dictionary Values ${tp_path}
443 ${tp_path_empty}= Set Variable True
444 Log ${tp_path_values}
445 Log ${tp_path_keys}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000446 # In case of not empty tp_path each value will be checked depending on must_exist
447 FOR ${key} IN @{tp_path_keys}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000448 ${value}= Get From Dictionary ${tp_path} ${key}
449 Run Keyword If ${must_exist} Should Not Be Empty ${value}
450 ... ELSE Should Be Empty ${value}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000451 END
452 Run Keyword If ${must_exist} Should Not Be Empty ${flow_params}
453 ... ELSE Should Be Empty ${flow_params}
TorstenThieme7c397d72021-07-14 11:51:09 +0000454
TorstenThieme17756ea2020-11-11 14:09:47 +0000455Validate Onu Data In Etcd
456 [Documentation] This keyword validates openonu-go-adapter Data stored in etcd.
457 ... It checks unique of serial_number and combination of pon, onu and uni in tp_path.
458 ... Furthermore it evaluates the values of onu_id and uni_id with values read from tp_path.
459 ... Number of etcd entries has to match with the passed number.
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000460 [Arguments] ${namespace}=default ${nbofetcddata}=${num_all_onus} ${defaultkvstoreprefix}=voltha_voltha
TorstenThiemefa29a892021-03-11 14:11:29 +0000461 ... ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000462 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000463 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme17756ea2020-11-11 14:09:47 +0000464 #prepare result for json convert
465 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
466 ${jsondata}= To Json ${result}
467 ${length}= Get Length ${jsondata}
468 log ${jsondata}
469 Run Keyword And Continue On Failure Should Be Equal As Integers ${length} ${nbofetcddata}
470 ... msg=Number etcd data (${length}) does not match required (${nbofetcddata})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000471 ${oltpononuuniidlist}= Create List
TorstenThieme17756ea2020-11-11 14:09:47 +0000472 ${serialnumberlist}= Create List
473 FOR ${INDEX} IN RANGE 0 ${length}
474 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra97f8d062020-11-17 15:48:23 -0800475 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
476 # When testing multi-tcont this may need some adjustment.
TorstenThieme45071602021-03-16 12:14:37 +0000477 Exit For Loop If not ('uni_config' in $value)
Girish Gowdra97f8d062020-11-17 15:48:23 -0800478 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000479 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
480 ${list_id}= Get Index From List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000481 Should Be Equal As Integers ${list_id} -1
TorstenThiemefe7099e2021-01-29 08:41:04 +0000482 ... msg=Combination of Pon, Onu and Uni (${oltpononuuniid}) exist multiple in etcd data!
483 Append To List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000484 Validate Onu Id ${value}
485 Validate Uni Id ${value}
486 ${serial_number}= Get From Dictionary ${value} serial_number
487 ${list_id}= Get Index From List ${serialnumberlist} ${serial_number}
488 Should Be Equal As Integers ${list_id} -1
489 ... msg=Serial number (${serial_number}) exists multiple in etcd data!
490 Append To List ${serialnumberlist} ${serial_number}
491 END
492
TorstenThieme712b2962021-11-17 14:16:15 +0000493Validate Onu Data In Etcd Removed
494 [Documentation] This keyword validates openonu-go-adapter Data stored in etcd are removed.
495 ... In case of a device is passed, only this will be checked.
496 [Arguments] ${namespace}=default ${device_id}=${EMPTY} ${defaultkvstoreprefix}=voltha_voltha
497 ... ${without_pm_data}=True
498 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
499 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} False ${without_pm_data}
500 ... ${device_id} True
501 Log ${etcddata}
502 Should Be Empty ${etcddata} Stale Openonu Data in Etcd (KV store) ${device_id}
503
TorstenThieme52ef8392020-11-10 13:42:26 +0000504Validate Vlan Rules In Etcd
505 [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd.
506 ... It checks the given number of cookie_slice, match_vid (=4096) and set_vid.
507 ... Furthermore it returns a list of all set_vid.
508 ... In case of a passed dictionary containing set_vids these will be checked for to
509 ... current set-vid depending on setvidequal (True=equal, False=not equal).
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000510 [Arguments] ${namespace}=default ${nbofcookieslice}=1 ${reqmatchvid}=4096 ${prevvlanrules}=${NONE}
511 ... ${setvidequal}=False ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000512 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000513 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme52ef8392020-11-10 13:42:26 +0000514 #prepare result for json convert
515 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
516 ${jsondata}= To Json ${result}
517 ${length}= Get Length ${jsondata}
518 log ${jsondata}
519 ${vlan_rules}= Create Dictionary
520 FOR ${INDEX} IN RANGE 0 ${length}
521 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra295c1692020-11-19 10:51:53 -0800522 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
523 # When testing multi-tcont this may need some adjustment.
524 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000525 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000526 ${cookieslice}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]} cookie_slice
527 #@{cookieslicelist}= Split String ${cookieslice} ,
528 ${foundcookieslices}= Get Length ${cookieslice}
529 Should Be Equal As Integers ${foundcookieslices} ${nbofcookieslice}
530 ${matchvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
531 ... match_vid
532 Should Be Equal As Integers ${matchvid} ${reqmatchvid}
533 ${setvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
534 ... set_vid
535 ${evalresult}= Evaluate 2 <= ${setvid} <= 4095
536 Should Be True ${evalresult} msg=set_vid out of range (${setvid})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000537 Set To Dictionary ${vlan_rules} ${oltpononuuniid} ${setvid}
TorstenThieme52ef8392020-11-10 13:42:26 +0000538 ${oldsetvidvalid} Set Variable If ${prevvlanrules} is ${NONE} False True
TorstenThiemefe7099e2021-01-29 08:41:04 +0000539 ${prevsetvid}= Set Variable If ${oldsetvidvalid} ${prevvlanrules['${oltpononuuniid}']}
TorstenThieme52ef8392020-11-10 13:42:26 +0000540 Run Keyword If ${oldsetvidvalid} and ${setvidequal}
541 ... Should Be Equal As Integers ${prevsetvid} ${setvid}
542 ... ELSE IF ${oldsetvidvalid} and not ${setvidequal}
543 ... Should Not Be Equal As Integers ${prevsetvid} ${setvid}
544 END
TorstenThieme440b7c02020-12-18 15:42:57 +0000545 log Many ${vlan_rules}
TorstenThieme52ef8392020-11-10 13:42:26 +0000546 [Return] ${vlan_rules}
547
548Get ONU Go Adapter ETCD Data
549 [Documentation] This keyword delivers openonu-go-adapter Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000550 [Arguments] ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True
TorstenThieme712b2962021-11-17 14:16:15 +0000551 ... ${without_pm_data}=True ${device_id}=${Empty} ${keys_only}=False
TorstenThieme52ef8392020-11-10 13:42:26 +0000552 ${podname}= Set Variable etcd
TorstenThieme3385cdc2021-02-04 13:50:50 +0000553 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
TorstenThieme3af12312021-03-10 16:15:24 +0000554 ${commandget}= Catenate
555 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/openonu'
TorstenThieme712b2962021-11-17 14:16:15 +0000556 ${commandget}= Run Keyword If ${keys_only} Catenate ${commandget} --keys-only
557 ... ELSE Set Variable ${commandget}
TorstenThieme3af12312021-03-10 16:15:24 +0000558 ${commandget}= Run Keyword If ${without_prefix} Catenate ${commandget}
559 ... | grep -v service/${kvstoreprefix}/openonu
TorstenThiemefa29a892021-03-11 14:11:29 +0000560 ... ELSE Set Variable ${commandget}
TorstenThieme3af12312021-03-10 16:15:24 +0000561 ${commandget}= Run Keyword If ${without_pm_data} Catenate ${commandget} | grep -v instances_active
TorstenThiemefa29a892021-03-11 14:11:29 +0000562 ... ELSE Set Variable ${commandget}
TorstenThieme712b2962021-11-17 14:16:15 +0000563 ${commandget}= Run Keyword If "${device_id}"!="${Empty}" Catenate ${commandget} | grep ${device_id}
564 ... ELSE Set Variable ${commandget}
Holger Hildebrandt23147742020-11-16 10:13:21 +0000565 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThieme52ef8392020-11-10 13:42:26 +0000566 log ${result}
567 [Return] ${result}
568
569Prepare ONU Go Adapter ETCD Data For Json
570 [Documentation] This keyword prepares openonu-go-adapter Data stored in etcd for converting
571 ... to json
572 [Arguments] ${etcddata}
573 #prepare result for json convert
574 ${prepresult}= Replace String ${etcddata} \n ,
575 ${prepresult}= Strip String ${prepresult} mode=right characters=,
576 ${prepresult}= Set Variable [${prepresult}]
577 log ${prepresult}
578 [Return] ${prepresult}
579
TorstenThieme52ef8392020-11-10 13:42:26 +0000580Read Pon Onu Uni String
TorstenThiemefe7099e2021-01-29 08:41:04 +0000581 [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 +0000582 ... taken from etcd data of onu go adapter
583 [Arguments] ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000584 ${tppathlines}= Replace String ${tp_path} / \n
TorstenThiemefe7099e2021-01-29 08:41:04 +0000585 ${olt}= Get Value Of Tp Path Element ${tppathlines} olt
TorstenThieme52ef8392020-11-10 13:42:26 +0000586 ${pon}= Get Value Of Tp Path Element ${tppathlines} pon
587 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
588 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
TorstenThiemefe7099e2021-01-29 08:41:04 +0000589 ${valuesid}= Set Variable ${olt}/${pon}/${onu}/${uni}
TorstenThieme52ef8392020-11-10 13:42:26 +0000590 log ${valuesid}
591 [Return] ${valuesid}
592
593Get Value Of Tp Path Element
TorstenThieme17756ea2020-11-11 14:09:47 +0000594 [Documentation] This keyword delivers numeric value of given tp path element.
TorstenThieme52ef8392020-11-10 13:42:26 +0000595 [Arguments] ${tp_path_lines} ${element}
596 ${value}= Get Lines Containing String ${tp_path_lines} ${element}-\{
597 ${value}= Remove String ${value} ${element}-\{
598 ${value}= Remove String ${value} \}
599 log ${value}
600 [Return] ${value}
601
TorstenThieme17756ea2020-11-11 14:09:47 +0000602Validate Onu Id
603 [Documentation] This keyword validates ONU Id of passed etcd data.
604 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800605 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
606 # When testing multi-tcont this may need some adjustment.
607 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000608 ${tppathlines}= Replace String ${tp_path} / \n
609 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
610 ${onu_id}= Get From Dictionary ${value} onu_id
611 Should Be Equal As Integers ${onu} ${onu_id}
612 ... msg=Onu-Id (${onu_id}) does not match onu (${onu}) from tp_path in etcd data!
613 Should Be True ${onu_id}>=1
614
615Validate Uni Id
616 [Documentation] This keyword validates UNI Id of passed etcd data.
617 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800618 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
619 # When testing multi-tcont this may need some adjustment.
620 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000621 ${tppathlines}= Replace String ${tp_path} / \n
622 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
623 ${uni_id}= Get From Dictionary ${value['uni_config'][0]} uni_id
624 Should Be Equal As Integers ${uni} ${uni_id}
625 ... msg=Uni-Id (${uni_id}) does not match onu (${uni}) from tp_path in etcd data!
TorstenThieme52ef8392020-11-10 13:42:26 +0000626
TorstenThieme45071602021-03-16 12:14:37 +0000627Delete ONU Go Adapter ETCD Data
628 [Documentation] This keyword deletes openonu-go-adapter Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000629 [Arguments] ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha ${validate}=False
TorstenThieme45071602021-03-16 12:14:37 +0000630 ${podname}= Set Variable etcd
631 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
632 ${commandget}= Catenate
633 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/${kvstoreprefix}/openonu'
634 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
635 log ${result}
636 Run Keyword If ${validate} Wait Until Keyword Succeeds ${timeout} 1s
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000637 ... Validate Onu Data In Etcd namespace=${namespace} nbofetcddata=0 without_pm_data=False
TorstenThieme45071602021-03-16 12:14:37 +0000638 [Return] ${result}
639
TorstenThiemed6492882021-12-16 08:10:02 +0000640Validate ONOS Flows per OLT
641 [Documentation] This keyword validates onos flows per olt
642 [Arguments] ${olt_sn} ${expected_flows}
643 ${olt_of_id} Validate OLT Device in ONOS ${olt_sn}
644 ${flows}= Count flows ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${olt_of_id} added
645 Log Found added ${flows} of ${expected_flows} expected flows on device ${olt_sn}
646 Should Be Equal As Integers ${expected_flows} ${flows}
647
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000648Validate OLT Flows Per Onu
649 [Documentation] This keyword validates olt flows per onu
650 ... It checks checks presence/absence of olt flows depending on must_exist.
651 ... The values/content of olt flows will be not validated!
652 [Arguments] ${onu_device_id} ${must_exist}
653 ${rc} ${output}= Run and Return Rc and Output
654 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${onu_device_id} -m 8MB -o json
655 Should Be Equal As Integers ${rc} 0
656 ${jsondata}= To Json ${output}
657 Log ${jsondata}
658 # in case of ATT for ONU with removed flows there is default flow established
659 ${length}= Get Length ${jsondata}
660 ${value}= Run Keyword If ${length}>0 Get From List ${jsondata} 0
661 ${setvid}= Run Keyword If ${length}>0 Run Keyword If 'setvlanid' in ${value}
662 ... Get From Dictionary ${value} setvlanid
663 Run Keyword If "${workflow}"=="ATT" and not ${must_exist} Run Keywords
664 ... Should Be Equal As Numbers ${setvid} 4091 AND
665 ... Should Be Equal As Numbers ${length} 1 AND
666 ... Return From Keyword
667 Run Keyword If ${must_exist} Should Not Be Empty ${jsondata}
668 ... ELSE Should Be Empty ${jsondata}
669
TorstenThiemed4f48962020-12-08 12:17:19 +0000670Wait for Ports in ONOS for all OLTs
TorstenThieme440b7c02020-12-18 15:42:57 +0000671 [Documentation] Waits untill a certain number of ports are enabled in all OLTs
TorstenThieme731a7592021-07-01 14:26:54 +0000672 [Arguments] ${host} ${port} ${count} ${filter} ${max_wait_time}=10m ${determine_number}=False
TorstenThiemed4f48962020-12-08 12:17:19 +0000673 FOR ${J} IN RANGE 0 ${num_olts}
674 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
675 ${onu_count}= Set Variable ${list_olts}[${J}][onucount]
676 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
677 ... ${olt_serial_number}
678 Set Global Variable ${of_id}
TorstenThiemeff9c9142021-04-08 07:21:34 +0000679 ${count2check}= Set Variable If ${count}==${num_all_onus} ${onu_count} ${count}
680 # if flag determine_number is set to True, always determine the number of real ONUs (overwrite previous value)
681 ${count2check}= Run Keyword If ${determine_number} Determine Number Of ONU ${olt_serial_number}
682 ... ELSE Set Variable ${count2check}
TorstenThieme731a7592021-07-01 14:26:54 +0000683 Wait for Ports in ONOS ${host} ${port} ${count2check} ${of_id} BBSM ${max_wait_time}
TorstenThiemed4f48962020-12-08 12:17:19 +0000684 END
685
TorstenThieme440b7c02020-12-18 15:42:57 +0000686Wait for all ONU Ports in ONOS Disabled
687 [Documentation] Waits untill a all ONU ports are disabled in all ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000688 [Arguments] ${host} ${port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000689 FOR ${I} IN RANGE 0 ${num_all_onus}
690 ${src}= Set Variable ${hosts.src[${I}]}
691 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
692 ... ${src['olt']}
693 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']} ${of_id}
TorstenThieme731a7592021-07-01 14:26:54 +0000694 Wait Until Keyword Succeeds ${timeout} 2s Assert ONU Port Is Disabled ${host} ${port} ${of_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000695 ... ${onu_port}
696 END
697
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000698Map State
699 [Documentation] This keyword converts the passed numeric value or name of a onu state to its state values.
700 [Arguments] ${state}
701 # create state lists with corresponding return values
702 # ADMIN-STATE OPER-STATUS CONNECT-STATUS ONU-STATE (number/name)
703 ${state1} Create List ENABLED ACTIVATING REACHABLE 1 activating-onu
704 ${state2} Create List ENABLED ACTIVATING REACHABLE 2 starting-openomci
705 ${state3} Create List ENABLED ACTIVATING REACHABLE 3 discovery-mibsync-complete
706 ${state4} Create List ENABLED ACTIVE REACHABLE 4 initial-mib-downloaded
707 ${state5} Create List ENABLED ACTIVE REACHABLE 5 tech-profile-config-download-success
708 ${state6} Create List ENABLED ACTIVE REACHABLE 6 omci-flows-pushed
709 ${state7} Create List DISABLED UNKNOWN REACHABLE 7 omci-admin-lock
710 ${state8} Create List ENABLED ACTIVE REACHABLE 8 onu-reenabled
711 ${state9} Create List ENABLED DISCOVERED UNREACHABLE 9 stopping-openomci
712 ${state10} Create List ENABLED DISCOVERED REACHABLE 10 rebooting
713 ${state11} Create List ENABLED DISCOVERED REACHABLE 11 omci-flows-deleted
714 ${state12} Create List DISABLED UNKNOWN REACHABLE 12 tech-profile-config-delete-success
715 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Set Variable If
716 ... '${state}'=='1' or '${state}'=='activating-onu' ${state1}
717 ... '${state}'=='2' or '${state}'=='starting-openomci' ${state2}
718 ... '${state}'=='3' or '${state}'=='discovery-mibsync-complete' ${state3}
719 ... '${state}'=='4' or '${state}'=='initial-mib-downloaded' ${state4}
720 ... '${state}'=='5' or '${state}'=='tech-profile-config-download-success' ${state5}
721 ... '${state}'=='6' or '${state}'=='omci-flows-pushed' ${state6}
722 ... '${state}'=='7' or '${state}'=='omci-admin-lock' ${state7}
723 ... '${state}'=='8' or '${state}'=='onu-reenabled' ${state8}
724 ... '${state}'=='9' or '${state}'=='stopping-openomci' ${state9}
725 ... '${state}'=='10' or '${state}'=='rebooting' ${state10}
726 ... '${state}'=='11' or '${state}'=='omci-flows-deleted' ${state11}
727 ... '${state}'=='12' or '${state}'=='tech-profile-config-delete-success' ${state12}
728 [Return] ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}