[VOL-3780] Add Restart Pod By Label keyword and use it in the Restart And Check Onu Adaptor test
Change-Id: I764af63c52a46ab48fd412ca682c7190ebf7a185
diff --git a/libraries/k8s.robot b/libraries/k8s.robot
index 557158e..815cec4 100755
--- a/libraries/k8s.robot
+++ b/libraries/k8s.robot
@@ -42,7 +42,7 @@
Restart Pod
[Arguments] ${namespace} ${name}
- [Documentation] Uses kubectl to force delete pod
+ [Documentation] *DEPRECATED* Use Restart Pod By Label instead
${rc} ${restart_pod_name}= Run and Return Rc and Output
... kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}'
Log ${restart_pod_name}
@@ -51,6 +51,17 @@
... kubectl delete pod ${restart_pod_name} -n ${namespace} --grace-period=0 --force
Log ${output}
+Restart Pod By Label
+ [Arguments] ${namespace} ${label_key} ${label_value}
+ [Documentation] Uses kubectl to force delete pod
+ ${rc} ${restart_pod_name}= Run and Return Rc and Output
+ ... kubectl get pods -n ${namespace} -l ${label_key}=${label_value} --no-headers | awk '{print $1}'
+ Log ${restart_pod_name}
+ Should Not Be Empty ${restart_pod_name} Unable to parse pod name
+ ${rc} ${output}= Run and Return Rc and Output
+ ... kubectl delete pod ${restart_pod_name} -n ${namespace} --grace-period=0 --force
+ Log ${output}
+
Exec Pod
[Arguments] ${namespace} ${name} ${command}
[Documentation] Uses kubectl to execute a command in the pod and return the output