summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRajesh Madaka <rmadaka@redhat.com>2018-01-12 19:53:12 +0530
committerNigel Babu <nigelb@redhat.com>2018-02-02 03:36:01 +0000
commit94822dbb06d4f1a54bcd46c501e1116113192775 (patch)
tree0f67fc4113ef3e078b097f0a00f43b4be04dfb2a
parent50a5048ef2054e054cb59c1cccb1198dedcf677d (diff)
Test case for Validate Peer probe with invalid ip and non existing
host, non existing ip Library for Core file Create or Not, Added is_core_file_created() function to lib_utils.py Test Desc: Test script to verify peer probe non existing host and invalid-ip, peer probe has to be fail for non existing host, Glusterd services up and running after invalid peer probe, and core file should not get created under "/", /tmp, /var/log/core directory Adding glusterd peer probe test cases with modifications according to comments adding lib for core file verification Change-Id: I0ebd6ee2b340d1f1b01878cb0faf69f41fec2e10 Signed-off-by: Rajesh Madaka <rmadaka@redhat.com>
-rw-r--r--glustolibs-gluster/glustolibs/gluster/lib_utils.py58
-rw-r--r--tests/functional/glusterd/__init__.py0
-rw-r--r--tests/functional/glusterd/test_probe_glusterd.py103
3 files changed, 161 insertions, 0 deletions
diff --git a/glustolibs-gluster/glustolibs/gluster/lib_utils.py b/glustolibs-gluster/glustolibs/gluster/lib_utils.py
index 901fa10bf..472c58cba 100644
--- a/glustolibs-gluster/glustolibs/gluster/lib_utils.py
+++ b/glustolibs-gluster/glustolibs/gluster/lib_utils.py
@@ -774,3 +774,61 @@ def inject_msg_in_logs(nodes, log_msg, list_of_dirs=None, list_of_files=None):
log_msg, list_of_dirs, list_of_files, host)
_rc = False
return _rc
+
+
+def is_core_file_created(nodes, testrun_timestamp,
+ paths=['/', '/var/log/core', '/tmp']):
+ '''
+ Listing directories and files in "/", /var/log/core, /tmp
+ directory for checking if the core file created or not
+
+ Args:
+
+ nodes(list):
+ List of nodes need to pass from test method
+ testrun_timestamp:
+ This time stamp need to pass from test method
+ test case runing started time, time format is EPOCH
+ time format, use below command for getting timestamp
+ of test case 'date +%s'
+ paths(list):
+ By default core file will be verified in "/","/tmp",
+ "/var/log/core"
+ If test case need to verify core file in specific path,
+ need to pass path from test method
+ '''
+ count = 0
+ cmd_list = []
+ for path in paths:
+ cmd = ' '.join(['cd', path, '&&', 'ls', 'core*'])
+ cmd_list.append(cmd)
+
+ # Checks for core file in "/", "/var/log/core", "/tmp" directory
+ for node in nodes:
+ for cmd in cmd_list:
+ ret, out, _ = g.run(node, cmd)
+ g.log.info("storing all files and directory names into list")
+ dir_list = re.split(r'\s+', out)
+
+ # checking for core file created or not in "/"
+ # "/var/log/core", "/tmp" directory
+ g.log.info("checking core file created or not")
+ for file1 in dir_list:
+ if (re.search(r'\bcore\.[\S]+\b', file1)):
+ file_path_list = re.split('[\s]+', cmd)
+ file_path = file_path_list[1] + '/' + file1
+ time_cmd = 'stat ' + '-c ' + '%X ' + file_path
+ ret, file_timestamp, _ = g.run(node, time_cmd)
+ file_timestamp = file_timestamp.strip()
+ if(file_timestamp > testrun_timestamp):
+ count += 1
+ g.log.error("New core file created %s " % file1)
+ else:
+ g.log.info("Old core file Found")
+ # return the status of core file
+ if (count >= 1):
+ g.log.error("Core file created glusterd crashed")
+ return False
+ else:
+ g.log.info("No core files found ")
+ return True
diff --git a/tests/functional/glusterd/__init__.py b/tests/functional/glusterd/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/functional/glusterd/__init__.py
diff --git a/tests/functional/glusterd/test_probe_glusterd.py b/tests/functional/glusterd/test_probe_glusterd.py
new file mode 100644
index 000000000..0b035c933
--- /dev/null
+++ b/tests/functional/glusterd/test_probe_glusterd.py
@@ -0,0 +1,103 @@
+# Copyright (C) 2017-2018 Red Hat, Inc. <http://www.redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+""" Description:
+ Test Cases in this module related to peer probe invalid ip,
+ non existing ip, non existing host.
+"""
+from glusto.core import Glusto as g
+from glustolibs.gluster.gluster_base_class import GlusterBaseClass
+from glustolibs.gluster.peer_ops import peer_probe
+from glustolibs.gluster.lib_utils import is_core_file_created
+from glustolibs.gluster.gluster_init import is_glusterd_running
+
+
+class PeerProbeInvalidIpNonExistingHost(GlusterBaseClass):
+ @classmethod
+ def setUpClass(cls):
+ GlusterBaseClass.setUpClass.im_func(cls)
+ g.log.info("Starting %s " % cls.__name__)
+
+ def setUp(self):
+ """
+ setUp method for every test
+ """
+ # calling GlusterBaseClass setUp
+ GlusterBaseClass.setUp.im_func(self)
+
+ def tearDown(self):
+ """
+ tearDown for every test
+ """
+ # Calling GlusterBaseClass tearDown
+ GlusterBaseClass.tearDown.im_func(self)
+
+ def test_peer_probe_invalid_ip_nonexist_host_nonexist_ip(self):
+ '''
+ Test script to verify peer probe non existing ip,
+ non_exsting_host and invalid-ip, peer probe has to
+ be fail for invalid-ip, non-existing-ip and
+ non existing host, verify Glusterd services up and
+ running or not after invalid peer probe,
+ and core file should not get created
+ under "/", /var/log/core and /tmp directory
+ '''
+ ret, test_timestamp, _ = g.run_local('date +%s')
+ test_timestamp = test_timestamp.strip()
+ g.log.info("Running Test : %s" % self.id())
+
+ # Assigning non existing ip to variable
+ self.non_exist_ip = '256.256.256.256'
+
+ # Assigning invalid ip to vaiable
+ self.invalid_ip = '10.11.a'
+
+ # Assigning non existing host to variable
+ self.non_exist_host = 'abc.lab.eng.blr.redhat.com'
+
+ # Peer probe checks for non existing host
+ g.log.info("peer probe checking for non existing host")
+ ret, out, msg = peer_probe(self.mnode, self.non_exist_host)
+ self.assertNotEqual(ret, 0, "peer probe should fail for "
+ "non existhost: %s" % self.non_exist_host)
+ g.log.info("peer probe failed for non existing host")
+
+ # Peer probe checks for invalid ip
+ g.log.info("peer probe checking for invalid ip")
+ ret, out, msg = peer_probe(self.mnode, self.invalid_ip)
+ self.assertNotEqual(ret, 0, "peer probe shouldfail for "
+ "invalid ip: %s" % self.invalid_ip)
+ g.log.info("peer probe failed for invalid_ip")
+
+ # peer probe checks for non existing ip
+ g.log.info("peer probe checking for non existing ip")
+ ret, out, msg = peer_probe(self.mnode, self.non_exist_ip)
+ self.assertNotEqual(ret, 0, "peer probe should fail for non exist "
+ "ip :%s" % self.non_exist_ip)
+ g.log.info("peer probe failed for non existing ip")
+
+ # Checks Glusterd services running or not after peer probe
+ # to invalid host and non existing host
+
+ self.mnode_list = []
+ self.mnode_list.append(self.mnode)
+ ret = is_glusterd_running(self.mnode_list)
+ self.assertEqual(ret, 0, "Glusterd service should be running")
+
+ # Chekcing core file created or not in "/", "/tmp" and
+ # "/var/log/core" directory
+ ret = is_core_file_created(self.servers, test_timestamp)
+ self.assertTrue(ret, "core file found")