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