summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBala Konda Reddy M <bmekala@redhat.com>2019-08-09 15:48:45 +0530
committerBala Konda Reddy M <bmekala@redhat.com>2019-09-04 09:46:10 +0000
commit875ba99936c2fb8947d3f35e08b412e2223a54a2 (patch)
treec2430e2dadb443d269a7a777c2b9fcaef211efc3
parente6bca2db2d21a0a570919a0a52f4c7ab839a6f57 (diff)
Added a library for daemon reload and fixing testcase
After changing the type of unit file from INFO to DEBUG. Performing daemon reload. Earlier using running commands continuosly to generated debug messages instead of running continuosly, restarted glusterd in one of the nodes so that while handshake the logs will be in Debug mode. After validating reverting back the unit file to INFO and daemon reload Change-Id: I8c99407eff2ea98a836f37fc2d89bb99f7eeccb7 Signed-off-by: Bala Konda Reddy M <bmekala@redhat.com>
-rwxr-xr-xglustolibs-misc/glustolibs/misc/misc_libs.py27
-rw-r--r--tests/functional/glusterd/test_enabling_glusterd_debug_mode.py34
2 files changed, 53 insertions, 8 deletions
diff --git a/glustolibs-misc/glustolibs/misc/misc_libs.py b/glustolibs-misc/glustolibs/misc/misc_libs.py
index fb4bb49..ee6c74c 100755
--- a/glustolibs-misc/glustolibs/misc/misc_libs.py
+++ b/glustolibs-misc/glustolibs/misc/misc_libs.py
@@ -17,6 +17,7 @@
""" Description: Helper module for misc libs. """
from glusto.core import Glusto as g
+from glustolibs.gluster.lib_utils import is_rhel7
import os
import sys
import time
@@ -563,3 +564,29 @@ def drop_caches(hosts):
_rc = False
return _rc
+
+
+def daemon_reload(node):
+ """
+ Reloads the Daemons when unit files are changed
+
+ Args:
+ node : Node on which daemon has to be reloaded
+
+ Returns:
+ bool : True, On successful daemon reload
+ False, Otherwise
+ """
+ if is_rhel7([node]):
+ cmd = "systemctl daemon-reload"
+ ret, _, _ = g.run(node, cmd)
+ if ret != 0:
+ g.log.error("Failed to reload the daemon")
+ return False
+ else:
+ cmd = 'service glusterd reload'
+ ret, _, _ = g.run(node, cmd)
+ if ret != 0:
+ g.log.error("Failed to reload the daemon")
+ return False
+ return True
diff --git a/tests/functional/glusterd/test_enabling_glusterd_debug_mode.py b/tests/functional/glusterd/test_enabling_glusterd_debug_mode.py
index 7a355f8..8c5bf97 100644
--- a/tests/functional/glusterd/test_enabling_glusterd_debug_mode.py
+++ b/tests/functional/glusterd/test_enabling_glusterd_debug_mode.py
@@ -18,12 +18,13 @@ from time import sleep
from glusto.core import Glusto as g
from glustolibs.gluster.gluster_base_class import GlusterBaseClass
from glustolibs.gluster.exceptions import ExecutionError
-from glustolibs.gluster.gluster_init import (start_glusterd, stop_glusterd)
-from glustolibs.gluster.volume_ops import get_volume_info
+from glustolibs.gluster.gluster_init import (start_glusterd, stop_glusterd,
+ restart_glusterd)
from glustolibs.gluster.gluster_init import is_glusterd_running
from glustolibs.gluster.glusterfile import (move_file,
find_and_replace_in_file,
check_if_pattern_in_file)
+from glustolibs.misc.misc_libs import daemon_reload
class TestVolumeOptionSetWithMaxcharacters(GlusterBaseClass):
@@ -72,6 +73,12 @@ class TestVolumeOptionSetWithMaxcharacters(GlusterBaseClass):
raise ExecutionError("Reverting glusterd log failed.")
g.log.info("Reverting of glusterd log successful.")
+ # Daemon should be reloaded as unit file is changed
+ ret = daemon_reload(self.mnode)
+ if not ret:
+ raise ExecutionError("Unable to reload the daemon")
+ g.log.info("Daemon reloaded successfully")
+
# Restart glusterd
ret = start_glusterd(self.mnode)
if not ret:
@@ -139,13 +146,17 @@ class TestVolumeOptionSetWithMaxcharacters(GlusterBaseClass):
self.assertTrue(ret, "Renaming the glusterd log is failed")
g.log.info("Successfully renamed glusterd.log file.")
+ # Daemon reloading as the unit file of the daemon changed
+ ret = daemon_reload(self.mnode)
+ self.assertTrue(ret, "Daemon reloaded successfully")
+
# Start glusterd
ret = start_glusterd(self.mnode)
self.assertTrue(ret, "Failed to start glusterd on %s"
% self.mnode)
g.log.info('Successfully to started glusterd.')
- # Check if glusterd is runnibg or not.
+ # Check if glusterd is running or not.
count = 0
while count < 60:
ret = is_glusterd_running(self.mnode)
@@ -156,14 +167,21 @@ class TestVolumeOptionSetWithMaxcharacters(GlusterBaseClass):
self.assertEqual(ret, 0, "glusterd is not running on %s" % self.mnode)
g.log.info('glusterd is running after changing log_level to debug.')
- # Issue some gluster commands
+ # Instead of executing commands in loop, if glusterd is restarted in
+ # one of the nodes in the cluster the handshake messages
+ # will be in debug mode.
+ ret = restart_glusterd(self.servers[1])
+ self.assertTrue(ret, "restarted successfully")
+
count = 0
- while count < 9:
- ret = get_volume_info(self.mnode)
- self.assertIsNotNone(ret, "Failed to get volume info")
+ while count < 60:
+ ret = is_glusterd_running(self.mnode)
+ if ret:
+ break
sleep(2)
count += 1
- g.log.info("Successfully got volume info 9 times.")
+ self.assertEqual(ret, 0, "glusterd is not running on %s" % self.mnode)
+ g.log.info('glusterd is running after changing log_level to debug.')
# Check glusterd logs for debug messages
glusterd_log_file = "/var/log/glusterfs/glusterd.log"