summaryrefslogtreecommitdiffstats
path: root/tests/functional/quota
diff options
context:
space:
mode:
authorvenkata edara <redara@redhat.com>2018-02-01 18:37:40 +0530
committerJonathan Holloway <jholloway@redhat.com>2018-06-19 01:57:07 +0000
commit16fac017ad8e4450783783b24cd5fb6ba7297978 (patch)
tree0cfa18f197aebc4d07a966fb0df1ff77d776de89 /tests/functional/quota
parent30880d5b81b14796775761e28bac5f245a8d64d4 (diff)
Quota: Test Quota by renaming the dir.
This testcase will enable quota on dir of volume and rename it to other name and checks whether quota list is showing the renamed dir. Incorporated the changes made on the quota_ops and quota_libs. Change-Id: I7166a9810614c966a4a656b5e8976df55b102c01 Signed-off-by: venkata edara <redara@redhat.com> Signed-off-by: Vitalii Koriakov <vkoriako@redhat.com> Signed-off-by: Vinayak Papnoi <vpapnoi@redhat.com>
Diffstat (limited to 'tests/functional/quota')
-rwxr-xr-xtests/functional/quota/test_quota_renamed_dir.py130
1 files changed, 130 insertions, 0 deletions
diff --git a/tests/functional/quota/test_quota_renamed_dir.py b/tests/functional/quota/test_quota_renamed_dir.py
new file mode 100755
index 0000000..9f59d5e
--- /dev/null
+++ b/tests/functional/quota/test_quota_renamed_dir.py
@@ -0,0 +1,130 @@
+# Copyright (C) 2015-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 quota_enable, quota_limit_usage
+from glustolibs.gluster.quota_libs import quota_validate
+from glustolibs.gluster.glusterdir import mkdir
+from glustolibs.gluster.glusterfile import move_file
+from glustolibs.gluster.exceptions import ExecutionError
+
+
+@runs_on([['distributed-replicated', 'replicated', 'dispersed', 'distributed',
+ 'distributed-dispersed'],
+ ['glusterfs', 'nfs']])
+class TestQuotaRenamedDir(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)
+
+ # 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 %s"
+ % cls.volname)
+ 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_with_renamed_dir(self):
+ """
+ Verifying directory quota functionality with respect to
+ the limit-usage option.
+ If a directory has limit set on it and the same directory is renamed ,
+ then on doing a quota list the changed name should be reflected.
+
+ * Enable quota on volume
+ * Create a directory 'foo' from client
+ * Set quota limit of 1GB on /foo
+ * Check if quota limit set is correct
+ * Rename directory 'foo' to 'bar' from client
+ * Check if quota limit set on 'bar' is same as before
+ """
+
+ # Enable Quota on the volume
+ g.log.info("Enabling Quota on the volume %s", self.volname)
+ ret, _, _ = quota_enable(self.mnode, self.volname)
+ self.assertFalse(ret, "Failed to enable Quota on volume %s"
+ % self.volname)
+
+ # Create a directory named 'foo' under any mount dir
+ mount_obj = self.mounts[0]
+ mount_dir = mount_obj.mountpoint
+ client = mount_obj.client_system
+
+ g.log.info("Creating dir named 'foo' from client %s", client)
+ ret = mkdir(client, "%s/foo" % mount_dir)
+ self.assertTrue(ret, "Failed to create dir under %s-%s"
+ % (client, mount_dir))
+ g.log.info("Directory 'foo' created successfully")
+
+ # Set Quota Limit of 1GB for dir foo
+ g.log.info("Setting a quota limit of 1GB on directory 'foo' inside "
+ "volume %s", self.volname)
+ ret, _, _ = quota_limit_usage(self.mnode, self.volname,
+ "/foo", '1GB')
+ self.assertFalse(ret, "Failed to set Quota for dir '/foo'")
+ g.log.info("Set quota for dir '/foo' successfully")
+
+ # Get the Quota list and check '/foo' has Quota Limit of 1GB
+ g.log.info("Validating if the Quota limit set is correct for the "
+ "path '/foo' in volume %s", self.volname)
+ ret = quota_validate(self.mnode, self.volname, path="/foo",
+ hard_limit=1073741824)
+ self.assertTrue(ret, ("Quota Limit of 1GB was not set properly on the "
+ "path /foo' in volume %s", self.volname))
+ g.log.info("Successfully Validated Quota Limit of 1GB is set on the "
+ "path '/foo' in volume %s", self.volname)
+
+ # Rename the dir foo to bar
+ g.log.info("Renaming dir named 'foo' to 'bar' from client %s", client)
+ ret = move_file(client, "%s/foo" % (mount_dir), "%s/bar" % (mount_dir))
+ self.assertTrue(ret, "Failed to rename the directory 'foo' under "
+ "%s-%s" % (client, mount_dir))
+ g.log.info("Renamed the directory 'foo' to 'bar' successfully")
+
+ # Again get the quota list to check if directory /bar is present
+ g.log.info("Validating if the Quota limit set is correct for the "
+ "path '/bar' in volume %s", self.volname)
+ ret = quota_validate(self.mnode, self.volname, path="/bar",
+ hard_limit=1073741824)
+ self.assertTrue(ret, ("Failed to validate quota limit on the directory"
+ " 'bar'"))
+ g.log.info("Successfully Validated Quota Limit of 1GB is set on the "
+ "path '/bar' in volume %s", self.volname)