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