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