summaryrefslogtreecommitdiffstats
path: root/tests/functional/quota
diff options
context:
space:
mode:
authorVinayak Papnoi <vpapnoi@redhat.com>2018-01-23 23:18:03 +0530
committerNigel Babu <nigelb@redhat.com>2018-06-11 06:41:35 +0000
commit91a54bc94c3e7a255bdb9c810b2998b8532b2836 (patch)
tree8dc8f4f58a48215bb016a2f398daf9b815487a19 /tests/functional/quota
parent278dee07660f6a9d7a6b3f4124e0ae8598381667 (diff)
Quota : Test case for quota on single brick volume
This test case covers the quota functionality for a volume with a single brick (1x1). Quota help cli command is also validated here. Change-Id: I772f4646e2229c21f4547122410633715ef47668 Signed-off-by: Vinayak Papnoi <vpapnoi@redhat.com>
Diffstat (limited to 'tests/functional/quota')
-rw-r--r--tests/functional/quota/test_quota_single_brick_volume.py159
1 files changed, 159 insertions, 0 deletions
diff --git a/tests/functional/quota/test_quota_single_brick_volume.py b/tests/functional/quota/test_quota_single_brick_volume.py
new file mode 100644
index 0000000..c6d0bbf
--- /dev/null
+++ b/tests/functional/quota/test_quota_single_brick_volume.py
@@ -0,0 +1,159 @@
+# 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.
+
+from glusto.core import Glusto as g
+from glustolibs.gluster.gluster_base_class import (GlusterBaseClass,
+ runs_on)
+from glustolibs.gluster.quota_ops import (enable_quota,
+ set_quota_limit_usage,
+ get_quota_list)
+from glustolibs.io.utils import list_all_files_and_dirs_mounts
+from glustolibs.gluster.exceptions import ExecutionError
+from glustolibs.misc.misc_libs import upload_scripts
+from glustolibs.io.utils import validate_io_procs
+
+
+@runs_on([['distributed'], ['glusterfs', 'nfs', 'cifs']])
+class QuotaListPathValues(GlusterBaseClass):
+
+ @classmethod
+ def setUpClass(cls):
+ """
+ setup volume, mount volume and initialize necessary variables
+ which is used in tests
+ """
+
+ # calling GlusterBaseClass setUpClass
+ GlusterBaseClass.setUpClass.im_func(cls)
+
+ # Upload io scripts for running IO on mounts
+ g.log.info("Upload io scripts to clients %s for running IO on mounts",
+ cls.clients)
+ script_local_path = ("/usr/share/glustolibs/io/scripts/"
+ "file_dir_ops.py")
+ cls.script_upload_path = ("/usr/share/glustolibs/io/scripts/"
+ "file_dir_ops.py")
+ ret = upload_scripts(cls.clients, [script_local_path])
+ if not ret:
+ raise ExecutionError("Failed to upload IO scripts to clients")
+ g.log.info("Successfully uploaded IO scripts to clients %s",
+ cls.clients)
+
+ # Overriding the volume type to specifically test the volume type
+ if cls.volume_type == "distributed":
+ cls.volume['voltype'] = {
+ 'type': 'distributed',
+ 'dist_count': 1,
+ 'transport': 'tcp'}
+
+ # Setup Volume and Mount Volume
+ g.log.info("Starting to Setup and Mount Volume %s",
+ cls.volname)
+ ret = cls.setup_volume_and_mount_volume(mounts=cls.mounts)
+ if not ret:
+ raise ExecutionError("Failed to Setup_Volume and Mount_Volume")
+ g.log.info("Successful in Setup and Mount Volume %s", cls.volname)
+
+ @classmethod
+ def tearDownClass(cls):
+ """
+ Clean up the volume and umount volume from client
+ """
+
+ # stopping the volume
+ g.log.info("Starting to Unmount Volume and Cleanup Volume")
+ ret = cls.unmount_volume_and_cleanup_volume(mounts=cls.mounts)
+ if not ret:
+ raise ExecutionError("Failed to Unmount Volume and Cleanup Volume")
+ g.log.info("Successful in Unmount Volume and Cleanup Volume")
+
+ # calling GlusterBaseClass tearDownClass
+ GlusterBaseClass.tearDownClass.im_func(cls)
+
+ def test_quota_single_brick_volume(self):
+ """
+ Verifying directory quota functionality on a single brick volume.
+
+ * Create a volume with single brick (1x1) start and mount it
+ * Enable quota on the volume
+ * Set a limit of 1GB on this volume
+ * Create some directories and files in the mount point
+ * Execute a quota list command
+
+ """
+
+ # Enable Quota
+ g.log.info("Enabling quota on the volume %s", self.volname)
+ ret, _, _ = enable_quota(self.mnode, self.volname)
+ self.assertEqual(ret, 0, ("Failed to enable quota on the "
+ "volume %s", self.volname))
+ g.log.info("Successfully enabled quota on the volume %s", self.volname)
+
+ # Path to set quota limit
+ path = "/"
+
+ # Set Quota limit on the root of the volume
+ g.log.info("Set Quota Limit on the path %s of the volume %s",
+ path, self.volname)
+ ret, _, _ = set_quota_limit_usage(self.mnode, self.volname,
+ path=path, limit="1GB")
+ self.assertEqual(ret, 0, ("Failed to set quota limit on path %s of "
+ "the volume %s", path, self.volname))
+ g.log.info("Successfully set the Quota limit on %s of the volume %s",
+ path, self.volname)
+
+ # Starting IO on the mounts
+ all_mounts_procs = []
+ count = 1
+ for mount_obj in self.mounts:
+ g.log.info("Starting IO on %s:%s", mount_obj.client_system,
+ mount_obj.mountpoint)
+ cmd = ("python %s create_deep_dirs_with_files "
+ "--dirname-start-num %d "
+ "--dir-depth 2 "
+ "--dir-length 20 "
+ "--max-num-of-dirs 5 "
+ "--num-of-files 5 %s" % (self.script_upload_path,
+ count,
+ mount_obj.mountpoint))
+ proc = g.run_async(mount_obj.client_system, cmd,
+ user=mount_obj.user)
+ all_mounts_procs.append(proc)
+ count = count + 10
+
+ # Validate IO
+ g.log.info("Validating IO's")
+ ret = validate_io_procs(all_mounts_procs, self.mounts)
+ self.assertTrue(ret, "IO failed on some of the clients")
+ g.log.info("Successfully validated all io's")
+
+ # Get Quota list on Volume
+ g.log.info("Get Quota list for the volume %s", self.volname)
+ quota_list1 = get_quota_list(self.mnode, self.volname)
+ self.assertIsNotNone(quota_list1, ("Failed to get the quota list for "
+ "the volume %s", self.volname))
+ self.assertIn(path, quota_list1.keys(),
+ ("%s not part of the ""quota list %s even if "
+ "it is set on the volume %s", path,
+ quota_list1, self.volname))
+ g.log.info("Successfully listed quota list %s of the "
+ "volume %s", quota_list1, self.volname)
+
+ # List all files and dirs created
+ g.log.info("List all files and directories:")
+ ret = list_all_files_and_dirs_mounts(self.mounts)
+ self.assertTrue(ret, "Failed to list all files and dirs")
+ g.log.info("Listing all files and directories is successful")