def tearDown(self):
        """
        tearDown for every test
        Clean up and unmount the volume
        """
        # calling GlusterBaseClass tearDown
        self.get_super_method(self, 'tearDown')()

        # Delete the glusterfind sessions
        ret, _, _ = gfind_delete(self.mnode, self.volname, self.session)
        if ret:
            raise ExecutionError("Failed to delete session %s" % self.session)
        g.log.info("Successfully deleted session %s", self.session)

        # Remove the outfile created during 'glusterfind pre and query'
        ret = remove_file(self.mnode, self.outfile, force=True)
        if not ret:
            raise ExecutionError("Failed to remove the outfile")
        g.log.info("Successfully removed the outfile")

        # Cleanup the volume
        ret = self.unmount_volume_and_cleanup_volume(mounts=self.mounts)
        if not ret:
            raise ExecutionError("Failed to Cleanup Volume")
        g.log.info("Successful in Cleanup Volume")
    def tearDown(self):
        """
        tearDown for every test
        Clean up and unmount the volume
        """
        # calling GlusterBaseClass tearDown
        self.get_super_method(self, 'tearDown')()

        # Delete the glusterfind sessions
        ret, _, _ = gfind_delete(self.mnode, self.volname, self.session)
        if ret:
            raise ExecutionError("Failed to delete session %s" % self.session)
        g.log.info("Successfully deleted session %s", self.session)

        # Remove the outfiles created during 'glusterfind pre'
        for out in self.outfiles:
            ret = remove_file(self.mnode, out, force=True)
            if not ret:
                raise ExecutionError("Failed to remove the outfile %s" % out)
        g.log.info("Successfully removed the outfiles")

        # Wait for the peers to be connected.
        ret = wait_for_peers_to_connect(self.mnode, self.servers, 100)
        if not ret:
            raise ExecutionError("Peers are not in connected state.")

        # Cleanup the volume
        ret = self.unmount_volume_and_cleanup_volume(mounts=self.mounts)
        if not ret:
            raise ExecutionError("Failed to Cleanup Volume")
        g.log.info("Successful in Cleanup Volume")
Esempio n. 3
0
    def tearDown(self):
        """
        tearDown for every test
        Clean up and unmount the volume
        """

        ret, _, _ = gfind_delete(self.mnode, self.volname, self.session)
        if ret != 0:
            raise ExecutionError("Failed to delete session %s" % self.session)
        g.log.info("Successfully deleted session %s", self.session)

        g.log.info("Removing the outfiles created during 'glusterfind pre'")
        for out in self.outfiles:
            ret = remove_file(self.mnode, out, force=True)
            if not ret:
                raise ExecutionError("Failed to remove the outfile %s" % out)
        g.log.info("Successfully removed the outfiles")

        # Reset the volume
        g.log.info("Reset the volume")
        ret, _, _ = volume_reset(self.mnode, self.volname)
        if ret != 0:
            raise ExecutionError("Failed to reset the volume %s" %
                                 self.volname)
        g.log.info("Successfully reset the volume %s", self.volname)

        # Cleanup the volume
        g.log.info("Starting to Cleanup Volume")
        ret = self.unmount_volume_and_cleanup_volume(mounts=self.mounts)
        if not ret:
            raise ExecutionError("Failed to Cleanup Volume")
        g.log.info("Successful in Cleanup Volume")

        # calling GlusterBaseClass tearDown
        self.get_super_method(self, 'tearDown')()
    def _fallocate_file(self):
        """
        Perform `fallocate -l <alloc_size> <fqpath>` on <client>
        """

        # Delete the files if exists (sparsefile is created on absolute sizes)
        ret = remove_file(self.client, self.fqpath + '*', force=True)
        self.assertTrue(
            ret, 'Unable to delete existing file for `fallocate` of new file')
        sleep(5)

        # Create multiple sparsefiles rather than one big file
        sizes = [self.alloc_size]
        if self.alloc_size >= self.brick_size:
            sizes = ([self.brick_size // 2] *
                     (self.alloc_size // self.brick_size))
            sizes *= 2
            sizes.append(self.alloc_size % self.brick_size)
            rem_size = self.alloc_size - sum(sizes)
            if rem_size:
                sizes.append(rem_size)

        for count, size in enumerate(sizes, start=1):
            ret, _, _ = g.run(
                self.client,
                'fallocate -l {}G {}{}'.format(size, self.fqpath, count))
            self.assertEqual(
                ret, 0, 'Not able to fallocate {}* file on {}'.format(
                    self.fqpath, self.client))
            count += 1
Esempio n. 5
0
 def tearDownClass(cls):
     for each_client in cls.clients:
         ret = remove_file(each_client, cls.script_upload_path)
         if not ret:
             raise ExecutionError("Failed to delete file {}".format(
                 cls.script_upload_path))
     cls.get_super_method(cls, 'tearDownClass')()
Esempio n. 6
0
    def tearDown(self):
        """
        tearDown for every test and Clean up and unmount the volume
        """

        g.log.info("Removing the outfile created during 'glusterfind pre'")
        ret = remove_file(self.mnode, self.outfile, force=True)
        if not ret:
            raise ExecutionError("Failed to remove the outfile")
        g.log.info("Successfully removed the outfile")

        # stopping the volume
        g.log.info("Starting to Cleanup Volume")
        ret = self.unmount_volume_and_cleanup_volume(mounts=self.mounts)
        if not ret:
            raise ExecutionError("Failed to Cleanup Volume")
        g.log.info("Successful in Cleanup Volume")

        # calling GlusterBaseClass tearDown
        self.get_super_method(self, 'tearDown')()
Esempio n. 7
0
    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])