diff options
author | Arun Kumar <arukumar@arukumar.remote.csb> | 2019-09-16 10:00:16 +0530 |
---|---|---|
committer | Vaibhav Mahajan <vamahaja@redhat.com> | 2019-12-26 12:25:25 +0000 |
commit | 5ae45abc159a37af04c43acf45dd4b0a21f323a2 (patch) | |
tree | 7f3f6f15060eaaa5c3b8f0f95919f405ec306aca /openshift-storage-libs/openshiftstoragelibs/openshift_ops.py | |
parent | d28b637d972aa600ed15ef437e4cb59c53e0ca5e (diff) |
Add TC and config data for metrics
Test case to validate metrics
add config data for metrics
add config data of registry namespace to validate metrics
Change-Id: I4886482ee33847f506ad898d4a313df866d0348c
Diffstat (limited to 'openshift-storage-libs/openshiftstoragelibs/openshift_ops.py')
-rw-r--r-- | openshift-storage-libs/openshiftstoragelibs/openshift_ops.py | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py index c8460d1a..da8225a5 100644 --- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py +++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py @@ -1102,36 +1102,39 @@ def wait_for_pods_be_ready( raise exceptions.ExecutionError(err_msg) -def get_pod_names_from_dc(hostname, dc_name, timeout=180, wait_step=3): +def get_pod_names_from_dc_or_rc( + hostname, rname, rtype='dc', timeout=180, wait_step=3): """Return list of POD names by their DC. Args: hostname (str): hostname on which 'oc' commands will be executed. - dc_name (str): deployment_confidg name + rname (str): deployment_config name or replication_controller name + rtype (str): resource type, 'dc' or 'rc', Default value is 'rc' timeout (int): timeout value. Default value is 180 sec. wait_step( int): Wait step, default value is 3 sec. Returns: list: list of strings which are POD names Raises: exceptions.ExecutionError """ + if rtype not in ('dc', 'rc'): + raise NameError("Value of rtype should be either 'dc' or 'rc'.") get_replicas_amount_cmd = ( - "oc get dc --no-headers --all-namespaces " + "oc get %s --no-headers --all-namespaces " "-o=custom-columns=:.spec.replicas,:.metadata.name " - "| grep '%s' | awk '{print $1}'" % dc_name) - replicas = int(command.cmd_run( - get_replicas_amount_cmd, hostname=hostname)) - + "| grep '%s' | awk '{print $1}'" % (rtype, rname)) get_pod_names_cmd = ( "oc get pods --all-namespaces -o=custom-columns=:.metadata.name " - "--no-headers=true --selector deploymentconfig=%s" % dc_name) + "--no-headers=true --selector %s=%s" % ( + "deploymentconfig" if rtype == "dc" else "name", rname)) + replicas = int(command.cmd_run(get_replicas_amount_cmd, hostname=hostname)) for w in waiter.Waiter(timeout, wait_step): out = command.cmd_run(get_pod_names_cmd, hostname=hostname) pod_names = [o.strip() for o in out.split('\n') if o.strip()] if len(pod_names) != replicas: continue g.log.info( - "POD names for '%s' DC are '%s'. " - "Expected amount of PODs is '%s'.", dc_name, out, replicas) + "POD names for '%s %s' are '%s'. " + "Expected amount of PODs is '%s'.", rname, rtype, out, replicas) return pod_names if w.expired: err_msg = ("Exceeded %s sec timeout waiting for PODs to appear " @@ -1140,11 +1143,21 @@ def get_pod_names_from_dc(hostname, dc_name, timeout=180, wait_step=3): raise exceptions.ExecutionError(err_msg) +def get_pod_names_from_dc(hostname, rname, timeout=180, wait_step=3): + return get_pod_names_from_dc_or_rc( + hostname, rname, timeout=timeout, wait_step=wait_step) + + def get_pod_name_from_dc(hostname, dc_name, timeout=180, wait_step=3): - return get_pod_names_from_dc( + return get_pod_names_from_dc_or_rc( hostname, dc_name, timeout=timeout, wait_step=wait_step)[0] +def get_pod_name_from_rc(hostname, rc_name, timeout=180, wait_step=3): + return get_pod_names_from_dc_or_rc( + hostname, rc_name, rtype='rc', timeout=timeout, wait_step=wait_step)[0] + + def get_pvc_status(hostname, pvc_name): ''' This function verifies the if pod is running |