summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_ops.py19
-rw-r--r--tests/functional/gluster_stability/test_gluster_services_restart.py8
-rw-r--r--tests/functional/test_node_restart.py2
3 files changed, 19 insertions, 10 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
index 51865106..c8275c5c 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py
@@ -32,7 +32,7 @@ PODS_WIDE_RE = re.compile(
r'(\S+)\s+(\S+)\s+(\w+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(\S+).*\n')
SERVICE_STATUS = "systemctl status %s"
SERVICE_RESTART = "systemctl restart %s"
-SERVICE_STATUS_REGEX = r"Active: active \((.*)\) since .*;.*"
+SERVICE_STATUS_REGEX = r"Active: (.*) \((.*)\) since .*;.*"
def oc_get_pods(ocp_node, selector=None):
@@ -1296,7 +1296,7 @@ def match_pv_and_heketi_block_volumes(
def check_service_status_on_pod(
- ocp_client, podname, service, status, timeout=180, wait_step=3):
+ ocp_client, podname, service, status, state, timeout=180, wait_step=3):
"""Check a service state on a pod.
Args:
@@ -1304,6 +1304,9 @@ def check_service_status_on_pod(
podname (str): pod name on which service needs to be checked
service (str): service which needs to be checked
status (str): status to be checked
+ e.g. 'active', 'inactive', 'failed'
+ state (str): state to be checked
+ e.g. 'running', 'exited', 'dead'
timeout (int): seconds to wait before service starts having
specified 'status'
wait_step (int): interval in seconds to wait before checking
@@ -1322,7 +1325,8 @@ def check_service_status_on_pod(
for line in out.splitlines():
status_match = re.search(SERVICE_STATUS_REGEX, line)
- if status_match and status_match.group(1) == status:
+ if (status_match and status_match.group(1) == status and
+ status_match.group(2) == state):
return True
if w.expired:
@@ -1331,13 +1335,17 @@ def check_service_status_on_pod(
def wait_for_service_status_on_gluster_pod_or_node(
- ocp_client, service, status, gluster_node, timeout=180, wait_step=3):
+ ocp_client, service, status, state, gluster_node,
+ timeout=180, wait_step=3):
"""Wait for a service specific status on a Gluster POD or node.
Args:
ocp_client (str): hostname on which we want to check service
service (str): target service to be checked
status (str): service status which we wait for
+ e.g. 'active', 'inactive', 'failed'
+ state (str): service state which we wait for
+ e.g. 'running', 'exited', 'dead'
gluster_node (str): Gluster node IPv4 which stores either Gluster POD
or Gluster services directly.
timeout (int): seconds to wait before service starts having
@@ -1353,7 +1361,8 @@ def wait_for_service_status_on_gluster_pod_or_node(
ocp_client, SERVICE_STATUS % service, gluster_node)
for line in out.splitlines():
status_match = re.search(SERVICE_STATUS_REGEX, line)
- if status_match and status_match.group(1) == status:
+ if (status_match and status_match.group(1) == status and
+ status_match.group(2) == state):
return True
if w.expired:
g.log.error(err_msg)
diff --git a/tests/functional/gluster_stability/test_gluster_services_restart.py b/tests/functional/gluster_stability/test_gluster_services_restart.py
index ff00407b..0d5077c3 100644
--- a/tests/functional/gluster_stability/test_gluster_services_restart.py
+++ b/tests/functional/gluster_stability/test_gluster_services_restart.py
@@ -288,9 +288,9 @@ class GlusterStabilityTestSetup(BaseClass):
# checks if all glusterfs services are in running state
for g_node in g_nodes:
for service in (SERVICE_BLOCKD, SERVICE_TCMU, SERVICE_TARGET):
- status = "exited" if service == SERVICE_TARGET else "running"
+ state = "exited" if service == SERVICE_TARGET else "running"
self.assertTrue(wait_for_service_status_on_gluster_pod_or_node(
- self.oc_node, service, status, g_node))
+ self.oc_node, service, 'active', state, g_node))
# validates pvc, pv, heketi block and gluster block count after
# service restarts
@@ -312,9 +312,9 @@ class GlusterStabilityTestSetup(BaseClass):
# checks if all glusterfs services are in running state
for g_node in g_nodes:
for service in (SERVICE_BLOCKD, SERVICE_TCMU, SERVICE_TARGET):
- status = "exited" if service == SERVICE_TARGET else "running"
+ state = "exited" if service == SERVICE_TARGET else "running"
self.assertTrue(wait_for_service_status_on_gluster_pod_or_node(
- self.oc_node, service, status, g_node))
+ self.oc_node, service, 'active', state, g_node))
# validates pvc, pv, heketi block and gluster block count after
# service restarts
diff --git a/tests/functional/test_node_restart.py b/tests/functional/test_node_restart.py
index d1be4232..745ea2db 100644
--- a/tests/functional/test_node_restart.py
+++ b/tests/functional/test_node_restart.py
@@ -134,7 +134,7 @@ class TestNodeRestart(BaseClass):
g.log.info("gluster_pod - '%s' : gluster_service '%s'" % (
gluster_pod, service))
check_service_status_on_pod(
- self.oc_node, gluster_pod, service, "running"
+ self.oc_node, gluster_pod, service, "active", "running"
)
@skip("Blocked by BZ-1652913")