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 | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 21 | Calculate Timeout |
| 22 | [Documentation] Calculates the timeout regarding num-onus in case of more than 4 onus |
| 23 | [Arguments] ${basetimeout}=60s |
| 24 | ${new_timeout} Fetch From Left ${basetimeout} s |
| 25 | ${new_timeout}= evaluate ${new_timeout}+((${num_all_onus}-4)*10) |
| 26 | ${new_timeout}= Set Variable If (not ${debugmode}) and (${new_timeout}>300) |
| 27 | ... 300 ${new_timeout} |
| 28 | ${new_timeout}= Catenate SEPARATOR= ${new_timeout} s |
| 29 | [Return] ${new_timeout} |
| 30 | |
| 31 | Power On ONU Device |
| 32 | [Documentation] This keyword turns on the power for all onus. |
| 33 | [Arguments] ${namespace} |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 34 | FOR ${J} IN RANGE 0 ${num_olts} |
| 35 | ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn] |
| 36 | ${bbsim}= Catenate SEPARATOR= bbsim ${J} |
| 37 | ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim} |
| 38 | Power On ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod} |
| 39 | END |
| 40 | |
| 41 | Power On ONU Device per OLT |
| 42 | [Documentation] This keyword turns on the power for all onus. |
| 43 | [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod} |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 44 | FOR ${I} IN RANGE 0 ${num_all_onus} |
| 45 | ${src}= Set Variable ${hosts.src[${I}]} |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 46 | Continue For Loop If "${olt_serial_number}"!="${src['olt']}" |
| 47 | Power On ONU ${namespace} ${bbsim_pod} ${src['onu']} |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 48 | END |
| 49 | |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 50 | Power Off ONU Device |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 51 | [Documentation] This keyword turns off the power for all onus per olt. |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 52 | [Arguments] ${namespace} |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 53 | FOR ${J} IN RANGE 0 ${num_olts} |
| 54 | ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn] |
| 55 | ${bbsim}= Catenate SEPARATOR= bbsim ${J} |
| 56 | ${bbsim_pod}= Get Pod Name By Label ${namespace} release ${bbsim} |
| 57 | Power Off ONU Device per OLT ${namespace} ${olt_serial_number} ${bbsim_pod} |
| 58 | END |
| 59 | |
| 60 | Power Off ONU Device per OLT |
| 61 | [Documentation] This keyword turns off the power for all onus per olt. |
| 62 | [Arguments] ${namespace} ${olt_serial_number} ${bbsim_pod} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 63 | FOR ${I} IN RANGE 0 ${num_all_onus} |
| 64 | ${src}= Set Variable ${hosts.src[${I}]} |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 65 | Continue For Loop If "${olt_serial_number}"!="${src['olt']}" |
| 66 | Power Off ONU ${namespace} ${bbsim_pod} ${src['onu']} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 67 | END |
| 68 | |
| 69 | Current State Test |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 70 | [Documentation] This keyword checks the passed state of the given onu. |
| 71 | [Arguments] ${state} ${onu} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY} |
| 72 | ... ${reqconnectstatus}=${EMPTY} |
| 73 | ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state} |
| 74 | ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state} |
| 75 | ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status} |
| 76 | ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus} |
| 77 | ... ${connect_status} |
| 78 | Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms |
| 79 | ... Validate Device ${admin_state} ${oper_status} ${connect_status} |
| 80 | ... ${onu} onu=True onu_reason=${onu_state} |
| 81 | |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 82 | Current State Test All Onus |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 83 | [Documentation] This keyword checks the passed state of all onus. |
| 84 | ... Hint: ${timeStart} will be not evaluated here! |
| 85 | [Arguments] ${state} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY} ${reqconnectstatus}=${EMPTY} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 86 | ... ${alternativeonustate}=${EMPTY} ${timeout}=${timeout} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 87 | ${timeStart}= Get Current Date |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 88 | ${list_onus} Create List |
| 89 | Build ONU SN List ${list_onus} |
| 90 | ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state} |
| 91 | ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state} |
| 92 | ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status} |
| 93 | ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus} |
| 94 | ... ${connect_status} |
| 95 | Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms |
| 96 | ... Validate ONU Devices With Duration |
| 97 | ... ${admin_state} ${oper_status} ${connect_status} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 98 | ... ${onu_state} ${list_onus} ${timeStart} alternate_reason=${alternativeonustate} |
TorstenThieme | 53450ff | 2021-05-11 09:44:33 +0000 | [diff] [blame] | 99 | # teardown is used as 'return' for result of Validate ONU Devices With Duration (used for ONUNegativeStateTests) |
| 100 | [Teardown] Run Keyword If "${KEYWORD STATUS}"=="FAIL" Set Suite Variable ${StateTestAllONUs} False |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 101 | |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 102 | Log Ports |
| 103 | [Documentation] This keyword logs all port data available in ONOS of first port per ONU |
| 104 | [Arguments] ${onlyenabled}=False |
| 105 | ${cmd} Set Variable If ${onlyenabled} ports -e ports |
TorstenThieme | 731a759 | 2021-07-01 14:26:54 +0000 | [diff] [blame] | 106 | ${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] | 107 | ${lines} = Get Lines Matching Regexp ${onu_ports} .*portName=BBSM[0-9]{8}-1 |
| 108 | Log ${lines} |
| 109 | |
| 110 | Kill Adaptor |
| 111 | [Documentation] This keyword kills the passed adaptor. |
| 112 | [Arguments] ${namespace} ${name} |
| 113 | ${cmd} Catenate |
| 114 | ... kubectl exec -it -n voltha $(kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}') |
| 115 | ... -- /bin/sh -c "kill 1" |
| 116 | ${rc} ${output}= Run and Return Rc and Output ${cmd} |
| 117 | Log ${output} |
| 118 | |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 119 | Kill And Check Onu Adaptor |
| 120 | [Documentation] This keyword kills ONU Adaptor and waits for it to come up again |
| 121 | ... Following steps will be executed: |
| 122 | ... - kill openonu adaptor |
| 123 | ... - check openonu adaptor is ready again |
| 124 | [Arguments] ${namespace} |
| 125 | ${list_openonu_apps} Create List adapter-open-onu |
| 126 | ${adaptorname}= Set Variable open-onu |
| 127 | Kill Adaptor ${namespace} ${adaptorname} |
| 128 | Sleep 5s |
| 129 | Wait For Pods Ready ${namespace} ${list_openonu_apps} |
| 130 | |
| 131 | Restart And Check Onu Adaptor |
| 132 | [Documentation] This keyword restarts ONU Adaptor and waits for it to come up again |
| 133 | ... Following steps will be executed: |
| 134 | ... - restart openonu adaptor |
| 135 | ... - check openonu adaptor is ready again |
| 136 | [Arguments] ${namespace} |
| 137 | ${list_openonu_apps} Create List adapter-open-onu |
Matteo Scandolo | 6f24ea9 | 2021-04-29 11:55:50 -0700 | [diff] [blame] | 138 | ${openonu_label_key} Set Variable app |
| 139 | ${openonu_label_value} Set Variable adapter-open-onu |
| 140 | Restart Pod By Label ${namespace} ${openonu_label_key} ${openonu_label_value} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 141 | Sleep 5s |
| 142 | Wait For Pods Ready ${namespace} ${list_openonu_apps} |
| 143 | |
| 144 | Disable Onu Device |
| 145 | [Documentation] This keyword disables all onus. |
TorstenThieme | 70bc526 | 2021-01-19 12:12:55 +0000 | [diff] [blame] | 146 | ${onu_list} Create List |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 147 | FOR ${I} IN RANGE 0 ${num_all_onus} |
| 148 | ${src}= Set Variable ${hosts.src[${I}]} |
| 149 | ${onu_device_id}= Get Device ID From SN ${src['onu']} |
TorstenThieme | 70bc526 | 2021-01-19 12:12:55 +0000 | [diff] [blame] | 150 | ${onu_id}= Get Index From List ${onu_list} ${onu_device_id} |
| 151 | Continue For Loop If -1 != ${onu_id} |
| 152 | Append To List ${onu_list} ${onu_device_id} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 153 | Disable Device ${onu_device_id} |
| 154 | Wait Until Keyword Succeeds 20s 2s Test Devices Disabled in VOLTHA Id=${onu_device_id} |
| 155 | END |
| 156 | |
| 157 | Enable Onu Device |
| 158 | [Documentation] This keyword enables all onus. |
TorstenThieme | 70bc526 | 2021-01-19 12:12:55 +0000 | [diff] [blame] | 159 | ${onu_list} Create List |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 160 | FOR ${I} IN RANGE 0 ${num_all_onus} |
| 161 | ${src}= Set Variable ${hosts.src[${I}]} |
| 162 | ${onu_device_id}= Get Device ID From SN ${src['onu']} |
TorstenThieme | 70bc526 | 2021-01-19 12:12:55 +0000 | [diff] [blame] | 163 | ${onu_id}= Get Index From List ${onu_list} ${onu_device_id} |
| 164 | Continue For Loop If -1 != ${onu_id} |
| 165 | Append To List ${onu_list} ${onu_device_id} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 166 | Enable Device ${onu_device_id} |
| 167 | END |
| 168 | |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 169 | Verify MIB Template Data Available |
| 170 | [Documentation] This keyword verifies MIB Template Data stored in etcd |
| 171 | ${namespace}= Set Variable default |
TorstenThieme | d4f4896 | 2020-12-08 12:17:19 +0000 | [diff] [blame] | 172 | ${podname}= Set Variable etcd |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 173 | ${commandget} Catenate |
Matteo Scandolo | 341b937 | 2020-12-09 14:15:06 -0800 | [diff] [blame] | 174 | ... /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] | 175 | ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget} |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 176 | Should Not Be Empty ${result} No MIB Template Data stored in etcd! |
| 177 | |
| 178 | Delete MIB Template Data |
| 179 | [Documentation] This keyword deletes MIB Template Data stored in etcd |
| 180 | ${namespace}= Set Variable default |
| 181 | ${podname}= Set Variable etcd |
| 182 | ${commanddel} Catenate |
Matteo Scandolo | 341b937 | 2020-12-09 14:15:06 -0800 | [diff] [blame] | 183 | ... /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] | 184 | ${result}= Exec Pod In Kube ${namespace} ${podname} ${commanddel} |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 185 | Sleep 3s |
| 186 | ${commandget} Catenate |
Matteo Scandolo | 341b937 | 2020-12-09 14:15:06 -0800 | [diff] [blame] | 187 | ... /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] | 188 | ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget} |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 189 | Should Be Empty ${result} Could not delete MIB Template Data stored in etcd! |
| 190 | |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 191 | Set Tech Profile |
| 192 | [Documentation] This keyword sets the passed TechProfile for the test |
| 193 | [Arguments] ${TechProfile} |
| 194 | Log To Console \nTechProfile:${TechProfile} |
| 195 | ${namespace}= Set Variable default |
| 196 | ${podname}= Set Variable etcd |
| 197 | ${src}= Set Variable ${data_dir}/TechProfile-${TechProfile}.json |
| 198 | ${dest}= Set Variable /tmp/flexpod.json |
| 199 | ${command} Catenate |
| 200 | ... /bin/sh -c 'cat ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64' |
| 201 | Copy File To Pod ${namespace} ${podname} ${src} ${dest} |
| 202 | Exec Pod In Kube ${namespace} ${podname} ${command} |
| 203 | ${commandget} Catenate |
| 204 | ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64' |
| 205 | Exec Pod In Kube ${namespace} ${podname} ${commandget} |
| 206 | |
| 207 | Remove Tech Profile |
| 208 | [Documentation] This keyword removes TechProfile |
| 209 | Log To Console \nTechProfile:${TechProfile} |
| 210 | ${namespace}= Set Variable default |
| 211 | ${podname}= Set Variable etcd |
| 212 | ${command} Catenate |
| 213 | ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/64' |
| 214 | Exec Pod In Kube ${namespace} ${podname} ${command} |
| 215 | ${commandget} Catenate |
| 216 | ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64' |
| 217 | Exec Pod In Kube ${namespace} ${podname} ${commandget} |
| 218 | |
TorstenThieme | 7c397d7 | 2021-07-14 11:51:09 +0000 | [diff] [blame^] | 219 | Validate Resource Instances Used Gem Ports |
| 220 | [Documentation] This keyword validates resource instances data stored in etcd. |
| 221 | ... It checks checks the number of gemport-ids which has matched with used Tech Profile |
| 222 | [Arguments] ${nbofgemports} ${defaultkvstoreprefix}=voltha_voltha |
| 223 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
| 224 | ${etcddata}= Get ONU Go Adapter ETCD Data ${kvstoreprefix} |
| 225 | #prepare result for json convert |
| 226 | ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata} |
| 227 | ${jsondata}= To Json ${result} |
| 228 | ${length}= Get Length ${jsondata} |
| 229 | log ${jsondata} |
| 230 | FOR ${INDEX} IN RANGE 0 ${length} |
| 231 | ${value}= Get From List ${jsondata} ${INDEX} |
| 232 | # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow. |
| 233 | # When testing multi-tcont this may need some adjustment. |
| 234 | Exit For Loop If not ('uni_config' in $value) |
| 235 | ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64 |
| 236 | ${resourcedata}= Get Resource Instances ETCD Data ${tp_path} ${kvstoreprefix} |
| 237 | log ${resourcedata} |
| 238 | ${decoderesult}= volthatools.Tech Profile Decode Resource Instance ${resourcedata} return_default=true |
| 239 | log ${decoderesult} |
| 240 | ${gemportids}= Get From Dictionary ${decoderesult} gemport_ids |
| 241 | ${length}= Get Length ${gemportids} |
| 242 | Should Be Equal As Integers ${nbofgemports} ${length} |
| 243 | ... msg=Number of gem ports (${length}) does not match with techprofile ${techprofile}/${nbofgemports} |
| 244 | END |
| 245 | |
| 246 | Get Resource Instances ETCD Data |
| 247 | [Documentation] This keyword delivers Resource Instances Data stored in etcd |
| 248 | [Arguments] ${tppath} ${defaultkvstoreprefix}=voltha_voltha |
| 249 | ${namespace}= Set Variable default |
| 250 | ${podname}= Set Variable etcd |
| 251 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
| 252 | ${commandget}= Catenate |
| 253 | ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/resource_instances/${tppath} |
| 254 | ... --print-value-only --hex' |
| 255 | ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget} |
| 256 | log ${result} |
| 257 | [Return] ${result} |
| 258 | |
| 259 | |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 260 | Validate Onu Data In Etcd |
| 261 | [Documentation] This keyword validates openonu-go-adapter Data stored in etcd. |
| 262 | ... It checks unique of serial_number and combination of pon, onu and uni in tp_path. |
| 263 | ... Furthermore it evaluates the values of onu_id and uni_id with values read from tp_path. |
| 264 | ... Number of etcd entries has to match with the passed number. |
TorstenThieme | 3385cdc | 2021-02-04 13:50:50 +0000 | [diff] [blame] | 265 | [Arguments] ${nbofetcddata}=${num_all_onus} ${defaultkvstoreprefix}=voltha_voltha |
TorstenThieme | fa29a89 | 2021-03-11 14:11:29 +0000 | [diff] [blame] | 266 | ... ${without_prefix}=True ${without_pm_data}=True |
TorstenThieme | 3385cdc | 2021-02-04 13:50:50 +0000 | [diff] [blame] | 267 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
TorstenThieme | fa29a89 | 2021-03-11 14:11:29 +0000 | [diff] [blame] | 268 | ${etcddata}= Get ONU Go Adapter ETCD Data ${kvstoreprefix} ${without_prefix} ${without_pm_data} |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 269 | #prepare result for json convert |
| 270 | ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata} |
| 271 | ${jsondata}= To Json ${result} |
| 272 | ${length}= Get Length ${jsondata} |
| 273 | log ${jsondata} |
| 274 | Run Keyword And Continue On Failure Should Be Equal As Integers ${length} ${nbofetcddata} |
| 275 | ... msg=Number etcd data (${length}) does not match required (${nbofetcddata})! |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 276 | ${oltpononuuniidlist}= Create List |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 277 | ${serialnumberlist}= Create List |
| 278 | FOR ${INDEX} IN RANGE 0 ${length} |
| 279 | ${value}= Get From List ${jsondata} ${INDEX} |
Girish Gowdra | 97f8d06 | 2020-11-17 15:48:23 -0800 | [diff] [blame] | 280 | # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow. |
| 281 | # When testing multi-tcont this may need some adjustment. |
TorstenThieme | 4507160 | 2021-03-16 12:14:37 +0000 | [diff] [blame] | 282 | Exit For Loop If not ('uni_config' in $value) |
Girish Gowdra | 97f8d06 | 2020-11-17 15:48:23 -0800 | [diff] [blame] | 283 | ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64 |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 284 | ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path} |
| 285 | ${list_id}= Get Index From List ${oltpononuuniidlist} ${oltpononuuniid} |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 286 | Should Be Equal As Integers ${list_id} -1 |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 287 | ... msg=Combination of Pon, Onu and Uni (${oltpononuuniid}) exist multiple in etcd data! |
| 288 | Append To List ${oltpononuuniidlist} ${oltpononuuniid} |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 289 | Validate Onu Id ${value} |
| 290 | Validate Uni Id ${value} |
| 291 | ${serial_number}= Get From Dictionary ${value} serial_number |
| 292 | ${list_id}= Get Index From List ${serialnumberlist} ${serial_number} |
| 293 | Should Be Equal As Integers ${list_id} -1 |
| 294 | ... msg=Serial number (${serial_number}) exists multiple in etcd data! |
| 295 | Append To List ${serialnumberlist} ${serial_number} |
| 296 | END |
| 297 | |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 298 | Validate Vlan Rules In Etcd |
| 299 | [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd. |
| 300 | ... It checks the given number of cookie_slice, match_vid (=4096) and set_vid. |
| 301 | ... Furthermore it returns a list of all set_vid. |
| 302 | ... In case of a passed dictionary containing set_vids these will be checked for to |
| 303 | ... current set-vid depending on setvidequal (True=equal, False=not equal). |
| 304 | [Arguments] ${nbofcookieslice}=1 ${reqmatchvid}=4096 ${prevvlanrules}=${NONE} ${setvidequal}=False |
TorstenThieme | fa29a89 | 2021-03-11 14:11:29 +0000 | [diff] [blame] | 305 | ... ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True ${without_pm_data}=True |
TorstenThieme | 3385cdc | 2021-02-04 13:50:50 +0000 | [diff] [blame] | 306 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
TorstenThieme | fa29a89 | 2021-03-11 14:11:29 +0000 | [diff] [blame] | 307 | ${etcddata}= Get ONU Go Adapter ETCD Data ${kvstoreprefix} ${without_prefix} ${without_pm_data} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 308 | #prepare result for json convert |
| 309 | ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata} |
| 310 | ${jsondata}= To Json ${result} |
| 311 | ${length}= Get Length ${jsondata} |
| 312 | log ${jsondata} |
| 313 | ${vlan_rules}= Create Dictionary |
| 314 | FOR ${INDEX} IN RANGE 0 ${length} |
| 315 | ${value}= Get From List ${jsondata} ${INDEX} |
Girish Gowdra | 295c169 | 2020-11-19 10:51:53 -0800 | [diff] [blame] | 316 | # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow. |
| 317 | # When testing multi-tcont this may need some adjustment. |
| 318 | ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64 |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 319 | ${oltpononuuniid}= Read Pon Onu Uni String ${tp_path} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 320 | ${cookieslice}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]} cookie_slice |
| 321 | #@{cookieslicelist}= Split String ${cookieslice} , |
| 322 | ${foundcookieslices}= Get Length ${cookieslice} |
| 323 | Should Be Equal As Integers ${foundcookieslices} ${nbofcookieslice} |
| 324 | ${matchvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']} |
| 325 | ... match_vid |
| 326 | Should Be Equal As Integers ${matchvid} ${reqmatchvid} |
| 327 | ${setvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']} |
| 328 | ... set_vid |
| 329 | ${evalresult}= Evaluate 2 <= ${setvid} <= 4095 |
| 330 | Should Be True ${evalresult} msg=set_vid out of range (${setvid})! |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 331 | Set To Dictionary ${vlan_rules} ${oltpononuuniid} ${setvid} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 332 | ${oldsetvidvalid} Set Variable If ${prevvlanrules} is ${NONE} False True |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 333 | ${prevsetvid}= Set Variable If ${oldsetvidvalid} ${prevvlanrules['${oltpononuuniid}']} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 334 | Run Keyword If ${oldsetvidvalid} and ${setvidequal} |
| 335 | ... Should Be Equal As Integers ${prevsetvid} ${setvid} |
| 336 | ... ELSE IF ${oldsetvidvalid} and not ${setvidequal} |
| 337 | ... Should Not Be Equal As Integers ${prevsetvid} ${setvid} |
| 338 | END |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 339 | log Many ${vlan_rules} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 340 | [Return] ${vlan_rules} |
| 341 | |
| 342 | Get ONU Go Adapter ETCD Data |
| 343 | [Documentation] This keyword delivers openonu-go-adapter Data stored in etcd |
TorstenThieme | 3af1231 | 2021-03-10 16:15:24 +0000 | [diff] [blame] | 344 | [Arguments] ${defaultkvstoreprefix}=voltha_voltha ${without_prefix}=True ${without_pm_data}=True |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 345 | ${namespace}= Set Variable default |
| 346 | ${podname}= Set Variable etcd |
TorstenThieme | 3385cdc | 2021-02-04 13:50:50 +0000 | [diff] [blame] | 347 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
TorstenThieme | 3af1231 | 2021-03-10 16:15:24 +0000 | [diff] [blame] | 348 | ${commandget}= Catenate |
| 349 | ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/${kvstoreprefix}/openonu' |
| 350 | ${commandget}= Run Keyword If ${without_prefix} Catenate ${commandget} |
| 351 | ... | grep -v service/${kvstoreprefix}/openonu |
TorstenThieme | fa29a89 | 2021-03-11 14:11:29 +0000 | [diff] [blame] | 352 | ... ELSE Set Variable ${commandget} |
TorstenThieme | 3af1231 | 2021-03-10 16:15:24 +0000 | [diff] [blame] | 353 | ${commandget}= Run Keyword If ${without_pm_data} Catenate ${commandget} | grep -v instances_active |
TorstenThieme | fa29a89 | 2021-03-11 14:11:29 +0000 | [diff] [blame] | 354 | ... ELSE Set Variable ${commandget} |
Holger Hildebrandt | 2314774 | 2020-11-16 10:13:21 +0000 | [diff] [blame] | 355 | ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 356 | log ${result} |
| 357 | [Return] ${result} |
| 358 | |
| 359 | Prepare ONU Go Adapter ETCD Data For Json |
| 360 | [Documentation] This keyword prepares openonu-go-adapter Data stored in etcd for converting |
| 361 | ... to json |
| 362 | [Arguments] ${etcddata} |
| 363 | #prepare result for json convert |
| 364 | ${prepresult}= Replace String ${etcddata} \n , |
| 365 | ${prepresult}= Strip String ${prepresult} mode=right characters=, |
| 366 | ${prepresult}= Set Variable [${prepresult}] |
| 367 | log ${prepresult} |
| 368 | [Return] ${prepresult} |
| 369 | |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 370 | Read Pon Onu Uni String |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 371 | [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] | 372 | ... taken from etcd data of onu go adapter |
| 373 | [Arguments] ${tp_path} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 374 | ${tppathlines}= Replace String ${tp_path} / \n |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 375 | ${olt}= Get Value Of Tp Path Element ${tppathlines} olt |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 376 | ${pon}= Get Value Of Tp Path Element ${tppathlines} pon |
| 377 | ${onu}= Get Value Of Tp Path Element ${tppathlines} onu |
| 378 | ${uni}= Get Value Of Tp Path Element ${tppathlines} uni |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 379 | ${valuesid}= Set Variable ${olt}/${pon}/${onu}/${uni} |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 380 | log ${valuesid} |
| 381 | [Return] ${valuesid} |
| 382 | |
| 383 | Get Value Of Tp Path Element |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 384 | [Documentation] This keyword delivers numeric value of given tp path element. |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 385 | [Arguments] ${tp_path_lines} ${element} |
| 386 | ${value}= Get Lines Containing String ${tp_path_lines} ${element}-\{ |
| 387 | ${value}= Remove String ${value} ${element}-\{ |
| 388 | ${value}= Remove String ${value} \} |
| 389 | log ${value} |
| 390 | [Return] ${value} |
| 391 | |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 392 | Validate Onu Id |
| 393 | [Documentation] This keyword validates ONU Id of passed etcd data. |
| 394 | [Arguments] ${value} |
Girish Gowdra | 295c169 | 2020-11-19 10:51:53 -0800 | [diff] [blame] | 395 | # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow. |
| 396 | # When testing multi-tcont this may need some adjustment. |
| 397 | ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64 |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 398 | ${tppathlines}= Replace String ${tp_path} / \n |
| 399 | ${onu}= Get Value Of Tp Path Element ${tppathlines} onu |
| 400 | ${onu_id}= Get From Dictionary ${value} onu_id |
| 401 | Should Be Equal As Integers ${onu} ${onu_id} |
| 402 | ... msg=Onu-Id (${onu_id}) does not match onu (${onu}) from tp_path in etcd data! |
| 403 | Should Be True ${onu_id}>=1 |
| 404 | |
| 405 | Validate Uni Id |
| 406 | [Documentation] This keyword validates UNI Id of passed etcd data. |
| 407 | [Arguments] ${value} |
Girish Gowdra | 295c169 | 2020-11-19 10:51:53 -0800 | [diff] [blame] | 408 | # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow. |
| 409 | # When testing multi-tcont this may need some adjustment. |
| 410 | ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64 |
TorstenThieme | 17756ea | 2020-11-11 14:09:47 +0000 | [diff] [blame] | 411 | ${tppathlines}= Replace String ${tp_path} / \n |
| 412 | ${uni}= Get Value Of Tp Path Element ${tppathlines} uni |
| 413 | ${uni_id}= Get From Dictionary ${value['uni_config'][0]} uni_id |
| 414 | Should Be Equal As Integers ${uni} ${uni_id} |
| 415 | ... msg=Uni-Id (${uni_id}) does not match onu (${uni}) from tp_path in etcd data! |
TorstenThieme | 52ef839 | 2020-11-10 13:42:26 +0000 | [diff] [blame] | 416 | |
TorstenThieme | 4507160 | 2021-03-16 12:14:37 +0000 | [diff] [blame] | 417 | Delete ONU Go Adapter ETCD Data |
| 418 | [Documentation] This keyword deletes openonu-go-adapter Data stored in etcd |
| 419 | [Arguments] ${defaultkvstoreprefix}=voltha_voltha ${validate}=False |
| 420 | ${namespace}= Set Variable default |
| 421 | ${podname}= Set Variable etcd |
| 422 | ${kvstoreprefix}= Get Kv Store Prefix ${defaultkvstoreprefix} |
| 423 | ${commandget}= Catenate |
| 424 | ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/${kvstoreprefix}/openonu' |
| 425 | ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget} |
| 426 | log ${result} |
| 427 | Run Keyword If ${validate} Wait Until Keyword Succeeds ${timeout} 1s |
| 428 | ... Validate Onu Data In Etcd 0 without_pm_data=False |
| 429 | [Return] ${result} |
| 430 | |
TorstenThieme | d4f4896 | 2020-12-08 12:17:19 +0000 | [diff] [blame] | 431 | Wait for Ports in ONOS for all OLTs |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 432 | [Documentation] Waits untill a certain number of ports are enabled in all OLTs |
TorstenThieme | 731a759 | 2021-07-01 14:26:54 +0000 | [diff] [blame] | 433 | [Arguments] ${host} ${port} ${count} ${filter} ${max_wait_time}=10m ${determine_number}=False |
TorstenThieme | d4f4896 | 2020-12-08 12:17:19 +0000 | [diff] [blame] | 434 | FOR ${J} IN RANGE 0 ${num_olts} |
| 435 | ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn] |
| 436 | ${onu_count}= Set Variable ${list_olts}[${J}][onucount] |
| 437 | ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS |
| 438 | ... ${olt_serial_number} |
| 439 | Set Global Variable ${of_id} |
TorstenThieme | ff9c914 | 2021-04-08 07:21:34 +0000 | [diff] [blame] | 440 | ${count2check}= Set Variable If ${count}==${num_all_onus} ${onu_count} ${count} |
| 441 | # if flag determine_number is set to True, always determine the number of real ONUs (overwrite previous value) |
| 442 | ${count2check}= Run Keyword If ${determine_number} Determine Number Of ONU ${olt_serial_number} |
| 443 | ... ELSE Set Variable ${count2check} |
TorstenThieme | 731a759 | 2021-07-01 14:26:54 +0000 | [diff] [blame] | 444 | 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] | 445 | END |
| 446 | |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 447 | Wait for all ONU Ports in ONOS Disabled |
| 448 | [Documentation] Waits untill a all ONU ports are disabled in all ONOS |
TorstenThieme | 731a759 | 2021-07-01 14:26:54 +0000 | [diff] [blame] | 449 | [Arguments] ${host} ${port} |
TorstenThieme | 440b7c0 | 2020-12-18 15:42:57 +0000 | [diff] [blame] | 450 | FOR ${I} IN RANGE 0 ${num_all_onus} |
| 451 | ${src}= Set Variable ${hosts.src[${I}]} |
| 452 | ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS |
| 453 | ... ${src['olt']} |
| 454 | ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']} ${of_id} |
TorstenThieme | 731a759 | 2021-07-01 14:26:54 +0000 | [diff] [blame] | 455 | 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] | 456 | ... ${onu_port} |
| 457 | END |
| 458 | |
TorstenThieme | fd7e7ba | 2020-11-06 13:57:57 +0000 | [diff] [blame] | 459 | Map State |
| 460 | [Documentation] This keyword converts the passed numeric value or name of a onu state to its state values. |
| 461 | [Arguments] ${state} |
| 462 | # create state lists with corresponding return values |
| 463 | # ADMIN-STATE OPER-STATUS CONNECT-STATUS ONU-STATE (number/name) |
| 464 | ${state1} Create List ENABLED ACTIVATING REACHABLE 1 activating-onu |
| 465 | ${state2} Create List ENABLED ACTIVATING REACHABLE 2 starting-openomci |
| 466 | ${state3} Create List ENABLED ACTIVATING REACHABLE 3 discovery-mibsync-complete |
| 467 | ${state4} Create List ENABLED ACTIVE REACHABLE 4 initial-mib-downloaded |
| 468 | ${state5} Create List ENABLED ACTIVE REACHABLE 5 tech-profile-config-download-success |
| 469 | ${state6} Create List ENABLED ACTIVE REACHABLE 6 omci-flows-pushed |
| 470 | ${state7} Create List DISABLED UNKNOWN REACHABLE 7 omci-admin-lock |
| 471 | ${state8} Create List ENABLED ACTIVE REACHABLE 8 onu-reenabled |
| 472 | ${state9} Create List ENABLED DISCOVERED UNREACHABLE 9 stopping-openomci |
| 473 | ${state10} Create List ENABLED DISCOVERED REACHABLE 10 rebooting |
| 474 | ${state11} Create List ENABLED DISCOVERED REACHABLE 11 omci-flows-deleted |
| 475 | ${state12} Create List DISABLED UNKNOWN REACHABLE 12 tech-profile-config-delete-success |
| 476 | ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Set Variable If |
| 477 | ... '${state}'=='1' or '${state}'=='activating-onu' ${state1} |
| 478 | ... '${state}'=='2' or '${state}'=='starting-openomci' ${state2} |
| 479 | ... '${state}'=='3' or '${state}'=='discovery-mibsync-complete' ${state3} |
| 480 | ... '${state}'=='4' or '${state}'=='initial-mib-downloaded' ${state4} |
| 481 | ... '${state}'=='5' or '${state}'=='tech-profile-config-download-success' ${state5} |
| 482 | ... '${state}'=='6' or '${state}'=='omci-flows-pushed' ${state6} |
| 483 | ... '${state}'=='7' or '${state}'=='omci-admin-lock' ${state7} |
| 484 | ... '${state}'=='8' or '${state}'=='onu-reenabled' ${state8} |
| 485 | ... '${state}'=='9' or '${state}'=='stopping-openomci' ${state9} |
| 486 | ... '${state}'=='10' or '${state}'=='rebooting' ${state10} |
| 487 | ... '${state}'=='11' or '${state}'=='omci-flows-deleted' ${state11} |
| 488 | ... '${state}'=='12' or '${state}'=='tech-profile-config-delete-success' ${state12} |
| 489 | [Return] ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state} |