blob: c4c16b3d7ac0e916030b27826346bcbb61b6c742 [file] [log] [blame]
Joey Armstrong9fadcbe2024-01-17 19:00:37 -05001# Copyright 2020-2024 Open Networking Foundation (ONF) and the ONF Contributors
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
TorstenThieme00fe8262022-01-19 10:43:07 +000018Resource ./bbsim.robot
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000019
TorstenThiemed4f48962020-12-08 12:17:19 +000020
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000021*** Keywords ***
TorstenThieme373adfe2021-12-16 13:03:04 +000022Printout ONU Serial Number and Device Id
23 [Documentation] Printouts the ONU serial number and corresponding device id.
24 [Arguments] ${onu_sn}=${EMPTY} ${print2console}=False
25 ${output}= Set Variable \r\n
26 ${onu_sn_list} Create List
27 Run Keyword If "${onu_sn}"=="${EMPTY}" Build ONU SN List ${onu_sn_list}
28 ... ELSE Append To List ${onu_sn_list} ${onu_sn}
29 FOR ${sn} IN @{onu_sn_list}
30 ${device_id}= Get Device ID From SN ${sn}
TorstenThieme0fa54432023-02-14 13:27:20 +000031 ${output}= Catenate ${output}ONU Serial Number: ${sn} ONU Device ID: ${device_id}\r\n
TorstenThieme373adfe2021-12-16 13:03:04 +000032 END
33 Log ${output}
34 Run Keyword If ${print2console} Log ${output} console=yes
35
TorstenThieme440b7c02020-12-18 15:42:57 +000036Calculate Timeout
37 [Documentation] Calculates the timeout regarding num-onus in case of more than 4 onus
38 [Arguments] ${basetimeout}=60s
39 ${new_timeout} Fetch From Left ${basetimeout} s
40 ${new_timeout}= evaluate ${new_timeout}+((${num_all_onus}-4)*10)
41 ${new_timeout}= Set Variable If (not ${debugmode}) and (${new_timeout}>300)
42 ... 300 ${new_timeout}
43 ${new_timeout}= Catenate SEPARATOR= ${new_timeout} s
44 [Return] ${new_timeout}
45
TorstenThieme3494ceb2021-07-19 09:47:24 +000046Get Logical Id of OLT
47 [Documentation] Fills the logical id of OLT(s) if missing
48 FOR ${I} IN RANGE 0 ${num_olts}
49 # exit loop if logical id already known
50 Exit For Loop IF "${olt_ids}[${I}][logical_id]" != "${EMPTY}"
51 #read current device values
52 ${olt}= Get From List ${olt_ids} ${I}
53 ${olt_serial_number}= Get From Dictionary ${olt} sn
54 # read logical id and store it
55 ${logical_id}= Get Logical Device ID From SN ${olt_serial_number}
56 Set To Dictionary ${olt} logical_id ${logical_id}
57 Set List Value ${olt_ids} ${I} ${olt}
58 END
59 Set Global Variable ${olt_ids}
60
TorstenThieme440b7c02020-12-18 15:42:57 +000061Power On ONU Device
62 [Documentation] This keyword turns on the power for all onus.
63 [Arguments] ${namespace}
TorstenThiemefe7099e2021-01-29 08:41:04 +000064 FOR ${J} IN RANGE 0 ${num_olts}
65 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
66 ${bbsim}= Catenate SEPARATOR= bbsim ${J}
67 ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
68 Power On ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
69 END
70
71Power On ONU Device per OLT
72 [Documentation] This keyword turns on the power for all onus.
73 [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
TorstenThieme00fe8262022-01-19 10:43:07 +000074 @{onu_list}= Create List
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000075 FOR ${I} IN RANGE 0 ${num_all_onus}
76 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThiemefe7099e2021-01-29 08:41:04 +000077 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
TorstenThieme00fe8262022-01-19 10:43:07 +000078 ${sn}= Set Variable ${src['onu']}
79 # make sure all actions are done only once per onu
80 ${onu_id}= Get Index From List ${onu_list} ${sn}
81 Continue For Loop If -1 != ${onu_id}
82 Append To List ${onu_list} ${sn}
83 Power On ONU ${namespace} ${bbsim_pod} ${sn}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000084 END
85
TorstenThieme440b7c02020-12-18 15:42:57 +000086Power Off ONU Device
TorstenThiemefe7099e2021-01-29 08:41:04 +000087 [Documentation] This keyword turns off the power for all onus per olt.
TorstenThieme440b7c02020-12-18 15:42:57 +000088 [Arguments] ${namespace}
TorstenThiemefe7099e2021-01-29 08:41:04 +000089 FOR ${J} IN RANGE 0 ${num_olts}
90 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
91 ${bbsim}= Catenate SEPARATOR= bbsim ${J}
92 ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
93 Power Off ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
94 END
95
96Power Off ONU Device per OLT
97 [Documentation] This keyword turns off the power for all onus per olt.
98 [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
TorstenThieme00fe8262022-01-19 10:43:07 +000099 @{onu_list}= Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000100 FOR ${I} IN RANGE 0 ${num_all_onus}
101 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThiemefe7099e2021-01-29 08:41:04 +0000102 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
TorstenThieme00fe8262022-01-19 10:43:07 +0000103 ${sn}= Set Variable ${src['onu']}
104 # make sure all actions are done only once per onu
105 ${onu_id}= Get Index From List ${onu_list} ${sn}
106 Continue For Loop If -1 != ${onu_id}
107 Append To List ${onu_list} ${sn}
108 Power Off ONU ${namespace} ${bbsim_pod} ${sn}
109 END
110
111Set Wrong MDS Counter All ONUs
112 [Documentation] This keyword sets wrong MDS counter for all onus.
113 [Arguments] ${namespace}
114 FOR ${J} IN RANGE 0 ${num_olts}
115 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
116 ${bbsim}= Catenate SEPARATOR= bbsim ${J}
117 ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim}
118 Set Wrong MDS Counter per OLT ${namespace} ${olt_serial_number} ${bbsim_pod}
119 END
120
121Set Wrong MDS Counter per OLT
122 [Documentation] This keyword sets wrong MDS counter for all onus per olt.
123 [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod}
124 @{onu_list}= Create List
125 FOR ${I} IN RANGE 0 ${num_all_onus}
126 ${src}= Set Variable ${hosts.src[${I}]}
127 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
128 ${sn}= Set Variable ${src['onu']}
129 # make sure all actions are done only once per onu
130 ${onu_id}= Get Index From List ${onu_list} ${sn}
131 Continue For Loop If -1 != ${onu_id}
132 Append To List ${onu_list} ${sn}
133 Set Wrong MDS Counter ONU ${namespace} ${bbsim_pod} ${sn}
TorstenThieme440b7c02020-12-18 15:42:57 +0000134 END
135
136Current State Test
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000137 [Documentation] This keyword checks the passed state of the given onu.
138 [Arguments] ${state} ${onu} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY}
139 ... ${reqconnectstatus}=${EMPTY}
140 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
141 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
142 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
143 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
144 ... ${connect_status}
145 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
146 ... Validate Device ${admin_state} ${oper_status} ${connect_status}
147 ... ${onu} onu=True onu_reason=${onu_state}
148
TorstenThieme440b7c02020-12-18 15:42:57 +0000149Current State Test All Onus
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000150 [Documentation] This keyword checks the passed state of all onus.
151 ... Hint: ${timeStart} will be not evaluated here!
152 [Arguments] ${state} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY} ${reqconnectstatus}=${EMPTY}
TorstenThieme53450ff2021-05-11 09:44:33 +0000153 ... ${alternativeonustate}=${EMPTY} ${timeout}=${timeout}
TorstenThieme440b7c02020-12-18 15:42:57 +0000154 ${timeStart}= Get Current Date
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000155 ${list_onus} Create List
156 Build ONU SN List ${list_onus}
157 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
158 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
159 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
160 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
161 ... ${connect_status}
162 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
163 ... Validate ONU Devices With Duration
164 ... ${admin_state} ${oper_status} ${connect_status}
TorstenThieme52ef8392020-11-10 13:42:26 +0000165 ... ${onu_state} ${list_onus} ${timeStart} alternate_reason=${alternativeonustate}
TorstenThieme53450ff2021-05-11 09:44:33 +0000166 # teardown is used as 'return' for result of Validate ONU Devices With Duration (used for ONUNegativeStateTests)
167 [Teardown] Run Keyword If "${KEYWORD STATUS}"=="FAIL" Set Suite Variable ${StateTestAllONUs} False
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000168
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000169Reconcile Onu Adapter
170 [Documentation] Restarts the openonu adapter and waits for reconciling is finished and expected oper-state is reached
TorstenThieme712b2962021-11-17 14:16:15 +0000171 [Arguments] ${namespace} ${usekill2restart} ${oper_status} ${olt_to_be_deleted_sn}=${EMPTY}
TorstenThieme00fe8262022-01-19 10:43:07 +0000172 ... ${flow_delete_params}=&{EMPTY} ${wrong_MDS_counter}=False
TorstenThieme7e9f1252022-01-05 13:43:59 +0000173 # get last ready timestamp of openonu adapter
174 ${previous_ready_ts}= Get Pod Ready Timestamp by Label ${namespace} app adapter-open-onu
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000175 # restart OpenONU adapter
176 Run Keyword If ${usekill2restart} Kill And Check Onu Adaptor ${namespace}
177 ... ELSE Restart And Check Onu Adaptor ${namespace}
TorstenThieme7e9f1252022-01-05 13:43:59 +0000178 #check ready timestamp of openonu adapter, should be younger than the previous ready timestamp
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000179 ${openonu_ready_ts}= Get Pod Ready Timestamp by Label ${namespace} app adapter-open-onu
TorstenThieme7e9f1252022-01-05 13:43:59 +0000180 ${restart_duration}= Subtract Date From Date ${openonu_ready_ts} ${previous_ready_ts}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000181 Should Be True ${restart_duration}>0
rbodapat27ad26b2025-01-09 14:38:15 +0530182 # "Once the onu adapter is restarted, it takes a bit of time for the ONUs to reconcile, if the OLT is deleted before
183 # the ONUs are reconiled successfully there would be stale entries. This scenario is not handled in VOLTHA as of now.
184 # And there is no other to check if the reconcile has happened for all the ONUs. Due to this limitations a sleep
185 # of 60s is introduced to give enough time for onu adapter to reconcile the ONUs."
186 Sleep 60s
TorstenThieme712b2962021-11-17 14:16:15 +0000187 # delete the olt passed, if available (special feature)
188 ${olt_to_be_deleted_device_id}= Run Keyword IF "${olt_to_be_deleted_sn}"!="${EMPTY}"
189 ... Get OLTDeviceID From OLT List ${olt_to_be_deleted_sn}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000190 Run Keyword If "${olt_to_be_deleted_sn}"!="${EMPTY}" Delete Device ${olt_to_be_deleted_device_id}
191 # remove flows if params passed for it (special feature II)
TorstenThieme00fe8262022-01-19 10:43:07 +0000192 Run Keyword If ${flow_delete_params}!=&{EMPTY} Remove Flows Conditional ${flow_delete_params['unitag']}
193 ... ${flow_delete_params['onu_sn']} ${flow_delete_params['of_id']} ${flow_delete_params['onu_port']}
194 # Set wrong MDS counter (for all ONUs) if required (special feature III)
195 Run Keyword If ${wrong_MDS_counter} Set Wrong MDS Counter All ONUs ${namespace}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700196 # wait for the reconcile to complete
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000197 # - we check that communication to openonu-adapter is established again
198 # - we check that all ONUs leave reconcile state by validate a simple voltctl request will not responds with error
199 Wait Until Keyword Succeeds ${timeout} 1s Validate Last ONU Communication
TorstenThieme712b2962021-11-17 14:16:15 +0000200 Wait Until Keyword Succeeds ${timeout} 1s Validate All Onus Accessible ${olt_to_be_deleted_sn}
201 # - 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 +0000202 ${list_onus} Create List
TorstenThieme712b2962021-11-17 14:16:15 +0000203 FOR ${J} IN RANGE 0 ${num_olts}
204 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
205 Continue For Loop If "${olt_to_be_deleted_sn}"=="${olt_serial_number}"
206 Build ONU SN List ${list_onus} ${olt_serial_number}
207 END
208 Log ${list_onus}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000209 Run Keyword And Ignore Error Wait Until Keyword Succeeds ${timeout}
210 ... 1s Check all ONU OperStatus ${list_onus} ${oper_status}
211
TorstenThiemee512b1d2021-11-12 10:52:29 +0000212Validate All Onus Accessible
213 [Documentation] This keyword checks all onus accessible (again) with help of a simple voltctl request.
214 ... As long we've got an rc!=0 keyword will fail -> onu is not accessible.
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000215 ... As get request Onu image list is used, any other get command could be used for this check.
TorstenThieme712b2962021-11-17 14:16:15 +0000216 ... Will not check ONUs of passed deleted OLT (special feature)
217 [Arguments] ${deleted_olt}=${EMPTY}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700218 ${onu_list} Create List
219 FOR ${I} IN RANGE 0 ${num_all_onus}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000220 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThieme712b2962021-11-17 14:16:15 +0000221 ${olt_serial_number}= Set Variable ${src['olt']}
222 Continue For Loop If "${deleted_olt}"=="${olt_serial_number}"
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000223 ${onu_device_id}= Get Device ID From SN ${src['onu']}
224 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700225 Continue For Loop If -1 != ${onu_id}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000226 Append To List ${onu_list} ${onu_device_id}
227 ${rc} ${output}= Get Onu Image List ${onu_device_id}
TorstenThieme712b2962021-11-17 14:16:15 +0000228 Should Be True ${rc}==0 Onu ${src['onu']} (${onu_device_id}) still not accessible.
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700229 END
230
TorstenThieme00fe8262022-01-19 10:43:07 +0000231Remove Flows Conditional
232 [Documentation] This keyword removes the flows (subscriber) conditional depending on unitag.
233 ... In case of unitagsub==False (normal case) single subscriber remove will be executed.
234 ... In case of multi uni each uni id will be deleted.
235 [Arguments] ${unitagsub} ${onu_sn} ${of_id} ${onu_port}
236 # first handle 'normal' case without uni ports
237 Run Keyword If ${unitagsub}==False Wait Until Keyword Succeeds ${timeout} 2s
238 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
239 ... volt-remove-subscriber-access ${of_id} ${onu_port}
240 Return From Keyword If ${unitagsub}==False
241 # handle multi uni case
242 FOR ${I} IN RANGE 0 ${num_all_onus}
243 ${src}= Set Variable ${hosts.src[${I}]}
244 Continue For Loop If "${onu_sn}"!="${src['onu']}"
245 ${add_sub_cmd}= Catenate volt-remove-subscriber-unitag --tpId ${src['tp_id']} --sTag ${src['s_tag']}
246 ... --cTag ${src['c_tag']} ${src['onu']}-${src['uni_id']}
247 Wait Until Keyword Succeeds ${timeout} 2s Execute ONOS CLI Command use single connection
248 ... ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${add_sub_cmd}
249 END
250
TorstenThieme700ccbf2022-02-11 10:24:05 +0000251Remove Flows all ONUs
252 [Documentation] Remove all Flows from all onus
TorstenThieme22491b72022-03-31 13:12:27 +0000253 @{onu_list}= Create List
TorstenThieme700ccbf2022-02-11 10:24:05 +0000254 FOR ${I} IN RANGE 0 ${num_all_onus}
255 # Collect data for remove flow(s)
256 ${src}= Set Variable ${hosts.src[${I}]}
TorstenThieme22491b72022-03-31 13:12:27 +0000257 # skip if we have already handled this ONU
258 ${onu_sn}= Set Variable ${src['onu']}
259 ${onu_id}= Get Index From List ${onu_list} ${onu_sn}
260 Continue For Loop If -1 != ${onu_id}
261 Append To List ${onu_list} ${onu_sn}
TorstenThieme700ccbf2022-02-11 10:24:05 +0000262 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS ${src['olt']}
TorstenThieme22491b72022-03-31 13:12:27 +0000263 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${onu_sn}
TorstenThieme700ccbf2022-02-11 10:24:05 +0000264 ... ${of_id} ${src['uni_id']}
TorstenThieme700ccbf2022-02-11 10:24:05 +0000265 # Remove Flows
266 Remove Flows Conditional ${unitag_sub} ${onu_sn} ${of_id} ${onu_port}
267 END
268
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000269Log Ports
270 [Documentation] This keyword logs all port data available in ONOS of first port per ONU
271 [Arguments] ${onlyenabled}=False
272 ${cmd} Set Variable If ${onlyenabled} ports -e ports
TorstenThieme731a7592021-07-01 14:26:54 +0000273 ${onu_ports}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${cmd}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000274 ${lines} = Get Lines Matching Regexp ${onu_ports} .*portName=BBSM[0-9]{8}-1
275 Log ${lines}
276
277Kill Adaptor
278 [Documentation] This keyword kills the passed adaptor.
279 [Arguments] ${namespace} ${name}
280 ${cmd} Catenate
Matteo Scandolo6b524122021-10-22 14:34:29 -0700281 ... kubectl exec -it -n ${namespace} $(kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}')
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000282 ... -- /bin/sh -c "kill 1"
283 ${rc} ${output}= Run and Return Rc and Output ${cmd}
284 Log ${output}
285
TorstenThieme440b7c02020-12-18 15:42:57 +0000286Kill And Check Onu Adaptor
287 [Documentation] This keyword kills ONU Adaptor and waits for it to come up again
288 ... Following steps will be executed:
289 ... - kill openonu adaptor
290 ... - check openonu adaptor is ready again
291 [Arguments] ${namespace}
292 ${list_openonu_apps} Create List adapter-open-onu
293 ${adaptorname}= Set Variable open-onu
294 Kill Adaptor ${namespace} ${adaptorname}
295 Sleep 5s
296 Wait For Pods Ready ${namespace} ${list_openonu_apps}
297
298Restart And Check Onu Adaptor
299 [Documentation] This keyword restarts ONU Adaptor and waits for it to come up again
300 ... Following steps will be executed:
301 ... - restart openonu adaptor
302 ... - check openonu adaptor is ready again
303 [Arguments] ${namespace}
304 ${list_openonu_apps} Create List adapter-open-onu
Matteo Scandolo6f24ea92021-04-29 11:55:50 -0700305 ${openonu_label_key} Set Variable app
306 ${openonu_label_value} Set Variable adapter-open-onu
307 Restart Pod By Label ${namespace} ${openonu_label_key} ${openonu_label_value}
TorstenThieme440b7c02020-12-18 15:42:57 +0000308 Sleep 5s
309 Wait For Pods Ready ${namespace} ${list_openonu_apps}
310
311Disable Onu Device
312 [Documentation] This keyword disables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000313 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000314 FOR ${I} IN RANGE 0 ${num_all_onus}
315 ${src}= Set Variable ${hosts.src[${I}]}
316 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000317 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
318 Continue For Loop If -1 != ${onu_id}
319 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000320 Disable Device ${onu_device_id}
321 Wait Until Keyword Succeeds 20s 2s Test Devices Disabled in VOLTHA Id=${onu_device_id}
322 END
323
324Enable Onu Device
325 [Documentation] This keyword enables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000326 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000327 FOR ${I} IN RANGE 0 ${num_all_onus}
328 ${src}= Set Variable ${hosts.src[${I}]}
329 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000330 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
331 Continue For Loop If -1 != ${onu_id}
332 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000333 Enable Device ${onu_device_id}
334 END
335
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000336Verify MIB Template Data Available
337 [Documentation] This keyword verifies MIB Template Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000338 [Arguments] ${namespace}=default
TorstenThiemed4f48962020-12-08 12:17:19 +0000339 ${podname}= Set Variable etcd
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000340 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800341 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000342 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000343 Should Not Be Empty ${result} No MIB Template Data stored in etcd!
344
345Delete MIB Template Data
346 [Documentation] This keyword deletes MIB Template Data stored in etcd
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000347 [Arguments] ${namespace}=default
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000348 ${podname}= Set Variable etcd
349 ${commanddel} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800350 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000351 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commanddel}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000352 Sleep 3s
353 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800354 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000355 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000356 Should Be Empty ${result} Could not delete MIB Template Data stored in etcd!
357
TorstenThieme2d8327b2022-03-15 08:42:27 +0000358Get ONU MIB Template Data
359 [Documentation] This keyword delivers MIB Template Data stored in etcd
360 [Arguments] ${namespace}=default ${without_prefix}=True
361 ${podname}= Set Variable etcd
362 ${commandget} Catenate
363 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
364 ${commandget}= Run Keyword If ${without_prefix} Catenate ${commandget}
365 ... | grep -v service/voltha/omci_mibs/go_templates/
366 ... ELSE Set Variable ${commandget}
367 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
368 log ${result}
369 [Return] ${result}
370
TorstenThieme440b7c02020-12-18 15:42:57 +0000371Set Tech Profile
372 [Documentation] This keyword sets the passed TechProfile for the test
TorstenThieme00fe8262022-01-19 10:43:07 +0000373 [Arguments] ${TechProfile} ${namespace}=default ${tp_id}=64
374 Log To Console \nSet TechProfile:${TechProfile} tp_id:${tp_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000375 ${podname}= Set Variable etcd
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200376 ${label}= Set Variable app.kubernetes.io/name=${podname}
TorstenThieme440b7c02020-12-18 15:42:57 +0000377 ${src}= Set Variable ${data_dir}/TechProfile-${TechProfile}.json
378 ${dest}= Set Variable /tmp/flexpod.json
379 ${command} Catenate
TorstenThieme00fe8262022-01-19 10:43:07 +0000380 ... /bin/sh -c 'cat ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/${tp_id}'
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200381 Copy File To Pod ${namespace} ${label} ${src} ${dest}
TorstenThieme440b7c02020-12-18 15:42:57 +0000382 Exec Pod In Kube ${namespace} ${podname} ${command}
383 ${commandget} Catenate
TorstenThieme00fe8262022-01-19 10:43:07 +0000384 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/${tp_id}'
Andrea Campanella0aa21d62021-07-22 10:44:32 +0200385 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
386 Should Not Be Empty ${result} No Tech Profile stored in etcd!
TorstenThieme440b7c02020-12-18 15:42:57 +0000387
388Remove Tech Profile
389 [Documentation] This keyword removes TechProfile
TorstenThieme00fe8262022-01-19 10:43:07 +0000390 [Arguments] ${namespace}=default ${tp_id}=64
391 Run Keyword If "${TechProfile}"!="${EMPTY}" Log To Console \nRemove TechProfile:${TechProfile} tp_id:${tp_id}
392 ... ELSE Log To Console \nRemove Tech Profile template at tp_id:${tp_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000393 ${podname}= Set Variable etcd
394 ${command} Catenate
TorstenThieme00fe8262022-01-19 10:43:07 +0000395 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/${tp_id}'
TorstenThieme440b7c02020-12-18 15:42:57 +0000396 Exec Pod In Kube ${namespace} ${podname} ${command}
397 ${commandget} Catenate
TorstenThieme00fe8262022-01-19 10:43:07 +0000398 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/${tp_id}'
TorstenThieme440b7c02020-12-18 15:42:57 +0000399 Exec Pod In Kube ${namespace} ${podname} ${commandget}
400
TorstenThiemea7315f12021-07-23 11:56:34 +0000401Do Onu Subscriber Add Per OLT
402 [Documentation] Add Subscriber per OLT
403 [Arguments] ${of_id} ${olt_serial_number} ${print2console}=False
TorstenThieme029d5f02022-05-03 09:25:01 +0000404 ${onu_list} Create List
TorstenThiemea7315f12021-07-23 11:56:34 +0000405 FOR ${I} IN RANGE 0 ${num_all_onus}
406 ${src}= Set Variable ${hosts.src[${I}]}
407 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
408 ${onu_device_id}= Get Device ID From SN ${src['onu']}
409 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
410 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
TorstenThieme029d5f02022-05-03 09:25:01 +0000411 ${of_id_onu_port}= Catenate SEPARATOR=- ${of_id} ${onu_port}
412 ${pair_id}= Get Index From List ${onu_list} ${of_id_onu_port}
TorstenThiemed9cc06e2022-11-09 12:12:46 +0000413 Continue For Loop If -1 != ${pair_id} and ${unitag_sub} == False
TorstenThieme029d5f02022-05-03 09:25:01 +0000414 Append To List ${onu_list} ${of_id_onu_port}
TorstenThiemed9cc06e2022-11-09 12:12:46 +0000415 # Add subscriber
416 ${add_sub_cmd}= Run Keyword If ${unitag_sub}
417 ... Catenate volt-add-subscriber-unitag --tpId ${src['tp_id']} --sTag ${src['s_tag']}
418 ... --cTag ${src['c_tag']} ${src['onu']}-${src['uni_id']}
419 ... ELSE
420 ... Set Variable volt-add-subscriber-access ${of_id} ${onu_port}
TorstenThiemea7315f12021-07-23 11:56:34 +0000421 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
TorstenThiemed9cc06e2022-11-09 12:12:46 +0000422 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${add_sub_cmd}
TorstenThiemea7315f12021-07-23 11:56:34 +0000423 Run Keyword If ${print2console} Log \r\n[${I}] volt-add-subscriber-access ${of_id} ${onu_port}.
424 ... console=yes
425 END
426
427Do Onu Flow Check Per OLT
428 [Documentation] Checks all ONU flows show up in ONOS and Voltha
429 [Arguments] ${of_id} ${nni_port} ${olt_serial_number} ${print2console}=False
430 FOR ${I} IN RANGE 0 ${num_all_onus}
431 ${src}= Set Variable ${hosts.src[${I}]}
432 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
433 ${onu_device_id}= Get Device ID From SN ${src['onu']}
434 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
435 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
436 # Verify subscriber access flows are added for the ONU port
437 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
438 ... Verify Subscriber Access Flows Added For ONU ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${of_id}
439 ... ${onu_port} ${nni_port} ${src['c_tag']} ${src['s_tag']}
440 ${logoutput} Catenate \r\n[${I}] Verify Subscriber Access Flows Added For
441 ... ONU ${of_id} ${onu_port} ${src['c_tag']} ${src['s_tag']}.
442 Run Keyword If ${print2console} Log ${logoutput} console=yes
443 END
444
445Do Onu Subscriber Remove Per OLT
446 [Documentation] Removes per OLT subscribers in ONOS and Voltha
447 [Arguments] ${of_id} ${olt_serial_number} ${print2console}=False
TorstenThieme029d5f02022-05-03 09:25:01 +0000448 ${onu_list} Create List
TorstenThiemea7315f12021-07-23 11:56:34 +0000449 FOR ${I} IN RANGE 0 ${num_all_onus}
450 ${src}= Set Variable ${hosts.src[${I}]}
451 ${dst}= Set Variable ${hosts.dst[${I}]}
452 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
453 ${onu_device_id}= Get Device ID From SN ${src['onu']}
454 ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s
455 ... Get ONU Port in ONOS ${src['onu']} ${of_id}
TorstenThieme029d5f02022-05-03 09:25:01 +0000456 ${of_id_onu_port}= Catenate SEPARATOR=- ${of_id} ${onu_port}
457 ${pair_id}= Get Index From List ${onu_list} ${of_id_onu_port}
458 Continue For Loop If -1 != ${pair_id}
459 Append To List ${onu_list} ${of_id_onu_port}
TorstenThiemea7315f12021-07-23 11:56:34 +0000460 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2
461 ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
462 ... volt-remove-subscriber-access ${of_id} ${onu_port}
463 Run Keyword If ${print2console} Log \r\n[${I}] volt-remove-subscriber-access ${of_id} ${onu_port}.
464 ... console=yes
465 END
466
TorstenThieme7c397d72021-07-14 11:51:09 +0000467Validate Resource Instances Used Gem Ports
468 [Documentation] This keyword validates resource instances data stored in etcd.
469 ... It checks checks the number of gemport-ids which has matched with used Tech Profile
Andrea Campanella388cd872022-02-10 09:11:39 +0100470 [Arguments] ${nbofgemports} ${namespace}=default ${defaultkvstoreprefix}=voltha/voltha_voltha
TorstenThieme7c397d72021-07-14 11:51:09 +0000471 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000472 ${etcddata}= Get ONU Go Adapter ETCD Data namespace=${namespace} defaultkvstoreprefix=${kvstoreprefix}
TorstenThieme7c397d72021-07-14 11:51:09 +0000473 #prepare result for json convert
474 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
475 ${jsondata}= To Json ${result}
476 ${length}= Get Length ${jsondata}
477 log ${jsondata}
478 FOR ${INDEX} IN RANGE 0 ${length}
479 ${value}= Get From List ${jsondata} ${INDEX}
480 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
481 # When testing multi-tcont this may need some adjustment.
482 Exit For Loop If not ('uni_config' in $value)
483 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000484 ${resourcedata}= Get Resource Instances ETCD Data ${tp_path} namespace=${namespace}
485 ... defaultkvstoreprefix=${kvstoreprefix}
TorstenThieme7c397d72021-07-14 11:51:09 +0000486 log ${resourcedata}
487 ${decoderesult}= volthatools.Tech Profile Decode Resource Instance ${resourcedata} return_default=true
488 log ${decoderesult}
489 ${gemportids}= Get From Dictionary ${decoderesult} gemport_ids
490 ${length}= Get Length ${gemportids}
491 Should Be Equal As Integers ${nbofgemports} ${length}
TorstenThiemed9cc06e2022-11-09 12:12:46 +0000492 ... msg=Number of gem ports (${length}) does not match with techprofile ${nbofgemports}
TorstenThieme7c397d72021-07-14 11:51:09 +0000493 END
494
495Get Resource Instances ETCD Data
496 [Documentation] This keyword delivers Resource Instances Data stored in etcd
Andrea Campanella388cd872022-02-10 09:11:39 +0100497 [Arguments] ${tppath} ${namespace}=default ${defaultkvstoreprefix}=voltha/voltha_voltha
TorstenThieme7c397d72021-07-14 11:51:09 +0000498 ${podname}= Set Variable etcd
499 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
500 ${commandget}= Catenate
501 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/resource_instances/${tppath}
502 ... --print-value-only --hex'
503 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
504 log ${result}
505 [Return] ${result}
506
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000507Validate Tech Profiles and Flows in ETCD Data Per Onu
508 [Documentation] This keyword validates tech profiles and flows data stored in etcd per onu.
509 ... It checks checks presence/absence of tech profiles and flows depending on must_exist.
510 ... The values/content of tech profiles and flows will be not validated!
Andrea Campanella388cd872022-02-10 09:11:39 +0100511 [Arguments] ${onu_sn} ${namespace}=default ${defaultkvstoreprefix}=voltha/voltha_voltha ${must_exist}=True
TorstenThieme569ef452022-02-07 14:00:26 +0000512 ... ${check_tcont_map_empty}=False ${check_default_flow_att}=True
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000513 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
514 ${etcddata}= Get ONU Go Adapter ETCD Data namespace=${namespace} defaultkvstoreprefix=${kvstoreprefix}
515 #prepare result for json convert
516 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
517 ${jsondata}= To Json ${result}
518 ${length}= Get Length ${jsondata}
519 log ${jsondata}
520 ${matched}= Set Variable False
521 FOR ${INDEX} IN RANGE 0 ${length}
522 ${value}= Get From List ${jsondata} ${INDEX}
523 ${uni_config}= Get From Dictionary ${value} uni_config
524 ${uni_config}= Set Variable ${uni_config[0]}
525 ${sn}= Get From Dictionary ${value} serial_number
TorstenThieme00fe8262022-01-19 10:43:07 +0000526 ${tcont_map}= Get From Dictionary ${value} tcont_map
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000527 ${matched}= Set Variable If '${sn}'=='${onu_sn}' True False
528 Exit For Loop If ${matched}
529 END
530 Should Be True ${matched} No ETCD data found for ONU ${onu_sn}
531 Log ${uni_config}
532 ${tp_path}= Get From Dictionary ${uni_config} PersTpPathMap
533 Log ${tp_path}
534 ${flow_params}= Get From Dictionary ${uni_config} flow_params
535 Log ${flow_params}
536 # in case of ATT for ONU with removed flows there is default flow established
537 ${length}= Get Length ${flow_params}
538 ${cookieslice}= Run Keyword If ${length}>0 Run Keyword If 'cookie_slice' in ${flow_params[0]}
539 ... Get From Dictionary ${flow_params[0]} cookie_slice
540 ${setvid}= Run Keyword If ${length}>0 Run Keyword If 'set_vid' in ${flow_params[0]['vlan_rule_params']}
541 ... Get From Dictionary ${flow_params[0]['vlan_rule_params']} set_vid
542 ${cookie_slice_length}= Run Keyword If ${length}>0 Run Keyword If 'cookie_slice' in ${flow_params[0]}
543 ... Get Length ${cookieslice}
TorstenThieme569ef452022-02-07 14:00:26 +0000544 Run Keyword If "${workflow}"=="ATT" and not ${must_exist} and ${check_default_flow_att} Run Keywords
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000545 ... Should Be Equal As Numbers ${setvid} 4091 AND
546 ... Should Be Equal As Numbers ${cookie_slice_length} 1 AND
547 ... Should Not Be Empty ${tp_path} AND
548 ... Return From Keyword
549 ${tp_path_length}= Get Length ${tp_path}
550 # validate tp_path is not Empty for case must_exist, case not must_exist will be validated implicitly with FOR loop
551 Run Keyword If ${must_exist} Should Not Be Empty ${tp_path}
552 ${tp_path_keys}= Run Keyword If ${tp_path_length}==0 Create List
553 ... ELSE Get Dictionary Keys ${tp_path}
554 ${tp_path_values}= Run Keyword If ${tp_path_length}==0 Create List
555 ... ELSE Get Dictionary Values ${tp_path}
556 ${tp_path_empty}= Set Variable True
557 Log ${tp_path_values}
558 Log ${tp_path_keys}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000559 # In case of not empty tp_path each value will be checked depending on must_exist
560 FOR ${key} IN @{tp_path_keys}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000561 ${value}= Get From Dictionary ${tp_path} ${key}
562 Run Keyword If ${must_exist} Should Not Be Empty ${value}
563 ... ELSE Should Be Empty ${value}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000564 END
565 Run Keyword If ${must_exist} Should Not Be Empty ${flow_params}
566 ... ELSE Should Be Empty ${flow_params}
TorstenThieme00fe8262022-01-19 10:43:07 +0000567 Run Keyword If ${check_tcont_map_empty} Log ${tcont_map}
568 Run Keyword If ${check_tcont_map_empty} Should Be Empty ${tcont_map}
TorstenThieme7c397d72021-07-14 11:51:09 +0000569
TorstenThieme17756ea2020-11-11 14:09:47 +0000570Validate Onu Data In Etcd
571 [Documentation] This keyword validates openonu-go-adapter Data stored in etcd.
572 ... It checks unique of serial_number and combination of pon, onu and uni in tp_path.
573 ... Furthermore it evaluates the values of onu_id and uni_id with values read from tp_path.
574 ... Number of etcd entries has to match with the passed number.
Andrea Campanella388cd872022-02-10 09:11:39 +0100575 [Arguments] ${namespace}=default ${nbofetcddata}=${num_all_onus} ${defaultkvstoreprefix}=voltha/voltha_voltha
TorstenThiemefa29a892021-03-11 14:11:29 +0000576 ... ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000577 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000578 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme17756ea2020-11-11 14:09:47 +0000579 #prepare result for json convert
580 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
581 ${jsondata}= To Json ${result}
582 ${length}= Get Length ${jsondata}
583 log ${jsondata}
584 Run Keyword And Continue On Failure Should Be Equal As Integers ${length} ${nbofetcddata}
585 ... msg=Number etcd data (${length}) does not match required (${nbofetcddata})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000586 ${oltpononuuniidlist}= Create List
TorstenThieme17756ea2020-11-11 14:09:47 +0000587 ${serialnumberlist}= Create List
588 FOR ${INDEX} IN RANGE 0 ${length}
589 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra97f8d062020-11-17 15:48:23 -0800590 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
591 # When testing multi-tcont this may need some adjustment.
TorstenThieme45071602021-03-16 12:14:37 +0000592 Exit For Loop If not ('uni_config' in $value)
Girish Gowdra97f8d062020-11-17 15:48:23 -0800593 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000594 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
595 ${list_id}= Get Index From List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000596 Should Be Equal As Integers ${list_id} -1
TorstenThiemefe7099e2021-01-29 08:41:04 +0000597 ... msg=Combination of Pon, Onu and Uni (${oltpononuuniid}) exist multiple in etcd data!
598 Append To List ${oltpononuuniidlist} ${oltpononuuniid}
TorstenThieme17756ea2020-11-11 14:09:47 +0000599 Validate Onu Id ${value}
600 Validate Uni Id ${value}
601 ${serial_number}= Get From Dictionary ${value} serial_number
602 ${list_id}= Get Index From List ${serialnumberlist} ${serial_number}
603 Should Be Equal As Integers ${list_id} -1
604 ... msg=Serial number (${serial_number}) exists multiple in etcd data!
605 Append To List ${serialnumberlist} ${serial_number}
606 END
607
TorstenThieme712b2962021-11-17 14:16:15 +0000608Validate Onu Data In Etcd Removed
609 [Documentation] This keyword validates openonu-go-adapter Data stored in etcd are removed.
610 ... In case of a device is passed, only this will be checked.
Andrea Campanella388cd872022-02-10 09:11:39 +0100611 [Arguments] ${namespace}=default ${device_id}=${EMPTY} ${defaultkvstoreprefix}=voltha/voltha_voltha
TorstenThieme712b2962021-11-17 14:16:15 +0000612 ... ${without_pm_data}=True
613 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
614 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} False ${without_pm_data}
615 ... ${device_id} True
616 Log ${etcddata}
617 Should Be Empty ${etcddata} Stale Openonu Data in Etcd (KV store) ${device_id}
618
TorstenThieme52ef8392020-11-10 13:42:26 +0000619Validate Vlan Rules In Etcd
620 [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd.
621 ... It checks the given number of cookie_slice, match_vid (=4096) and set_vid.
622 ... Furthermore it returns a list of all set_vid.
623 ... In case of a passed dictionary containing set_vids these will be checked for to
624 ... current set-vid depending on setvidequal (True=equal, False=not equal).
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000625 [Arguments] ${namespace}=default ${nbofcookieslice}=1 ${reqmatchvid}=4096 ${prevvlanrules}=${NONE}
Andrea Campanella388cd872022-02-10 09:11:39 +0100626 ... ${setvidequal}=False ${defaultkvstoreprefix}=voltha/voltha_voltha
627 ... ${without_prefix}=True ${without_pm_data}=True
TorstenThieme3385cdc2021-02-04 13:50:50 +0000628 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000629 ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} ${without_prefix} ${without_pm_data}
TorstenThieme52ef8392020-11-10 13:42:26 +0000630 #prepare result for json convert
631 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
632 ${jsondata}= To Json ${result}
633 ${length}= Get Length ${jsondata}
634 log ${jsondata}
635 ${vlan_rules}= Create Dictionary
636 FOR ${INDEX} IN RANGE 0 ${length}
637 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra295c1692020-11-19 10:51:53 -0800638 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
639 # When testing multi-tcont this may need some adjustment.
640 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThiemefe7099e2021-01-29 08:41:04 +0000641 ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000642 ${cookieslice}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]} cookie_slice
643 #@{cookieslicelist}= Split String ${cookieslice} ,
644 ${foundcookieslices}= Get Length ${cookieslice}
645 Should Be Equal As Integers ${foundcookieslices} ${nbofcookieslice}
646 ${matchvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
647 ... match_vid
648 Should Be Equal As Integers ${matchvid} ${reqmatchvid}
649 ${setvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
650 ... set_vid
651 ${evalresult}= Evaluate 2 <= ${setvid} <= 4095
652 Should Be True ${evalresult} msg=set_vid out of range (${setvid})!
TorstenThiemefe7099e2021-01-29 08:41:04 +0000653 Set To Dictionary ${vlan_rules} ${oltpononuuniid} ${setvid}
TorstenThieme52ef8392020-11-10 13:42:26 +0000654 ${oldsetvidvalid} Set Variable If ${prevvlanrules} is ${NONE} False True
TorstenThiemefe7099e2021-01-29 08:41:04 +0000655 ${prevsetvid}= Set Variable If ${oldsetvidvalid} ${prevvlanrules['${oltpononuuniid}']}
TorstenThieme52ef8392020-11-10 13:42:26 +0000656 Run Keyword If ${oldsetvidvalid} and ${setvidequal}
657 ... Should Be Equal As Integers ${prevsetvid} ${setvid}
658 ... ELSE IF ${oldsetvidvalid} and not ${setvidequal}
659 ... Should Not Be Equal As Integers ${prevsetvid} ${setvid}
660 END
TorstenThieme440b7c02020-12-18 15:42:57 +0000661 log Many ${vlan_rules}
TorstenThieme52ef8392020-11-10 13:42:26 +0000662 [Return] ${vlan_rules}
663
664Get ONU Go Adapter ETCD Data
665 [Documentation] This keyword delivers openonu-go-adapter Data stored in etcd
Andrea Campanella388cd872022-02-10 09:11:39 +0100666 [Arguments] ${namespace}=default ${defaultkvstoreprefix}=voltha/voltha_voltha ${without_prefix}=True
TorstenThieme712b2962021-11-17 14:16:15 +0000667 ... ${without_pm_data}=True ${device_id}=${Empty} ${keys_only}=False
TorstenThieme52ef8392020-11-10 13:42:26 +0000668 ${podname}= Set Variable etcd
TorstenThieme3385cdc2021-02-04 13:50:50 +0000669 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
TorstenThieme3af12312021-03-10 16:15:24 +0000670 ${commandget}= Catenate
671 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/openonu'
TorstenThieme712b2962021-11-17 14:16:15 +0000672 ${commandget}= Run Keyword If ${keys_only} Catenate ${commandget} --keys-only
673 ... ELSE Set Variable ${commandget}
TorstenThieme3af12312021-03-10 16:15:24 +0000674 ${commandget}= Run Keyword If ${without_prefix} Catenate ${commandget}
675 ... | grep -v service/${kvstoreprefix}/openonu
TorstenThiemefa29a892021-03-11 14:11:29 +0000676 ... ELSE Set Variable ${commandget}
TorstenThieme3af12312021-03-10 16:15:24 +0000677 ${commandget}= Run Keyword If ${without_pm_data} Catenate ${commandget} | grep -v instances_active
TorstenThiemefa29a892021-03-11 14:11:29 +0000678 ... ELSE Set Variable ${commandget}
TorstenThieme712b2962021-11-17 14:16:15 +0000679 ${commandget}= Run Keyword If "${device_id}"!="${Empty}" Catenate ${commandget} | grep ${device_id}
680 ... ELSE Set Variable ${commandget}
Holger Hildebrandt23147742020-11-16 10:13:21 +0000681 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThieme52ef8392020-11-10 13:42:26 +0000682 log ${result}
683 [Return] ${result}
684
685Prepare ONU Go Adapter ETCD Data For Json
686 [Documentation] This keyword prepares openonu-go-adapter Data stored in etcd for converting
687 ... to json
688 [Arguments] ${etcddata}
689 #prepare result for json convert
690 ${prepresult}= Replace String ${etcddata} \n ,
691 ${prepresult}= Strip String ${prepresult} mode=right characters=,
692 ${prepresult}= Set Variable [${prepresult}]
693 log ${prepresult}
694 [Return] ${prepresult}
695
TorstenThieme52ef8392020-11-10 13:42:26 +0000696Read Pon Onu Uni String
TorstenThiemefe7099e2021-01-29 08:41:04 +0000697 [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 +0000698 ... taken from etcd data of onu go adapter
699 [Arguments] ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000700 ${tppathlines}= Replace String ${tp_path} / \n
TorstenThiemefe7099e2021-01-29 08:41:04 +0000701 ${olt}= Get Value Of Tp Path Element ${tppathlines} olt
TorstenThieme52ef8392020-11-10 13:42:26 +0000702 ${pon}= Get Value Of Tp Path Element ${tppathlines} pon
703 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
704 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
TorstenThiemefe7099e2021-01-29 08:41:04 +0000705 ${valuesid}= Set Variable ${olt}/${pon}/${onu}/${uni}
TorstenThieme52ef8392020-11-10 13:42:26 +0000706 log ${valuesid}
707 [Return] ${valuesid}
708
709Get Value Of Tp Path Element
TorstenThieme17756ea2020-11-11 14:09:47 +0000710 [Documentation] This keyword delivers numeric value of given tp path element.
TorstenThieme52ef8392020-11-10 13:42:26 +0000711 [Arguments] ${tp_path_lines} ${element}
712 ${value}= Get Lines Containing String ${tp_path_lines} ${element}-\{
713 ${value}= Remove String ${value} ${element}-\{
714 ${value}= Remove String ${value} \}
715 log ${value}
716 [Return] ${value}
717
TorstenThieme17756ea2020-11-11 14:09:47 +0000718Validate Onu Id
719 [Documentation] This keyword validates ONU Id of passed etcd data.
720 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800721 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
722 # When testing multi-tcont this may need some adjustment.
723 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000724 ${tppathlines}= Replace String ${tp_path} / \n
725 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
726 ${onu_id}= Get From Dictionary ${value} onu_id
727 Should Be Equal As Integers ${onu} ${onu_id}
728 ... msg=Onu-Id (${onu_id}) does not match onu (${onu}) from tp_path in etcd data!
729 Should Be True ${onu_id}>=1
730
731Validate Uni Id
732 [Documentation] This keyword validates UNI Id of passed etcd data.
733 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800734 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
735 # When testing multi-tcont this may need some adjustment.
736 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000737 ${tppathlines}= Replace String ${tp_path} / \n
738 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
739 ${uni_id}= Get From Dictionary ${value['uni_config'][0]} uni_id
740 Should Be Equal As Integers ${uni} ${uni_id}
741 ... msg=Uni-Id (${uni_id}) does not match onu (${uni}) from tp_path in etcd data!
TorstenThieme52ef8392020-11-10 13:42:26 +0000742
TorstenThieme45071602021-03-16 12:14:37 +0000743Delete ONU Go Adapter ETCD Data
744 [Documentation] This keyword deletes openonu-go-adapter Data stored in etcd
Andrea Campanella388cd872022-02-10 09:11:39 +0100745 [Arguments] ${namespace}=default ${defaultkvstoreprefix}=voltha/voltha_voltha ${validate}=False
TorstenThieme45071602021-03-16 12:14:37 +0000746 ${podname}= Set Variable etcd
747 ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix}
748 ${commandget}= Catenate
749 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/${kvstoreprefix}/openonu'
750 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
751 log ${result}
752 Run Keyword If ${validate} Wait Until Keyword Succeeds ${timeout} 1s
Hardik Windlass4288c6a2021-09-28 07:22:06 +0000753 ... Validate Onu Data In Etcd namespace=${namespace} nbofetcddata=0 without_pm_data=False
TorstenThieme45071602021-03-16 12:14:37 +0000754 [Return] ${result}
755
TorstenThiemed6492882021-12-16 08:10:02 +0000756Validate ONOS Flows per OLT
757 [Documentation] This keyword validates onos flows per olt
758 [Arguments] ${olt_sn} ${expected_flows}
759 ${olt_of_id} Validate OLT Device in ONOS ${olt_sn}
760 ${flows}= Count flows ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${olt_of_id} added
761 Log Found added ${flows} of ${expected_flows} expected flows on device ${olt_sn}
762 Should Be Equal As Integers ${expected_flows} ${flows}
763
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000764Validate OLT Flows Per Onu
765 [Documentation] This keyword validates olt flows per onu
766 ... It checks checks presence/absence of olt flows depending on must_exist.
767 ... The values/content of olt flows will be not validated!
768 [Arguments] ${onu_device_id} ${must_exist}
769 ${rc} ${output}= Run and Return Rc and Output
Andrea Campanella28989d12022-01-11 09:49:21 +0100770 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${onu_device_id} -m 32MB -o json
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000771 Should Be Equal As Integers ${rc} 0
772 ${jsondata}= To Json ${output}
773 Log ${jsondata}
774 # in case of ATT for ONU with removed flows there is default flow established
775 ${length}= Get Length ${jsondata}
776 ${value}= Run Keyword If ${length}>0 Get From List ${jsondata} 0
777 ${setvid}= Run Keyword If ${length}>0 Run Keyword If 'setvlanid' in ${value}
778 ... Get From Dictionary ${value} setvlanid
779 Run Keyword If "${workflow}"=="ATT" and not ${must_exist} Run Keywords
780 ... Should Be Equal As Numbers ${setvid} 4091 AND
781 ... Should Be Equal As Numbers ${length} 1 AND
782 ... Return From Keyword
783 Run Keyword If ${must_exist} Should Not Be Empty ${jsondata}
784 ... ELSE Should Be Empty ${jsondata}
785
TorstenThiemed4f48962020-12-08 12:17:19 +0000786Wait for Ports in ONOS for all OLTs
TorstenThieme440b7c02020-12-18 15:42:57 +0000787 [Documentation] Waits untill a certain number of ports are enabled in all OLTs
TorstenThieme731a7592021-07-01 14:26:54 +0000788 [Arguments] ${host} ${port} ${count} ${filter} ${max_wait_time}=10m ${determine_number}=False
TorstenThiemed4f48962020-12-08 12:17:19 +0000789 FOR ${J} IN RANGE 0 ${num_olts}
790 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
791 ${onu_count}= Set Variable ${list_olts}[${J}][onucount]
792 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
793 ... ${olt_serial_number}
794 Set Global Variable ${of_id}
TorstenThiemeff9c9142021-04-08 07:21:34 +0000795 ${count2check}= Set Variable If ${count}==${num_all_onus} ${onu_count} ${count}
796 # if flag determine_number is set to True, always determine the number of real ONUs (overwrite previous value)
797 ${count2check}= Run Keyword If ${determine_number} Determine Number Of ONU ${olt_serial_number}
798 ... ELSE Set Variable ${count2check}
TorstenThieme731a7592021-07-01 14:26:54 +0000799 Wait for Ports in ONOS ${host} ${port} ${count2check} ${of_id} BBSM ${max_wait_time}
TorstenThiemed4f48962020-12-08 12:17:19 +0000800 END
801
TorstenThieme440b7c02020-12-18 15:42:57 +0000802Wait for all ONU Ports in ONOS Disabled
803 [Documentation] Waits untill a all ONU ports are disabled in all ONOS
TorstenThieme00fe8262022-01-19 10:43:07 +0000804 [Arguments] ${host} ${port} ${unitag}=False
TorstenThieme440b7c02020-12-18 15:42:57 +0000805 FOR ${I} IN RANGE 0 ${num_all_onus}
806 ${src}= Set Variable ${hosts.src[${I}]}
807 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
808 ... ${src['olt']}
TorstenThieme00fe8262022-01-19 10:43:07 +0000809 ${onu_uni_id}= Set Variable If ${unitag} ${src['uni_id']} 1
810 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']} ${of_id}
811 ... ${onu_uni_id}
TorstenThieme731a7592021-07-01 14:26:54 +0000812 Wait Until Keyword Succeeds ${timeout} 2s Assert ONU Port Is Disabled ${host} ${port} ${of_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000813 ... ${onu_port}
814 END
815
TorstenThiemed9cc06e2022-11-09 12:12:46 +0000816Validate Events All ONUs
817 [Documentation] Validates kafka events for all ONUs
818 [Arguments] ${list_onu_device_id} ${expected_event}
819 ${Kafka_Records}= kafka.Records Get voltha.events
820 ${RecordsLength}= Get Length ${Kafka_Records}
821 FOR ${Index} IN RANGE 0 ${RecordsLength}
822 ${metric}= Set Variable ${Kafka_Records[${Index}]}
823 ${message}= Get From Dictionary ${metric} message
824 ${event}= volthatools.Events Decode Event ${message} return_default=true
825 Continue For Loop If not 'device_event' in ${event}
826 ${event_name}= Get From Dictionary ${event['device_event']} device_event_name
827 Continue For Loop If "${event_name}" != "${expected_event}"
828 ${resource_id}= Get From Dictionary ${event['device_event']} resource_id
829 Remove Values From List ${list_onu_device_id} ${resource_id}
830 END
831 Should Be Empty ${list_onu_device_id} Missing "${expected_event}" for ONUs ${list_onu_device_id}!
832
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000833Map State
834 [Documentation] This keyword converts the passed numeric value or name of a onu state to its state values.
835 [Arguments] ${state}
836 # create state lists with corresponding return values
837 # ADMIN-STATE OPER-STATUS CONNECT-STATUS ONU-STATE (number/name)
838 ${state1} Create List ENABLED ACTIVATING REACHABLE 1 activating-onu
839 ${state2} Create List ENABLED ACTIVATING REACHABLE 2 starting-openomci
840 ${state3} Create List ENABLED ACTIVATING REACHABLE 3 discovery-mibsync-complete
841 ${state4} Create List ENABLED ACTIVE REACHABLE 4 initial-mib-downloaded
842 ${state5} Create List ENABLED ACTIVE REACHABLE 5 tech-profile-config-download-success
843 ${state6} Create List ENABLED ACTIVE REACHABLE 6 omci-flows-pushed
844 ${state7} Create List DISABLED UNKNOWN REACHABLE 7 omci-admin-lock
845 ${state8} Create List ENABLED ACTIVE REACHABLE 8 onu-reenabled
846 ${state9} Create List ENABLED DISCOVERED UNREACHABLE 9 stopping-openomci
847 ${state10} Create List ENABLED DISCOVERED REACHABLE 10 rebooting
848 ${state11} Create List ENABLED DISCOVERED REACHABLE 11 omci-flows-deleted
849 ${state12} Create List DISABLED UNKNOWN REACHABLE 12 tech-profile-config-delete-success
850 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Set Variable If
851 ... '${state}'=='1' or '${state}'=='activating-onu' ${state1}
852 ... '${state}'=='2' or '${state}'=='starting-openomci' ${state2}
853 ... '${state}'=='3' or '${state}'=='discovery-mibsync-complete' ${state3}
854 ... '${state}'=='4' or '${state}'=='initial-mib-downloaded' ${state4}
855 ... '${state}'=='5' or '${state}'=='tech-profile-config-download-success' ${state5}
856 ... '${state}'=='6' or '${state}'=='omci-flows-pushed' ${state6}
857 ... '${state}'=='7' or '${state}'=='omci-admin-lock' ${state7}
858 ... '${state}'=='8' or '${state}'=='onu-reenabled' ${state8}
859 ... '${state}'=='9' or '${state}'=='stopping-openomci' ${state9}
860 ... '${state}'=='10' or '${state}'=='rebooting' ${state10}
861 ... '${state}'=='11' or '${state}'=='omci-flows-deleted' ${state11}
862 ... '${state}'=='12' or '${state}'=='tech-profile-config-delete-success' ${state12}
863 [Return] ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}