summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ansible/nfs_ganesha_client_setup.yml2
-rwxr-xr-xglustolibs-io/glustolibs/io/utils.py44
-rwxr-xr-xglustolibs-misc/glustolibs/misc/misc_libs.py35
-rw-r--r--tests/functional/nfs_ganesha/test_cthon.py121
4 files changed, 201 insertions, 1 deletions
diff --git a/ansible/nfs_ganesha_client_setup.yml b/ansible/nfs_ganesha_client_setup.yml
index 8327e2431..86dea397d 100644
--- a/ansible/nfs_ganesha_client_setup.yml
+++ b/ansible/nfs_ganesha_client_setup.yml
@@ -5,5 +5,5 @@
tasks:
- name: Setup Clients to run NFS-Ganesha tests.
yum:
- name: ['wget', 'iozone', 'perl-Test-Harness', 'libacl*', 'gcc']
+ name: ['wget', 'iozone', 'perl-Test-Harness', 'libacl*', 'gcc', 'git', 'make', 'time']
state: latest
diff --git a/glustolibs-io/glustolibs/io/utils.py b/glustolibs-io/glustolibs/io/utils.py
index ba73b1711..7bb8314c1 100755
--- a/glustolibs-io/glustolibs/io/utils.py
+++ b/glustolibs-io/glustolibs/io/utils.py
@@ -928,3 +928,47 @@ def run_crefi(client, mountpoint, number, breadth, depth, thread=5,
g.log.error("Failed to run crefi on %s." % client)
return False
return True
+
+
+def run_cthon(mnode, volname, clients, dir_name):
+ """This function runs the cthon test suite.
+
+ Args:
+ mnode (str) : IP of the server exporting the gluster volume.
+ volname (str) : The volume name.
+ clients (list) : List of client machines where
+ the test needs to be run.
+ dir_name (str) : Directory where the repo
+ is cloned.
+
+ Returns:
+ bool : True if the cthon test passes successfully
+ False otherwise.
+ """
+ param_list = ['-b', '-g', '-s', '-l']
+ vers_list = ['4.0', '4.1']
+
+ for client in clients:
+ g.log.info("Running tests on client %s" % client)
+ for vers in vers_list:
+ g.log.info("Running tests on client version %s" % vers)
+ for param in param_list:
+ # Initialising the test_type that will be running
+ if param == '-b':
+ test_type = "Basic"
+ elif param == '-g':
+ test_type = "General"
+ elif param == '-s':
+ test_type = "Special"
+ else:
+ test_type = "Lock"
+ g.log.info("Running %s test" % test_type)
+ cmd = ("cd /root/%s; ./server %s -o vers=%s -p %s -N "
+ "1 %s;" % (dir_name, param, vers, volname, mnode))
+ ret, _, _ = g.run(client, cmd)
+ if ret:
+ g.log.error("Error with %s test" % test_type)
+ return False
+ else:
+ g.log.info("%s test successfully passed" % test_type)
+ return True
diff --git a/glustolibs-misc/glustolibs/misc/misc_libs.py b/glustolibs-misc/glustolibs/misc/misc_libs.py
index ee6c74c6d..7b8010cd9 100755
--- a/glustolibs-misc/glustolibs/misc/misc_libs.py
+++ b/glustolibs-misc/glustolibs/misc/misc_libs.py
@@ -590,3 +590,38 @@ def daemon_reload(node):
g.log.error("Failed to reload the daemon")
return False
return True
+
+
+def git_clone_and_compile(hosts, link, dir_name,
+ compile_option='False'):
+ """This function clones a repo and depending
+ on kwargs compiles it.
+ Args:
+ hosts (list|str): List of hosts where the repo needs to be cloned.
+ link (str): Link to the repo that needs to be cloned.
+ dir_name (str): Directory where the repo is to be cloned.
+
+ Kwargs:
+ compile_option (bool): If this option is set to True
+ then the cloned repo will be compiled otherwise
+ the repo is only cloned on the hosts.
+
+ Returns:
+ bool : True on successfull cloning (and compilation)
+ False otherwise.
+ """
+ if isinstance(hosts, str):
+ hosts = [hosts]
+
+ cmd = ("cd /root; git clone %s %s;" % (link, dir_name))
+ if compile_option:
+ cmd = cmd + (("cd /root/%s; make") % dir_name)
+
+ for host in hosts:
+ ret, _, _ = g.run(host, cmd)
+ if ret:
+ g.log.error("Cloning/Compiling repo failed on %s" % host)
+ return False
+ else:
+ g.log.info("Successfully cloned/compiled repo on %s" % host)
+ return True
diff --git a/tests/functional/nfs_ganesha/test_cthon.py b/tests/functional/nfs_ganesha/test_cthon.py
new file mode 100644
index 000000000..5c1c5869d
--- /dev/null
+++ b/tests/functional/nfs_ganesha/test_cthon.py
@@ -0,0 +1,121 @@
+# Copyright (C) 2019 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:
+ This cthon test is specific to NFS Ganesha
+ and runs on v.4.0, v4.1 clients.
+"""
+
+from glusto.core import Glusto as g
+from glustolibs.gluster.gluster_base_class import GlusterBaseClass, runs_on
+from glustolibs.gluster.nfs_ganesha_libs import NfsGaneshaClusterSetupClass
+from glustolibs.gluster.exceptions import ExecutionError
+from glustolibs.io.utils import run_cthon
+from glustolibs.misc.misc_libs import git_clone_and_compile
+
+
+@runs_on([['replicated', 'distributed', 'distributed-replicated',
+ 'dispersed', 'distributed-dispersed'],
+ ['nfs']])
+class TestCthon(NfsGaneshaClusterSetupClass):
+ """
+ Cthon test on NFS Ganesha v4.0, v4.1
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ """
+ Setup nfs-ganesha if not exists.
+ """
+ NfsGaneshaClusterSetupClass.setUpClass.im_func(cls)
+
+ # Setup nfs-ganesha if not exists.
+ ret = cls.setup_nfs_ganesha()
+ if not ret:
+ raise ExecutionError("Failed to setup nfs-ganesha cluster")
+ g.log.info("nfs-ganesha cluster is healthy")
+
+ # Cloning the cthon test repo
+ cls.dir_name = "repo_dir"
+ link = 'git://linux-nfs.org/~steved/cthon04.git'
+ ret = git_clone_and_compile(cls.clients, link, cls.dir_name,
+ compile_option=True)
+ if not ret:
+ raise ExecutionError("Failed to clone the cthon repo."
+ "Check error logs to know which"
+ "node it failed on.")
+ else:
+ g.log.info("Successfully cloned the"
+ "test repo on provided nodes.")
+
+ def setUp(self):
+ """
+ Setup volume
+ """
+ GlusterBaseClass.setUp.im_func(self)
+
+ g.log.info("Starting to setup volume %s", self.volname)
+ ret = self.setup_volume(volume_create_force=True)
+ if not ret:
+ raise ExecutionError("Failed to setup"
+ "volume %s" % self.volname)
+ g.log.info("Successful setup of volume %s" % self.volname)
+
+ def test_NFS_cthon(self):
+ """The cthon test is divied into four groups.
+ Basic : basic file system operations tests
+ General : general file system tests
+ Special : tests that poke certain common problem areas
+ Lock : tests that exercise network locking
+ """
+ ret = run_cthon(self.mnode, self.volname,
+ self.clients, self.dir_name)
+ self.assertTrue(ret, ("Cthon test failed"))
+ g.log.info("Cthon test successfully passed")
+
+ def tearDown(self):
+ """
+ Cleanup volume
+ """
+ GlusterBaseClass.tearDown.im_func(self)
+
+ # Cleanup volume
+ ret = self.cleanup_volume()
+ if not ret:
+ raise ExecutionError("Failed to cleanup volume")
+ g.log.info("Cleanup of volume %s"
+ " completed successfully", self.volname)
+
+ # Cleanup test repo
+ flag = 0
+ for client in self.clients:
+ ret = g.run(client, "rm -rf /root/%s" % self.dir_name)
+ if ret:
+ g.log.error("Failed to cleanup test repo on "
+ "client %s" % client)
+ flag = 1
+ else:
+ g.log.info("Test repo successfully cleaned on "
+ "client %s" % client)
+ if flag:
+ raise ExecutionError("Test repo failed. "
+ "Check log errors for more info")
+ else:
+ g.log.info("Test repo cleanup successfull on all clients")
+
+ @classmethod
+ def tearDownClass(cls):
+ NfsGaneshaClusterSetupClass.tearDownClass.im_func(cls)