path: root/openshift-storage-libs
diff options
authorArun Kumar <>2020-09-09 17:04:45 +0530
committerVaibhav Mahajan <>2020-09-28 16:50:33 +0000
commit4c8f312a8258818ed77d09a0f74aee35d1189290 (patch)
tree58f6443984160fe8f83a089797ecd476c9880308 /openshift-storage-libs
parent5c38cc25d9f302f7717d9e3fe485096cb3d2871f (diff)
[Test] Add TC to perform post deployment validations of prometheus
Change-Id: I026f2aa944aaa6b338c45c54ac4504ecb854f00c Signed-off-by: Arun Kumar <>
Diffstat (limited to 'openshift-storage-libs')
1 files changed, 25 insertions, 10 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/ b/openshift-storage-libs/openshiftstoragelibs/
index cf1e342..5f53dab 100644
--- a/openshift-storage-libs/openshiftstoragelibs/
+++ b/openshift-storage-libs/openshiftstoragelibs/
@@ -39,21 +39,24 @@ KILL_SERVICE = "kill -9 %s"
IS_ACTIVE_SERVICE = "systemctl is-active %s"
-def oc_get_pods(ocp_node, selector=None):
+def oc_get_pods(ocp_node, selector=None, name=None):
"""Gets the pods info with 'wide' option in the current project.
ocp_node (str): Node in which ocp command will be executed.
selector (str): optional option. Selector for OCP pods.
example: "glusterfs-node=pod" for filtering out only Gluster PODs.
+ name (str): name of the pod to get details.
dict : dict of pods info in the current project.
- cmd = "oc get -o wide --no-headers=true pods"
+ cmd = "oc get -o wide --no-headers=true pods "
if selector:
cmd += " --selector %s" % selector
+ if name:
+ cmd += name
out = command.cmd_run(cmd, hostname=ocp_node)
return _parse_wide_pods_output(out)
@@ -1100,13 +1103,15 @@ def wait_for_pod_be_ready(hostname, pod_name,
def wait_for_pods_be_ready(
- hostname, pod_count, selector, timeout=600, wait_step=10):
+ hostname, pod_count, selector=None, field_selector=None,
+ timeout=600, wait_step=10):
"""Wait to 'pod_count' gluster pods be in Ready state.
hostname (str): Node where we want to run our commands.
pod_count (int): No of pods to be waited for.
selector (str): Selector to select pods of given label.
+ field_selector (str): Selector to select pods.
timeout (int): Seconds to wait for Node to be Ready.
wait_step (int): Interval in seconds to wait before checking
status again.
@@ -1115,20 +1120,30 @@ def wait_for_pods_be_ready(
AssertionError: In case it fails to get pods.
ExecutionError: In case pods won't get in ready state for given time.
- if not selector:
+ if not selector and not field_selector:
raise exceptions.ExecutionError(
- "selector parameter should be provided")
+ "Either selector or field-selector parameter should be provided")
custom = (
pod_status = None
for w in waiter.Waiter(timeout, wait_step):
pod_status = oc_get_custom_resource(
- hostname, "pod", custom, selector=selector)
- if not pod_status:
- raise exceptions.ExecutionError(
- "Unable to find pod with selector %s" % selector)
+ hostname, "pod", custom, selector=selector,
+ field_selector=field_selector)
+ if not pod_status and pod_count != 0:
+ selection_text = ''
+ if selector and field_selector:
+ selection_text += 'selector {} and field-selector {}'.format(
+ selector, field_selector)
+ elif selector:
+ selection_text += 'selector {}'.format(selector)
+ else:
+ selection_text += 'field-selector {}'.format(field_selector)
+ raise exceptions.ExecutionError(
+ "Unable to find pods with mentioned {}".format(
+ selection_text))
status = [status for _, status in pod_status]
if len(status) == pod_count == status.count("True"):