blob: 8b9586d7433b2ac0ca271e90a15bd4b7404d647b [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
31Power On ONU Device
32 [Documentation] This keyword turns on the power for all onus.
33 [Arguments] ${namespace}
TorstenThiemefe7099e2021-01-29 08:41:04 +000034 FOR ${J} IN RANGE 0 ${num_olts}
35 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
36 ${bbsim}= Catenate SEPARATOR= bbsim ${J}
37 ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
38 Power On ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
39 END
40
41Power On ONU Device per OLT
42 [Documentation] This keyword turns on the power for all onus.
43 [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000044 FOR ${I} IN RANGE 0 ${num_all_onus}
45 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThiemefe7099e2021-01-29 08:41:04 +000046 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
47 Power On ONU ${namespace} ${bbsim_pod} ${src['onu']}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000048 END
49
TorstenThieme440b7c02020-12-18 15:42:57 +000050Power Off ONU Device
TorstenThiemefe7099e2021-01-29 08:41:04 +000051 [Documentation] This keyword turns off the power for all onus per olt.
TorstenThieme440b7c02020-12-18 15:42:57 +000052 [Arguments] ${namespace}
TorstenThiemefe7099e2021-01-29 08:41:04 +000053 FOR ${J} IN RANGE 0 ${num_olts}
54 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
55 ${bbsim}= Catenate SEPARATOR= bbsim ${J}
56 ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
57 Power Off ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
58 END
59
60Power Off ONU Device per OLT
61 [Documentation] This keyword turns off the power for all onus per olt.
62 [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
TorstenThieme440b7c02020-12-18 15:42:57 +000063 FOR ${I} IN RANGE 0 ${num_all_onus}
64 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThiemefe7099e2021-01-29 08:41:04 +000065 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
66 Power Off ONU ${namespace} ${bbsim_pod} ${src['onu']}
TorstenThieme440b7c02020-12-18 15:42:57 +000067 END
68
69Current State Test
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000070 [Documentation] This keyword checks the passed state of the given onu.
71 [Arguments] ${state} ${onu} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY}
72 ... ${reqconnectstatus}=${EMPTY}
73 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
74 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
75 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
76 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
77 ... ${connect_status}
78 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
79 ... Validate Device ${admin_state} ${oper_status} ${connect_status}
80 ... ${onu} onu=True onu_reason=${onu_state}
81
TorstenThieme440b7c02020-12-18 15:42:57 +000082Current State Test All Onus
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000083 [Documentation] This keyword checks the passed state of all onus.
84 ... Hint: ${timeStart} will be not evaluated here!
85 [Arguments] ${state} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY} ${reqconnectstatus}=${EMPTY}
TorstenThieme53450ff2021-05-11 09:44:33 +000086 ... ${alternativeonustate}=${EMPTY} ${timeout}=${timeout}
TorstenThieme440b7c02020-12-18 15:42:57 +000087 ${timeStart}= Get Current Date
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000088 ${list_onus} Create List
89 Build ONU SN List ${list_onus}
90 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
91 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
92 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
93 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
94 ... ${connect_status}
95 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
96 ... Validate ONU Devices With Duration
97 ... ${admin_state} ${oper_status} ${connect_status}
TorstenThieme52ef8392020-11-10 13:42:26 +000098 ... ${onu_state} ${list_onus} ${timeStart} alternate_reason=${alternativeonustate}
TorstenThieme53450ff2021-05-11 09:44:33 +000099 # teardown is used as 'return' for result of Validate ONU Devices With Duration (used for ONUNegativeStateTests)
100 [Teardown] Run Keyword If "${KEYWORD STATUS}"=="FAIL" Set Suite Variable ${StateTestAllONUs} False
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000101
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000102Log Ports
103 [Documentation] This keyword logs all port data available in ONOS of first port per ONU
104 [Arguments] ${onlyenabled}=False
105 ${cmd} Set Variable If ${onlyenabled} ports -e ports
TorstenThieme731a7592021-07-01 14:26:54 +0000106 ${onu_ports}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${cmd}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000107 ${lines} = Get Lines Matching Regexp ${onu_ports} .*portName=BBSM[0-9]{8}-1
108 Log ${lines}
109
110Kill Adaptor
111 [Documentation] This keyword kills the passed adaptor.
112 [Arguments] ${namespace} ${name}
113 ${cmd} Catenate
114 ... kubectl exec -it -n voltha $(kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}')
115 ... -- /bin/sh -c "kill 1"
116 ${rc} ${output}= Run and Return Rc and Output ${cmd}
117 Log ${output}
118
TorstenThieme440b7c02020-12-18 15:42:57 +0000119Kill And Check Onu Adaptor
120 [Documentation] This keyword kills ONU Adaptor and waits for it to come up again
121 ... Following steps will be executed:
122 ... - kill openonu adaptor
123 ... - check openonu adaptor is ready again
124 [Arguments] ${namespace}
125 ${list_openonu_apps} Create List adapter-open-onu
126 ${adaptorname}= Set Variable open-onu
127 Kill Adaptor ${namespace} ${adaptorname}
128 Sleep 5s
129 Wait For Pods Ready ${namespace} ${list_openonu_apps}
130
131Restart And Check Onu Adaptor
132 [Documentation] This keyword restarts ONU Adaptor and waits for it to come up again
133 ... Following steps will be executed:
134 ... - restart openonu adaptor
135 ... - check openonu adaptor is ready again
136 [Arguments] ${namespace}
137 ${list_openonu_apps} Create List adapter-open-onu
Matteo Scandolo6f24ea92021-04-29 11:55:50 -0700138 ${openonu_label_key} Set Variable app
139 ${openonu_label_value} Set Variable adapter-open-onu
140 Restart Pod By Label ${namespace} ${openonu_label_key} ${openonu_label_value}
TorstenThieme440b7c02020-12-18 15:42:57 +0000141 Sleep 5s
142 Wait For Pods Ready ${namespace} ${list_openonu_apps}
143
144Disable Onu Device
145 [Documentation] This keyword disables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000146 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000147 FOR ${I} IN RANGE 0 ${num_all_onus}
148 ${src}= Set Variable ${hosts.src[${I}]}
149 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000150 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
151 Continue For Loop If -1 != ${onu_id}
152 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000153 Disable Device ${onu_device_id}
154 Wait Until Keyword Succeeds 20s 2s Test Devices Disabled in VOLTHA Id=${onu_device_id}
155 END
156
157Enable Onu Device
158 [Documentation] This keyword enables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000159 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000160 FOR ${I} IN RANGE 0 ${num_all_onus}
161 ${src}= Set Variable ${hosts.src[${I}]}
162 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000163 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
164 Continue For Loop If -1 != ${onu_id}
165 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000166 Enable Device ${onu_device_id}
167 END
168
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000169Verify MIB Template Data Available
170 [Documentation] This keyword verifies MIB Template Data stored in etcd
171 ${namespace}= Set Variable default
TorstenThiemed4f48962020-12-08 12:17:19 +0000172 ${podname}= Set Variable etcd
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000173 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800174 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000175 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000176 Should Not Be Empty ${result} No MIB Template Data stored in etcd!
177
178Delete MIB Template Data
179 [Documentation] This keyword deletes MIB Template Data stored in etcd
180 ${namespace}= Set Variable default
181 ${podname}= Set Variable etcd
182 ${commanddel} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800183 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000184 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commanddel}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000185 Sleep 3s
186 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800187 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000188 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000189 Should Be Empty ${result} Could not delete MIB Template Data stored in etcd!
190
TorstenThieme440b7c02020-12-18 15:42:57 +0000191Set Tech Profile
192 [Documentation] This keyword sets the passed TechProfile for the test
193 [Arguments] ${TechProfile}
194 Log To Console \nTechProfile:${TechProfile}
195 ${namespace}= Set Variable default
196 ${podname}= Set Variable etcd
197 ${src}= Set Variable ${data_dir}/TechProfile-${TechProfile}.json
198 ${dest}= Set Variable /tmp/flexpod.json
199 ${command} Catenate
200 ... /bin/sh -c 'cat ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64'
201 Copy File To Pod ${namespace} ${podname} ${src} ${dest}
202 Exec Pod In Kube ${namespace} ${podname} ${command}
203 ${commandget} Catenate
204 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
205 Exec Pod In Kube ${namespace} ${podname} ${commandget}
206
207Remove Tech Profile
208 [Documentation] This keyword removes TechProfile
209 Log To Console \nTechProfile:${TechProfile}
210 ${namespace}= Set Variable default
211 ${podname}= Set Variable etcd
212 ${command} Catenate
213 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/64'
214 Exec Pod In Kube ${namespace} ${podname} ${command}
215 ${commandget} Catenate
216 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
217 Exec Pod In Kube ${namespace} ${podname} ${commandget}
218
TorstenThieme7c397d72021-07-14 11:51:09 +0000219Validate Resource Instances Used Gem Ports
220 [Documentation] This keyword validates resource instances data stored in etcd.
221 ... It checks checks the number of gemport-ids which has matched with used Tech Profile
222 [Arguments] ${nbofgemports} ${defaultkvstoreprefix}=voltha_voltha
223 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
224 ${etcddata}= Get ONU Go Adapter ETCD Data ${kvstoreprefix}
225 #prepare result for json convert
226 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
227 ${jsondata}= To Json ${result}
228 ${length}= Get Length ${jsondata}
229 log ${jsondata}
230 FOR ${INDEX} IN RANGE 0 ${length}
231 ${value}= Get From List ${jsondata} ${INDEX}
232 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
233 # When testing multi-tcont this may need some adjustment.
234 Exit For Loop If not ('uni_config' in $value)
235 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
236 ${resourcedata}= Get Resource Instances ETCD Data ${tp_path} ${kvstoreprefix}
237 log ${resourcedata}
238 ${decoderesult}= volthatools.Tech Profile Decode Resource Instance ${resourcedata} return_default=true
239 log ${decoderesult}
240 ${gemportids}= Get From Dictionary ${decoderesult} gemport_ids
241 ${length}= Get Length ${gemportids}
242 Should Be Equal As Integers ${nbofgemports} ${length}
243 ... msg=Number of gem ports (${length}) does not match with techprofile ${techprofile}/${nbofgemports}
244 END
245
246Get Resource Instances ETCD Data
247 [Documentation] This keyword delivers Resource Instances Data stored in etcd
248 [Arguments] ${tppath} ${defaultkvstoreprefix}=voltha_voltha
249 ${namespace}= Set Variable default
250 ${podname}= Set Variable etcd
251 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
252 ${commandget}= Catenate
253 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/resource_instances/${tppath}
254 ... --print-value-only --hex'
255 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
256 log ${result}
257 [Return] ${result}
258
259
TorstenThieme17756ea2020-11-11 14:09:47 +0000260Validate Onu Data In Etcd
261 [Documentation] This keyword validates openonu-go-adapter Data stored in etcd.
262 ... It checks unique of serial_number and combination of pon, onu and uni in tp_path.
263 ... Furthermore it evaluates the values of onu_id and uni_id with values read from tp_path.
264 ... Number of etcd entries has to match with the passed number.
TorstenThieme3385cdc2021-02-04 13:50:50 +0000265 [Arguments] ${nbofetcddata}=${num_all_onus} ${defaultkvstoreprefix}=voltha_voltha
TorstenThiemefa29a892021-03-11 14:11:29 +0000266 ... ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000267 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
TorstenThiemefa29a892021-03-11 14:11:29 +0000268 ${etcddata}= Get ONU Go Adapter ETCD Data ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme17756ea2020-11-11 14:09:47 +0000269 #prepare result for json convert
270 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
271 ${jsondata}= To Json ${result}
272 ${length}= Get Length ${jsondata}
273 log ${jsondata}
274 Run Keyword And Continue On Failure Should Be Equal As Integers ${length} ${nbofetcddata}
275 ... msg=Number etcd data (${length}) does not match required (${nbofetcddata})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000276 ${oltpononuuniidlist}= Create List
TorstenThieme17756ea2020-11-11 14:09:47 +0000277 ${serialnumberlist}= Create List
278 FOR ${INDEX} IN RANGE 0 ${length}
279 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra97f8d062020-11-17 15:48:23 -0800280 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
281 # When testing multi-tcont this may need some adjustment.
TorstenThieme45071602021-03-16 12:14:37 +0000282 Exit For Loop If not ('uni_config' in $value)
Girish Gowdra97f8d062020-11-17 15:48:23 -0800283 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000284 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
285 ${list_id}= Get Index From List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000286 Should Be Equal As Integers ${list_id} -1
TorstenThiemefe7099e2021-01-29 08:41:04 +0000287 ... msg=Combination of Pon, Onu and Uni (${oltpononuuniid}) exist multiple in etcd data!
288 Append To List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000289 Validate Onu Id ${value}
290 Validate Uni Id ${value}
291 ${serial_number}= Get From Dictionary ${value} serial_number
292 ${list_id}= Get Index From List ${serialnumberlist} ${serial_number}
293 Should Be Equal As Integers ${list_id} -1
294 ... msg=Serial number (${serial_number}) exists multiple in etcd data!
295 Append To List ${serialnumberlist} ${serial_number}
296 END
297
TorstenThieme52ef8392020-11-10 13:42:26 +0000298Validate Vlan Rules In Etcd
299 [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd.
300 ... It checks the given number of cookie_slice, match_vid (=4096) and set_vid.
301 ... Furthermore it returns a list of all set_vid.
302 ... In case of a passed dictionary containing set_vids these will be checked for to
303 ... current set-vid depending on setvidequal (True=equal, False=not equal).
304 [Arguments] ${nbofcookieslice}=1 ${reqmatchvid}=4096 ${prevvlanrules}=${NONE} ${setvidequal}=False
TorstenThiemefa29a892021-03-11 14:11:29 +0000305 ... ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000306 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
TorstenThiemefa29a892021-03-11 14:11:29 +0000307 ${etcddata}= Get ONU Go Adapter ETCD Data ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme52ef8392020-11-10 13:42:26 +0000308 #prepare result for json convert
309 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
310 ${jsondata}= To Json ${result}
311 ${length}= Get Length ${jsondata}
312 log ${jsondata}
313 ${vlan_rules}= Create Dictionary
314 FOR ${INDEX} IN RANGE 0 ${length}
315 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra295c1692020-11-19 10:51:53 -0800316 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
317 # When testing multi-tcont this may need some adjustment.
318 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000319 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000320 ${cookieslice}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]} cookie_slice
321 #@{cookieslicelist}= Split String ${cookieslice} ,
322 ${foundcookieslices}= Get Length ${cookieslice}
323 Should Be Equal As Integers ${foundcookieslices} ${nbofcookieslice}
324 ${matchvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
325 ... match_vid
326 Should Be Equal As Integers ${matchvid} ${reqmatchvid}
327 ${setvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
328 ... set_vid
329 ${evalresult}= Evaluate 2 <= ${setvid} <= 4095
330 Should Be True ${evalresult} msg=set_vid out of range (${setvid})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000331 Set To Dictionary ${vlan_rules} ${oltpononuuniid} ${setvid}
TorstenThieme52ef8392020-11-10 13:42:26 +0000332 ${oldsetvidvalid} Set Variable If ${prevvlanrules} is ${NONE} False True
TorstenThiemefe7099e2021-01-29 08:41:04 +0000333 ${prevsetvid}= Set Variable If ${oldsetvidvalid} ${prevvlanrules['${oltpononuuniid}']}
TorstenThieme52ef8392020-11-10 13:42:26 +0000334 Run Keyword If ${oldsetvidvalid} and ${setvidequal}
335 ... Should Be Equal As Integers ${prevsetvid} ${setvid}
336 ... ELSE IF ${oldsetvidvalid} and not ${setvidequal}
337 ... Should Not Be Equal As Integers ${prevsetvid} ${setvid}
338 END
TorstenThieme440b7c02020-12-18 15:42:57 +0000339 log Many ${vlan_rules}
TorstenThieme52ef8392020-11-10 13:42:26 +0000340 [Return] ${vlan_rules}
341
342Get ONU Go Adapter ETCD Data
343 [Documentation] This keyword delivers openonu-go-adapter Data stored in etcd
TorstenThieme3af12312021-03-10 16:15:24 +0000344 [Arguments] ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True ${without_pm_data}=True
TorstenThieme52ef8392020-11-10 13:42:26 +0000345 ${namespace}= Set Variable default
346 ${podname}= Set Variable etcd
TorstenThieme3385cdc2021-02-04 13:50:50 +0000347 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
TorstenThieme3af12312021-03-10 16:15:24 +0000348 ${commandget}= Catenate
349 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/openonu'
350 ${commandget}= Run Keyword If ${without_prefix} Catenate ${commandget}
351 ... | grep -v service/${kvstoreprefix}/openonu
TorstenThiemefa29a892021-03-11 14:11:29 +0000352 ... ELSE Set Variable ${commandget}
TorstenThieme3af12312021-03-10 16:15:24 +0000353 ${commandget}= Run Keyword If ${without_pm_data} Catenate ${commandget} | grep -v instances_active
TorstenThiemefa29a892021-03-11 14:11:29 +0000354 ... ELSE Set Variable ${commandget}
Holger Hildebrandt23147742020-11-16 10:13:21 +0000355 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThieme52ef8392020-11-10 13:42:26 +0000356 log ${result}
357 [Return] ${result}
358
359Prepare ONU Go Adapter ETCD Data For Json
360 [Documentation] This keyword prepares openonu-go-adapter Data stored in etcd for converting
361 ... to json
362 [Arguments] ${etcddata}
363 #prepare result for json convert
364 ${prepresult}= Replace String ${etcddata} \n ,
365 ${prepresult}= Strip String ${prepresult} mode=right characters=,
366 ${prepresult}= Set Variable [${prepresult}]
367 log ${prepresult}
368 [Return] ${prepresult}
369
TorstenThieme52ef8392020-11-10 13:42:26 +0000370Read Pon Onu Uni String
TorstenThiemefe7099e2021-01-29 08:41:04 +0000371 [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 +0000372 ... taken from etcd data of onu go adapter
373 [Arguments] ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000374 ${tppathlines}= Replace String ${tp_path} / \n
TorstenThiemefe7099e2021-01-29 08:41:04 +0000375 ${olt}= Get Value Of Tp Path Element ${tppathlines} olt
TorstenThieme52ef8392020-11-10 13:42:26 +0000376 ${pon}= Get Value Of Tp Path Element ${tppathlines} pon
377 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
378 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
TorstenThiemefe7099e2021-01-29 08:41:04 +0000379 ${valuesid}= Set Variable ${olt}/${pon}/${onu}/${uni}
TorstenThieme52ef8392020-11-10 13:42:26 +0000380 log ${valuesid}
381 [Return] ${valuesid}
382
383Get Value Of Tp Path Element
TorstenThieme17756ea2020-11-11 14:09:47 +0000384 [Documentation] This keyword delivers numeric value of given tp path element.
TorstenThieme52ef8392020-11-10 13:42:26 +0000385 [Arguments] ${tp_path_lines} ${element}
386 ${value}= Get Lines Containing String ${tp_path_lines} ${element}-\{
387 ${value}= Remove String ${value} ${element}-\{
388 ${value}= Remove String ${value} \}
389 log ${value}
390 [Return] ${value}
391
TorstenThieme17756ea2020-11-11 14:09:47 +0000392Validate Onu Id
393 [Documentation] This keyword validates ONU Id of passed etcd data.
394 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800395 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
396 # When testing multi-tcont this may need some adjustment.
397 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000398 ${tppathlines}= Replace String ${tp_path} / \n
399 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
400 ${onu_id}= Get From Dictionary ${value} onu_id
401 Should Be Equal As Integers ${onu} ${onu_id}
402 ... msg=Onu-Id (${onu_id}) does not match onu (${onu}) from tp_path in etcd data!
403 Should Be True ${onu_id}>=1
404
405Validate Uni Id
406 [Documentation] This keyword validates UNI Id of passed etcd data.
407 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800408 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
409 # When testing multi-tcont this may need some adjustment.
410 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000411 ${tppathlines}= Replace String ${tp_path} / \n
412 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
413 ${uni_id}= Get From Dictionary ${value['uni_config'][0]} uni_id
414 Should Be Equal As Integers ${uni} ${uni_id}
415 ... msg=Uni-Id (${uni_id}) does not match onu (${uni}) from tp_path in etcd data!
TorstenThieme52ef8392020-11-10 13:42:26 +0000416
TorstenThieme45071602021-03-16 12:14:37 +0000417Delete ONU Go Adapter ETCD Data
418 [Documentation] This keyword deletes openonu-go-adapter Data stored in etcd
419 [Arguments] ${defaultkvstoreprefix}=voltha_voltha ${validate}=False
420 ${namespace}= Set Variable default
421 ${podname}= Set Variable etcd
422 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
423 ${commandget}= Catenate
424 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/${kvstoreprefix}/openonu'
425 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
426 log ${result}
427 Run Keyword If ${validate} Wait Until Keyword Succeeds ${timeout} 1s
428 ... Validate Onu Data In Etcd 0 without_pm_data=False
429 [Return] ${result}
430
TorstenThiemed4f48962020-12-08 12:17:19 +0000431Wait for Ports in ONOS for all OLTs
TorstenThieme440b7c02020-12-18 15:42:57 +0000432 [Documentation] Waits untill a certain number of ports are enabled in all OLTs
TorstenThieme731a7592021-07-01 14:26:54 +0000433 [Arguments] ${host} ${port} ${count} ${filter} ${max_wait_time}=10m ${determine_number}=False
TorstenThiemed4f48962020-12-08 12:17:19 +0000434 FOR ${J} IN RANGE 0 ${num_olts}
435 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
436 ${onu_count}= Set Variable ${list_olts}[${J}][onucount]
437 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
438 ... ${olt_serial_number}
439 Set Global Variable ${of_id}
TorstenThiemeff9c9142021-04-08 07:21:34 +0000440 ${count2check}= Set Variable If ${count}==${num_all_onus} ${onu_count} ${count}
441 # if flag determine_number is set to True, always determine the number of real ONUs (overwrite previous value)
442 ${count2check}= Run Keyword If ${determine_number} Determine Number Of ONU ${olt_serial_number}
443 ... ELSE Set Variable ${count2check}
TorstenThieme731a7592021-07-01 14:26:54 +0000444 Wait for Ports in ONOS ${host} ${port} ${count2check} ${of_id} BBSM ${max_wait_time}
TorstenThiemed4f48962020-12-08 12:17:19 +0000445 END
446
TorstenThieme440b7c02020-12-18 15:42:57 +0000447Wait for all ONU Ports in ONOS Disabled
448 [Documentation] Waits untill a all ONU ports are disabled in all ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000449 [Arguments] ${host} ${port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000450 FOR ${I} IN RANGE 0 ${num_all_onus}
451 ${src}= Set Variable ${hosts.src[${I}]}
452 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
453 ... ${src['olt']}
454 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']} ${of_id}
TorstenThieme731a7592021-07-01 14:26:54 +0000455 Wait Until Keyword Succeeds ${timeout} 2s Assert ONU Port Is Disabled ${host} ${port} ${of_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000456 ... ${onu_port}
457 END
458
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000459Map State
460 [Documentation] This keyword converts the passed numeric value or name of a onu state to its state values.
461 [Arguments] ${state}
462 # create state lists with corresponding return values
463 # ADMIN-STATE OPER-STATUS CONNECT-STATUS ONU-STATE (number/name)
464 ${state1} Create List ENABLED ACTIVATING REACHABLE 1 activating-onu
465 ${state2} Create List ENABLED ACTIVATING REACHABLE 2 starting-openomci
466 ${state3} Create List ENABLED ACTIVATING REACHABLE 3 discovery-mibsync-complete
467 ${state4} Create List ENABLED ACTIVE REACHABLE 4 initial-mib-downloaded
468 ${state5} Create List ENABLED ACTIVE REACHABLE 5 tech-profile-config-download-success
469 ${state6} Create List ENABLED ACTIVE REACHABLE 6 omci-flows-pushed
470 ${state7} Create List DISABLED UNKNOWN REACHABLE 7 omci-admin-lock
471 ${state8} Create List ENABLED ACTIVE REACHABLE 8 onu-reenabled
472 ${state9} Create List ENABLED DISCOVERED UNREACHABLE 9 stopping-openomci
473 ${state10} Create List ENABLED DISCOVERED REACHABLE 10 rebooting
474 ${state11} Create List ENABLED DISCOVERED REACHABLE 11 omci-flows-deleted
475 ${state12} Create List DISABLED UNKNOWN REACHABLE 12 tech-profile-config-delete-success
476 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Set Variable If
477 ... '${state}'=='1' or '${state}'=='activating-onu' ${state1}
478 ... '${state}'=='2' or '${state}'=='starting-openomci' ${state2}
479 ... '${state}'=='3' or '${state}'=='discovery-mibsync-complete' ${state3}
480 ... '${state}'=='4' or '${state}'=='initial-mib-downloaded' ${state4}
481 ... '${state}'=='5' or '${state}'=='tech-profile-config-download-success' ${state5}
482 ... '${state}'=='6' or '${state}'=='omci-flows-pushed' ${state6}
483 ... '${state}'=='7' or '${state}'=='omci-admin-lock' ${state7}
484 ... '${state}'=='8' or '${state}'=='onu-reenabled' ${state8}
485 ... '${state}'=='9' or '${state}'=='stopping-openomci' ${state9}
486 ... '${state}'=='10' or '${state}'=='rebooting' ${state10}
487 ... '${state}'=='11' or '${state}'=='omci-flows-deleted' ${state11}
488 ... '${state}'=='12' or '${state}'=='tech-profile-config-delete-success' ${state12}
489 [Return] ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}