[VOL-1958]Restart pod
Change-Id: Id0fd5f8e33908009a7ba492ac0aa53c415e602f5
diff --git a/libraries/k8s.robot b/libraries/k8s.robot
index 62a5b11..1b3ac39 100644
--- a/libraries/k8s.robot
+++ b/libraries/k8s.robot
@@ -252,3 +252,19 @@
${rc} ${count} Run and Return Rc and Output
... kubectl -n ${namespace} get pods -l ${key}=${value} -o json | jq -r ".items[].status.containerStatuses[].ready" | grep -c false
Should Be Equal as Integers ${rc} 0
+
+Validate Pod Status
+ [Arguments] ${pod_name} ${namespace} ${expectedStatus}
+ [Documentation] To run the kubectl command and check the status of the given pod matches the expected status
+ ${length}= Run ${KUBECTL_CONFIG}; kubectl get pod -n ${namespace} | wc -l
+ FOR ${index} IN RANGE ${length}-1
+ ${currentPodName}= Run ${KUBECTL_CONFIG}; kubectl get pod -n ${namespace} -o jsonpath={.items[${index}].status.containerStatuses[0].name}
+ Log Required Pod : ${pod_name}
+ Log Current Pod: ${currentPodName}
+ Run Keyword and Ignore Error Run Keyword If '${currentPodName}'=='${pod_name}' Exit For Loop
+ END
+ ${currentStatusofPod}= Run ${KUBECTL_CONFIG}; kubectl get pod -n ${namespace} -o jsonpath={.items[${index}].status.phase}
+ Log ${currentStatusofPod}
+ Should Contain ${currentStatusofPod} ${expectedStatus}
+
+