def test_gfind_list_cli(self): """ Verifying the glusterfind list command functionality with valid and invalid values for the required and optional parameters. * Create a volume * Create a session on the volume and call glusterfind list with the following combinations: - Valid values for optional parameters - Invalid values for optional parameters NOTE: There are no required parameters for glusterfind list command. """ # Creating a glusterfind session self.session = "session1" ret, _, _ = gfind_create(self.mnode, self.volname, self.session) self.assertEqual( ret, 0, "Glusterfind session creation for the " "volume %s failed" % self.volname) # Checking output of glusterfind list ret, out, _ = gfind_list(self.mnode) self.assertEqual(ret, 0, "Glusterfind list failed") self._check_glusterfind_list_output(out) g.log.info("glusterfind list cmd validation without any param passed") # Check output for glusterfind list with valid and invalid volume name for volume, expected_value, validation in ((self.volname, 0, 'valid'), ("abc", 1, 'invalid')): ret, out, _ = gfind_list(self.mnode, volname=volume) self.assertEqual( ret, expected_value, "Glusterfind list --volume check with %s " "parameter failed" % validation) if not ret: self._check_glusterfind_list_output(out) g.log.info("glusterind list cmd check with --volume param passed") # Check output for glusterfind list with valid and invalid session name for session, expected_value, validation in ((self.session, 0, 'valid'), ("abc", 1, 'invalid')): ret, out, _ = gfind_list(self.mnode, sessname=session) self.assertEqual( ret, expected_value, "Glusterfind list --session check with %s " "parameter failed" % validation) if not ret: self._check_glusterfind_list_output(out) g.log.info("glusterfind list cmd check with --session param passed") # Check output of glusterind list with debug parameter ret, _, _ = gfind_list(self.mnode, debug=True) self.assertEqual(ret, 0, "Glusterfind list --debug parameter failed") g.log.info("glusterfind list cmd check with --debug param passed")
def test_gfind_when_brick_down(self): """ Verifying the glusterfind functionality when a brick is down. 1. Create a volume 2. Create a session on the volume 3. Create various files from mount point 4. Bring down brick process on one of the node 5. Perform glusterfind pre 6. Perform glusterfind post 7. Check the contents of outfile """ # pylint: disable=too-many-statements # Create a session for the volume 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 _, out, _ = gfind_list(self.mnode, volname=self.volname, sessname=self.session) self.assertNotEqual(out, "No sessions found.", "Failed to list the glusterfind session") g.log.info("Successfully listed the glusterfind session") self._perform_io_and_validate_presence_of_files() # Wait for changelog to get updated sleep(2) # Bring one of the brick down. brick_list = get_all_bricks(self.mnode, self.volname) ret = bring_bricks_offline(self.volname, choice(brick_list)) self.assertTrue(ret, "Failed to bring down the brick.") g.log.info("Succesfully brought down one brick.") self._perform_glusterfind_pre_and_validate_outfile() # Perform glusterfind post for the 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") # Bring the brick process up. ret = volume_start(self.mnode, self.volname, force=True) self.assertTrue(ret, "Failed to start the volume.") g.log.info("Successfully started the volume.")
def test_gfind_when_node_down(self): """ Verifying the glusterfind functionality when node is down. 1. Create a volume 2. Create a session on the volume 3. Create various files from mount point 4. Bring down glusterd on one of the node 5. Perform glusterfind pre 6. Perform glusterfind post 7. Check the contents of outfile 8. Create more files from mountpoint 9. Reboot one of the nodes 10. Perform gluserfind pre 11. Perform glusterfind post 12. Check the contents of outfile """ # pylint: disable=too-many-statements # Create a session for the volume 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 _, out, _ = gfind_list(self.mnode, volname=self.volname, sessname=self.session) self.assertNotEqual(out, "No sessions found.", "Failed to list the glusterfind session") g.log.info("Successfully listed the glusterfind session") self._perform_io_and_validate_presence_of_files() # Wait for changelog to get updated sleep(2) # Bring one of the node down. self.random_server = choice(self.servers[1:]) ret = stop_glusterd(self.random_server) self.assertTrue(ret, "Failed to stop glusterd on one node.") g.log.info("Succesfully stopped glusterd on one node.") # Wait till glusterd is completely down. while is_glusterd_running(self.random_server) != 1: sleep(2) self._perform_glusterfind_pre_and_validate_outfile() # Perform glusterfind post for the 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") # Bring glusterd which was downed on a random node, up. ret = start_glusterd(self.random_server) self.assertTrue(ret, "Failed to start glusterd on %s" % self.random_server) g.log.info("Successfully started glusterd on node : %s", self.random_server) # Waiting for glusterd to start completely. ret = wait_for_glusterd_to_start(self.random_server) self.assertTrue(ret, "glusterd is not running on %s" % self.random_server) g.log.info("glusterd is started and running on %s", self.random_server) self._perform_io_and_validate_presence_of_files() # Perform IO self._perform_io_and_validate_presence_of_files() # Wait for changelog to get updated sleep(2) # Reboot one of the nodes. self.random_server = choice(self.servers[1:]) ret = reboot_nodes(self.random_server) self.assertTrue(ret, "Failed to reboot the said node.") g.log.info("Successfully started reboot process on one node.") self._perform_glusterfind_pre_and_validate_outfile() # Perform glusterfind post for the 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") # Gradual sleep backoff till the node has rebooted. counter = 0 timeout = 300 ret = False while counter < timeout: ret, _ = are_nodes_online(self.random_server) if not ret: g.log.info("Node's offline, Retrying after 5 seconds ...") sleep(5) counter += 5 else: ret = True break self.assertTrue(ret, "Node is still offline.") g.log.info("Rebooted node is online") # Wait for glusterd to start completely ret = wait_for_glusterd_to_start(self.random_server) self.assertTrue(ret, "glusterd is not running on %s" % self.random_server) g.log.info("glusterd is started and running on %s", self.random_server)
def test_gfind_modify(self): """ Verifying the glusterfind functionality with deletion of files. * Create a volume * Create a session on the volume * Create various files from mount point * Perform glusterfind pre * Perform glusterfind post * Check the contents of outfile * Modify the contents of the files from mount point * Perform glusterfind pre * Perform glusterfind post * Check the contents of outfile Files modified must be listed """ # pylint: disable=too-many-statements # Create a session for the volume 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 _, out, _ = gfind_list(self.mnode, volname=self.volname, sessname=self.session) self.assertNotEqual(out, "No sessions found.", "Failed to list the glusterfind session") g.log.info("Successfully listed the glusterfind session") # Starting IO on the mounts cmd = "cd %s ; touch file{1..10}" % self.mounts[0].mountpoint ret, _, _ = g.run(self.mounts[0].client_system, cmd) self.assertEqual(ret, 0, "Failed to create files on mountpoint") g.log.info("Files created successfully on mountpoint") # Gather the list of files from the mount point files = list_files(self.mounts[0].client_system, self.mounts[0].mountpoint) self.assertIsNotNone(files, "Failed to get the list of files") g.log.info("Successfully gathered the list of files from mount point") # Check if the files exist for filename in files: ret = file_exists(self.mounts[0].client_system, filename) self.assertTrue(ret, ("Unexpected: File '%s' does not exist" % filename)) g.log.info("Successfully validated existence of '%s'", filename) # Wait for changelog to get updated sleep(2) # Perform glusterfind pre for the session ret, _, _ = gfind_pre(self.mnode, self.volname, self.session, self.outfiles[0], 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 ret = file_exists(self.mnode, self.outfiles[0]) self.assertTrue(ret, ("Unexpected: File '%s' does not exist" % self.outfiles[0])) g.log.info("Successfully validated existence of '%s'", self.outfiles[0]) # 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.outfiles[0]) self.assertEqual(ret, 0, ("File 'file%s' not listed in %s" % (i, self.outfiles[0]))) g.log.info("File 'file%s' listed in %s", i, self.outfiles[0]) # Perform glusterfind post for the 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") # Modify the files created from mount point mod_string = "this is a test string\n" for filenum in files: ret = append_string_to_file(self.mounts[0].client_system, filenum, mod_string) self.assertTrue(ret, "Failed to append to file '%s'" % filenum) g.log.info("Successfully modified all the files") # Check if the files modified exist from mount point for filenum in files: ret = check_if_pattern_in_file(self.mounts[0].client_system, mod_string, filenum) self.assertEqual(ret, 0, ("Unexpected: File '%s' does not contain" " the string '%s' after being modified" % (filenum, mod_string))) g.log.info("Successfully validated '%s' is modified", filenum) # Wait for changelog to get updated sleep(2) # Perform glusterfind pre for the session ret, _, _ = gfind_pre(self.mnode, self.volname, self.session, self.outfiles[1], debug=True) self.assertEqual(ret, 0, ("Failed to perform glusterfind pre")) g.log.info("Successfully performed glusterfind pre") # Check if the outfile exists ret = file_exists(self.mnode, self.outfiles[1]) self.assertTrue(ret, ("Unexpected: File '%s' does not exist" % self.outfiles[1])) g.log.info("Successfully validated existence of outfile '%s'", self.outfiles[1]) # Check if all the files are listed in the outfile for num in range(1, 11): pattern = "MODIFY file%s" % num ret = check_if_pattern_in_file(self.mnode, pattern, self.outfiles[1]) self.assertEqual(ret, 0, ("File 'file%s' not listed in '%s'" % (num, self.outfiles[1]))) g.log.info("File 'file%s' listed in '%s'", num, self.outfiles[1])
def test_gfind_full_type(self): """ Verifying the glusterfind --full functionality with --type f, --type f and --type both * Create a volume * Create a session on the volume * Create various files on mount point * Create various directories on point * Perform glusterfind pre with --full --type f --regenerate-outfile * Check the contents of outfile * Perform glusterfind pre with --full --type d --regenerate-outfile * Check the contents of outfile * Perform glusterfind pre with --full --type both --regenerate-outfile * Check the contents of outfile * Perform glusterfind query with --full --type f * Check the contents of outfile * Perform glusterfind query with --full --type d * Check the contents of outfile * Perform glusterfind query with --full --type both * Check the contents of outfile """ # Create some files and directories from the mount point cmd = ("cd {}; mkdir dir;mkdir .hiddendir;touch file;touch .hiddenfile" ";mknod blockfile b 1 5;mknod charfile b 1 5; mkfifo pipefile;" "touch fileforhardlink;touch fileforsoftlink;" "ln fileforhardlink hardlinkfile;ln -s fileforsoftlink " "softlinkfile".format(self.mounts[0].mountpoint)) ret, _, _ = g.run(self.mounts[0].client_system, cmd) # Create list of files and dir to be used for checking self.list_of_files = [ 'file', '.hiddenfile', 'blockfile', 'charfile', 'pipefile', 'fileforhardlink', 'fileforsoftlink', 'hardlinkfile', 'softlinkfile' ] self.list_of_dirs = ['dir', '.hiddendir'] self.assertEqual(ret, 0, "Failed to create files and dirs") g.log.info("Files and Dirs created successfully on mountpoint") # Create session for volume 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 _, out, _ = gfind_list(self.mnode, volname=self.volname, sessname=self.session) self.assertNotEqual(out, "No sessions found.", "Failed to list the glusterfind session") g.log.info("Successfully listed the glusterfind session") # Perform glusterfind full pre for the session with --type option for gftype in ('f', 'd', 'both'): ret, _, _ = gfind_pre(self.mnode, self.volname, self.session, self.outfile, full=True, gftype=gftype, regenoutfile=True) self.assertEqual( ret, 0, "glusterfind pre command successful " "with --type %s" % gftype) # Check the contents of the outfile self._check_contents_of_outfile(gftype) # Perform glusterfind full query with the --type option for gftype in ('f', 'd', 'both'): ret, _, _ = gfind_query(self.mnode, self.volname, self.outfile, full=True, gftype=gftype) self.assertEqual( ret, 0, "glusterfind query command successful " "with --type %s" % gftype) # Check the contents of the outfile self._check_contents_of_outfile(gftype)
def test_gfind_deletes(self): """ Verifying the glusterfind functionality with deletion of files. * Create a volume * Create a session on the volume * Create various files from mount point * Perform glusterfind pre * Perform glusterfind post * Check the contents of outfile * Delete the files created from mount point * Perform glusterfind pre * Perform glusterfind post * Check the contents of outfile Files deleted must be listed """ # 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 g.log.info("Creating Files on %s:%s", self.mounts[0].client_system, self.mounts[0].mountpoint) cmd = ("cd %s ; for i in `seq 1 10` ; " "do dd if=/dev/urandom of=file$i bs=1M count=1 ; " "done" % self.mounts[0].mountpoint) ret, _, _ = g.run(self.mounts[0].client_system, 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(self.mounts[0].client_system, '%s/file%s' % (self.mounts[0].mountpoint, i)) self.assertTrue(ret, "Unexpected: File 'file%s' does not exist" % i) g.log.info("Successfully validated existence of 'file%s'", i) sleep(5) # 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.outfiles[0], 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.outfiles[0]) self.assertTrue( ret, "Unexpected: File '%s' does not exist" % self.outfiles[0]) g.log.info("Successfully validated existence of '%s'", self.outfiles[0]) # 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.outfiles[0]) self.assertEqual(ret, 0, ("File 'file%s' not listed in %s" % (i, self.outfiles[0]))) g.log.info("File 'file%s' listed in %s", i, self.outfiles[0]) # 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") # Delete the files created from mount point g.log.info("Deleting the Files on %s:%s", self.mounts[0].client_system, self.mounts[0].mountpoint) for i in range(1, 11): ret = remove_file(self.mounts[0].client_system, "%s/file%s" % (self.mounts[0].mountpoint, i), force=True) self.assertTrue(ret, "Failed to delete file%s" % i) g.log.info("Successfully deleted all the files") # Check if the files deleted exist from mount point g.log.info("Checking the existence of files that were deleted " "(must not be present)") for i in range(1, 11): ret = file_exists(self.mounts[0].client_system, '%s/file%s' % (self.mounts[0].mountpoint, i)) self.assertFalse( ret, "Unexpected: File 'file%s' exists even after" " being deleted" % i) g.log.info("Successfully validated 'file%s' does not exist", i) sleep(5) # 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.outfiles[1], 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.outfiles[1]) self.assertTrue( ret, "Unexpected: File '%s' does not exist" % self.outfiles[1]) g.log.info("Successfully validated existence of '%s'", self.outfiles[1]) # Check if all the files are listed in the outfile for i in range(1, 11): pattern = "DELETE file%s" % i ret = check_if_pattern_in_file(self.mnode, pattern, self.outfiles[1]) self.assertEqual(ret, 0, ("File 'file%s' not listed in %s" % (i, self.outfiles[1]))) g.log.info("File 'file%s' listed in %s", i, self.outfiles[1])
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")
def test_gfind_delete_cli(self): """ Verifying the glusterfind delete command functionality with valid and invalid values for the required and optional parameters. * Create a volume * Create a session on the volume * Perform glusterfind list to check if session is created * Delete the glusterfind session 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 list to check if session is deleted Required parameters: volname and sessname Optional parameters: debug """ # 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") # Delete the glusterfind session using the invalid values for optional # parameters g.log.info("Deleting the session with invalid values for the optional " "parameters") ret, _, _ = g.run(self.mnode, ("glusterfind delete %s %s --dbug" % (self.volname, self.session))) self.assertNotEqual( ret, 0, "Unexpected: glusterfind session deleted " "even with invalid value for optional parameters") g.log.info("Successful: glusterfind delete failed with invalid value " "for optional parameters") # Delete the glusterfind session using the valid values for required # and optional parameters g.log.info("Deleting the session with valid values for the required " "and optional parameters") ret, _, _ = gfind_delete(self.mnode, self.volname, self.session, debug=True) self.assertEqual( ret, 0, "Unexpected: Failed to delete the session " "using the valid values for the required and " "optional parameters") g.log.info("Successfully deleted the session using valid values for " "required and optional parameters") # Perform glusterfind list to check if the session exists g.log.info("Performing glusterfind list to validate that the session " "is deleted") ret, _, _ = gfind_list(self.mnode, volname=self.volname, sessname=self.session) self.assertNotEqual( ret, 0, "Unexpected: glusterfind sessions is being" " listed even after being deleted") g.log.info("Successful: No glusterfind session is listed")
def test_gfind_create_cli(self): """ Verifying the glusterfind create command functionality with valid and invalid values for the required and optional parameters. * Create a volume * Create a session on the volume with the following combinations: - Valid values for required parameters - Invalid values for required parameters - Valid values for optional parameters - Invalid values for optional parameters Required parameters: volname and sessname Optional parameters: debug, force, reset-session-time """ # pylint: disable=too-many-statements # Create a session with valid inputs for required parameters session1 = 'validsession' g.log.info( "Creating a session for the volume %s with valid values" "for the required parameters", self.volname) ret, _, _ = gfind_create(self.mnode, self.volname, session1) self.assertEqual(ret, 0, ("Unexpected: Creation of a session for the " "volume %s failed", self.volname)) g.log.info("Successful in validating the glusterfind create command " "with valid values for required parameters") # Create a session with invalid inputs for required parameters session2 = 'invalidsession' g.log.info("Creating a session with invalid values for the " "required parameters") ret, _, _ = gfind_create(self.mnode, 'invalidvolumename', session2) self.assertNotEqual(ret, 0, ("Unexpected: Creation of a session is " "Successful with invalid values")) g.log.info("Successful in validating the glusterfind create command " "with invalid values for required parameters") # Create a session with valid inputs for optional parameters session3 = 'validoptsession' g.log.info( "Creating a session for the volume %s with valid values" "for the optional parameters", self.volname) ret, _, _ = gfind_create(self.mnode, self.volname, session3, force=True, resetsesstime=True, debug=True) self.assertEqual(ret, 0, ("Unexpected: Creation of a session for the " "volume %s failed", self.volname)) g.log.info("Successful in validating the glusterfind create command " "with valid values for optional parameters") # Create a session with invalid inputs for optional parameters session4 = 'invalidoptsession' g.log.info("Creating a session with invalid values for the " "optional parameters") cmd = ("glusterfind create %s %s --debg --frce --resetsessiontime" % (session4, self.volname)) ret, _, _ = g.run(self.mnode, cmd) self.assertNotEqual(ret, 0, ("Unexpected: Creation of a session is " "Successful with invalid values")) g.log.info("Successful in validating the glusterfind create command " "with invalid values for required parameters")