TorstenThieme | d4f4896 | 2020-12-08 12:17:19 +0000 | [diff] [blame] | 1 | # Copyright 2020 - present Open Networking Foundation |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 2 | # |
| 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. |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 14 | |
| 15 | *** Settings *** |
| 16 | Documentation Library for various openonu-go-adpter utilities |
TorstenThieme | 7c397d7 | 2021-07-14 11:51:09 +0000 | [diff] [blame] | 17 | Library grpc_robot.VolthaTools WITH NAME volthatools |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 18 | |
TorstenThieme | d4f4896 | 2020-12-08 12:17:19 +0000 | [diff] [blame] | 19 | |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 20 | *** Keywords *** |
TorstenThieme | 373adfe | 2021-12-16 13:03:04 +0000 | [diff] [blame] | 21 | Printout ONU Serial Number and Device Id |
| 22 | [Documentation] Printouts the ONU serial number and corresponding device id. |
| 23 | [Arguments] ${onu_sn}=${EMPTY} ${print2console}=False |
| 24 | ${output}= Set Variable \r\n |
| 25 | ${onu_sn_list} Create List |
| 26 | Run Keyword If "${onu_sn}"=="${EMPTY}" Build ONU SN List ${onu_sn_list} |
| 27 | ... ELSE Append To List ${onu_sn_list} ${onu_sn} |
| 28 | FOR ${sn} IN @{onu_sn_list} |
| 29 | ${device_id}= Get Device ID From SN ${sn} |
| 30 | ${output}= Catenate ${output} ONU Serial Number: ${sn} ONU Device ID: ${device_id}\r\n |
| 31 | END |
| 32 | Log ${output} |
| 33 | Run Keyword If ${print2console} Log ${output} console=yes |
| 34 | |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 35 | Calculate Timeout |
| 36 | [Documentation] Calculates the timeout regarding num-onus in case of more than 4 onus |
| 37 | [Arguments] ${basetimeout}=60s |
| 38 | ${new_timeout} Fetch From Left ${basetimeout} s |
| 39 | ${new_timeout}= evaluate ${new_timeout}+((${num_all_onus}-4)*10) |
| 40 | ${new_timeout}= Set Variable If (not ${debugmode}) and (${new_timeout}>300) |
| 41 | ... 300 ${new_timeout} |
| 42 | ${new_timeout}= Catenate SEPARATOR= ${new_timeout} s |
| 43 | [Return] ${new_timeout} |
| 44 | |
TorstenThieme | 3494ceb | 2021-07-19 09:47:24 +0000 | [diff] [blame] | 45 | Get Logical Id of OLT |
| 46 | [Documentation] Fills the logical id of OLT(s) if missing |
| 47 | FOR ${I} IN RANGE 0 ${num_olts} |
| 48 | # exit loop if logical id already known |
| 49 | Exit For Loop IF "${olt_ids}[${I}][logical_id]" != "${EMPTY}" |
| 50 | #read current device values |
| 51 | ${olt}= Get From List ${olt_ids} ${I} |
| 52 | ${olt_serial_number}= Get From Dictionary ${olt} sn |
| 53 | # read logical id and store it |
| 54 | ${logical_id}= Get Logical Device ID From SN ${olt_serial_number} |
| 55 | Set To Dictionary ${olt} logical_id ${logical_id} |
| 56 | Set List Value ${olt_ids} ${I} ${olt} |
| 57 | END |
| 58 | Set Global Variable ${olt_ids} |
| 59 | |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 60 | Power On ONU Device |
| 61 | [Documentation] This keyword turns on the power for all onus. |
| 62 | [Arguments] ${namespace} |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 63 | FOR ${J} IN RANGE 0 ${num_olts} |
| 64 | ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn] |
| 65 | ${bbsim}= Catenate SEPARATOR= bbsim ${J} |
| 66 | ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim} |
| 67 | Power On ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod} |
| 68 | END |
| 69 | |
| 70 | Power On ONU Device per OLT |
| 71 | [Documentation] This keyword turns on the power for all onus. |
| 72 | [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod} |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 73 | FOR ${I} IN RANGE 0 ${num_all_onus} |
| 74 | ${src}= Set Variable ${hosts.src[${I}]} |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 75 | Continue For Loop If "${olt_serial_number}"!="${src['olt']}" |
| 76 | Power On ONU ${namespace} ${bbsim_pod} ${src['onu']} |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 77 | END |
| 78 | |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 79 | Power Off ONU Device |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 80 | [Documentation] This keyword turns off the power for all onus per olt. |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 81 | [Arguments] ${namespace} |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 82 | FOR ${J} IN RANGE 0 ${num_olts} |
| 83 | ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn] |
| 84 | ${bbsim}= Catenate SEPARATOR= bbsim ${J} |
| 85 | ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim} |
| 86 | Power Off ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod} |
| 87 | END |
| 88 | |
| 89 | Power Off ONU Device per OLT |
| 90 | [Documentation] This keyword turns off the power for all onus per olt. |
| 91 | [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 92 | FOR ${I} IN RANGE 0 ${num_all_onus} |
| 93 | ${src}= Set Variable ${hosts.src[${I}]} |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 94 | Continue For Loop If "${olt_serial_number}"!="${src['olt']}" |
| 95 | Power Off ONU ${namespace} ${bbsim_pod} ${src['onu']} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 96 | END |
| 97 | |
| 98 | Current State Test |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 99 | [Documentation] This keyword checks the passed state of the given onu. |
| 100 | [Arguments] ${state} ${onu} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY} |
| 101 | ... ${reqconnectstatus}=${EMPTY} |
| 102 | ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state} |
| 103 | ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state} |
| 104 | ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status} |
| 105 | ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus} |
| 106 | ... ${connect_status} |
| 107 | Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms |
| 108 | ... Validate Device ${admin_state} ${oper_status} ${connect_status} |
| 109 | ... ${onu} onu=True onu_reason=${onu_state} |
| 110 | |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 111 | Current State Test All Onus |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 112 | [Documentation] This keyword checks the passed state of all onus. |
| 113 | ... Hint: ${timeStart} will be not evaluated here! |
| 114 | [Arguments] ${state} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY} ${reqconnectstatus}=${EMPTY} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 115 | ... ${alternativeonustate}=${EMPTY} ${timeout}=${timeout} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 116 | ${timeStart}= Get Current Date |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 117 | ${list_onus} Create List |
| 118 | Build ONU SN List ${list_onus} |
| 119 | ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state} |
| 120 | ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state} |
| 121 | ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status} |
| 122 | ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus} |
| 123 | ... ${connect_status} |
| 124 | Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms |
| 125 | ... Validate ONU Devices With Duration |
| 126 | ... ${admin_state} ${oper_status} ${connect_status} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 127 | ... ${onu_state} ${list_onus} ${timeStart} alternate_reason=${alternativeonustate} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 128 | # teardown is used as 'return' for result of Validate ONU Devices With Duration (used for ONUNegativeStateTests) |
| 129 | [Teardown] Run Keyword If "${KEYWORD STATUS}"=="FAIL" Set Suite Variable ${StateTestAllONUs} False |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 130 | |
TorstenThieme | 96fe9ee | 2021-10-21 10:24:08 +0000 | [diff] [blame] | 131 | Reconcile Onu Adapter |
| 132 | [Documentation] Restarts the openonu adapter and waits for reconciling is finished and expected oper-state is reached |
TorstenThieme | 712b296 | 2021-11-17 14:16:15 +0000 | [diff] [blame] | 133 | [Arguments] ${namespace} ${usekill2restart} ${oper_status} ${olt_to_be_deleted_sn}=${EMPTY} |
TorstenThieme | f7cd2be | 2021-12-06 14:30:11 +0000 | [diff] [blame] | 134 | ... ${flow_delete_params}=&{EMPTY} |
TorstenThieme | 96fe9ee | 2021-10-21 10:24:08 +0000 | [diff] [blame] | 135 | # get time of restart of openonu adapter |
| 136 | ${restart_ts}= Get Current Date |
| 137 | # restart OpenONU adapter |
| 138 | Run Keyword If ${usekill2restart} Kill And Check Onu Adaptor ${namespace} |
| 139 | ... ELSE Restart And Check Onu Adaptor ${namespace} |
| 140 | #check ready timestamp of openonu adapter, should be younger than restart timestamp |
| 141 | ${openonu_ready_ts}= Get Pod Ready Timestamp by Label ${namespace} app adapter-open-onu |
| 142 | ${restart_duration}= Subtract Date From Date ${openonu_ready_ts} ${restart_ts} |
| 143 | Should Be True ${restart_duration}>0 |
TorstenThieme | 712b296 | 2021-11-17 14:16:15 +0000 | [diff] [blame] | 144 | # delete the olt passed, if available (special feature) |
| 145 | ${olt_to_be_deleted_device_id}= Run Keyword IF "${olt_to_be_deleted_sn}"!="${EMPTY}" |
| 146 | ... Get OLTDeviceID From OLT List ${olt_to_be_deleted_sn} |
TorstenThieme | f7cd2be | 2021-12-06 14:30:11 +0000 | [diff] [blame] | 147 | Run Keyword If "${olt_to_be_deleted_sn}"!="${EMPTY}" Delete Device ${olt_to_be_deleted_device_id} |
| 148 | # remove flows if params passed for it (special feature II) |
| 149 | Run Keyword If ${flow_delete_params}!=&{EMPTY} Wait Until Keyword Succeeds ${timeout} 2s |
| 150 | ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} |
| 151 | ... volt-remove-subscriber-access ${flow_delete_params['of_id']} ${flow_delete_params['onu_port']} |
Matteo Scandolo | 741d4fd | 2021-09-23 17:08:34 -0700 | [diff] [blame] | 152 | # wait for the reconcile to complete |
TorstenThieme | 96fe9ee | 2021-10-21 10:24:08 +0000 | [diff] [blame] | 153 | # - we check that communication to openonu-adapter is established again |
| 154 | # - we check that all ONUs leave reconcile state by validate a simple voltctl request will not responds with error |
| 155 | Wait Until Keyword Succeeds ${timeout} 1s Validate Last ONU Communication |
TorstenThieme | 712b296 | 2021-11-17 14:16:15 +0000 | [diff] [blame] | 156 | Wait Until Keyword Succeeds ${timeout} 1s Validate All Onus Accessible ${olt_to_be_deleted_sn} |
| 157 | # - then we wait that all ONU move to the next state, except ONU belonging to deleted OLT (special feature) |
TorstenThieme | 96fe9ee | 2021-10-21 10:24:08 +0000 | [diff] [blame] | 158 | ${list_onus} Create List |
TorstenThieme | 712b296 | 2021-11-17 14:16:15 +0000 | [diff] [blame] | 159 | FOR ${J} IN RANGE 0 ${num_olts} |
| 160 | ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn] |
| 161 | Continue For Loop If "${olt_to_be_deleted_sn}"=="${olt_serial_number}" |
| 162 | Build ONU SN List ${list_onus} ${olt_serial_number} |
| 163 | END |
| 164 | Log ${list_onus} |
TorstenThieme | 96fe9ee | 2021-10-21 10:24:08 +0000 | [diff] [blame] | 165 | Run Keyword And Ignore Error Wait Until Keyword Succeeds ${timeout} |
| 166 | ... 1s Check all ONU OperStatus ${list_onus} ${oper_status} |
| 167 | |
TorstenThieme | e512b1d | 2021-11-12 10:52:29 +0000 | [diff] [blame] | 168 | Validate All Onus Accessible |
| 169 | [Documentation] This keyword checks all onus accessible (again) with help of a simple voltctl request. |
| 170 | ... As long we've got an rc!=0 keyword will fail -> onu is not accessible. |
TorstenThieme | 96fe9ee | 2021-10-21 10:24:08 +0000 | [diff] [blame] | 171 | ... As get request Onu image list is used, any other get command could be used for this check. |
TorstenThieme | 712b296 | 2021-11-17 14:16:15 +0000 | [diff] [blame] | 172 | ... Will not check ONUs of passed deleted OLT (special feature) |
| 173 | [Arguments] ${deleted_olt}=${EMPTY} |
Matteo Scandolo | 741d4fd | 2021-09-23 17:08:34 -0700 | [diff] [blame] | 174 | ${onu_list} Create List |
| 175 | FOR ${I} IN RANGE 0 ${num_all_onus} |
TorstenThieme | 96fe9ee | 2021-10-21 10:24:08 +0000 | [diff] [blame] | 176 | ${src}= Set Variable ${hosts.src[${I}]} |
TorstenThieme | 712b296 | 2021-11-17 14:16:15 +0000 | [diff] [blame] | 177 | ${olt_serial_number}= Set Variable ${src['olt']} |
| 178 | Continue For Loop If "${deleted_olt}"=="${olt_serial_number}" |
TorstenThieme | 96fe9ee | 2021-10-21 10:24:08 +0000 | [diff] [blame] | 179 | ${onu_device_id}= Get Device ID From SN ${src['onu']} |
| 180 | ${onu_id}= Get Index From List ${onu_list} ${onu_device_id} |
Matteo Scandolo | 741d4fd | 2021-09-23 17:08:34 -0700 | [diff] [blame] | 181 | Continue For Loop If -1 != ${onu_id} |
TorstenThieme | 96fe9ee | 2021-10-21 10:24:08 +0000 | [diff] [blame] | 182 | Append To List ${onu_list} ${onu_device_id} |
| 183 | ${rc} ${output}= Get Onu Image List ${onu_device_id} |
TorstenThieme | 712b296 | 2021-11-17 14:16:15 +0000 | [diff] [blame] | 184 | Should Be True ${rc}==0 Onu ${src['onu']} (${onu_device_id}) still not accessible. |
Matteo Scandolo | 741d4fd | 2021-09-23 17:08:34 -0700 | [diff] [blame] | 185 | END |
| 186 | |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 187 | Log Ports |
| 188 | [Documentation] This keyword logs all port data available in ONOS of first port per ONU |
| 189 | [Arguments] ${onlyenabled}=False |
| 190 | ${cmd} Set Variable If ${onlyenabled} ports -e ports |
TorstenThieme | 731a759 | 2021-07-01 14:26:54 +0000 | [diff] [blame] | 191 | ${onu_ports}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${cmd} |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 192 | ${lines} = Get Lines Matching Regexp ${onu_ports} .*portName=BBSM[0-9]{8}-1 |
| 193 | Log ${lines} |
| 194 | |
| 195 | Kill Adaptor |
| 196 | [Documentation] This keyword kills the passed adaptor. |
| 197 | [Arguments] ${namespace} ${name} |
| 198 | ${cmd} Catenate |
Matteo Scandolo | 6b52412 | 2021-10-22 14:34:29 -0700 | [diff] [blame] | 199 | ... kubectl exec -it -n ${namespace} $(kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}') |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 200 | ... -- /bin/sh -c "kill 1" |
| 201 | ${rc} ${output}= Run and Return Rc and Output ${cmd} |
| 202 | Log ${output} |
| 203 | |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 204 | Kill And Check Onu Adaptor |
| 205 | [Documentation] This keyword kills ONU Adaptor and waits for it to come up again |
| 206 | ... Following steps will be executed: |
| 207 | ... - kill openonu adaptor |
| 208 | ... - check openonu adaptor is ready again |
| 209 | [Arguments] ${namespace} |
| 210 | ${list_openonu_apps} Create List adapter-open-onu |
| 211 | ${adaptorname}= Set Variable open-onu |
| 212 | Kill Adaptor ${namespace} ${adaptorname} |
| 213 | Sleep 5s |
| 214 | Wait For Pods Ready ${namespace} ${list_openonu_apps} |
| 215 | |
| 216 | Restart And Check Onu Adaptor |
| 217 | [Documentation] This keyword restarts ONU Adaptor and waits for it to come up again |
| 218 | ... Following steps will be executed: |
| 219 | ... - restart openonu adaptor |
| 220 | ... - check openonu adaptor is ready again |
| 221 | [Arguments] ${namespace} |
| 222 | ${list_openonu_apps} Create List adapter-open-onu |
Matteo Scandolo | 6f24ea9 | 2021-04-29 11:55:50 -0700 | [diff] [blame] | 223 | ${openonu_label_key} Set Variable app |
| 224 | ${openonu_label_value} Set Variable adapter-open-onu |
| 225 | Restart Pod By Label ${namespace} ${openonu_label_key} ${openonu_label_value} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 226 | Sleep 5s |
| 227 | Wait For Pods Ready ${namespace} ${list_openonu_apps} |
| 228 | |
| 229 | Disable Onu Device |
| 230 | [Documentation] This keyword disables all onus. |
TorstenThieme | 70bc526 | 2021-01-19 12:12:55 +0000 | [diff] [blame] | 231 | ${onu_list} Create List |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 232 | FOR ${I} IN RANGE 0 ${num_all_onus} |
| 233 | ${src}= Set Variable ${hosts.src[${I}]} |
| 234 | ${onu_device_id}= Get Device ID From SN ${src['onu']} |
TorstenThieme | 70bc526 | 2021-01-19 12:12:55 +0000 | [diff] [blame] | 235 | ${onu_id}= Get Index From List ${onu_list} ${onu_device_id} |
| 236 | Continue For Loop If -1 != ${onu_id} |
| 237 | Append To List ${onu_list} ${onu_device_id} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 238 | Disable Device ${onu_device_id} |
| 239 | Wait Until Keyword Succeeds 20s 2s Test Devices Disabled in VOLTHA Id=${onu_device_id} |
| 240 | END |
| 241 | |
| 242 | Enable Onu Device |
| 243 | [Documentation] This keyword enables all onus. |
TorstenThieme | 70bc526 | 2021-01-19 12:12:55 +0000 | [diff] [blame] | 244 | ${onu_list} Create List |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 245 | FOR ${I} IN RANGE 0 ${num_all_onus} |
| 246 | ${src}= Set Variable ${hosts.src[${I}]} |
| 247 | ${onu_device_id}= Get Device ID From SN ${src['onu']} |
TorstenThieme | 70bc526 | 2021-01-19 12:12:55 +0000 | [diff] [blame] | 248 | ${onu_id}= Get Index From List ${onu_list} ${onu_device_id} |
| 249 | Continue For Loop If -1 != ${onu_id} |
| 250 | Append To List ${onu_list} ${onu_device_id} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 251 | Enable Device ${onu_device_id} |
| 252 | END |
| 253 | |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 254 | Verify MIB Template Data Available |
| 255 | [Documentation] This keyword verifies MIB Template Data stored in etcd |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 256 | [Arguments] ${namespace}=default |
TorstenThieme | d4f4896 | 2020-12-08 12:17:19 +0000 | [diff] [blame] | 257 | ${podname}= Set Variable etcd |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 258 | ${commandget} Catenate |
Matteo Scandolo | 341b937 | 2020-12-09 14:15:06 -0800 | [diff] [blame] | 259 | ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/' |
Holger Hildebrandt | 2314774 | 2020-11-16 10:13:21 +0000 | [diff] [blame] | 260 | ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget} |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 261 | Should Not Be Empty ${result} No MIB Template Data stored in etcd! |
| 262 | |
| 263 | Delete MIB Template Data |
| 264 | [Documentation] This keyword deletes MIB Template Data stored in etcd |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 265 | [Arguments] ${namespace}=default |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 266 | ${podname}= Set Variable etcd |
| 267 | ${commanddel} Catenate |
Matteo Scandolo | 341b937 | 2020-12-09 14:15:06 -0800 | [diff] [blame] | 268 | ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/omci_mibs/go_templates/' |
Holger Hildebrandt | 2314774 | 2020-11-16 10:13:21 +0000 | [diff] [blame] | 269 | ${result}= Exec Pod In Kube ${namespace} ${podname} ${commanddel} |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 270 | Sleep 3s |
| 271 | ${commandget} Catenate |
Matteo Scandolo | 341b937 | 2020-12-09 14:15:06 -0800 | [diff] [blame] | 272 | ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/' |
Holger Hildebrandt | 2314774 | 2020-11-16 10:13:21 +0000 | [diff] [blame] | 273 | ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget} |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 274 | Should Be Empty ${result} Could not delete MIB Template Data stored in etcd! |
| 275 | |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 276 | Set Tech Profile |
| 277 | [Documentation] This keyword sets the passed TechProfile for the test |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 278 | [Arguments] ${TechProfile} ${namespace}=default |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 279 | Log To Console \nTechProfile:${TechProfile} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 280 | ${podname}= Set Variable etcd |
Andrea Campanella | 0aa21d6 | 2021-07-22 10:44:32 +0200 | [diff] [blame] | 281 | ${label}= Set Variable app.kubernetes.io/name=${podname} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 282 | ${src}= Set Variable ${data_dir}/TechProfile-${TechProfile}.json |
| 283 | ${dest}= Set Variable /tmp/flexpod.json |
| 284 | ${command} Catenate |
| 285 | ... /bin/sh -c 'cat ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64' |
Andrea Campanella | 0aa21d6 | 2021-07-22 10:44:32 +0200 | [diff] [blame] | 286 | Copy File To Pod ${namespace} ${label} ${src} ${dest} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 287 | Exec Pod In Kube ${namespace} ${podname} ${command} |
| 288 | ${commandget} Catenate |
| 289 | ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64' |
Andrea Campanella | 0aa21d6 | 2021-07-22 10:44:32 +0200 | [diff] [blame] | 290 | ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget} |
| 291 | Should Not Be Empty ${result} No Tech Profile stored in etcd! |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 292 | |
| 293 | Remove Tech Profile |
| 294 | [Documentation] This keyword removes TechProfile |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 295 | [Arguments] ${namespace}=default |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 296 | Log To Console \nTechProfile:${TechProfile} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 297 | ${podname}= Set Variable etcd |
| 298 | ${command} Catenate |
| 299 | ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/64' |
| 300 | Exec Pod In Kube ${namespace} ${podname} ${command} |
| 301 | ${commandget} Catenate |
| 302 | ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64' |
| 303 | Exec Pod In Kube ${namespace} ${podname} ${commandget} |
| 304 | |
TorstenThieme | a7315f1 | 2021-07-23 11:56:34 +0000 | [diff] [blame] | 305 | Do Onu Subscriber Add Per OLT |
| 306 | [Documentation] Add Subscriber per OLT |
| 307 | [Arguments] ${of_id} ${olt_serial_number} ${print2console}=False |
| 308 | FOR ${I} IN RANGE 0 ${num_all_onus} |
| 309 | ${src}= Set Variable ${hosts.src[${I}]} |
| 310 | Continue For Loop If "${olt_serial_number}"!="${src['olt']}" |
| 311 | ${onu_device_id}= Get Device ID From SN ${src['onu']} |
| 312 | ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s |
| 313 | ... Get ONU Port in ONOS ${src['onu']} ${of_id} |
| 314 | Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2 |
| 315 | ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} |
| 316 | ... volt-add-subscriber-access ${of_id} ${onu_port} |
| 317 | Run Keyword If ${print2console} Log \r\n[${I}] volt-add-subscriber-access ${of_id} ${onu_port}. |
| 318 | ... console=yes |
| 319 | END |
| 320 | |
| 321 | Do Onu Flow Check Per OLT |
| 322 | [Documentation] Checks all ONU flows show up in ONOS and Voltha |
| 323 | [Arguments] ${of_id} ${nni_port} ${olt_serial_number} ${print2console}=False |
| 324 | FOR ${I} IN RANGE 0 ${num_all_onus} |
| 325 | ${src}= Set Variable ${hosts.src[${I}]} |
| 326 | Continue For Loop If "${olt_serial_number}"!="${src['olt']}" |
| 327 | ${onu_device_id}= Get Device ID From SN ${src['onu']} |
| 328 | ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s |
| 329 | ... Get ONU Port in ONOS ${src['onu']} ${of_id} |
| 330 | # Verify subscriber access flows are added for the ONU port |
| 331 | Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s |
| 332 | ... Verify Subscriber Access Flows Added For ONU ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${of_id} |
| 333 | ... ${onu_port} ${nni_port} ${src['c_tag']} ${src['s_tag']} |
| 334 | ${logoutput} Catenate \r\n[${I}] Verify Subscriber Access Flows Added For |
| 335 | ... ONU ${of_id} ${onu_port} ${src['c_tag']} ${src['s_tag']}. |
| 336 | Run Keyword If ${print2console} Log ${logoutput} console=yes |
| 337 | END |
| 338 | |
| 339 | Do Onu Subscriber Remove Per OLT |
| 340 | [Documentation] Removes per OLT subscribers in ONOS and Voltha |
| 341 | [Arguments] ${of_id} ${olt_serial_number} ${print2console}=False |
| 342 | FOR ${I} IN RANGE 0 ${num_all_onus} |
| 343 | ${src}= Set Variable ${hosts.src[${I}]} |
| 344 | ${dst}= Set Variable ${hosts.dst[${I}]} |
| 345 | Continue For Loop If "${olt_serial_number}"!="${src['olt']}" |
| 346 | ${onu_device_id}= Get Device ID From SN ${src['onu']} |
| 347 | ${onu_port}= Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2s |
| 348 | ... Get ONU Port in ONOS ${src['onu']} ${of_id} |
| 349 | Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 2 |
| 350 | ... Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT} |
| 351 | ... volt-remove-subscriber-access ${of_id} ${onu_port} |
| 352 | Run Keyword If ${print2console} Log \r\n[${I}] volt-remove-subscriber-access ${of_id} ${onu_port}. |
| 353 | ... console=yes |
| 354 | END |
| 355 | |
TorstenThieme | 7c397d7 | 2021-07-14 11:51:09 +0000 | [diff] [blame] | 356 | Validate Resource Instances Used Gem Ports |
| 357 | [Documentation] This keyword validates resource instances data stored in etcd. |
| 358 | ... It checks checks the number of gemport-ids which has matched with used Tech Profile |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 359 | [Arguments] ${nbofgemports} ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha |
TorstenThieme | 7c397d7 | 2021-07-14 11:51:09 +0000 | [diff] [blame] | 360 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 361 | ${etcddata}= Get ONU Go Adapter ETCD Data namespace=${namespace} defaultkvstoreprefix=${kvstoreprefix} |
TorstenThieme | 7c397d7 | 2021-07-14 11:51:09 +0000 | [diff] [blame] | 362 | #prepare result for json convert |
| 363 | ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata} |
| 364 | ${jsondata}= To Json ${result} |
| 365 | ${length}= Get Length ${jsondata} |
| 366 | log ${jsondata} |
| 367 | FOR ${INDEX} IN RANGE 0 ${length} |
| 368 | ${value}= Get From List ${jsondata} ${INDEX} |
| 369 | # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow. |
| 370 | # When testing multi-tcont this may need some adjustment. |
| 371 | Exit For Loop If not ('uni_config' in $value) |
| 372 | ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64 |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 373 | ${resourcedata}= Get Resource Instances ETCD Data ${tp_path} namespace=${namespace} |
| 374 | ... defaultkvstoreprefix=${kvstoreprefix} |
TorstenThieme | 7c397d7 | 2021-07-14 11:51:09 +0000 | [diff] [blame] | 375 | log ${resourcedata} |
| 376 | ${decoderesult}= volthatools.Tech Profile Decode Resource Instance ${resourcedata} return_default=true |
| 377 | log ${decoderesult} |
| 378 | ${gemportids}= Get From Dictionary ${decoderesult} gemport_ids |
| 379 | ${length}= Get Length ${gemportids} |
| 380 | Should Be Equal As Integers ${nbofgemports} ${length} |
| 381 | ... msg=Number of gem ports (${length}) does not match with techprofile ${techprofile}/${nbofgemports} |
| 382 | END |
| 383 | |
| 384 | Get Resource Instances ETCD Data |
| 385 | [Documentation] This keyword delivers Resource Instances Data stored in etcd |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 386 | [Arguments] ${tppath} ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha |
TorstenThieme | 7c397d7 | 2021-07-14 11:51:09 +0000 | [diff] [blame] | 387 | ${podname}= Set Variable etcd |
| 388 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
| 389 | ${commandget}= Catenate |
| 390 | ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/resource_instances/${tppath} |
| 391 | ... --print-value-only --hex' |
| 392 | ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget} |
| 393 | log ${result} |
| 394 | [Return] ${result} |
| 395 | |
TorstenThieme | f7cd2be | 2021-12-06 14:30:11 +0000 | [diff] [blame] | 396 | Validate Tech Profiles and Flows in ETCD Data Per Onu |
| 397 | [Documentation] This keyword validates tech profiles and flows data stored in etcd per onu. |
| 398 | ... It checks checks presence/absence of tech profiles and flows depending on must_exist. |
| 399 | ... The values/content of tech profiles and flows will be not validated! |
| 400 | [Arguments] ${onu_sn} ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha ${must_exist}=True |
| 401 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
| 402 | ${etcddata}= Get ONU Go Adapter ETCD Data namespace=${namespace} defaultkvstoreprefix=${kvstoreprefix} |
| 403 | #prepare result for json convert |
| 404 | ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata} |
| 405 | ${jsondata}= To Json ${result} |
| 406 | ${length}= Get Length ${jsondata} |
| 407 | log ${jsondata} |
| 408 | ${matched}= Set Variable False |
| 409 | FOR ${INDEX} IN RANGE 0 ${length} |
| 410 | ${value}= Get From List ${jsondata} ${INDEX} |
| 411 | ${uni_config}= Get From Dictionary ${value} uni_config |
| 412 | ${uni_config}= Set Variable ${uni_config[0]} |
| 413 | ${sn}= Get From Dictionary ${value} serial_number |
| 414 | ${matched}= Set Variable If '${sn}'=='${onu_sn}' True False |
| 415 | Exit For Loop If ${matched} |
| 416 | END |
| 417 | Should Be True ${matched} No ETCD data found for ONU ${onu_sn} |
| 418 | Log ${uni_config} |
| 419 | ${tp_path}= Get From Dictionary ${uni_config} PersTpPathMap |
| 420 | Log ${tp_path} |
| 421 | ${flow_params}= Get From Dictionary ${uni_config} flow_params |
| 422 | Log ${flow_params} |
| 423 | # in case of ATT for ONU with removed flows there is default flow established |
| 424 | ${length}= Get Length ${flow_params} |
| 425 | ${cookieslice}= Run Keyword If ${length}>0 Run Keyword If 'cookie_slice' in ${flow_params[0]} |
| 426 | ... Get From Dictionary ${flow_params[0]} cookie_slice |
| 427 | ${setvid}= Run Keyword If ${length}>0 Run Keyword If 'set_vid' in ${flow_params[0]['vlan_rule_params']} |
| 428 | ... Get From Dictionary ${flow_params[0]['vlan_rule_params']} set_vid |
| 429 | ${cookie_slice_length}= Run Keyword If ${length}>0 Run Keyword If 'cookie_slice' in ${flow_params[0]} |
| 430 | ... Get Length ${cookieslice} |
| 431 | Run Keyword If "${workflow}"=="ATT" and not ${must_exist} Run Keywords |
| 432 | ... Should Be Equal As Numbers ${setvid} 4091 AND |
| 433 | ... Should Be Equal As Numbers ${cookie_slice_length} 1 AND |
| 434 | ... Should Not Be Empty ${tp_path} AND |
| 435 | ... Return From Keyword |
| 436 | ${tp_path_length}= Get Length ${tp_path} |
| 437 | # validate tp_path is not Empty for case must_exist, case not must_exist will be validated implicitly with FOR loop |
| 438 | Run Keyword If ${must_exist} Should Not Be Empty ${tp_path} |
| 439 | ${tp_path_keys}= Run Keyword If ${tp_path_length}==0 Create List |
| 440 | ... ELSE Get Dictionary Keys ${tp_path} |
| 441 | ${tp_path_values}= Run Keyword If ${tp_path_length}==0 Create List |
| 442 | ... ELSE Get Dictionary Values ${tp_path} |
| 443 | ${tp_path_empty}= Set Variable True |
| 444 | Log ${tp_path_values} |
| 445 | Log ${tp_path_keys} |
TorstenThieme | f7cd2be | 2021-12-06 14:30:11 +0000 | [diff] [blame] | 446 | # In case of not empty tp_path each value will be checked depending on must_exist |
| 447 | FOR ${key} IN @{tp_path_keys} |
TorstenThieme | f7cd2be | 2021-12-06 14:30:11 +0000 | [diff] [blame] | 448 | ${value}= Get From Dictionary ${tp_path} ${key} |
| 449 | Run Keyword If ${must_exist} Should Not Be Empty ${value} |
| 450 | ... ELSE Should Be Empty ${value} |
TorstenThieme | f7cd2be | 2021-12-06 14:30:11 +0000 | [diff] [blame] | 451 | END |
| 452 | Run Keyword If ${must_exist} Should Not Be Empty ${flow_params} |
| 453 | ... ELSE Should Be Empty ${flow_params} |
TorstenThieme | 7c397d7 | 2021-07-14 11:51:09 +0000 | [diff] [blame] | 454 | |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 455 | Validate Onu Data In Etcd |
| 456 | [Documentation] This keyword validates openonu-go-adapter Data stored in etcd. |
| 457 | ... It checks unique of serial_number and combination of pon, onu and uni in tp_path. |
| 458 | ... Furthermore it evaluates the values of onu_id and uni_id with values read from tp_path. |
| 459 | ... Number of etcd entries has to match with the passed number. |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 460 | [Arguments] ${namespace}=default ${nbofetcddata}=${num_all_onus} ${defaultkvstoreprefix}=voltha_voltha |
TorstenThieme | fa29a89 | 2021-03-11 14:11:29 +0000 | [diff] [blame] | 461 | ... ${without_prefix}=True ${without_pm_data}=True |
TorstenThieme | 3385cdc | 2021-02-04 13:50:50 +0000 | [diff] [blame] | 462 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 463 | ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} ${without_prefix} ${without_pm_data} |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 464 | #prepare result for json convert |
| 465 | ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata} |
| 466 | ${jsondata}= To Json ${result} |
| 467 | ${length}= Get Length ${jsondata} |
| 468 | log ${jsondata} |
| 469 | Run Keyword And Continue On Failure Should Be Equal As Integers ${length} ${nbofetcddata} |
| 470 | ... msg=Number etcd data (${length}) does not match required (${nbofetcddata})! |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 471 | ${oltpononuuniidlist}= Create List |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 472 | ${serialnumberlist}= Create List |
| 473 | FOR ${INDEX} IN RANGE 0 ${length} |
| 474 | ${value}= Get From List ${jsondata} ${INDEX} |
Girish Gowdra | 97f8d06 | 2020-11-17 15:48:23 -0800 | [diff] [blame] | 475 | # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow. |
| 476 | # When testing multi-tcont this may need some adjustment. |
TorstenThieme | 4507160 | 2021-03-16 12:14:37 +0000 | [diff] [blame] | 477 | Exit For Loop If not ('uni_config' in $value) |
Girish Gowdra | 97f8d06 | 2020-11-17 15:48:23 -0800 | [diff] [blame] | 478 | ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64 |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 479 | ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path} |
| 480 | ${list_id}= Get Index From List ${oltpononuuniidlist} ${oltpononuuniid} |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 481 | Should Be Equal As Integers ${list_id} -1 |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 482 | ... msg=Combination of Pon, Onu and Uni (${oltpononuuniid}) exist multiple in etcd data! |
| 483 | Append To List ${oltpononuuniidlist} ${oltpononuuniid} |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 484 | Validate Onu Id ${value} |
| 485 | Validate Uni Id ${value} |
| 486 | ${serial_number}= Get From Dictionary ${value} serial_number |
| 487 | ${list_id}= Get Index From List ${serialnumberlist} ${serial_number} |
| 488 | Should Be Equal As Integers ${list_id} -1 |
| 489 | ... msg=Serial number (${serial_number}) exists multiple in etcd data! |
| 490 | Append To List ${serialnumberlist} ${serial_number} |
| 491 | END |
| 492 | |
TorstenThieme | 712b296 | 2021-11-17 14:16:15 +0000 | [diff] [blame] | 493 | Validate Onu Data In Etcd Removed |
| 494 | [Documentation] This keyword validates openonu-go-adapter Data stored in etcd are removed. |
| 495 | ... In case of a device is passed, only this will be checked. |
| 496 | [Arguments] ${namespace}=default ${device_id}=${EMPTY} ${defaultkvstoreprefix}=voltha_voltha |
| 497 | ... ${without_pm_data}=True |
| 498 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
| 499 | ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} False ${without_pm_data} |
| 500 | ... ${device_id} True |
| 501 | Log ${etcddata} |
| 502 | Should Be Empty ${etcddata} Stale Openonu Data in Etcd (KV store) ${device_id} |
| 503 | |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 504 | Validate Vlan Rules In Etcd |
| 505 | [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd. |
| 506 | ... It checks the given number of cookie_slice, match_vid (=4096) and set_vid. |
| 507 | ... Furthermore it returns a list of all set_vid. |
| 508 | ... In case of a passed dictionary containing set_vids these will be checked for to |
| 509 | ... current set-vid depending on setvidequal (True=equal, False=not equal). |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 510 | [Arguments] ${namespace}=default ${nbofcookieslice}=1 ${reqmatchvid}=4096 ${prevvlanrules}=${NONE} |
| 511 | ... ${setvidequal}=False ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True ${without_pm_data}=True |
TorstenThieme | 3385cdc | 2021-02-04 13:50:50 +0000 | [diff] [blame] | 512 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 513 | ${etcddata}= Get ONU Go Adapter ETCD Data ${namespace} ${kvstoreprefix} ${without_prefix} ${without_pm_data} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 514 | #prepare result for json convert |
| 515 | ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata} |
| 516 | ${jsondata}= To Json ${result} |
| 517 | ${length}= Get Length ${jsondata} |
| 518 | log ${jsondata} |
| 519 | ${vlan_rules}= Create Dictionary |
| 520 | FOR ${INDEX} IN RANGE 0 ${length} |
| 521 | ${value}= Get From List ${jsondata} ${INDEX} |
Girish Gowdra | 295c169 | 2020-11-19 10:51:53 -0800 | [diff] [blame] | 522 | # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow. |
| 523 | # When testing multi-tcont this may need some adjustment. |
| 524 | ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64 |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 525 | ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 526 | ${cookieslice}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]} cookie_slice |
| 527 | #@{cookieslicelist}= Split String ${cookieslice} , |
| 528 | ${foundcookieslices}= Get Length ${cookieslice} |
| 529 | Should Be Equal As Integers ${foundcookieslices} ${nbofcookieslice} |
| 530 | ${matchvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']} |
| 531 | ... match_vid |
| 532 | Should Be Equal As Integers ${matchvid} ${reqmatchvid} |
| 533 | ${setvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']} |
| 534 | ... set_vid |
| 535 | ${evalresult}= Evaluate 2 <= ${setvid} <= 4095 |
| 536 | Should Be True ${evalresult} msg=set_vid out of range (${setvid})! |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 537 | Set To Dictionary ${vlan_rules} ${oltpononuuniid} ${setvid} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 538 | ${oldsetvidvalid} Set Variable If ${prevvlanrules} is ${NONE} False True |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 539 | ${prevsetvid}= Set Variable If ${oldsetvidvalid} ${prevvlanrules['${oltpononuuniid}']} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 540 | Run Keyword If ${oldsetvidvalid} and ${setvidequal} |
| 541 | ... Should Be Equal As Integers ${prevsetvid} ${setvid} |
| 542 | ... ELSE IF ${oldsetvidvalid} and not ${setvidequal} |
| 543 | ... Should Not Be Equal As Integers ${prevsetvid} ${setvid} |
| 544 | END |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 545 | log Many ${vlan_rules} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 546 | [Return] ${vlan_rules} |
| 547 | |
| 548 | Get ONU Go Adapter ETCD Data |
| 549 | [Documentation] This keyword delivers openonu-go-adapter Data stored in etcd |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 550 | [Arguments] ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True |
TorstenThieme | 712b296 | 2021-11-17 14:16:15 +0000 | [diff] [blame] | 551 | ... ${without_pm_data}=True ${device_id}=${Empty} ${keys_only}=False |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 552 | ${podname}= Set Variable etcd |
TorstenThieme | 3385cdc | 2021-02-04 13:50:50 +0000 | [diff] [blame] | 553 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
TorstenThieme | 3af1231 | 2021-03-10 16:15:24 +0000 | [diff] [blame] | 554 | ${commandget}= Catenate |
| 555 | ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/openonu' |
TorstenThieme | 712b296 | 2021-11-17 14:16:15 +0000 | [diff] [blame] | 556 | ${commandget}= Run Keyword If ${keys_only} Catenate ${commandget} --keys-only |
| 557 | ... ELSE Set Variable ${commandget} |
TorstenThieme | 3af1231 | 2021-03-10 16:15:24 +0000 | [diff] [blame] | 558 | ${commandget}= Run Keyword If ${without_prefix} Catenate ${commandget} |
| 559 | ... | grep -v service/${kvstoreprefix}/openonu |
TorstenThieme | fa29a89 | 2021-03-11 14:11:29 +0000 | [diff] [blame] | 560 | ... ELSE Set Variable ${commandget} |
TorstenThieme | 3af1231 | 2021-03-10 16:15:24 +0000 | [diff] [blame] | 561 | ${commandget}= Run Keyword If ${without_pm_data} Catenate ${commandget} | grep -v instances_active |
TorstenThieme | fa29a89 | 2021-03-11 14:11:29 +0000 | [diff] [blame] | 562 | ... ELSE Set Variable ${commandget} |
TorstenThieme | 712b296 | 2021-11-17 14:16:15 +0000 | [diff] [blame] | 563 | ${commandget}= Run Keyword If "${device_id}"!="${Empty}" Catenate ${commandget} | grep ${device_id} |
| 564 | ... ELSE Set Variable ${commandget} |
Holger Hildebrandt | 2314774 | 2020-11-16 10:13:21 +0000 | [diff] [blame] | 565 | ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 566 | log ${result} |
| 567 | [Return] ${result} |
| 568 | |
| 569 | Prepare ONU Go Adapter ETCD Data For Json |
| 570 | [Documentation] This keyword prepares openonu-go-adapter Data stored in etcd for converting |
| 571 | ... to json |
| 572 | [Arguments] ${etcddata} |
| 573 | #prepare result for json convert |
| 574 | ${prepresult}= Replace String ${etcddata} \n , |
| 575 | ${prepresult}= Strip String ${prepresult} mode=right characters=, |
| 576 | ${prepresult}= Set Variable [${prepresult}] |
| 577 | log ${prepresult} |
| 578 | [Return] ${prepresult} |
| 579 | |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 580 | Read Pon Onu Uni String |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 581 | [Documentation] This keyword builds a four digit string using Olt, Pon, Onu and Uni value of given tp-path taken |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 582 | ... taken from etcd data of onu go adapter |
| 583 | [Arguments] ${tp_path} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 584 | ${tppathlines}= Replace String ${tp_path} / \n |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 585 | ${olt}= Get Value Of Tp Path Element ${tppathlines} olt |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 586 | ${pon}= Get Value Of Tp Path Element ${tppathlines} pon |
| 587 | ${onu}= Get Value Of Tp Path Element ${tppathlines} onu |
| 588 | ${uni}= Get Value Of Tp Path Element ${tppathlines} uni |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 589 | ${valuesid}= Set Variable ${olt}/${pon}/${onu}/${uni} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 590 | log ${valuesid} |
| 591 | [Return] ${valuesid} |
| 592 | |
| 593 | Get Value Of Tp Path Element |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 594 | [Documentation] This keyword delivers numeric value of given tp path element. |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 595 | [Arguments] ${tp_path_lines} ${element} |
| 596 | ${value}= Get Lines Containing String ${tp_path_lines} ${element}-\{ |
| 597 | ${value}= Remove String ${value} ${element}-\{ |
| 598 | ${value}= Remove String ${value} \} |
| 599 | log ${value} |
| 600 | [Return] ${value} |
| 601 | |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 602 | Validate Onu Id |
| 603 | [Documentation] This keyword validates ONU Id of passed etcd data. |
| 604 | [Arguments] ${value} |
Girish Gowdra | 295c169 | 2020-11-19 10:51:53 -0800 | [diff] [blame] | 605 | # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow. |
| 606 | # When testing multi-tcont this may need some adjustment. |
| 607 | ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64 |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 608 | ${tppathlines}= Replace String ${tp_path} / \n |
| 609 | ${onu}= Get Value Of Tp Path Element ${tppathlines} onu |
| 610 | ${onu_id}= Get From Dictionary ${value} onu_id |
| 611 | Should Be Equal As Integers ${onu} ${onu_id} |
| 612 | ... msg=Onu-Id (${onu_id}) does not match onu (${onu}) from tp_path in etcd data! |
| 613 | Should Be True ${onu_id}>=1 |
| 614 | |
| 615 | Validate Uni Id |
| 616 | [Documentation] This keyword validates UNI Id of passed etcd data. |
| 617 | [Arguments] ${value} |
Girish Gowdra | 295c169 | 2020-11-19 10:51:53 -0800 | [diff] [blame] | 618 | # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow. |
| 619 | # When testing multi-tcont this may need some adjustment. |
| 620 | ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64 |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 621 | ${tppathlines}= Replace String ${tp_path} / \n |
| 622 | ${uni}= Get Value Of Tp Path Element ${tppathlines} uni |
| 623 | ${uni_id}= Get From Dictionary ${value['uni_config'][0]} uni_id |
| 624 | Should Be Equal As Integers ${uni} ${uni_id} |
| 625 | ... msg=Uni-Id (${uni_id}) does not match onu (${uni}) from tp_path in etcd data! |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 626 | |
TorstenThieme | 4507160 | 2021-03-16 12:14:37 +0000 | [diff] [blame] | 627 | Delete ONU Go Adapter ETCD Data |
| 628 | [Documentation] This keyword deletes openonu-go-adapter Data stored in etcd |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 629 | [Arguments] ${namespace}=default ${defaultkvstoreprefix}=voltha_voltha ${validate}=False |
TorstenThieme | 4507160 | 2021-03-16 12:14:37 +0000 | [diff] [blame] | 630 | ${podname}= Set Variable etcd |
| 631 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
| 632 | ${commandget}= Catenate |
| 633 | ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/${kvstoreprefix}/openonu' |
| 634 | ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget} |
| 635 | log ${result} |
| 636 | Run Keyword If ${validate} Wait Until Keyword Succeeds ${timeout} 1s |
Hardik Windlass | 4288c6a | 2021-09-28 07:22:06 +0000 | [diff] [blame] | 637 | ... Validate Onu Data In Etcd namespace=${namespace} nbofetcddata=0 without_pm_data=False |
TorstenThieme | 4507160 | 2021-03-16 12:14:37 +0000 | [diff] [blame] | 638 | [Return] ${result} |
| 639 | |
TorstenThieme | d649288 | 2021-12-16 08:10:02 +0000 | [diff] [blame] | 640 | Validate ONOS Flows per OLT |
| 641 | [Documentation] This keyword validates onos flows per olt |
| 642 | [Arguments] ${olt_sn} ${expected_flows} |
| 643 | ${olt_of_id} Validate OLT Device in ONOS ${olt_sn} |
| 644 | ${flows}= Count flows ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${olt_of_id} added |
| 645 | Log Found added ${flows} of ${expected_flows} expected flows on device ${olt_sn} |
| 646 | Should Be Equal As Integers ${expected_flows} ${flows} |
| 647 | |
TorstenThieme | f7cd2be | 2021-12-06 14:30:11 +0000 | [diff] [blame] | 648 | Validate OLT Flows Per Onu |
| 649 | [Documentation] This keyword validates olt flows per onu |
| 650 | ... It checks checks presence/absence of olt flows depending on must_exist. |
| 651 | ... The values/content of olt flows will be not validated! |
| 652 | [Arguments] ${onu_device_id} ${must_exist} |
| 653 | ${rc} ${output}= Run and Return Rc and Output |
| 654 | ... voltctl -c ${VOLTCTL_CONFIG} device flows ${onu_device_id} -m 8MB -o json |
| 655 | Should Be Equal As Integers ${rc} 0 |
| 656 | ${jsondata}= To Json ${output} |
| 657 | Log ${jsondata} |
| 658 | # in case of ATT for ONU with removed flows there is default flow established |
| 659 | ${length}= Get Length ${jsondata} |
| 660 | ${value}= Run Keyword If ${length}>0 Get From List ${jsondata} 0 |
| 661 | ${setvid}= Run Keyword If ${length}>0 Run Keyword If 'setvlanid' in ${value} |
| 662 | ... Get From Dictionary ${value} setvlanid |
| 663 | Run Keyword If "${workflow}"=="ATT" and not ${must_exist} Run Keywords |
| 664 | ... Should Be Equal As Numbers ${setvid} 4091 AND |
| 665 | ... Should Be Equal As Numbers ${length} 1 AND |
| 666 | ... Return From Keyword |
| 667 | Run Keyword If ${must_exist} Should Not Be Empty ${jsondata} |
| 668 | ... ELSE Should Be Empty ${jsondata} |
| 669 | |
TorstenThieme | d4f4896 | 2020-12-08 12:17:19 +0000 | [diff] [blame] | 670 | Wait for Ports in ONOS for all OLTs |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 671 | [Documentation] Waits untill a certain number of ports are enabled in all OLTs |
TorstenThieme | 731a759 | 2021-07-01 14:26:54 +0000 | [diff] [blame] | 672 | [Arguments] ${host} ${port} ${count} ${filter} ${max_wait_time}=10m ${determine_number}=False |
TorstenThieme | d4f4896 | 2020-12-08 12:17:19 +0000 | [diff] [blame] | 673 | FOR ${J} IN RANGE 0 ${num_olts} |
| 674 | ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn] |
| 675 | ${onu_count}= Set Variable ${list_olts}[${J}][onucount] |
| 676 | ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS |
| 677 | ... ${olt_serial_number} |
| 678 | Set Global Variable ${of_id} |
TorstenThieme | ff9c914 | 2021-04-08 07:21:34 +0000 | [diff] [blame] | 679 | ${count2check}= Set Variable If ${count}==${num_all_onus} ${onu_count} ${count} |
| 680 | # if flag determine_number is set to True, always determine the number of real ONUs (overwrite previous value) |
| 681 | ${count2check}= Run Keyword If ${determine_number} Determine Number Of ONU ${olt_serial_number} |
| 682 | ... ELSE Set Variable ${count2check} |
TorstenThieme | 731a759 | 2021-07-01 14:26:54 +0000 | [diff] [blame] | 683 | Wait for Ports in ONOS ${host} ${port} ${count2check} ${of_id} BBSM ${max_wait_time} |
TorstenThieme | d4f4896 | 2020-12-08 12:17:19 +0000 | [diff] [blame] | 684 | END |
| 685 | |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 686 | Wait for all ONU Ports in ONOS Disabled |
| 687 | [Documentation] Waits untill a all ONU ports are disabled in all ONOS |
TorstenThieme | 731a759 | 2021-07-01 14:26:54 +0000 | [diff] [blame] | 688 | [Arguments] ${host} ${port} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 689 | FOR ${I} IN RANGE 0 ${num_all_onus} |
| 690 | ${src}= Set Variable ${hosts.src[${I}]} |
| 691 | ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS |
| 692 | ... ${src['olt']} |
| 693 | ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']} ${of_id} |
TorstenThieme | 731a759 | 2021-07-01 14:26:54 +0000 | [diff] [blame] | 694 | Wait Until Keyword Succeeds ${timeout} 2s Assert ONU Port Is Disabled ${host} ${port} ${of_id} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 695 | ... ${onu_port} |
| 696 | END |
| 697 | |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 698 | Map State |
| 699 | [Documentation] This keyword converts the passed numeric value or name of a onu state to its state values. |
| 700 | [Arguments] ${state} |
| 701 | # create state lists with corresponding return values |
| 702 | # ADMIN-STATE OPER-STATUS CONNECT-STATUS ONU-STATE (number/name) |
| 703 | ${state1} Create List ENABLED ACTIVATING REACHABLE 1 activating-onu |
| 704 | ${state2} Create List ENABLED ACTIVATING REACHABLE 2 starting-openomci |
| 705 | ${state3} Create List ENABLED ACTIVATING REACHABLE 3 discovery-mibsync-complete |
| 706 | ${state4} Create List ENABLED ACTIVE REACHABLE 4 initial-mib-downloaded |
| 707 | ${state5} Create List ENABLED ACTIVE REACHABLE 5 tech-profile-config-download-success |
| 708 | ${state6} Create List ENABLED ACTIVE REACHABLE 6 omci-flows-pushed |
| 709 | ${state7} Create List DISABLED UNKNOWN REACHABLE 7 omci-admin-lock |
| 710 | ${state8} Create List ENABLED ACTIVE REACHABLE 8 onu-reenabled |
| 711 | ${state9} Create List ENABLED DISCOVERED UNREACHABLE 9 stopping-openomci |
| 712 | ${state10} Create List ENABLED DISCOVERED REACHABLE 10 rebooting |
| 713 | ${state11} Create List ENABLED DISCOVERED REACHABLE 11 omci-flows-deleted |
| 714 | ${state12} Create List DISABLED UNKNOWN REACHABLE 12 tech-profile-config-delete-success |
| 715 | ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Set Variable If |
| 716 | ... '${state}'=='1' or '${state}'=='activating-onu' ${state1} |
| 717 | ... '${state}'=='2' or '${state}'=='starting-openomci' ${state2} |
| 718 | ... '${state}'=='3' or '${state}'=='discovery-mibsync-complete' ${state3} |
| 719 | ... '${state}'=='4' or '${state}'=='initial-mib-downloaded' ${state4} |
| 720 | ... '${state}'=='5' or '${state}'=='tech-profile-config-download-success' ${state5} |
| 721 | ... '${state}'=='6' or '${state}'=='omci-flows-pushed' ${state6} |
| 722 | ... '${state}'=='7' or '${state}'=='omci-admin-lock' ${state7} |
| 723 | ... '${state}'=='8' or '${state}'=='onu-reenabled' ${state8} |
| 724 | ... '${state}'=='9' or '${state}'=='stopping-openomci' ${state9} |
| 725 | ... '${state}'=='10' or '${state}'=='rebooting' ${state10} |
| 726 | ... '${state}'=='11' or '${state}'=='omci-flows-deleted' ${state11} |
| 727 | ... '${state}'=='12' or '${state}'=='tech-profile-config-delete-success' ${state12} |
| 728 | [Return] ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state} |