summaryrefslogtreecommitdiffstats
path: root/tests/functional/afr
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2018-06-25 16:22:31 +0530
committerVijay Avuthu <vavuthu@redhat.com>2018-07-01 12:32:23 +0000
commit99ced148be3c1429a1f9832bc375aa5b2be50720 (patch)
tree2390d3c29c610a89839923b81d1a95ea3b180552 /tests/functional/afr
parent727030e14feb8c58109668e50ba34b049d18d9f9 (diff)
afr: test readlink fop
Polarion test case #RHG3-4094 Signed-off-by: Ravishankar N <ravishankar@redhat.com> Change-Id: I1f7100ddb6697cfc8749f8cd2c29e14e9bfdb5ce
Diffstat (limited to 'tests/functional/afr')
-rw-r--r--tests/functional/afr/test_readlink.py125
1 files changed, 125 insertions, 0 deletions
diff --git a/tests/functional/afr/test_readlink.py b/tests/functional/afr/test_readlink.py
new file mode 100644
index 0000000..0f2b34b
--- /dev/null
+++ b/tests/functional/afr/test_readlink.py
@@ -0,0 +1,125 @@
+# Copyright (C) 2015-2016 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.brick_libs import get_all_bricks
+from glustolibs.gluster.exceptions import ExecutionError
+from glustolibs.gluster.gluster_base_class import GlusterBaseClass, runs_on
+from glustolibs.misc.misc_libs import upload_scripts
+from glustolibs.gluster.glusterfile import get_file_stat
+
+
+@runs_on([['replicated'],
+ ['glusterfs']])
+class AfrReadlinkTest(GlusterBaseClass):
+ """
+ Description:
+ Test Case which tests the working of FOPS in AFR.
+ """
+ @classmethod
+ def setUpClass(cls):
+ # Calling GlusterBaseClass setUpClass
+ GlusterBaseClass.setUpClass.im_func(cls)
+
+ # Override replica count to be 3
+ if cls.volume_type == "replicated":
+ cls.volume['voltype'] = {
+ 'type': 'replicated',
+ 'replica_count': 3,
+ 'transport': 'tcp'}
+
+ # 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_abs_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_abs_path)
+ if not ret:
+ raise ExecutionError("Failed to upload IO scripts to clients")
+
+ def setUp(self):
+ # Calling GlusterBaseClass setUp
+ GlusterBaseClass.setUp.im_func(self)
+
+ # Setup Volume and Mount Volume
+ g.log.info("Starting to Setup Volume and Mount Volume")
+ ret = self.setup_volume_and_mount_volume(mounts=self.mounts,
+ volume_create_force=False)
+ if not ret:
+ raise ExecutionError("Failed to Setup_Volume and Mount_Volume")
+ g.log.info("Successful in Setup Volume and Mount Volume")
+
+ self.bricks_list = get_all_bricks(self.mnode, self.volname)
+ self.assertIsNotNone(self.bricks_list, "unable to get list of bricks")
+
+ def tearDown(self):
+ # Cleanup and umount volume
+ g.log.info("Starting to Unmount Volume and Cleanup Volume")
+ ret = self.unmount_volume_and_cleanup_volume(mounts=self.mounts)
+ if not ret:
+ raise ExecutionError("Failed to umount the vol & cleanup Volume")
+ g.log.info("Successful in umounting the volume and Cleanup")
+
+ # Calling GlusterBaseClass teardown
+ GlusterBaseClass.tearDown.im_func(self)
+
+ def test_readlink(self):
+ # create file
+ g.log.info("Creating %s/file.txt", self.mounts[0].mountpoint)
+ cmd = ("echo 'hello_world' > %s/file.txt" % self.mounts[0].mountpoint)
+ ret, _, _ = g.run(self.clients[0], cmd)
+ self.assertEqual(ret, 0, "File creation failed")
+ g.log.info("Created %s/file.txt", self.mounts[0].mountpoint)
+
+ # create symlink
+ g.log.info("Creating %s/symlink.txt to %s/file.txt",
+ self.mounts[0].mountpoint, self.mounts[0].mountpoint)
+ cmd = ("ln -s file.txt %s/symlink.txt" % self.mounts[0].mountpoint)
+ ret, _, _ = g.run(self.clients[0], cmd)
+ self.assertEqual(ret, 0, "symlink creation failed")
+ g.log.info("Created %s/symlink.txt to %s/file.txt",
+ self.mounts[0].mountpoint, self.mounts[0].mountpoint)
+
+ # stat symlink on mount and verify file type and permission.
+ g.log.info("Checking file permissions")
+ path = ("%s/symlink.txt" % self.mounts[0].mountpoint)
+ stat_dict = get_file_stat(self.clients[0], path)
+ self.assertEqual(stat_dict['filetype'], 'symbolic link', "Expected "
+ "symlink but found %s" % stat_dict['filetype'])
+ self.assertEqual(stat_dict['access'], '777', "Expected 777 "
+ "but found %s" % stat_dict['access'])
+ g.log.info("File permissions for symlink.txt is 777 as expected")
+
+ # readlink to verify contents
+ g.log.info("Performing readlink on %s/symlink.txt",
+ self.mounts[0].mountpoint)
+ cmd = ("readlink %s/symlink.txt" % self.mounts[0].mountpoint)
+ _, val, _ = g.run(self.clients[0], cmd)
+ content = val.strip()
+ self.assertEqual(content, "file.txt", "Readlink error:got %s"
+ % content)
+ g.log.info("readlink returned 'file.txt' as expected")
+
+ # stat symlink on bricks and verify file type and permission.
+ g.log.info("Checking file type and permissions on bricks")
+ for brick in self.bricks_list:
+ node, path = brick.split(':')
+ filepath = path + "/symlink.txt"
+ stat_dict = get_file_stat(node, filepath)
+ self.assertEqual(stat_dict['filetype'], 'symbolic link', "Expected"
+ " symlink but found %s" % stat_dict['filetype'])
+ g.log.info("file permission 777 for symlink.txt on %s", brick)