blob: 5a7fdfbbdb53c2a4157643df55915dbad8cf1e0a [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
17
TorstenThiemed4f48962020-12-08 12:17:19 +000018
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000019*** Keywords ***
TorstenThieme440b7c02020-12-18 15:42:57 +000020Calculate Timeout
21 [Documentation] Calculates the timeout regarding num-onus in case of more than 4 onus
22 [Arguments] ${basetimeout}=60s
23 ${new_timeout} Fetch From Left ${basetimeout} s
24 ${new_timeout}= evaluate ${new_timeout}+((${num_all_onus}-4)*10)
25 ${new_timeout}= Set Variable If (not ${debugmode}) and (${new_timeout}>300)
26 ... 300 ${new_timeout}
27 ${new_timeout}= Catenate SEPARATOR= ${new_timeout} s
28 [Return] ${new_timeout}
29
30Power On ONU Device
31 [Documentation] This keyword turns on the power for all onus.
32 [Arguments] ${namespace}
TorstenThiemefe7099e2021-01-29 08:41:04 +000033 FOR ${J} IN RANGE 0 ${num_olts}
34 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
35 ${bbsim}= Catenate SEPARATOR= bbsim ${J}
36 ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
37 Power On ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
38 END
39
40Power On ONU Device per OLT
41 [Documentation] This keyword turns on the power for all onus.
42 [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000043 FOR ${I} IN RANGE 0 ${num_all_onus}
44 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThiemefe7099e2021-01-29 08:41:04 +000045 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
46 Power On ONU ${namespace} ${bbsim_pod} ${src['onu']}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000047 END
48
TorstenThieme440b7c02020-12-18 15:42:57 +000049Power Off ONU Device
TorstenThiemefe7099e2021-01-29 08:41:04 +000050 [Documentation] This keyword turns off the power for all onus per olt.
TorstenThieme440b7c02020-12-18 15:42:57 +000051 [Arguments] ${namespace}
TorstenThiemefe7099e2021-01-29 08:41:04 +000052 FOR ${J} IN RANGE 0 ${num_olts}
53 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
54 ${bbsim}= Catenate SEPARATOR= bbsim ${J}
55 ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
56 Power Off ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
57 END
58
59Power Off ONU Device per OLT
60 [Documentation] This keyword turns off the power for all onus per olt.
61 [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
TorstenThieme440b7c02020-12-18 15:42:57 +000062 FOR ${I} IN RANGE 0 ${num_all_onus}
63 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThiemefe7099e2021-01-29 08:41:04 +000064 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
65 Power Off ONU ${namespace} ${bbsim_pod} ${src['onu']}
TorstenThieme440b7c02020-12-18 15:42:57 +000066 END
67
68Current State Test
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000069 [Documentation] This keyword checks the passed state of the given onu.
70 [Arguments] ${state} ${onu} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY}
71 ... ${reqconnectstatus}=${EMPTY}
72 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
73 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
74 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
75 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
76 ... ${connect_status}
77 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
78 ... Validate Device ${admin_state} ${oper_status} ${connect_status}
79 ... ${onu} onu=True onu_reason=${onu_state}
80
TorstenThieme440b7c02020-12-18 15:42:57 +000081Current State Test All Onus
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000082 [Documentation] This keyword checks the passed state of all onus.
83 ... Hint: ${timeStart} will be not evaluated here!
84 [Arguments] ${state} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY} ${reqconnectstatus}=${EMPTY}
TorstenThieme53450ff2021-05-11 09:44:33 +000085 ... ${alternativeonustate}=${EMPTY} ${timeout}=${timeout}
TorstenThieme440b7c02020-12-18 15:42:57 +000086 ${timeStart}= Get Current Date
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000087 ${list_onus} Create List
88 Build ONU SN List ${list_onus}
89 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
90 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
91 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
92 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
93 ... ${connect_status}
94 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
95 ... Validate ONU Devices With Duration
96 ... ${admin_state} ${oper_status} ${connect_status}
TorstenThieme52ef8392020-11-10 13:42:26 +000097 ... ${onu_state} ${list_onus} ${timeStart} alternate_reason=${alternativeonustate}
TorstenThieme53450ff2021-05-11 09:44:33 +000098 # teardown is used as 'return' for result of Validate ONU Devices With Duration (used for ONUNegativeStateTests)
99 [Teardown] Run Keyword If "${KEYWORD STATUS}"=="FAIL" Set Suite Variable ${StateTestAllONUs} False
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000100
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000101Log Ports
102 [Documentation] This keyword logs all port data available in ONOS of first port per ONU
103 [Arguments] ${onlyenabled}=False
104 ${cmd} Set Variable If ${onlyenabled} ports -e ports
TorstenThieme731a7592021-07-01 14:26:54 +0000105 ${onu_ports}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${cmd}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000106 ${lines} = Get Lines Matching Regexp ${onu_ports} .*portName=BBSM[0-9]{8}-1
107 Log ${lines}
108
109Kill Adaptor
110 [Documentation] This keyword kills the passed adaptor.
111 [Arguments] ${namespace} ${name}
112 ${cmd} Catenate
113 ... kubectl exec -it -n voltha $(kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}')
114 ... -- /bin/sh -c "kill 1"
115 ${rc} ${output}= Run and Return Rc and Output ${cmd}
116 Log ${output}
117
TorstenThieme440b7c02020-12-18 15:42:57 +0000118Kill And Check Onu Adaptor
119 [Documentation] This keyword kills ONU Adaptor and waits for it to come up again
120 ... Following steps will be executed:
121 ... - kill openonu adaptor
122 ... - check openonu adaptor is ready again
123 [Arguments] ${namespace}
124 ${list_openonu_apps} Create List adapter-open-onu
125 ${adaptorname}= Set Variable open-onu
126 Kill Adaptor ${namespace} ${adaptorname}
127 Sleep 5s
128 Wait For Pods Ready ${namespace} ${list_openonu_apps}
129
130Restart And Check Onu Adaptor
131 [Documentation] This keyword restarts ONU Adaptor and waits for it to come up again
132 ... Following steps will be executed:
133 ... - restart openonu adaptor
134 ... - check openonu adaptor is ready again
135 [Arguments] ${namespace}
136 ${list_openonu_apps} Create List adapter-open-onu
Matteo Scandolo6f24ea92021-04-29 11:55:50 -0700137 ${openonu_label_key} Set Variable app
138 ${openonu_label_value} Set Variable adapter-open-onu
139 Restart Pod By Label ${namespace} ${openonu_label_key} ${openonu_label_value}
TorstenThieme440b7c02020-12-18 15:42:57 +0000140 Sleep 5s
141 Wait For Pods Ready ${namespace} ${list_openonu_apps}
142
143Disable Onu Device
144 [Documentation] This keyword disables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000145 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000146 FOR ${I} IN RANGE 0 ${num_all_onus}
147 ${src}= Set Variable ${hosts.src[${I}]}
148 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000149 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
150 Continue For Loop If -1 != ${onu_id}
151 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000152 Disable Device ${onu_device_id}
153 Wait Until Keyword Succeeds 20s 2s Test Devices Disabled in VOLTHA Id=${onu_device_id}
154 END
155
156Enable Onu Device
157 [Documentation] This keyword enables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000158 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000159 FOR ${I} IN RANGE 0 ${num_all_onus}
160 ${src}= Set Variable ${hosts.src[${I}]}
161 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000162 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
163 Continue For Loop If -1 != ${onu_id}
164 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000165 Enable Device ${onu_device_id}
166 END
167
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000168Verify MIB Template Data Available
169 [Documentation] This keyword verifies MIB Template Data stored in etcd
170 ${namespace}= Set Variable default
TorstenThiemed4f48962020-12-08 12:17:19 +0000171 ${podname}= Set Variable etcd
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000172 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800173 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000174 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000175 Should Not Be Empty ${result} No MIB Template Data stored in etcd!
176
177Delete MIB Template Data
178 [Documentation] This keyword deletes MIB Template Data stored in etcd
179 ${namespace}= Set Variable default
180 ${podname}= Set Variable etcd
181 ${commanddel} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800182 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000183 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commanddel}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000184 Sleep 3s
185 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800186 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000187 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000188 Should Be Empty ${result} Could not delete MIB Template Data stored in etcd!
189
TorstenThieme440b7c02020-12-18 15:42:57 +0000190Set Tech Profile
191 [Documentation] This keyword sets the passed TechProfile for the test
192 [Arguments] ${TechProfile}
193 Log To Console \nTechProfile:${TechProfile}
194 ${namespace}= Set Variable default
195 ${podname}= Set Variable etcd
196 ${src}= Set Variable ${data_dir}/TechProfile-${TechProfile}.json
197 ${dest}= Set Variable /tmp/flexpod.json
198 ${command} Catenate
199 ... /bin/sh -c 'cat ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64'
200 Copy File To Pod ${namespace} ${podname} ${src} ${dest}
201 Exec Pod In Kube ${namespace} ${podname} ${command}
202 ${commandget} Catenate
203 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
204 Exec Pod In Kube ${namespace} ${podname} ${commandget}
205
206Remove Tech Profile
207 [Documentation] This keyword removes TechProfile
208 Log To Console \nTechProfile:${TechProfile}
209 ${namespace}= Set Variable default
210 ${podname}= Set Variable etcd
211 ${command} Catenate
212 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/64'
213 Exec Pod In Kube ${namespace} ${podname} ${command}
214 ${commandget} Catenate
215 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
216 Exec Pod In Kube ${namespace} ${podname} ${commandget}
217
TorstenThieme17756ea2020-11-11 14:09:47 +0000218Validate Onu Data In Etcd
219 [Documentation] This keyword validates openonu-go-adapter Data stored in etcd.
220 ... It checks unique of serial_number and combination of pon, onu and uni in tp_path.
221 ... Furthermore it evaluates the values of onu_id and uni_id with values read from tp_path.
222 ... Number of etcd entries has to match with the passed number.
TorstenThieme3385cdc2021-02-04 13:50:50 +0000223 [Arguments] ${nbofetcddata}=${num_all_onus} ${defaultkvstoreprefix}=voltha_voltha
TorstenThiemefa29a892021-03-11 14:11:29 +0000224 ... ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000225 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
TorstenThiemefa29a892021-03-11 14:11:29 +0000226 ${etcddata}= Get ONU Go Adapter ETCD Data ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme17756ea2020-11-11 14:09:47 +0000227 #prepare result for json convert
228 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
229 ${jsondata}= To Json ${result}
230 ${length}= Get Length ${jsondata}
231 log ${jsondata}
232 Run Keyword And Continue On Failure Should Be Equal As Integers ${length} ${nbofetcddata}
233 ... msg=Number etcd data (${length}) does not match required (${nbofetcddata})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000234 ${oltpononuuniidlist}= Create List
TorstenThieme17756ea2020-11-11 14:09:47 +0000235 ${serialnumberlist}= Create List
236 FOR ${INDEX} IN RANGE 0 ${length}
237 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra97f8d062020-11-17 15:48:23 -0800238 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
239 # When testing multi-tcont this may need some adjustment.
TorstenThieme45071602021-03-16 12:14:37 +0000240 Exit For Loop If not ('uni_config' in $value)
Girish Gowdra97f8d062020-11-17 15:48:23 -0800241 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000242 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
243 ${list_id}= Get Index From List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000244 Should Be Equal As Integers ${list_id} -1
TorstenThiemefe7099e2021-01-29 08:41:04 +0000245 ... msg=Combination of Pon, Onu and Uni (${oltpononuuniid}) exist multiple in etcd data!
246 Append To List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000247 Validate Onu Id ${value}
248 Validate Uni Id ${value}
249 ${serial_number}= Get From Dictionary ${value} serial_number
250 ${list_id}= Get Index From List ${serialnumberlist} ${serial_number}
251 Should Be Equal As Integers ${list_id} -1
252 ... msg=Serial number (${serial_number}) exists multiple in etcd data!
253 Append To List ${serialnumberlist} ${serial_number}
254 END
255
TorstenThieme52ef8392020-11-10 13:42:26 +0000256Validate Vlan Rules In Etcd
257 [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd.
258 ... It checks the given number of cookie_slice, match_vid (=4096) and set_vid.
259 ... Furthermore it returns a list of all set_vid.
260 ... In case of a passed dictionary containing set_vids these will be checked for to
261 ... current set-vid depending on setvidequal (True=equal, False=not equal).
262 [Arguments] ${nbofcookieslice}=1 ${reqmatchvid}=4096 ${prevvlanrules}=${NONE} ${setvidequal}=False
TorstenThiemefa29a892021-03-11 14:11:29 +0000263 ... ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000264 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
TorstenThiemefa29a892021-03-11 14:11:29 +0000265 ${etcddata}= Get ONU Go Adapter ETCD Data ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme52ef8392020-11-10 13:42:26 +0000266 #prepare result for json convert
267 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
268 ${jsondata}= To Json ${result}
269 ${length}= Get Length ${jsondata}
270 log ${jsondata}
271 ${vlan_rules}= Create Dictionary
272 FOR ${INDEX} IN RANGE 0 ${length}
273 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra295c1692020-11-19 10:51:53 -0800274 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
275 # When testing multi-tcont this may need some adjustment.
276 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000277 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000278 ${cookieslice}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]} cookie_slice
279 #@{cookieslicelist}= Split String ${cookieslice} ,
280 ${foundcookieslices}= Get Length ${cookieslice}
281 Should Be Equal As Integers ${foundcookieslices} ${nbofcookieslice}
282 ${matchvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
283 ... match_vid
284 Should Be Equal As Integers ${matchvid} ${reqmatchvid}
285 ${setvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
286 ... set_vid
287 ${evalresult}= Evaluate 2 <= ${setvid} <= 4095
288 Should Be True ${evalresult} msg=set_vid out of range (${setvid})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000289 Set To Dictionary ${vlan_rules} ${oltpononuuniid} ${setvid}
TorstenThieme52ef8392020-11-10 13:42:26 +0000290 ${oldsetvidvalid} Set Variable If ${prevvlanrules} is ${NONE} False True
TorstenThiemefe7099e2021-01-29 08:41:04 +0000291 ${prevsetvid}= Set Variable If ${oldsetvidvalid} ${prevvlanrules['${oltpononuuniid}']}
TorstenThieme52ef8392020-11-10 13:42:26 +0000292 Run Keyword If ${oldsetvidvalid} and ${setvidequal}
293 ... Should Be Equal As Integers ${prevsetvid} ${setvid}
294 ... ELSE IF ${oldsetvidvalid} and not ${setvidequal}
295 ... Should Not Be Equal As Integers ${prevsetvid} ${setvid}
296 END
TorstenThieme440b7c02020-12-18 15:42:57 +0000297 log Many ${vlan_rules}
TorstenThieme52ef8392020-11-10 13:42:26 +0000298 [Return] ${vlan_rules}
299
300Get ONU Go Adapter ETCD Data
301 [Documentation] This keyword delivers openonu-go-adapter Data stored in etcd
TorstenThieme3af12312021-03-10 16:15:24 +0000302 [Arguments] ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True ${without_pm_data}=True
TorstenThieme52ef8392020-11-10 13:42:26 +0000303 ${namespace}= Set Variable default
304 ${podname}= Set Variable etcd
TorstenThieme3385cdc2021-02-04 13:50:50 +0000305 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
TorstenThieme3af12312021-03-10 16:15:24 +0000306 ${commandget}= Catenate
307 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/openonu'
308 ${commandget}= Run Keyword If ${without_prefix} Catenate ${commandget}
309 ... | grep -v service/${kvstoreprefix}/openonu
TorstenThiemefa29a892021-03-11 14:11:29 +0000310 ... ELSE Set Variable ${commandget}
TorstenThieme3af12312021-03-10 16:15:24 +0000311 ${commandget}= Run Keyword If ${without_pm_data} Catenate ${commandget} | grep -v instances_active
TorstenThiemefa29a892021-03-11 14:11:29 +0000312 ... ELSE Set Variable ${commandget}
Holger Hildebrandt23147742020-11-16 10:13:21 +0000313 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThieme52ef8392020-11-10 13:42:26 +0000314 log ${result}
315 [Return] ${result}
316
317Prepare ONU Go Adapter ETCD Data For Json
318 [Documentation] This keyword prepares openonu-go-adapter Data stored in etcd for converting
319 ... to json
320 [Arguments] ${etcddata}
321 #prepare result for json convert
322 ${prepresult}= Replace String ${etcddata} \n ,
323 ${prepresult}= Strip String ${prepresult} mode=right characters=,
324 ${prepresult}= Set Variable [${prepresult}]
325 log ${prepresult}
326 [Return] ${prepresult}
327
TorstenThieme52ef8392020-11-10 13:42:26 +0000328Read Pon Onu Uni String
TorstenThiemefe7099e2021-01-29 08:41:04 +0000329 [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 +0000330 ... taken from etcd data of onu go adapter
331 [Arguments] ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000332 ${tppathlines}= Replace String ${tp_path} / \n
TorstenThiemefe7099e2021-01-29 08:41:04 +0000333 ${olt}= Get Value Of Tp Path Element ${tppathlines} olt
TorstenThieme52ef8392020-11-10 13:42:26 +0000334 ${pon}= Get Value Of Tp Path Element ${tppathlines} pon
335 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
336 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
TorstenThiemefe7099e2021-01-29 08:41:04 +0000337 ${valuesid}= Set Variable ${olt}/${pon}/${onu}/${uni}
TorstenThieme52ef8392020-11-10 13:42:26 +0000338 log ${valuesid}
339 [Return] ${valuesid}
340
341Get Value Of Tp Path Element
TorstenThieme17756ea2020-11-11 14:09:47 +0000342 [Documentation] This keyword delivers numeric value of given tp path element.
TorstenThieme52ef8392020-11-10 13:42:26 +0000343 [Arguments] ${tp_path_lines} ${element}
344 ${value}= Get Lines Containing String ${tp_path_lines} ${element}-\{
345 ${value}= Remove String ${value} ${element}-\{
346 ${value}= Remove String ${value} \}
347 log ${value}
348 [Return] ${value}
349
TorstenThieme17756ea2020-11-11 14:09:47 +0000350Validate Onu Id
351 [Documentation] This keyword validates ONU Id of passed etcd data.
352 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800353 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
354 # When testing multi-tcont this may need some adjustment.
355 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000356 ${tppathlines}= Replace String ${tp_path} / \n
357 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
358 ${onu_id}= Get From Dictionary ${value} onu_id
359 Should Be Equal As Integers ${onu} ${onu_id}
360 ... msg=Onu-Id (${onu_id}) does not match onu (${onu}) from tp_path in etcd data!
361 Should Be True ${onu_id}>=1
362
363Validate Uni Id
364 [Documentation] This keyword validates UNI Id of passed etcd data.
365 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800366 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
367 # When testing multi-tcont this may need some adjustment.
368 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000369 ${tppathlines}= Replace String ${tp_path} / \n
370 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
371 ${uni_id}= Get From Dictionary ${value['uni_config'][0]} uni_id
372 Should Be Equal As Integers ${uni} ${uni_id}
373 ... msg=Uni-Id (${uni_id}) does not match onu (${uni}) from tp_path in etcd data!
TorstenThieme52ef8392020-11-10 13:42:26 +0000374
TorstenThieme45071602021-03-16 12:14:37 +0000375Delete ONU Go Adapter ETCD Data
376 [Documentation] This keyword deletes openonu-go-adapter Data stored in etcd
377 [Arguments] ${defaultkvstoreprefix}=voltha_voltha ${validate}=False
378 ${namespace}= Set Variable default
379 ${podname}= Set Variable etcd
380 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
381 ${commandget}= Catenate
382 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/${kvstoreprefix}/openonu'
383 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
384 log ${result}
385 Run Keyword If ${validate} Wait Until Keyword Succeeds ${timeout} 1s
386 ... Validate Onu Data In Etcd 0 without_pm_data=False
387 [Return] ${result}
388
TorstenThiemed4f48962020-12-08 12:17:19 +0000389Wait for Ports in ONOS for all OLTs
TorstenThieme440b7c02020-12-18 15:42:57 +0000390 [Documentation] Waits untill a certain number of ports are enabled in all OLTs
TorstenThieme731a7592021-07-01 14:26:54 +0000391 [Arguments] ${host} ${port} ${count} ${filter} ${max_wait_time}=10m ${determine_number}=False
TorstenThiemed4f48962020-12-08 12:17:19 +0000392 FOR ${J} IN RANGE 0 ${num_olts}
393 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
394 ${onu_count}= Set Variable ${list_olts}[${J}][onucount]
395 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
396 ... ${olt_serial_number}
397 Set Global Variable ${of_id}
TorstenThiemeff9c9142021-04-08 07:21:34 +0000398 ${count2check}= Set Variable If ${count}==${num_all_onus} ${onu_count} ${count}
399 # if flag determine_number is set to True, always determine the number of real ONUs (overwrite previous value)
400 ${count2check}= Run Keyword If ${determine_number} Determine Number Of ONU ${olt_serial_number}
401 ... ELSE Set Variable ${count2check}
TorstenThieme731a7592021-07-01 14:26:54 +0000402 Wait for Ports in ONOS ${host} ${port} ${count2check} ${of_id} BBSM ${max_wait_time}
TorstenThiemed4f48962020-12-08 12:17:19 +0000403 END
404
TorstenThieme440b7c02020-12-18 15:42:57 +0000405Wait for all ONU Ports in ONOS Disabled
406 [Documentation] Waits untill a all ONU ports are disabled in all ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000407 [Arguments] ${host} ${port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000408 FOR ${I} IN RANGE 0 ${num_all_onus}
409 ${src}= Set Variable ${hosts.src[${I}]}
410 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
411 ... ${src['olt']}
412 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']} ${of_id}
TorstenThieme731a7592021-07-01 14:26:54 +0000413 Wait Until Keyword Succeeds ${timeout} 2s Assert ONU Port Is Disabled ${host} ${port} ${of_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000414 ... ${onu_port}
415 END
416
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000417Map State
418 [Documentation] This keyword converts the passed numeric value or name of a onu state to its state values.
419 [Arguments] ${state}
420 # create state lists with corresponding return values
421 # ADMIN-STATE OPER-STATUS CONNECT-STATUS ONU-STATE (number/name)
422 ${state1} Create List ENABLED ACTIVATING REACHABLE 1 activating-onu
423 ${state2} Create List ENABLED ACTIVATING REACHABLE 2 starting-openomci
424 ${state3} Create List ENABLED ACTIVATING REACHABLE 3 discovery-mibsync-complete
425 ${state4} Create List ENABLED ACTIVE REACHABLE 4 initial-mib-downloaded
426 ${state5} Create List ENABLED ACTIVE REACHABLE 5 tech-profile-config-download-success
427 ${state6} Create List ENABLED ACTIVE REACHABLE 6 omci-flows-pushed
428 ${state7} Create List DISABLED UNKNOWN REACHABLE 7 omci-admin-lock
429 ${state8} Create List ENABLED ACTIVE REACHABLE 8 onu-reenabled
430 ${state9} Create List ENABLED DISCOVERED UNREACHABLE 9 stopping-openomci
431 ${state10} Create List ENABLED DISCOVERED REACHABLE 10 rebooting
432 ${state11} Create List ENABLED DISCOVERED REACHABLE 11 omci-flows-deleted
433 ${state12} Create List DISABLED UNKNOWN REACHABLE 12 tech-profile-config-delete-success
434 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Set Variable If
435 ... '${state}'=='1' or '${state}'=='activating-onu' ${state1}
436 ... '${state}'=='2' or '${state}'=='starting-openomci' ${state2}
437 ... '${state}'=='3' or '${state}'=='discovery-mibsync-complete' ${state3}
438 ... '${state}'=='4' or '${state}'=='initial-mib-downloaded' ${state4}
439 ... '${state}'=='5' or '${state}'=='tech-profile-config-download-success' ${state5}
440 ... '${state}'=='6' or '${state}'=='omci-flows-pushed' ${state6}
441 ... '${state}'=='7' or '${state}'=='omci-admin-lock' ${state7}
442 ... '${state}'=='8' or '${state}'=='onu-reenabled' ${state8}
443 ... '${state}'=='9' or '${state}'=='stopping-openomci' ${state9}
444 ... '${state}'=='10' or '${state}'=='rebooting' ${state10}
445 ... '${state}'=='11' or '${state}'=='omci-flows-deleted' ${state11}
446 ... '${state}'=='12' or '${state}'=='tech-profile-config-delete-success' ${state12}
447 [Return] ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}