Joey Armstrong | 888f1ee | 2023-01-11 17:14:30 -0500 | [diff] [blame] | 1 | # Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Matteo Scandolo | a80b473 | 2020-09-04 13:51:10 -0700 | [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. |
| 14 | # onos common functions |
| 15 | |
| 16 | *** Settings *** |
| 17 | Documentation Library for BBSimCtl interactions |
| 18 | Resource ./k8s.robot |
| 19 | |
Hardik Windlass | 513afd1 | 2021-02-03 15:19:46 +0000 | [diff] [blame] | 20 | *** Variables *** |
| 21 | &{IGMP_TASK_DICT} join=0 leave=1 joinv3=2 |
| 22 | |
Matteo Scandolo | a80b473 | 2020-09-04 13:51:10 -0700 | [diff] [blame] | 23 | *** Keywords *** |
| 24 | List ONUs |
| 25 | [Documentation] Lists ONUs via BBSimctl |
| 26 | [Arguments] ${namespace} ${bbsim_pod_name} |
| 27 | ${onus} ${rc}= Exec Pod And Return Output And RC ${namespace} ${bbsim_pod_name} |
| 28 | ... bbsimctl onu list |
| 29 | Log ${onus} |
| 30 | Should Be Equal as Integers ${rc} 0 |
| 31 | |
| 32 | Restart Auth |
| 33 | [Documentation] Restart Authentication on a BBSim ONU |
| 34 | [Arguments] ${namespace} ${bbsim_pod_name} ${onu} |
| 35 | ${res} ${rc}= Exec Pod And Return Output And RC ${namespace} ${bbsim_pod_name} |
| 36 | ... bbsimctl onu auth_restart ${onu} |
| 37 | Log ${res} |
| 38 | Should Be Equal as Integers ${rc} 0 |
| 39 | |
| 40 | Restart DHCP |
| 41 | [Documentation] Restart Dhcp on a BBSim ONU |
| 42 | [Arguments] ${namespace} ${bbsim_pod_name} ${onu} |
| 43 | ${res} ${rc}= Exec Pod And Return Output And RC ${namespace} ${bbsim_pod_name} |
| 44 | ... bbsimctl onu dhcp_restart ${onu} |
| 45 | Log ${res} |
| 46 | Should Be Equal as Integers ${rc} 0 |
| 47 | |
| 48 | List Service |
| 49 | [Documentation] Lists Service via BBSimctl |
| 50 | [Arguments] ${namespace} ${bbsim_pod_name} |
| 51 | ${service} ${rc}= Exec Pod And Return Output And RC ${namespace} ${bbsim_pod_name} |
| 52 | ... bbsimctl service list |
| 53 | Log ${service} |
| 54 | Should Be Equal as Integers ${rc} 0 |
| 55 | |
Hardik Windlass | 513afd1 | 2021-02-03 15:19:46 +0000 | [diff] [blame] | 56 | JoinOrLeave Igmp Rest Based |
| 57 | [Documentation] Joins or Leaves Igmp on a BBSim ONU (based on Rest Endpoint) |
| 58 | [Arguments] ${bbsim_rel_session} ${onu} ${task} ${group_address} |
| 59 | ${resp}= Post Request ${bbsim_rel_session} |
| 60 | ... /v1/olt/onus/${onu}/igmp/${IGMP_TASK_DICT}[${task}]/${group_address} |
| 61 | Log ${resp} |
| 62 | |
Matteo Scandolo | a80b473 | 2020-09-04 13:51:10 -0700 | [diff] [blame] | 63 | JoinOrLeave Igmp |
| 64 | [Documentation] Joins or Leaves Igmp on a BBSim ONU |
| 65 | [Arguments] ${namespace} ${bbsim_pod_name} ${onu} ${task} ${group_address}=224.0.0.22 |
| 66 | ${res} ${rc}= Exec Pod And Return Output And RC ${namespace} ${bbsim_pod_name} |
| 67 | ... bbsimctl onu igmp ${onu} ${task} ${group_address} |
| 68 | Log ${res} |
| 69 | Should Be Equal as Integers ${rc} 0 |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 70 | |
| 71 | Power On ONU |
| 72 | [Documentation] This keyword turns on the power for onu device. |
| 73 | [Arguments] ${namespace} ${bbsim_pod_name} ${onu} |
| 74 | ${result} ${rc}= Exec Pod And Return Output And RC ${namespace} ${bbsim_pod_name} |
| 75 | ... bbsimctl onu poweron ${onu} |
| 76 | Should Contain ${result} successfully msg=Can not poweron ${onu} values=False |
| 77 | |
| 78 | Power Off ONU |
| 79 | [Documentation] This keyword turns off the power for onu device. |
| 80 | [Arguments] ${namespace} ${bbsim_pod_name} ${onu} |
| 81 | ${result} ${rc}= Exec Pod And Return Output And RC ${namespace} ${bbsim_pod_name} |
| 82 | ... bbsimctl onu shutdown ${onu} |
| 83 | Should Contain ${result} successfully msg=Can not shutdown ${onu} values=False |
Hardik Windlass | 513afd1 | 2021-02-03 15:19:46 +0000 | [diff] [blame] | 84 | |
TorstenThieme | 00fe826 | 2022-01-19 10:43:07 +0000 | [diff] [blame] | 85 | Set Wrong MDS Counter ONU |
| 86 | [Documentation] This keyword sets wrong MDS counter for onu device. |
| 87 | [Arguments] ${namespace} ${bbsim_pod_name} ${onu} |
| 88 | ${result} ${rc}= Exec Pod And Return Output And RC ${namespace} ${bbsim_pod_name} |
| 89 | ... bbsimctl onu invalidate_mds ${onu} |
| 90 | Should Be Equal as Integers ${rc} 0 |
| 91 | Should Contain ${result} MDS counter of ONU msg=Can not invalidate MDS counter ${onu} values=False |
| 92 | Should Contain ${result} , set to msg=Can not invalidate MDS counter ${onu} values=False |
| 93 | |
Hardik Windlass | 513afd1 | 2021-02-03 15:19:46 +0000 | [diff] [blame] | 94 | Get ONUs List |
| 95 | [Documentation] Fetches ONUs via BBSimctl |
| 96 | [Arguments] ${namespace} ${bbsim_pod_name} |
| 97 | ${onus} ${rc}= Exec Pod And Return Output And RC ${namespace} ${bbsim_pod_name} |
Hardik Windlass | cdf827a | 2021-06-23 05:06:31 +0000 | [diff] [blame] | 98 | ... bbsimctl onu list | awk 'NR>1 {print $3}' |
Hardik Windlass | 513afd1 | 2021-02-03 15:19:46 +0000 | [diff] [blame] | 99 | @{onuList}= Split To Lines ${onus} |
| 100 | Should Be Equal as Integers ${rc} 0 |
| 101 | [Return] ${onuList} |
Hardik Windlass | c082c42 | 2021-03-16 15:44:10 +0000 | [diff] [blame] | 102 | |
| 103 | Restart Grpc Server |
| 104 | [Documentation] Restart Grpc Server on a BBSim OLT |
| 105 | [Arguments] ${namespace} ${bbsim_pod_name} ${delay} |
| 106 | ${res} ${rc}= Exec Pod And Return Output And RC ${namespace} ${bbsim_pod_name} |
| 107 | ... bbsimctl olt restartServer ${delay} |
| 108 | Log ${res} |
| 109 | Should Be Equal as Integers ${rc} 0 |
Hardik Windlass | c310c7c | 2021-03-25 13:16:59 +0000 | [diff] [blame] | 110 | |
| 111 | Verify ONU Device Image On BBSim |
| 112 | [Documentation] Validates the state of ONU in case of Image Upgrade |
| 113 | [Arguments] ${namespace} ${bbsim_pod_name} ${onu} ${internal_state} |
| 114 | ${res} ${rc}= Exec Pod And Return Output And RC ${namespace} ${bbsim_pod_name} |
Hardik Windlass | cdf827a | 2021-06-23 05:06:31 +0000 | [diff] [blame] | 115 | ... bbsimctl onu list | grep ${onu} | awk '{print $5}' |
Hardik Windlass | c310c7c | 2021-03-25 13:16:59 +0000 | [diff] [blame] | 116 | Should Be Equal as Integers ${rc} 0 |
| 117 | Should Be Equal ${res} ${internal_state} |
TorstenThieme | f3e492c | 2021-11-08 15:25:48 +0000 | [diff] [blame] | 118 | |
| 119 | Get Images Count |
| 120 | [Documentation] Validates the state of ONU in case of Image Upgrade |
| 121 | [Arguments] ${webserver_port}=50074 |
| 122 | ${rc} ${output}= Run and Return Rc and Output curl localhost:${webserver_port}/images-count 2>/dev/null |
| 123 | Should Be Equal as Integers ${rc} 0 Could not access images-count of bbsim |
| 124 | ${value}= Fetch From Right ${output} : |
| 125 | ${count}= Fetch From Left ${value} } |
| 126 | [Return] ${count} |
TorstenThieme | b56633f | 2022-07-06 09:41:04 +0000 | [diff] [blame] | 127 | |
| 128 | Restart And Check BBSIM |
| 129 | [Documentation] This keyword restarts bbsim and waits for it to come up again |
| 130 | ... Following steps will be executed: |
| 131 | ... - restart bbsim adaptor |
| 132 | ... - check bbsim adaptor is ready again |
| 133 | [Arguments] ${namespace} |
| 134 | ${bbsim_apps} Create List bbsim |
| 135 | ${label_key} Set Variable app |
| 136 | ${bbsim_label_value} Set Variable bbsim |
| 137 | Restart Pod By Label ${namespace} ${label_key} ${bbsim_label_value} |
| 138 | Sleep 5s |
| 139 | Wait For Pods Ready ${namespace} ${bbsim_apps} |
| 140 | |
| 141 | Get BBSIM Svc and Webserver Port |
| 142 | [Documentation] This keyword gets bbsim instance and bbsim webserver port from image url |
| 143 | @{words}= Split String ${image_url} / |
| 144 | ${SvcAndPort} Set Variable @{words}[2] |
| 145 | ${bbsim_svc} ${webserver_port}= Split String ${SvcAndPort} : 1 |
| 146 | ${svc_return} Set Variable If '${bbsim_svc}'!='${EMPTY}' ${bbsim_svc} ${BBSIM_INSTANCE} |
| 147 | ${port_return} Set Variable If '${webserver_port}'!='${EMPTY}' ${webserver_port} ${BBSIM_WEBSERVER_PORT} |
| 148 | [Return] ${svc_return} ${port_return} |
| 149 | |
| 150 | # keywords regarding OMCC message version |
| 151 | |
| 152 | Get BBSIM OMCC Version |
| 153 | [Documentation] Retrieves OMCC Version from BBSIM |
| 154 | [Arguments] ${namespace} ${instance}=0 |
| 155 | ${rc} ${exec_pod_name}= Run and Return Rc and Output |
| 156 | ... kubectl get pods -n ${namespace} | grep bbsim${instance} | awk 'NR==1{print $1}' |
| 157 | Log ${exec_pod_name} |
| 158 | Should Not Be Empty ${exec_pod_name} Unable to parse pod name |
| 159 | ${rc} ${output}= Run and Return Rc and Output |
| 160 | ... kubectl -n ${namespace} get pods ${exec_pod_name} -o=jsonpath="{.spec.containers[].command}" |
| 161 | Log ${output} |
| 162 | Should Be Equal as Integers ${rc} 0 |
| 163 | Should Not Be Empty ${output} Unable to read OMCC Version |
| 164 | ${output}= Remove String ${output} " [ ] |
TorstenThieme | e7b10bd | 2022-07-08 08:32:10 +0000 | [diff] [blame] | 165 | ${is_comma_separated}= Evaluate "," in """${output}""" |
| 166 | @{commands}= Run Keyword If ${is_comma_separated} Split String ${output} , |
| 167 | ... ELSE Split String ${output} |
TorstenThieme | b56633f | 2022-07-06 09:41:04 +0000 | [diff] [blame] | 168 | ${length}= Get Length ${commands} |
| 169 | ${match}= Set Variable False |
| 170 | FOR ${I} IN RANGE 0 ${length} |
| 171 | ${item}= Get From List ${commands} ${I} |
| 172 | ${match}= Set Variable If "${item}"=="-omccVersion" True ${match} |
| 173 | ${omcc_version}= Run Keyword If ${match} Get From List ${commands} ${I+1} |
| 174 | Exit For Loop IF ${match} |
| 175 | END |
| 176 | Should Be True ${match} Unable to read OMCC Version |
| 177 | ${is_extended}= Is OMCC Extended Version ${omcc_version} |
| 178 | [return] ${omcc_version} ${is_extended} |
| 179 | |
| 180 | Is OMCC Extended Version |
| 181 | [Documentation] Checks passed value and return False (baseline) or True (extended) |
| 182 | ... baseline: 124-130, 160-163 |
| 183 | ... extended: 150, 176-180 |
| 184 | [Arguments] ${omcc_version} |
| 185 | ${is_extended}= Set Variable If '${omcc_version}'=='150' True |
| 186 | ... '${omcc_version}'>='176' and '${omcc_version}'<='180' True |
| 187 | ... False |
| 188 | [return] ${is_extended} |
| 189 | |
| 190 | # Keywords regarding restart BBSIM by Helm Charts |
| 191 | |
| 192 | Restart BBSIM by Helm Charts |
| 193 | [Documentation] Restart BBSIM by helm charts |
| 194 | ... Attention: config-yaml file has to pass by ${extra_helm_flags}! |
| 195 | [Arguments] ${namespace} ${instance}=0 ${extra_helm_flags}=${EMPTY} |
| 196 | Remove BBSIM Helm Charts ${namespace} ${instance} |
| 197 | Restart BBSIM Helm Charts ${namespace} ${instance} extra_helm_flags=${extra_helm_flags} |
| 198 | Restart Port Forward BBSIM ${namespace} ${instance} |
| 199 | |
| 200 | Remove BBSIM Helm Charts |
| 201 | [Documentation] Remove BBSIM helm charts |
| 202 | [Arguments] ${namespace} ${instance}=0 |
| 203 | ${cmd} Catenate helm delete -n '${namespace}' 'bbsim${instance}' |
| 204 | ${rc} Run And Return Rc ${cmd} |
| 205 | Should Be Equal as Integers ${rc} 0 |
| 206 | ${list} Create List bbsim${instance} |
| 207 | Wait For Pods Not Exist ${namespace} ${list} |
| 208 | |
| 209 | Restart BBSIM Helm Charts |
| 210 | [Documentation] Restart BBSIM helm charts |
| 211 | ... Attention: config-yaml file has to pass by ${extra_helm_flags}! |
| 212 | [Arguments] ${namespace} ${instance}=0 ${extra_helm_flags}=${EMPTY} |
| 213 | ${cmd} Catenate |
| 214 | ... helm upgrade --install -n ${namespace} bbsim${instance} onf/bbsim |
| 215 | ... --set olt_id=1${instance} |
| 216 | ... --set global.image_pullPolicy=Always |
| 217 | ... --set global.image_tag=master |
| 218 | ... --set global.image_org=voltha/ |
| 219 | ... --set global.image_registry= |
| 220 | ... --set global.log_level=${helmloglevel} ${extra_helm_flags} |
| 221 | ${rc} Run And Return Rc ${cmd} |
| 222 | Should Be Equal as Integers ${rc} 0 |
| 223 | ${list} Create List bbsim |
| 224 | Wait For Pods Ready ${namespace} ${list} |
| 225 | |
| 226 | Restart Port Forward BBSIM |
| 227 | [Documentation] Restart Port forward BBSIM |
| 228 | [Arguments] ${namespace} ${instance}=0 |
| 229 | ${tag} Catenate bbsim${instance} |
| 230 | Restart VOLTHA Port Forward ${tag} |