Joey Armstrong | 9fadcbe | 2024-01-17 19:00:37 -0500 | [diff] [blame] | 1 | # Copyright 2017-2024 Open Networking Foundation (ONF) and the ONF Contributors |
David Bainbridge | 117d23e | 2019-09-30 20:37:51 +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. |
David Bainbridge | 117d23e | 2019-09-30 20:37:51 +0000 | [diff] [blame] | 14 | # voltctl common functions |
| 15 | |
| 16 | *** Settings *** |
| 17 | Documentation Library for various utilities |
| 18 | Library SSHLibrary |
David Bainbridge | 117d23e | 2019-09-30 20:37:51 +0000 | [diff] [blame] | 19 | Library String |
| 20 | Library DateTime |
| 21 | Library Process |
| 22 | Library Collections |
| 23 | Library RequestsLibrary |
| 24 | Library OperatingSystem |
| 25 | |
| 26 | *** Keywords *** |
| 27 | Lookup Service IP |
| 28 | [Arguments] ${namespace} ${name} |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 29 | [Documentation] Uses kubectl to resolve a service name to an IP |
Gilles Depatie | 675a206 | 2019-10-22 12:44:42 -0400 | [diff] [blame] | 30 | ${rc} ${ip}= Run and Return Rc and Output |
| 31 | ... kubectl get svc -n ${namespace} ${name} -o jsonpath={.spec.clusterIP} |
David Bainbridge | 117d23e | 2019-09-30 20:37:51 +0000 | [diff] [blame] | 32 | Should Be Equal as Integers ${rc} 0 |
| 33 | [Return] ${ip} |
| 34 | |
| 35 | Lookup Service PORT |
| 36 | [Arguments] ${namespace} ${name} |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 37 | [Documentation] Uses kubectl to resolve a service name to an PORT |
Gilles Depatie | 675a206 | 2019-10-22 12:44:42 -0400 | [diff] [blame] | 38 | ${rc} ${port}= Run and Return Rc and Output |
| 39 | ... kubectl get svc -n ${namespace} ${name} -o jsonpath={.spec.ports[0].port} |
David Bainbridge | 117d23e | 2019-09-30 20:37:51 +0000 | [diff] [blame] | 40 | Should Be Equal as Integers ${rc} 0 |
| 41 | [Return] ${port} |
suraj gour | d64356b | 2019-11-07 13:26:20 +0000 | [diff] [blame] | 42 | |
Matteo Scandolo | 6f24ea9 | 2021-04-29 11:55:50 -0700 | [diff] [blame] | 43 | Restart Pod By Label |
| 44 | [Arguments] ${namespace} ${label_key} ${label_value} |
TorstenThieme | 3716540 | 2021-09-03 11:39:40 +0000 | [diff] [blame] | 45 | [Documentation] Uses kubectl to force delete pod(s) |
Matteo Scandolo | 6f24ea9 | 2021-04-29 11:55:50 -0700 | [diff] [blame] | 46 | ${rc} ${restart_pod_name}= Run and Return Rc and Output |
| 47 | ... kubectl get pods -n ${namespace} -l ${label_key}=${label_value} --no-headers | awk '{print $1}' |
| 48 | Log ${restart_pod_name} |
| 49 | Should Not Be Empty ${restart_pod_name} Unable to parse pod name |
TorstenThieme | 3716540 | 2021-09-03 11:39:40 +0000 | [diff] [blame] | 50 | @{pods}= Split String ${restart_pod_name} separator=${\n} |
| 51 | FOR ${pod_name} IN @{pods} |
| 52 | ${rc} ${output}= Run and Return Rc and Output |
| 53 | ... kubectl delete pod ${pod_name} -n ${namespace} --grace-period=0 --force |
| 54 | Log ${output} |
| 55 | END |
Matteo Scandolo | 6f24ea9 | 2021-04-29 11:55:50 -0700 | [diff] [blame] | 56 | |
Scott Baker | 60e570d | 2020-02-02 22:10:13 -0800 | [diff] [blame] | 57 | Exec Pod |
| 58 | [Arguments] ${namespace} ${name} ${command} |
| 59 | [Documentation] Uses kubectl to execute a command in the pod and return the output |
| 60 | ${rc} ${exec_pod_name}= Run and Return Rc and Output |
Andrea Campanella | 1b25ac5 | 2020-09-09 14:34:31 +0200 | [diff] [blame] | 61 | ... kubectl -n ${namespace} get pods -l app=${name} -o name |
Scott Baker | 60e570d | 2020-02-02 22:10:13 -0800 | [diff] [blame] | 62 | Log ${exec_pod_name} |
| 63 | Should Not Be Empty ${exec_pod_name} Unable to parse pod name |
| 64 | ${rc} ${output}= Run and Return Rc and Output |
| 65 | ... kubectl exec -i ${exec_pod_name} -n ${namespace} -- ${command} |
| 66 | Log ${output} |
| 67 | [return] ${output} |
| 68 | |
Holger Hildebrandt | 2314774 | 2020-11-16 10:13:21 +0000 | [diff] [blame] | 69 | Exec Pod In Kube |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 70 | [Arguments] ${namespace} ${name} ${command} ${grep}=${EMPTY} |
Holger Hildebrandt | 2314774 | 2020-11-16 10:13:21 +0000 | [diff] [blame] | 71 | [Documentation] Uses kubectl to execute a command in the pod and return the output |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 72 | ${rc} ${exec_pod_name}= Run Keyword If '${grep}'=='${EMPTY}' |
Hardik Windlass | 801eaa0 | 2021-10-27 13:22:10 +0000 | [diff] [blame] | 73 | ... Run and Return Rc and Output |
| 74 | ... kubectl -n ${namespace} get pods -l app.kubernetes.io/name=${name} -o name | awk 'NR==1{print $1}' |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 75 | ... ELSE Run and Return Rc and Output |
| 76 | ... kubectl -n ${namespace} get pods -l app.kubernetes.io/name=${name} -o name \| grep ${grep} |
Hardik Windlass | ec86c23 | 2021-02-02 13:56:12 +0000 | [diff] [blame] | 77 | Log ${exec_pod_name} |
| 78 | Should Not Be Empty ${exec_pod_name} Unable to parse pod name |
| 79 | ${rc} ${output}= Run and Return Rc and Output |
| 80 | ... kubectl exec -i ${exec_pod_name} -n ${namespace} -- ${command} |
| 81 | Log ${output} |
| 82 | [return] ${output} |
Matteo Scandolo | a80b473 | 2020-09-04 13:51:10 -0700 | [diff] [blame] | 83 | |
| 84 | Exec Pod And Return Output And RC |
| 85 | [Arguments] ${namespace} ${name} ${command} |
| 86 | [Documentation] Uses kubectl to execute a command in the pod and return the output |
| 87 | ${rc} ${exec_pod_name}= Run and Return Rc and Output |
| 88 | ... kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}' |
Holger Hildebrandt | 2314774 | 2020-11-16 10:13:21 +0000 | [diff] [blame] | 89 | Log ${exec_pod_name} |
| 90 | Should Not Be Empty ${exec_pod_name} Unable to parse pod name |
| 91 | ${rc} ${output}= Run and Return Rc and Output |
| 92 | ... kubectl exec -i ${exec_pod_name} -n ${namespace} -- ${command} |
| 93 | Log ${output} |
Matteo Scandolo | a80b473 | 2020-09-04 13:51:10 -0700 | [diff] [blame] | 94 | [return] ${output} ${rc} |
Holger Hildebrandt | 2314774 | 2020-11-16 10:13:21 +0000 | [diff] [blame] | 95 | |
Scott Baker | 60e570d | 2020-02-02 22:10:13 -0800 | [diff] [blame] | 96 | Exec Pod Separate Stderr |
| 97 | [Arguments] ${namespace} ${name} ${command} |
| 98 | [Documentation] Uses kubectl to execute a command in the pod and return the stderr and stdout |
| 99 | ${rc} ${exec_pod_name}= Run and Return Rc and Output |
Andrea Campanella | 1b25ac5 | 2020-09-09 14:34:31 +0200 | [diff] [blame] | 100 | ... kubectl -n ${namespace} get pods -l app=${name} -o name |
Scott Baker | 60e570d | 2020-02-02 22:10:13 -0800 | [diff] [blame] | 101 | Log ${exec_pod_name} |
| 102 | Should Not Be Empty ${exec_pod_name} Unable to parse pod name |
| 103 | @{args}= Split String ${command} |
| 104 | ${result}= Run Process |
| 105 | ... kubectl exec -i ${exec_pod_name} -n ${namespace} -- @{args} |
| 106 | ${stdout}= Set Variable ${result.stdout} |
| 107 | ${stderr}= Set Variable ${result.stderr} |
| 108 | Log ${stdout} |
| 109 | Log ${stderr} |
| 110 | [return] ${stdout} ${stderr} |
| 111 | |
Scott Baker | 0478bab | 2020-04-10 17:19:57 -0700 | [diff] [blame] | 112 | Copy File To Pod |
Andrea Campanella | 0aa21d6 | 2021-07-22 10:44:32 +0200 | [diff] [blame] | 113 | [Arguments] ${namespace} ${label} ${src} ${dest} |
Scott Baker | 0478bab | 2020-04-10 17:19:57 -0700 | [diff] [blame] | 114 | [Documentation] Uses kubectl to copy a file to a pod |
| 115 | ${rc} ${exec_pod_name}= Run and Return Rc and Output |
Andrea Campanella | 0aa21d6 | 2021-07-22 10:44:32 +0200 | [diff] [blame] | 116 | ... kubectl get pods -n ${namespace} -l ${label} --no-headers | awk 'NR==1{print $1}' |
Scott Baker | 0478bab | 2020-04-10 17:19:57 -0700 | [diff] [blame] | 117 | Log ${exec_pod_name} |
| 118 | Should Not Be Empty ${exec_pod_name} Unable to parse pod name |
| 119 | ${rc} ${output}= Run and Return Rc and Output |
| 120 | ... kubectl cp -n ${namespace} ${src} ${exec_pod_name}:${dest} |
| 121 | Log ${output} |
| 122 | [return] ${output} |
| 123 | |
Andrea Speranza | 8b6f46f | 2022-08-23 14:22:15 +0200 | [diff] [blame] | 124 | Copy File From Pod |
| 125 | [Arguments] ${namespace} ${label} ${src} ${dest} |
| 126 | [Documentation] Uses kubectl to copy a file from a pod |
| 127 | ${rc} ${exec_pod_name}= Run and Return Rc and Output |
| 128 | ... kubectl get pods -n ${namespace} -l ${label} --no-headers | awk 'NR==1{print $1}' |
| 129 | Log ${exec_pod_name} |
| 130 | Should Not Be Empty ${exec_pod_name} Unable to parse pod name |
| 131 | ${rc} ${output}= Run and Return Rc and Output |
| 132 | ... kubectl cp -n ${namespace} ${exec_pod_name}:${src} ${dest} |
| 133 | Log ${output} |
| 134 | [return] ${output} |
| 135 | |
Scott Baker | 60e570d | 2020-02-02 22:10:13 -0800 | [diff] [blame] | 136 | Apply Kubernetes Resources |
| 137 | [Arguments] ${resource_yaml} ${namespace} |
| 138 | [Documentation] Use kubectl to create resources given a yaml file |
| 139 | ${rc} Run and Return Rc |
| 140 | ... kubectl apply -n ${namespace} -f ${resource_yaml} |
| 141 | Should Be Equal as Integers ${rc} 0 |
| 142 | |
Scott Baker | 0478bab | 2020-04-10 17:19:57 -0700 | [diff] [blame] | 143 | Delete Kubernetes Resources |
| 144 | [Arguments] ${resource_yaml} ${namespace} |
| 145 | [Documentation] Use kubectl to delete resources given a yaml file |
| 146 | ${rc} Run and Return Rc |
| 147 | ... kubectl delete -n ${namespace} -f ${resource_yaml} |
| 148 | Should Be Equal as Integers ${rc} 0 |
| 149 | |
suraj gour | 1ecfae9 | 2019-12-20 15:11:40 +0000 | [diff] [blame] | 150 | Validate Pod Status |
| 151 | [Arguments] ${pod_name} ${namespace} ${expectedStatus} |
| 152 | [Documentation] To run the kubectl command and check the status of the given pod matches the expected status |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 153 | ${length}= Run kubectl get pod -n ${namespace} -o name | wc -l |
| 154 | ${matched}= Set Variable False |
| 155 | FOR ${index} IN RANGE ${length} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 156 | ${currentPodName}= Run |
| 157 | ... kubectl get pod -n ${namespace} -o=jsonpath="{.items[${index}].status.containerStatuses[0].name}" |
suraj gour | 1ecfae9 | 2019-12-20 15:11:40 +0000 | [diff] [blame] | 158 | Log Required Pod : ${pod_name} |
| 159 | Log Current Pod: ${currentPodName} |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 160 | ${matched}= Set Variable If '${currentPodName}'=='${pod_name}' True False |
| 161 | Exit For Loop If ${matched} |
suraj gour | 1ecfae9 | 2019-12-20 15:11:40 +0000 | [diff] [blame] | 162 | END |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 163 | Should Be True ${matched} No pod ${podname} found |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 164 | ${currentStatusofPod}= Run |
| 165 | ... kubectl get pod -n ${namespace} -o=jsonpath="{.items[${index}].status.phase}" |
suraj gour | 1ecfae9 | 2019-12-20 15:11:40 +0000 | [diff] [blame] | 166 | Log ${currentStatusofPod} |
| 167 | Should Contain ${currentStatusofPod} ${expectedStatus} |
| 168 | |
Matteo Scandolo | a80b473 | 2020-09-04 13:51:10 -0700 | [diff] [blame] | 169 | Get Pod Name By Label |
| 170 | [Arguments] ${namespace} ${label_key} ${label_value} |
| 171 | [Documentation] Return a pod name from a given label |
| 172 | ${rc} ${pod_name}= Run and Return Rc and Output |
| 173 | ... kubectl get pods -n ${namespace} -l ${label_key}=${label_value} --no-headers | awk '{print $1}' |
| 174 | Should Not Be Empty ${pod_name} Pod not found |
| 175 | [return] ${pod_name} |
| 176 | |
Hung-Wei Chiu | 2bee4d4 | 2020-04-24 11:31:50 -0700 | [diff] [blame] | 177 | Validate Pods Status By Label |
| 178 | [Arguments] ${namespace} ${label_key} ${label_value} ${expectedStatus} |
| 179 | [Documentation] To run the kubectl command and check the status of all pods filter |
| 180 | ... by label matche the expected status |
| 181 | ${command}= Catenate |
| 182 | ... kubectl -n ${namespace} get pods -l ${label_key}=${label_value} |
| 183 | ... -o=jsonpath="{.items[?(.status.phase=='${expectedStatus}')].status.phase}" |
| 184 | ${pods_status}= Run ${command} |
| 185 | Should Not Be Equal ${pods_status} ${EMPTY} Can't filter out Pods with exptected status ${expectedStatus} |
| 186 | |
Andrea Campanella | 4c40463 | 2020-08-26 14:41:36 +0200 | [diff] [blame] | 187 | Validate Pods Status By Name |
| 188 | [Arguments] ${namespace} ${name} ${expectedStatus} |
| 189 | [Documentation] To run the kubectl command and check the status of all pods filter |
| 190 | ... by label matche the expected status |
| 191 | ${command}= Catenate |
| 192 | ... kubectl -n ${namespace} get pods ${name} |
| 193 | ... -o=jsonpath="{.status.phase}" |
| 194 | ${pods_status}= Run ${command} |
| 195 | Should Not Be Equal ${pods_status} ${EMPTY} Can't filter out Pods with exptected status ${expectedStatus} |
| 196 | |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 197 | Verify All Voltha Pods For Any Error Logs |
Matteo Scandolo | 6b52412 | 2021-10-22 14:34:29 -0700 | [diff] [blame] | 198 | [Arguments] ${datetime} ${namespace} |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 199 | [Documentation] This keyword checks for the error occurence in the voltha pods |
| 200 | &{errorPodDict} Create Dictionary |
Matteo Scandolo | 142e627 | 2020-04-29 17:36:59 -0700 | [diff] [blame] | 201 | &{containerDict} Get Container Dictionary voltha |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 202 | FOR ${podName} IN @{PODLIST1} |
| 203 | ${containerName} Get From Dictionary ${containerDict} ${podName} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 204 | ${rc} ${logOutput} Run And Return Rc And Output |
Matteo Scandolo | 6b52412 | 2021-10-22 14:34:29 -0700 | [diff] [blame] | 205 | ... kubectl logs --timestamps -n ${namespace} --since-time=${datetime} ${containerName} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 206 | Run Keyword And Ignore Error |
| 207 | ... Run Keyword If '${logOutput}'=='${EMPTY}' |
| 208 | ... Run Keywords Log No Log found in pod ${podName} |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 209 | ... AND Continue For Loop |
| 210 | ${errorDict} Check For Error Logs in Pod Type1 Given the Log Output ${logOutput} |
| 211 | ${returnStatusFlagList} Get Dictionary Keys ${errorDict} |
| 212 | ${returnStatusFlag} Get From List ${returnStatusFlagList} 0 |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 213 | Run Keyword And Ignore Error |
| 214 | ... Run Keyword If '${returnStatusFlag}'=='Nologfound' |
| 215 | ... Run Keywords Log No Error Log found in pod ${podName} |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 216 | ... AND Continue For Loop |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 217 | Run Keyword And Ignore Error |
| 218 | ... Run Keyword If '${returnStatusFlag}'=='UnexpectedErrorfound' |
| 219 | ... Run Keywords Log Unexpected Error Log found in pod ${podName} |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 220 | ... AND Set to Dictionary ${errorPodDict} ${podName} ${errorDict} |
| 221 | END |
| 222 | FOR ${podName} IN @{PODLIST2} |
| 223 | ${containerName} Get From Dictionary ${containerDict} ${podName} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 224 | ${rc} ${logOutput} Run And Return Rc And Output |
Matteo Scandolo | 6b52412 | 2021-10-22 14:34:29 -0700 | [diff] [blame] | 225 | ... kubectl logs --timestamps -n ${namespace} --since-time=${datetime} ${containerName} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 226 | Run Keyword And Ignore Error |
| 227 | ... Run Keyword If '${logOutput}'=='${EMPTY}' |
| 228 | ... Run Keywords Log No Log found in pod ${podName} |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 229 | ... AND Continue For Loop |
| 230 | ${errorDict} Check For Error Logs in Pod Type2 Given the Log Output ${logOutput} |
| 231 | ${returnStatusFlagList} Get Dictionary Keys ${errorDict} |
| 232 | ${returnStatusFlag} Get From List ${returnStatusFlagList} 0 |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 233 | Run Keyword And Ignore Error |
| 234 | ... Run Keyword If '${returnStatusFlag}'=='Nologfound' |
| 235 | ... Run Keywords Log No Error Log found in pod ${podName} |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 236 | ... AND Continue For Loop |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 237 | Run Keyword And Ignore Error |
| 238 | ... Run Keyword If '${returnStatusFlag}'=='UnexpectedErrorfound' |
| 239 | ... Run Keywords Log Unexpected Error Log found in pod ${podName} |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 240 | ... AND Set to Dictionary ${errorPodDict} ${podName} ${errorDict} |
| 241 | END |
| 242 | Print to Console Error Statement logged in the following pods : ${errorPodDict} |
| 243 | [Return] ${errorPodDict} |
| 244 | |
| 245 | Check For Error Logs in Pod Type1 Given the Log Output |
| 246 | [Arguments] ${logOutput} ${logLevel}=error ${errorMessage}=${EMPTY} |
| 247 | [Documentation] Checks for error message in the particular list of pods |
| 248 | Log ${logOutput} |
| 249 | ${linesContainingLog} = Get Lines Matching Regexp ${logOutput} .*\s\${logLevel}.* partial_match=true |
| 250 | ${is_exec_status} ${output} Run Keyword And Ignore Error Should Be Empty ${linesContainingLog} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 251 | ${returnStatusFlag} Set Variable If '${is_exec_status}'=='PASS' |
| 252 | ... Nologfound '${is_exec_status}'=='FAIL' Errorlogfound |
| 253 | ${linesContainingError} = Get Lines Matching Regexp |
| 254 | ... ${logOutput} .*\s\${logLevel}.*${errorMessage} partial_match=true |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 255 | ${is_exec_status} ${output} Run Keyword And Ignore Error Should Be Empty ${linesContainingError} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 256 | ${returnStatusFlag} Set Variable If '${is_exec_status}'=='PASS' |
| 257 | ... UnexpectedErrorfound '${is_exec_status}'=='FAIL' MatchingErrorlogfound |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 258 | Log {linesContainingError} |
| 259 | &{errorDict} Create Dictionary ${returnStatusFlag} ${linesContainingLog} |
| 260 | [Return] ${errorDict} |
| 261 | |
| 262 | Check For Error Logs in Pod Type2 Given the Log Output |
| 263 | [Arguments] ${logOutput} ${logLevel}=warn ${errorMessage}=${EMPTY} |
| 264 | [Documentation] Checks for error message in the particular set of pods |
| 265 | Log ${logOutput} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 266 | ${linesContainingLog} = Get Lines Matching Regexp |
| 267 | ... ${logOutput} .*?\s.*level.*${logLevel}.* partial_match=true |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 268 | ${is_exec_status} ${output} Run Keyword And Ignore Error Should Be Empty ${linesContainingLog} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 269 | ${returnStatusFlag} Set Variable If '${is_exec_status}'=='PASS' |
| 270 | ... Nologfound '${is_exec_status}'=='FAIL' Errorlogfound |
| 271 | ${linesContainingError} = Get Lines Matching Regexp |
| 272 | ... ${logOutput} .*?\s.*level.*${logLevel}.*msg.*${errorMessage} partial_match=true |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 273 | ${is_exec_status} ${output} Run Keyword And Ignore Error Should Be Empty ${linesContainingError} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 274 | ${returnStatusFlag} Set Variable If '${is_exec_status}'=='PASS' |
| 275 | ... UnexpectedErrorfound '${is_exec_status}'=='FAIL' MatchingErrorlogfound |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 276 | Log {linesContainingError} |
| 277 | &{errorDict} Create Dictionary ${returnStatusFlag} ${linesContainingLog} |
| 278 | [Return] ${errorDict} |
| 279 | |
| 280 | Get Container Dictionary |
Matteo Scandolo | 142e627 | 2020-04-29 17:36:59 -0700 | [diff] [blame] | 281 | [Arguments] ${namespace} |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 282 | [Documentation] Creates a mapping for pod name and container name and returns the same |
| 283 | &{containerDict} Create Dictionary |
| 284 | ${containerName} Set Variable ${EMPTY} |
Matteo Scandolo | 142e627 | 2020-04-29 17:36:59 -0700 | [diff] [blame] | 285 | ${podName} Run kubectl get deployment -n ${namespace} | awk 'NR>1 {print $1}' |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 286 | @{podNameList}= Split To Lines ${podName} |
| 287 | Append To List ${podNameList} voltha-etcd-cluster voltha-kafka voltha-ro-core voltha-zookeeper |
| 288 | Log ${podNameList} |
| 289 | #Creatiing dictionary to correspond pod name and container name |
| 290 | FOR ${pod} IN @{podNameList} |
Matteo Scandolo | 142e627 | 2020-04-29 17:36:59 -0700 | [diff] [blame] | 291 | ${containerName} Run kubectl get pod -n ${namespace} | grep ${pod} | awk '{print $1}' |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 292 | &{containerDict} Set To Dictionary ${containerDict} ${pod} ${containerName} |
| 293 | END |
| 294 | Log ${containerDict} |
| 295 | [Return] ${containerDict} |
| 296 | |
| 297 | Validate Error For Given Pods |
Matteo Scandolo | 6b52412 | 2021-10-22 14:34:29 -0700 | [diff] [blame] | 298 | [Arguments] ${datetime} ${podDict} ${namespace} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 299 | [Documentation] |
| 300 | ... This keyword is used to get the list of pods if there is any unexpected error |
| 301 | ... in a particular pod(s) given the time-${datetime} from which the log needs to |
| 302 | ... be analysed and the dictionary of pods and the error in the dictionary format |
| 303 | ... ${podDict] . |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 304 | ... |
Matteo Scandolo | 6b52412 | 2021-10-22 14:34:29 -0700 | [diff] [blame] | 305 | ... Usage: ${returnStatusFlag} Validate Error For Given Pods ${datetime} ${podDict} ${namespace} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 306 | ... |
| 307 | ... Arguments: |
| 308 | ... |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 309 | ... ${datetime} = time from which the log needs to be taken |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 310 | ... ${podDict} = Key-value pair of the pod name and the error msg |
Matteo Scandolo | 6b52412 | 2021-10-22 14:34:29 -0700 | [diff] [blame] | 311 | ... ${namespace} = the namespace into which look for pods |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 312 | ... |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 313 | ... Example: ${podDict} = Set Dictionary ${podDict} radius sample error message. |
| 314 | ... |
| 315 | ... In case the radius pod log has any other error than the expected |
| 316 | ... error, then the podname will be returned |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 317 | ${podList} = Get Dictionary Keys ${podDict} |
| 318 | FOR ${podName} IN @{podList} |
| 319 | ${containerName} Get From Dictionary ${containerDict} ${podName} |
| 320 | ${expectedError} Get From Dictionary ${podDict} ${podName} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 321 | ${rc} ${logOutput} Run And Return Rc And Output |
Matteo Scandolo | 6b52412 | 2021-10-22 14:34:29 -0700 | [diff] [blame] | 322 | ... kubectl logs --timestamps -n ${namespace} --since-time=${datetime} ${containerName} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 323 | Run Keyword And Ignore Error |
| 324 | ... Run Keyword If '${logOutput}'=='${EMPTY}' |
| 325 | ... Run Keywords Log No Log found in pod ${podName} |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 326 | ... AND Continue For Loop |
| 327 | ${returnStatusFlag} Check For Error Logs in Pod Type1 Given the Log Output ${logOutput} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 328 | Run Keyword And Ignore Error |
| 329 | ... Run Keyword If '${returnStatusFlag}'=='Nologfound' |
| 330 | ... Run Keywords Log No Error Log found in pod ${podName} |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 331 | ... AND Continue For Loop |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 332 | Run Keyword And Ignore Error |
| 333 | ... Run Keyword If '${returnStatusFlag}'=='UnexpectedErrorfound' |
| 334 | ... Run Keywords Log Unexpected Error Log found in pod ${podName} |
Gayathri.Selvan | 61fbcdb | 2019-11-14 05:08:19 +0000 | [diff] [blame] | 335 | ... AND Append To List ${errorPodList} ${podName} |
| 336 | END |
| 337 | [Return] ${errorPodList} |
| 338 | |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 339 | Delete K8s Pod |
| 340 | [Arguments] ${namespace} ${name} |
| 341 | [Documentation] Uses kubectl to delete a named POD |
| 342 | ${rc} Run and Return Rc |
| 343 | ... kubectl delete -n ${namespace} pod/${name} |
| 344 | Should Be Equal as Integers ${rc} 0 |
| 345 | |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 346 | Delete K8s Pods By Label |
| 347 | [Arguments] ${namespace} ${key} ${value} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 348 | [Documentation] Uses kubectl to delete a PODs, filtering by label |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 349 | ${rc}= Run and Return Rc |
| 350 | ... kubectl -n ${namespace} delete pods -l${key}=${value} |
| 351 | Should Be Equal as Integers ${rc} 0 |
| 352 | |
Andrea Campanella | 4c40463 | 2020-08-26 14:41:36 +0200 | [diff] [blame] | 353 | Delete K8s Pods By Name |
| 354 | [Arguments] ${namespace} ${value} |
| 355 | [Documentation] Uses kubectl to delete a PODs, filtering by label |
| 356 | ${rc}= Run and Return Rc |
| 357 | ... kubectl -n ${namespace} delete pods ${value} |
| 358 | Should Be Equal as Integers ${rc} 0 |
| 359 | |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 360 | Scale K8s Deployment |
| 361 | [Arguments] ${namespace} ${name} ${count} |
| 362 | [Documentation] Uses kubectl to scale a named deployment |
| 363 | ${rc} Run and Return Rc |
| 364 | ... kubectl scale --replicas=${count} -n ${namespace} deploy/${name} |
| 365 | Should Be Equal as Integers ${rc} 0 |
| 366 | |
Andrea Campanella | 3dcce27 | 2021-01-15 16:04:47 +0100 | [diff] [blame] | 367 | Get K8s Deployment by Pod Label |
| 368 | [Arguments] ${namespace} ${key} ${value} |
| 369 | [Documentation] Uses kubectl to scale a deployment given the app name of the pod |
| 370 | ${rc} ${name} Run And Return Rc And Output |
Hardik Windlass | dd1a9a1 | 2021-02-23 15:34:50 +0000 | [diff] [blame] | 371 | ... kubectl describe rs -n ${namespace} -l ${key}=${value} | grep "Controlled By" | awk -F'/' '{print $2}' | awk 'FNR == 1' |
Andrea Campanella | 3dcce27 | 2021-01-15 16:04:47 +0100 | [diff] [blame] | 372 | Should Be Equal as Integers ${rc} 0 |
| 373 | [Return] ${name} |
| 374 | |
| 375 | Scale K8s Deployment by Pod Label |
| 376 | [Arguments] ${namespace} ${key} ${value} ${count} |
| 377 | [Documentation] Uses kubectl to scale a deployment given the app name of the pod |
| 378 | ${name} Get K8s Deployment by Pod Label ${namespace} ${key} ${value} |
| 379 | Scale K8s Deployment ${namespace} ${name} ${count} |
| 380 | |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 381 | Pod Exists |
| 382 | [Arguments] ${namespace} ${name} |
| 383 | [Documentation] Succeeds it the named POD exists |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 384 | ${rc} ${count} Run and Return Rc |
| 385 | ... kubectl get -n ${namespace} pod -o json | jq -r ".items[].metadata.name" | grep ${name} |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 386 | Should Be True ${count}>0 Pod ${name} not found |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 387 | |
| 388 | Pod Does Not Exist |
| 389 | [Arguments] ${namespace} ${name} |
| 390 | [Documentation] Succeeds if the named POD does not exist |
| 391 | ${rc} ${count} Run and Return Rc And Output |
| 392 | ... kubectl get -n ${namespace} pod -o json | jq -r ".items[].metadata.name" | grep -c ${name} |
| 393 | Should Be Equal As Integers ${count} 0 |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 394 | Should Be True ${count}==0 Pod ${name} exists but should not |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 395 | |
TorstenThieme | d2cd91d | 2020-07-28 07:13:44 +0000 | [diff] [blame] | 396 | Wait For Pods Not Exist |
| 397 | [Arguments] ${namespace} ${list_names} |
| 398 | [Documentation] Checks the passed PODs are no longer existing |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 399 | FOR ${pod_name} IN @{list_names} |
TorstenThieme | d2cd91d | 2020-07-28 07:13:44 +0000 | [diff] [blame] | 400 | Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 3s |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 401 | ... Pod Does Not Exist ${namespace} ${pod_name} |
TorstenThieme | d2cd91d | 2020-07-28 07:13:44 +0000 | [diff] [blame] | 402 | END |
| 403 | |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 404 | Pods Do Not Exist By Label |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 405 | [Arguments] ${namespace} ${key} ${value} |
| 406 | [Documentation] Succeeds if the named POD does not exist |
| 407 | ${rc} ${count} Run and Return Rc And Output |
| 408 | ... kubectl get -n ${namespace} pod -l${key}=${value} -o json | jq -r ".items[].metadata.name" | wc -l |
| 409 | Should Be Equal As Integers ${count} 0 |
Andy Bavier | b63f6d2 | 2020-03-12 15:34:37 -0700 | [diff] [blame] | 410 | Should Be True ${count}==0 Pod with label ${key}=${value} exists but should not |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 411 | |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 412 | Get Available Deployment Replicas |
| 413 | [Arguments] ${namespace} ${name} |
| 414 | [Documentation] Succeeds if the named POD exists and has a ready count > 0 |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 415 | ${rc} ${count} Run and Return Rc and Output |
| 416 | ... kubectl get -n ${namespace} deploy/${name} -o jsonpath='{.status.availableReplicas}' |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 417 | ${result}= Run Keyword If '${count}' == '' Set Variable 0 |
| 418 | ... ELSE Set Variable ${count} |
| 419 | [Return] ${result} |
| 420 | |
Andrea Campanella | 3dcce27 | 2021-01-15 16:04:47 +0100 | [diff] [blame] | 421 | Check Expected Available Deployment Replicas By Pod Label |
| 422 | [Arguments] ${namespace} ${key} ${value} ${expected} |
| 423 | [Documentation] Succeeds if the named deployment has the expected number of available replicas |
| 424 | ${name} Get K8s Deployment by Pod Label ${namespace} ${key} ${value} |
| 425 | Check Expected Available Deployment Replicas ${namespace} ${name} ${expected} |
| 426 | |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 427 | Check Expected Available Deployment Replicas |
| 428 | [Arguments] ${namespace} ${name} ${expected} |
| 429 | [Documentation] Succeeds if the named deployment has the expected number of available replicas |
| 430 | ${count}= Get Available Deployment Replicas ${namespace} ${name} |
| 431 | Should Be Equal As Integers ${expected} ${count} |
| 432 | |
| 433 | Get Deployment Replica Count |
| 434 | [Arguments] ${namespace} ${name} |
| 435 | [Documentation] Uses kubectl to fetch the number of configured replicas on a deployment |
| 436 | ${rc} ${value} Run and Return Rc and Output |
| 437 | ... kubectl -n ${namespace} get deploy/${name} -o 'jsonpath={.status.replicas}' |
| 438 | Should Be Equal as Integers ${rc} 0 |
| 439 | ${replicas}= Run Keyword If '${value}' == '' Set Variable 0 |
| 440 | ... ELSE Set Variable ${value} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 441 | [Return] ${replicas} |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 442 | |
| 443 | Does Deployment Have Replicas |
| 444 | [Arguments] ${namespace} ${name} ${expected_count} |
| 445 | [Documentation] Uses kubectl to fetch the number of configured replicas on a deployment |
| 446 | ${rc} ${value} Run and Return Rc and Output |
| 447 | ... kubectl -n ${namespace} get deploy/${name} -o 'jsonpath={.status.replicas}' |
| 448 | Should Be Equal as Integers ${rc} 0 |
| 449 | ${replicas}= Run Keyword If '${value}' == '' Set Variable 0 |
| 450 | ... ELSE Set Variable ${value} |
| 451 | Should be Equal as Integers ${replicas} ${expected_count} |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 452 | |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 453 | Pods Are Ready By Label |
hwchiu | 8569593 | 2019-12-18 08:05:25 +0000 | [diff] [blame] | 454 | [Arguments] ${namespace} ${key} ${value} |
Zack Williams | a8fe75a | 2020-01-10 14:25:27 -0700 | [diff] [blame] | 455 | [Documentation] Check that all pods with a label are ready |
TorstenThieme | 3716540 | 2021-09-03 11:39:40 +0000 | [diff] [blame] | 456 | ${pod_names}= Get Pod Name By Label ${namespace} ${key} ${value} |
| 457 | Should Not Be Empty ${pod_names} Unable to parse pod name |
| 458 | @{pods}= Split String ${pod_names} separator=${\n} |
| 459 | ${lenght}= Get Length ${pods} |
| 460 | FOR ${I} IN RANGE 0 ${lenght} |
| 461 | ${output}= Run |
| 462 | ... kubectl -n ${namespace} get pods -l ${key}=${value} -o=jsonpath="{.items[${I}].status.containerStatuses[].ready}" |
Cristina de Francisco | c4cfd7e | 2023-10-09 10:55:08 +0200 | [diff] [blame] | 463 | Should Not Contain ${output} false All pods with label ${key}=${value} are not ready |
TorstenThieme | 3716540 | 2021-09-03 11:39:40 +0000 | [diff] [blame] | 464 | END |
TorstenThieme | d2cd91d | 2020-07-28 07:13:44 +0000 | [diff] [blame] | 465 | |
| 466 | Wait For Pods Ready |
| 467 | [Arguments] ${namespace} ${list_apps} |
| 468 | [Documentation] Checks the passed PODs are ready |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 469 | FOR ${app_name} IN @{list_apps} |
TorstenThieme | d2cd91d | 2020-07-28 07:13:44 +0000 | [diff] [blame] | 470 | Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 3s |
TorstenThieme | fe7099e | 2021-01-29 08:41:04 +0000 | [diff] [blame] | 471 | ... Pods Are Ready By Label ${namespace} app ${app_name} |
TorstenThieme | d2cd91d | 2020-07-28 07:13:44 +0000 | [diff] [blame] | 472 | END |
Gayathri.Selvan | 4939896 | 2020-01-13 07:19:12 +0000 | [diff] [blame] | 473 | |
TorstenThieme | 96fe9ee | 2021-10-21 10:24:08 +0000 | [diff] [blame] | 474 | Get Pod Ready Timestamp by Label |
| 475 | [Arguments] ${namespace} ${key} ${value} |
| 476 | [Documentation] delivers timestamp of pod was ready |
| 477 | ${cmd}= Catenate kubectl -n ${namespace} get pods -l ${key}=${value} -o=json | jq -r |
| 478 | ... ".items[].status.containerStatuses[].state.running.startedAt" |
| 479 | ${output}= Run ${cmd} |
| 480 | [Return] ${output} |
| 481 | |
hwchiu | 58af72d | 2020-01-14 00:50:35 +0000 | [diff] [blame] | 482 | Check Expected Running Pods Number By Label |
| 483 | [Arguments] ${namespace} ${key} ${value} ${number} |
| 484 | [Documentation] Succeeds if the desired pod has expected number replicas |
| 485 | ${rc} ${count} Run and Return Rc and Output |
| 486 | ... kubectl -n ${namespace} get pods -l ${key}=${value} -o json | jq -r ".items[].status.phase" | wc -l |
| 487 | Should Be Equal as Integers ${count} ${number} |
Andrea Campanella | 962fe83 | 2020-09-21 10:41:47 +0200 | [diff] [blame] | 488 | |
| 489 | Get Number of Running Pods Number By Label |
| 490 | [Arguments] ${namespace} ${key} ${value} |
| 491 | [Documentation] Returns the number of pods for a given label |
| 492 | ${rc} ${count} Run and Return Rc and Output |
| 493 | ... kubectl -n ${namespace} get pods -l ${key}=${value} -o name | wc -l |
| 494 | [Return] ${count} |
Hardik Windlass | dd1a9a1 | 2021-02-23 15:34:50 +0000 | [diff] [blame] | 495 | |
| 496 | Get Pod Restart Count |
| 497 | [Arguments] ${namespace} ${name} |
| 498 | [Documentation] Returns the restart count for the given Pod |
| 499 | ${rc} ${count}= Run and Return Rc and Output |
| 500 | ... kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $4}' |
| 501 | [Return] ${count} |
| 502 | |
TorstenThieme | 96fe9ee | 2021-10-21 10:24:08 +0000 | [diff] [blame] | 503 | Get Pod Age |
| 504 | [Arguments] ${namespace} ${name} |
| 505 | [Documentation] Returns the age for the given Pod |
| 506 | ${rc} ${age}= Run and Return Rc and Output |
| 507 | ... kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $5}' |
| 508 | [Return] ${age} |
| 509 | |
Hardik Windlass | dd1a9a1 | 2021-02-23 15:34:50 +0000 | [diff] [blame] | 510 | Verify ONOS Pod Restart |
| 511 | [Arguments] ${restarted}=True |
| 512 | [Documentation] Verifies if any of the given ONOS instances restarted |
| 513 | ${num_onos}= Wait Until Keyword Succeeds 20s 5s Get Number of Running Pods Number By Label default |
| 514 | ... app onos-onos-classic |
| 515 | FOR ${I} IN RANGE 0 ${num_onos} |
| 516 | ${onos_pod}= Catenate SEPARATOR=- onos-onos-classic ${I} |
| 517 | ${count}= Get Pod Restart Count default ${onos_pod} |
| 518 | Run Keyword If ${restarted} |
| 519 | ... Should Not Be Equal As Integers ${count} 0 ONOS Pod ${onos_pod} Not Restarted |
| 520 | ... ELSE |
| 521 | ... Should Be Equal As Integers ${count} 0 ONOS Pod ${onos_pod} Restarted |
| 522 | END |
| 523 | |
| 524 | Deploy Pod New Image |
| 525 | [Arguments] ${namespace} ${deployment} ${container} ${image} |
| 526 | [Documentation] Deploys the Pod given image |
| 527 | ${rc} Run and Return Rc |
| 528 | ... kubectl -n ${namespace} set image deployment/${deployment} ${container}=${image} |
| 529 | Should Be Equal as Integers ${rc} 0 |
| 530 | |
| 531 | Verify Pod Image |
| 532 | [Arguments] ${namespace} ${key} ${value} ${image} |
| 533 | [Documentation] Verifies the Pod Image |
| 534 | ${output}= Run |
Hardik Windlass | 0845130 | 2021-03-09 12:14:36 +0000 | [diff] [blame] | 535 | ... kubectl -n ${namespace} get pods -l ${key}=${value} -o=jsonpath="{.items[*].spec.containers[*].image}" |
| 536 | Should Be Equal '${output}' '${image}' |
Hardik Windlass | dc2610f | 2021-03-09 07:33:51 +0000 | [diff] [blame] | 537 | |
| 538 | Get Pod Image And App Version And Helm Chart By Label |
| 539 | [Arguments] ${namespace} ${key} ${value} |
| 540 | [Documentation] Retrieves Pod Image and, App and Helm Chart Version details |
| 541 | ${image}= Run |
| 542 | ... kubectl -n ${namespace} get pods -l ${key}=${value} -o=jsonpath="{.items[*].spec.containers[*].image}" |
| 543 | ${cmd}= Catenate SEPARATOR= |
| 544 | ... kubectl -n ${namespace} get pods -l ${key}=${value} -o= |
| 545 | ... jsonpath="{.items[*].metadata.labels.\\app\\.kubernetes\\.io\\/version}" |
| 546 | ${app_version}= Run ${cmd} |
| 547 | ${helm_chart}= Run |
| 548 | ... kubectl -n ${namespace} get pods -l ${key}=${value} -o=jsonpath="{.items[*].metadata.labels.\\helm\\.sh\\/chart}" |
| 549 | [Return] ${image} ${app_version} ${helm_chart} |