def _perform_glusterfind_pre_and_validate_outfile(self): """ Function to perform glusterfind pre and validate outfile """ # 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, self.file_limit+1): 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])
def _check_contents_of_outfile(self, gftype): """Check contents of outfile created by query and pre""" if gftype == 'f': content = self.list_of_files elif gftype == 'd': content = self.list_of_dirs else: content = self.list_of_files + self.list_of_dirs # Check if outfile is created or not ret = file_exists(self.mnode, self.outfile) self.assertTrue(ret, "Unexpected: File '%s' does not exist" % self.outfile) for value in content: ret = check_if_pattern_in_file(self.mnode, value, self.outfile) self.assertEqual( ret, 0, "Entry for '%s' not listed in %s" % (value, self.outfile))
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_query_cli(self): """ Verifying the glusterfind query command functionality with valid and invalid values for the required and optional parameters. * Create a volume * Perform some I/O from the mount point * Perform glusterfind query with the following combinations: - Valid values for required parameters - Invalid values for required parameters - Valid values for optional parameters - Invalid values for optional parameters Where Required parameters: volname and sessname Optional parameters: debug """ # pylint: disable=too-many-statements # 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 query for the volume g.log.info("Performing glusterfind query using valid values for the " "required parameters") ret, _, _ = gfind_query(self.mnode, self.volname, self.outfile, full=True) self.assertEqual(ret, 0, "Failed to perform glusterfind query") g.log.info("Successfully performed glusterfind query") # Check if the outfile exists g.log.info("Checking if outfile created during glusterfind query " "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 query using the invalid values for required # parameters not_volume = 'invalid-volume-name-for-glusterfind-query' g.log.info("Performing glusterfind query using invalid values for " "required parameters") ret, _, _ = gfind_query(self.mnode, not_volume, self.outfile, since='none') self.assertNotEqual(ret, 0, "Unexpected: glusterfind query Successful " "even with invalid values for required parameters") g.log.info("Successful: glusterfind query failed with invalid values " "for required parameters") # Perform glusterfind query using the invalid values for optional # parameters g.log.info("Performing glusterfind query using invalid values for the " "optional parameters") invalid_options = [' --dbug', ' --noencod', ' --type n', ' --fll', ' --tagforfullfind', ' --disablepartial', ' --outprefix none', ' --namespc'] for opt in invalid_options: ret, _, _ = g.run(self.mnode, ("glusterfind query %s %s %s" % (self.volname, self.outfile, opt))) self.assertNotEqual(ret, 0, "Unexpected: glusterfind query " " Successful for option %s which is invalid" % opt) g.log.info("Successful: glusterfind query failed with invalid value " "for optional parameters")
def test_ec_open_fd(self): """ Test Steps: - disable server side heal - Create a file - Set volume option to implement open FD on file - Bring a brick down,say b1 - Open FD on file - Bring brick b1 up - write to open FD file - Monitor heal - Check xattr , ec.version and ec.size of file - Check stat of file """ # pylint: disable=too-many-branches,too-many-statements,too-many-locals mountpoint = self.mounts[0].mountpoint # Disable server side heal ret = disable_heal(self.mnode, self.volname) self.assertTrue(ret, ("Failed to disable server side heal")) g.log.info("Successfully disabled server side heal") # Log Volume Info and Status after disabling server side heal ret = log_volume_info_and_status(self.mnode, self.volname) self.assertTrue(ret, ("Logging volume info and status failed " "on volume %s", self.volname)) # Create a file cmd = ("cd %s; touch 'file_openfd';" % mountpoint) ret, _, err = g.run(self.mounts[0].client_system, cmd) self.assertEqual(ret, 0, err) g.log.info('Finished creating a file while all the bricks are UP') # Set volume options ret = set_volume_options(self.mnode, self.volname, {"performance.read-after-open": "yes"}) self.assertTrue(ret, 'Failed to set volume {}' ' options'.format(self.volname)) g.log.info('Successfully set %s volume options', self.volname,) # Bringing brick b1 offline sub_vols = get_subvols(self.mnode, self.volname) subvols_list = sub_vols['volume_subvols'] bricks_list1 = subvols_list[0] brick_b1_down = choice(bricks_list1) ret = bring_bricks_offline(self.volname, brick_b1_down) self.assertTrue(ret, 'Brick %s is not offline' % brick_b1_down) g.log.info('Brick %s is offline successfully', brick_b1_down) node = self.mounts[0].client_system # Open FD proc = open_file_fd(mountpoint, time=100, client=node) # Bring brick b1 online ret = bring_bricks_online(self.mnode, self.volname, [brick_b1_down], 'glusterd_restart') self.assertTrue(ret, 'Brick {} is not brought ' 'online'.format(brick_b1_down)) g.log.info('Brick %s is online successfully', brick_b1_down) # Validate peers are connected ret = self.validate_peers_are_connected() self.assertTrue(ret, "Peers are not in connected state after bringing" " an offline brick to online via `glusterd restart`") g.log.info("Successfully validated peers are in connected state") # Check if write to FD is successful g.log.info('Open FD on file successful') ret, _, _ = proc.async_communicate() self.assertEqual(ret, 0, "Write to FD is successful") # Monitor heal completion ret = monitor_heal_completion(self.mnode, self.volname) self.assertTrue(ret, 'Heal has not yet completed') g.log.info('Heal has completed successfully') file_openfd = os.path.join(mountpoint, 'file_openfd') # Check if data exists on file ret = check_if_pattern_in_file(node, 'xyz', file_openfd) self.assertEqual(ret, 0, 'xyz does not exists in file') g.log.info('xyz exists in file') file_fd = 'file_openfd' # Check if EC version is same on all bricks which are up ret = validate_xattr_on_all_bricks(bricks_list1, file_fd, 'trusted.ec.version') self.assertTrue(ret, "Healing not completed and EC version is " "not updated") g.log.info("Healing is completed and EC version is updated") # Check if EC size is same on all bricks which are up ret = validate_xattr_on_all_bricks(bricks_list1, file_fd, 'trusted.ec.size') self.assertTrue(ret, "Healing not completed and EC size is " "not updated") g.log.info("Healing is completed and EC size is updated") # Check stat of file cmd = "cd %s; du -kh file_openfd" % mountpoint ret, _, err = g.run(self.mounts[0].client_system, cmd) self.assertEqual(ret, 0, err) g.log.info('File %s is accessible', file_fd)
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_get_state_on_brick_unmount(self): """ Steps: 1. Form a gluster cluster by peer probing and create a volume 2. Unmount the brick using which the volume is created 3. Run 'gluster get-state' and validate absence of error 'Failed to get daemon state. Check glusterd log file for more details' 4. Create another volume and start it using different bricks which are not used to create above volume 5. Run 'gluster get-state' and validate the absence of above error. """ # Setup Volume ret = setup_volume(mnode=self.mnode, all_servers_info=self.all_servers_info, volume_config=self.volume, create_only=True) self.assertTrue(ret, "Failed to setup volume {}".format(self.volname)) g.log.info("Successful in setting up volume %s", self.volname) # Select one of the bricks in the volume to unmount brick_list = get_all_bricks(self.mnode, self.volname) self.assertIsNotNone(brick_list, ("Not able to get list of bricks " "of volume %s", self.volname)) select_brick = choice(brick_list) self.umount_host, self.umount_brick = ( select_brick[0:select_brick.rfind('/')].split(':')) # Verify mount entry in /etc/fstab ret = check_if_pattern_in_file(self.umount_host, self.umount_brick, '/etc/fstab') self.assertEqual( ret, 0, "Fail: Brick mount entry is not" " found in /etc/fstab of {}".format(self.umount_host)) # Unmount the selected brick cmd = 'umount {}'.format(self.umount_brick) ret, _, _ = g.run(self.umount_host, cmd) self.assertEqual( 0, ret, "Fail: Not able to unmount {} on " "{}".format(self.umount_brick, self.umount_host)) # Run 'gluster get-state' and verify absence of any error ret = get_gluster_state(self.mnode) self.assertIsNotNone( ret, "Fail: 'gluster get-state' didn't dump the " "state of glusterd when {} unmounted from " "{}".format(self.umount_brick, self.umount_host)) # Create another volume self.volume['name'] = 'second_volume' ret = setup_volume(self.mnode, self.all_servers_info, self.volume) self.assertTrue(ret, 'Failed to create and start volume') g.log.info('Second volume created and started successfully') # Run 'gluster get-state' and verify absence of any error after # creation of second-volume ret = get_gluster_state(self.mnode) self.assertIsNotNone( ret, "Fail: 'gluster get-state' didn't dump the " "state of glusterd ")
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_enabling_gluster_debug_mode(self): # pylint: disable=too-many-statements """ Testcase: 1. Stop glusterd. 2. Change log level to DEBUG in /usr/local/lib/systemd/system/glusterd.service. 3. Remove glusterd log 4. Start glusterd 5. Issue some gluster commands 6. Check for debug messages in glusterd log """ # Stop glusterd ret = stop_glusterd(self.mnode) self.assertTrue(ret, "Failed to stop glusterd on %s" % self.mnode) g.log.info("Successfully stopped glusterd.") # Change log level in /usr/lib/systemd/system/glusterd.service # to DEBUG glusterd_file = "/usr/lib/systemd/system/glusterd.service" ret = find_and_replace_in_file(self.mnode, 'LOG_LEVEL=INFO', 'LOG_LEVEL=DEBUG', glusterd_file) self.assertTrue(ret, "Unable to change Log_LEVEL to DEBUG.") # Archive old glusterd.log file. ret = move_file(self.mnode, '/var/log/glusterfs/glusterd.log', '/var/log/glusterfs/old.log') self.assertTrue(ret, "Renaming the glusterd log is failed") g.log.info("Successfully renamed glusterd.log file.") # Daemon reloading as the unit file of the daemon changed ret = daemon_reload(self.mnode) self.assertTrue(ret, "Daemon reloaded successfully") # Start glusterd ret = start_glusterd(self.mnode) self.assertTrue(ret, "Failed to start glusterd on %s" % self.mnode) g.log.info('Successfully to started glusterd.') # Check if glusterd is running or not. count = 0 while count < 60: ret = is_glusterd_running(self.mnode) if ret: break sleep(2) count += 1 self.assertEqual(ret, 0, "glusterd is not running on %s" % self.mnode) g.log.info('glusterd is running after changing log_level to debug.') # Instead of executing commands in loop, if glusterd is restarted in # one of the nodes in the cluster the handshake messages # will be in debug mode. ret = restart_glusterd(self.servers[1]) self.assertTrue(ret, "restarted successfully") count = 0 while count < 60: ret = is_glusterd_running(self.mnode) if ret: break sleep(2) count += 1 self.assertEqual(ret, 0, "glusterd is not running on %s" % self.mnode) g.log.info('glusterd is running after changing log_level to debug.') # Check glusterd logs for debug messages glusterd_log_file = "/var/log/glusterfs/glusterd.log" ret = check_if_pattern_in_file(self.mnode, ' D ', glusterd_log_file) self.assertEqual(ret, 0, "Debug messages are not present in log.") g.log.info("Debug messages are present in log.")