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