summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinayak Papnoi <vpapnoi@redhat.com>2019-06-20 15:53:54 +0530
committerBala Konda Reddy M <bmekala@redhat.com>2019-06-30 17:54:29 +0000
commitf54b94609a3b5fce1fd85f23c06b27bcdfc99b46 (patch)
treeeeb892ade9d1b965a5393e797ac37d73de712d42
parent366df056ce284f2dbef040a8bc4851273ef2d2ae (diff)
[glusterfind] Test case to verify the 'glusterfind pre' functionality
Verifying the 'glusterfind pre' command functionality with valid and invalid values for the required and optional parameters. * Create a session on the volume * Perform some I/O from the mount point * Perform glusterfind pre with the following combinations: - Valid values for required parameters - Invalid values for required parameters - Valid values for optional parameters - Invalid values for optional parameters * Perform glusterfind post Where Required parameters: volname, sessname and outfile Optional parameters: full, debug, gftype, tagforfullfind, namespace, noencode, disablepartial, regenoutfile, outprefix, fieldsep Change-Id: Id795d632ebb8f43f49a9d15d83aced87670007b6 Signed-off-by: Vinayak Papnoi <vpapnoi@redhat.com>
-rw-r--r--tests/functional/glusterfind/test_gfind_pre_cli.py204
1 files changed, 204 insertions, 0 deletions
diff --git a/tests/functional/glusterfind/test_gfind_pre_cli.py b/tests/functional/glusterfind/test_gfind_pre_cli.py
new file mode 100644
index 0000000..99bb388
--- /dev/null
+++ b/tests/functional/glusterfind/test_gfind_pre_cli.py
@@ -0,0 +1,204 @@
+# 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.
+
+from glusto.core import Glusto as g
+from glustolibs.gluster.exceptions import ExecutionError
+from glustolibs.gluster.gluster_base_class import GlusterBaseClass, runs_on
+from glustolibs.gluster.glusterfind_ops import (gfind_create,
+ gfind_list,
+ gfind_pre,
+ gfind_post,
+ gfind_delete)
+from glustolibs.gluster.glusterfile import (file_exists, remove_file,
+ check_if_pattern_in_file)
+
+
+@runs_on([['replicated', 'distributed-replicated', 'dispersed',
+ 'distributed', 'distributed-dispersed'],
+ ['glusterfs']])
+class TestGlusterFindPreCLI(GlusterBaseClass):
+ """
+ GlusterFindPreCLI contains tests which verifies the glusterfind pre
+ command functionality.
+ """
+
+ def setUp(self):
+ """
+ setup volume and mount volume
+ Initiate necessary variables
+ """
+
+ # calling GlusterBaseClass setUpClass
+ GlusterBaseClass.setUp.im_func(self)
+
+ # Setup Volume and Mount Volume
+ g.log.info("Starting to Setup %s", self.volname)
+ ret = self.setup_volume_and_mount_volume(mounts=self.mounts)
+ if not ret:
+ raise ExecutionError("Failed to Setup_Volume %s" % self.volname)
+ g.log.info("Successful in Setup Volume %s", self.volname)
+ self.session = 'test-session-%s' % self.volname
+ self.outfile = '/tmp/test-outfile-%s.txt' % self.volname
+
+ def tearDown(self):
+ """
+ tearDown for every test
+ Clean up and unmount the volume
+ """
+
+ ret, _, _ = gfind_delete(self.mnode, self.volname, self.session)
+ if ret != 0:
+ raise ExecutionError("Failed to delete session %s" % self.session)
+ g.log.info("Successfully deleted session %s", self.session)
+
+ g.log.info("Removing the outfile created during 'glusterfind pre'")
+ ret = remove_file(self.mnode, self.outfile, force=True)
+ if not ret:
+ raise ExecutionError("Failed to remove the outfile")
+ g.log.info("Successfully removed the outfile")
+
+ # stopping the volume
+ g.log.info("Starting to Cleanup Volume")
+ ret = self.unmount_volume_and_cleanup_volume(mounts=self.mounts)
+ if not ret:
+ raise ExecutionError("Failed to Cleanup Volume")
+ g.log.info("Successful in Cleanup Volume")
+
+ # calling GlusterBaseClass tearDownClass
+ GlusterBaseClass.tearDown.im_func(self)
+
+ def test_gfind_pre_cli(self):
+ """
+ Verifying the glusterfind pre command functionality with valid
+ and invalid values for the required and optional parameters.
+
+ * Create a volume
+ * Create a session on the volume
+ * Perform some I/O from the mount point
+ * Perform glusterfind pre with the following combinations:
+ - Valid values for required parameters
+ - Invalid values for required parameters
+ - Valid values for optional parameters
+ - Invalid values for optional parameters
+ * Perform glusterfind post
+
+ Where
+ Required parameters: volname, sessname and outfile
+ Optional parameters: full, debug, gftype, tagforfullfind,
+ namespace, noencode, disablepartial,
+ regenoutfile, outprefix, fieldsep
+ """
+
+ # pylint: disable=too-many-statements
+ # Creating a session for the volume
+ g.log.info("Creating a session for the volume %s", self.volname)
+ ret, _, _ = gfind_create(self.mnode, self.volname, self.session)
+ self.assertEqual(ret, 0, ("Unexpected: Creation of a session for the "
+ "volume %s failed" % self.volname))
+ g.log.info("Successfully created a session for the volume %s",
+ self.volname)
+
+ # Perform glusterfind list to check if session exists
+ g.log.info("Performing glusterfind list to check if the session is "
+ "created")
+ ret, _, _ = gfind_list(self.mnode, volname=self.volname,
+ sessname=self.session)
+ self.assertEqual(ret, 0, "Failed to list the glusterfind session")
+ g.log.info("Successfully listed the glusterfind session")
+
+ # Starting IO on the mounts
+ mount_obj = self.mounts[0]
+ mount_dir = mount_obj.mountpoint
+ client = mount_obj.client_system
+
+ g.log.info("Creating Files on %s:%s", client, mount_dir)
+ cmd = ("cd %s ; for i in `seq 1 10` ; "
+ "do dd if=/dev/urandom of=file$i bs=1M count=1 ; "
+ "done" % mount_dir)
+ ret, _, _ = g.run(client, cmd)
+ self.assertEqual(ret, 0, "Failed to create files on mountpoint")
+ g.log.info("Files created successfully on mountpoint")
+
+ # Check if the files exist
+ g.log.info("Checking the existence of files created during IO")
+ for i in range(1, 11):
+ ret = file_exists(client, '%s/file%s' % (mount_dir, i))
+ self.assertTrue(ret, "Unexpected: File 'file%s' does not exist"
+ % i)
+ g.log.info("Successfully validated existence of 'file%s'", i)
+
+ # Perform glusterfind pre for the session
+ g.log.info("Performing glusterfind pre for the session %s",
+ self.session)
+ ret, _, _ = gfind_pre(self.mnode, self.volname, self.session,
+ self.outfile, full=True, noencode=True,
+ debug=True)
+ self.assertEqual(ret, 0, ("Failed to perform glusterfind pre"))
+ g.log.info("Successfully performed glusterfind pre")
+
+ # Check if the outfile exists
+ g.log.info("Checking if outfile created during glusterfind pre command"
+ " exists")
+ ret = file_exists(self.mnode, self.outfile)
+ self.assertTrue(ret, "Unexpected: File '%s' does not exist"
+ % self.outfile)
+ g.log.info("Successfully validated existence of '%s'", self.outfile)
+
+ # Check if all the files are listed in the outfile
+ for i in range(1, 11):
+ ret = check_if_pattern_in_file(self.mnode, 'file%s' % i,
+ self.outfile)
+ self.assertEqual(ret, 0,
+ ("File 'file%s' not listed in %s"
+ % (i, self.outfile)))
+ g.log.info("File 'file%s' listed in %s", i, self.outfile)
+
+ # Perform glusterfind post for the session
+ g.log.info("Performing glusterfind post for the session %s",
+ self.session)
+ ret, _, _ = gfind_post(self.mnode, self.volname, self.session)
+ self.assertEqual(ret, 0, ("Failed to perform glusterfind post"))
+ g.log.info("Successfully performed glusterfind post")
+
+ # Perform glusterfind pre using the invalid values for required
+ # parameters
+ not_volume = 'invalid-volume-name'
+ not_session = 'invalid-session-name'
+ not_outfile = '/tmp/not'
+ g.log.info("Performing glusterfind pre with invalid values for the "
+ "required parameters")
+ ret, _, _ = gfind_pre(self.mnode, not_volume, not_session, not_outfile)
+ self.assertNotEqual(ret, 0, "Unexpected: glusterfind pre Successful "
+ "even with invalid values for required parameters")
+ g.log.info("Successful: glusterfind pre failed with invalid values "
+ "for required parameters")
+
+ # Perform glusterfind pre using the invalid values for optional
+ # parameters
+ g.log.info("Deleting the session with invalid values for the optional "
+ "parameters")
+ invalid_options = [' --dbug', ' --noencod', ' --regenout', ' --type n',
+ ' --tagforfullfind', ' --disablepartial', ' --fll'
+ ' --outprefix none', ' --namespc']
+ for opt in invalid_options:
+ ret, _, _ = g.run(self.mnode, ("glusterfind pre %s %s %s %s"
+ % (self.volname, self.session,
+ self.outfile, opt)))
+ self.assertNotEqual(ret, 0, "Unexpected: glusterfind pre "
+ " successful for option %s which is invalid"
+ % opt)
+ g.log.info("Successful: glusterfind pre failed with invalid value "
+ "for optional parameters")