summaryrefslogtreecommitdiffstats
path: root/tests/functional/afr
diff options
context:
space:
mode:
authorVitalii Koriakov <vkoriako@redhat.com>2018-02-16 16:41:02 +0200
committerVitalii Koriakov <vkoriako@redhat.com>2018-03-28 15:43:08 +0300
commit8d915c9b2a1dcc4ff6f96d112f3c534c8a219b36 (patch)
tree2cf2118018a353f7cba1924974dd0c8bce20a517 /tests/functional/afr
parent1c566e0bf28089727a31ada1b5d640c92c165b11 (diff)
Test client side quorum with auto option for a x2 volume and client quorum as auto first brick must be up to have a rw filesystem in a x2 volume
Change-Id: I98b0808070e6d254b1deeb1a3a744d19adccbf03 Signed-off-by: Vitalii Koriakov <vkoriako@redhat.com>
Diffstat (limited to 'tests/functional/afr')
-rwxr-xr-x[-rw-r--r--]tests/functional/afr/test_client_side_quorum.py285
1 files changed, 285 insertions, 0 deletions
diff --git a/tests/functional/afr/test_client_side_quorum.py b/tests/functional/afr/test_client_side_quorum.py
index ba0aaa7..3c4cb78 100644..100755
--- a/tests/functional/afr/test_client_side_quorum.py
+++ b/tests/functional/afr/test_client_side_quorum.py
@@ -350,6 +350,291 @@ class ClientSideQuorumTests(GlusterBaseClass):
"in replica set", options, self.volname)
+@runs_on([['replicated', 'distributed-replicated'],
+ ['glusterfs', 'nfs', 'cifs']])
+class ClientSideQuorumCross2Tests(GlusterBaseClass):
+ """
+ ClientSideQuorumTests contains tests which verifies the
+ client side quorum Test Cases
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ # 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 %s"
+ % cls.clients)
+ g.log.info("Successfully uploaded IO scripts to clients %s"
+ % cls.clients)
+
+ cls.counter = 1
+ """int: Value of counter is used for dirname-start-num argument for
+ file_dir_ops.py create_deep_dirs_with_files.
+
+ The --dir-length argument value for
+ file_dir_ops.py create_deep_dirs_with_files is set to 10
+ (refer to the cmd in setUp method). This means every mount will create
+ 10 top level dirs. For every mountpoint/testcase to create new set of
+ dirs, we are incrementing the counter by --dir-length value i.e 10
+ in this test suite.
+
+ If we are changing the --dir-length to new value, ensure the counter
+ is also incremented by same value to create new set of files/dirs.
+ """
+
+ # Override Volumes
+ if cls.volume_type == "distributed-replicated":
+ # Define 2x2 distributed-replicated volume
+ cls.volume['voltype'] = {
+ 'type': 'distributed-replicated',
+ 'replica_count': 2,
+ 'dist_count': 2,
+ 'transport': 'tcp'}
+
+ if cls.volume_type == "replicated":
+ # Define x2 replicated volume
+ cls.volume['voltype'] = {
+ 'type': 'replicated',
+ 'replica_count': 2,
+ 'transport': 'tcp'}
+
+ def setUp(self):
+ """
+ setUp method for every test
+ """
+
+ # calling GlusterBaseClass setUp
+ GlusterBaseClass.setUp.im_func(self)
+
+ # Setup Volume and Mount Volume
+ g.log.info("Starting to Setup Volume %s" % self.volname)
+ ret = self.setup_volume_and_mount_volume(self.mounts)
+ if not ret:
+ raise ExecutionError("Failed to Setup_Volume and Mount_Volume")
+ g.log.info("Successful in Setup Volume and Mount Volume")
+
+ def tearDown(self):
+ """
+ tearDown for every test
+ """
+
+ # stopping the 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 Unmount Volume and Cleanup Volume")
+ g.log.info("Successful in Unmount Volume and Cleanup Volume")
+
+ # Calling GlusterBaseClass tearDown
+ GlusterBaseClass.tearDown.im_func(self)
+
+ def test_client_side_quorum_with_auto_option_cross2(self):
+ """
+ Test Script to verify the Client Side Quorum with auto option
+
+ * set cluster.quorum-type to auto.
+ * start I/O from the mount point.
+ * kill 2-nd brick process from the each and every replica set
+ * perform ops
+
+ """
+ # set cluster.quorum-type to auto
+ options = {"cluster.quorum-type": "auto"}
+ g.log.info("setting cluster.quorum-type to auto on "
+ "volume %s" % self.volname)
+ ret = set_volume_options(self.mnode, self.volname, options)
+ self.assertTrue(ret, ("Unable to set volume option %s for"
+ "volume %s" % (options, self.volname)))
+ g.log.info("Sucessfully set %s for volume %s"
+ % (options, self.volname))
+
+ # Start IO on mounts
+ g.log.info("Starting IO on all mounts...")
+ all_mounts_procs = []
+ 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_files "
+ "-f 10 --base-file-name file %s" % (self.script_upload_path,
+ mount_obj.mountpoint))
+ proc = g.run_async(mount_obj.client_system, cmd,
+ user=mount_obj.user)
+ all_mounts_procs.append(proc)
+
+ # Validate IO
+ g.log.info("Validating IO on mounts")
+ ret = validate_io_procs(all_mounts_procs, self.mounts)
+ self.assertTrue(ret, "IO failed on some of the clients")
+ g.log.info("IO is successful on all mounts")
+
+ # get the subvolumes
+ g.log.info("Starting to get sub-volumes for volume %s" % self.volname)
+ subvols_dict = get_subvols(self.mnode, self.volname)
+ num_subvols = len(subvols_dict['volume_subvols'])
+ g.log.info("Number of subvolumes in volume %s:" % num_subvols)
+
+ # bring 2-nd bricks offline for all the subvolumes
+ for i in range(0, num_subvols):
+ subvol_brick_list = subvols_dict['volume_subvols'][i]
+ g.log.info("sub-volume %s brick list : %s"
+ % (i, subvol_brick_list))
+ bricks_to_bring_offline = subvol_brick_list[1]
+ g.log.info("Going to bring down the brick process "
+ "for %s" % bricks_to_bring_offline)
+ ret = bring_bricks_offline(self.volname, bricks_to_bring_offline)
+ self.assertTrue(ret, ("Failed to bring down the bricks. Please "
+ "check the log file for more details."))
+ g.log.info("Brought down the brick process "
+ "for %s successfully" % bricks_to_bring_offline)
+
+ # create new file named newfile0.txt
+ g.log.info("Start creating new file on all mounts...")
+ all_mounts_procs = []
+ for mount_obj in self.mounts:
+ cmd = ("python %s create_files "
+ "-f 1 --base-file-name newfile %s" %
+ (self.script_upload_path, mount_obj.mountpoint))
+ proc = g.run_async(mount_obj.client_system, cmd,
+ user=mount_obj.user)
+ all_mounts_procs.append(proc)
+
+ # Validate IO
+ g.log.info("Validating IO on mounts")
+ ret = validate_io_procs(all_mounts_procs, self.mounts)
+ self.assertTrue(ret, "IO failed on some of the clients")
+ g.log.info("IO is successful on all mounts")
+
+ # create directory user1
+ g.log.info("Start creating directory on all mounts...")
+ all_mounts_procs = []
+ for mount_obj in self.mounts:
+ cmd = ("python %s create_deep_dir %s"
+ % (self.script_upload_path, mount_obj.mountpoint))
+ proc = g.run_async(mount_obj.client_system, cmd,
+ user=mount_obj.user)
+ all_mounts_procs.append(proc)
+
+ # Validate IO
+ g.log.info("Validating IO on mounts")
+ ret = validate_io_procs(all_mounts_procs, self.mounts)
+ self.assertTrue(ret, "IO failed on some of the clients")
+ g.log.info("IO is successful on all mounts")
+
+ # create h/w link to file
+ g.log.info("Start creating hard link for file0.txt on all mounts")
+ for mount_obj in self.mounts:
+ cmd = ("ln %s/file0.txt %s/file0.txt_hwlink"
+ % (mount_obj.mountpoint, mount_obj.mountpoint))
+ ret, out, err = g.run(mount_obj.client_system, cmd)
+ self.assertFalse(ret, 'Failed to create hard link '
+ 'for file0.txt on %s'
+ % mount_obj.mountpoint)
+ g.log.info("Hard link for file0.txt on %s is created successfully"
+ % mount_obj.mountpoint)
+
+ # create s/w link
+ g.log.info("Start creating soft link for file1.txt on all mounts")
+ for mount_obj in self.mounts:
+ cmd = ("ln -s %s/file1.txt %s/file1.txt_swlink"
+ % (mount_obj.mountpoint, mount_obj.mountpoint))
+ ret, out, err = g.run(mount_obj.client_system, cmd)
+ self.assertFalse(ret, 'Failed to create soft link '
+ 'for file1.txt on %s'
+ % mount_obj.mountpoint)
+ g.log.info("Soft link for file1.txt on %s is created successfully"
+ % mount_obj.mountpoint)
+
+ # append to file
+ g.log.info("Appending to file1.txt on all mounts")
+ for mount_obj in self.mounts:
+ cmd = ("cat %s/file0.txt >> %s/file1.txt"
+ % (mount_obj.mountpoint, mount_obj.mountpoint))
+ ret, out, err = g.run(mount_obj.client_system, cmd)
+ self.assertFalse(ret, 'Failed to append file1.txt on %s'
+ % mount_obj.mountpoint)
+ g.log.info("Appending for file1.txt on %s is successful"
+ % mount_obj.mountpoint)
+
+ # modify the file
+ g.log.info("Modifying file1.txt on all mounts")
+ for mount_obj in self.mounts:
+ cmd = ("echo 'Modify Contents' > %s/file1.txt"
+ % mount_obj.mountpoint)
+ ret, out, err = g.run(mount_obj.client_system, cmd)
+ self.assertFalse(ret, 'Failed to modify file1.txt on %s'
+ % mount_obj.mountpoint)
+ g.log.info("Modifying for file1.txt on %s is successful"
+ % mount_obj.mountpoint)
+
+ # truncate the file
+ g.log.info("Truncating file1.txt on all mounts")
+ for mount_obj in self.mounts:
+ cmd = "truncate -s 0 %s/file1.txt" % mount_obj.mountpoint
+ ret, out, err = g.run(mount_obj.client_system, cmd)
+ self.assertFalse(ret, 'Failed to truncate file1.txt on %s'
+ % mount_obj.mountpoint)
+ g.log.info("Truncating for file1.txt on %s is successful"
+ % mount_obj.mountpoint)
+
+ # read the file
+ g.log.info("Starting reading files on all mounts")
+ all_mounts_procs = []
+ for mount_obj in self.mounts:
+ cmd = ("python %s read %s"
+ % (self.script_upload_path, mount_obj.mountpoint))
+ proc = g.run_async(mount_obj.client_system, cmd,
+ user=mount_obj.user)
+ all_mounts_procs.append(proc)
+
+ # Validate IO
+ g.log.info("validating IO on all mounts")
+ ret = validate_io_procs(all_mounts_procs, self.mounts)
+ self.assertTrue(ret, "Reads failed on some of the clients")
+ g.log.info("Reads successful on all mounts")
+
+ # stat on file
+ g.log.info("stat on file1.txt on all mounts")
+ for mount_obj in self.mounts:
+ cmd = "stat %s/file1.txt" % mount_obj.mountpoint
+ ret, out, err = g.run(mount_obj.client_system, cmd)
+ self.assertFalse(ret, 'Failed to stat file1.txt on %s'
+ % mount_obj.mountpoint)
+ g.log.info("Stat for file1.txt on %s is successful"
+ % mount_obj.mountpoint)
+
+ # stat on dir
+ g.log.info("stat on directory on all mounts")
+ for mount_obj in self.mounts:
+ cmd = ("python %s stat %s"
+ % (self.script_upload_path, mount_obj.mountpoint))
+ ret, out, err = g.run(mount_obj.client_system, cmd)
+ self.assertFalse(ret, 'Failed to stat directory on %s'
+ % mount_obj.mountpoint)
+ g.log.info("Stat for directory on %s is successful"
+ % mount_obj.mountpoint)
+
+ # ls on mount point
+ g.log.info("ls on mount point on all mounts")
+ for mount_obj in self.mounts:
+ cmd = ("python %s ls %s"
+ % (self.script_upload_path, mount_obj.mountpoint))
+ ret, out, err = g.run(mount_obj.client_system, cmd)
+ self.assertFalse(ret, 'Failed to ls on %s'
+ % mount_obj.mountpoint)
+ g.log.info("ls for %s is successful" % mount_obj.mountpoint)
+
+
@runs_on([['distributed-replicated'],
['glusterfs']])
class ClientSideQuorumTestsMultipleVols(GlusterBaseClass):