Esempio n. 1
0
    def tearDown(self):
        """
        Cleanup and umount volume
        """
        # Disable Quota
        ret, _, _ = quota_disable(self.mnode, self.volname)
        if ret:
            raise ExecutionError("Failed to disable quota on the volume %s")
        g.log.info("Successfully disabled quota on the volume %")

        # Cleanup and umount 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
        self.get_super_method(self, 'tearDown')()
    def test_quota_deem_statfs_quotad(self):
        """
        Verifying directory quota functionality with respect
        to the quota daemon and deem-statfs quota option with
        quota being enabled and disabled on the volume.

        * Check for quota daemon on all nodes when quota is
          not enabled on the volume. NO quota daemon process must
          be running.
        * Enable Quota on the Volume
        * Check for volume option features.quota-deem-statfs on the
          volume. It should be ON for the volume since quota was enabled.
        * Check for the quota daemon process on all nodes.
          There should be ONE quota daemon process running.
        * Disable quota on the volume.
        * Check for volume option features.quota-deem-statfs on the
          volume. It should be OFF for the volume since quota was disabled.
        * Check for the quota daemon process on all nodes.
          There should be NO quota daemon process running.
        """

        nodes = self.servers

        # Enable Quota
        g.log.info("Enabling quota on the volume %s", self.volname)
        ret, _, _ = quota_enable(self.mnode, self.volname)
        self.assertEqual(
            ret, 0, ("Failed to enable quota on the volume %s", self.volname))
        g.log.info("Successfully enabled quota on the volume %s", self.volname)

        # Check for quota-deem-statfs on the volume
        g.log.info("Validating features.quota-deem-statfs on the volume %s",
                   self.volname)
        ret = quota_check_deem_statfs(self.mnode, self.volname)
        self.assertTrue(
            ret, "Failed to validate volume option "
            "'features.quota-deem-statfs' on the volume %s" % self.volname)

        # Check for the quota daemon on all nodes
        g.log.info(
            "Validating presence of quota daemon process on all the "
            "nodes belonging to volume %s", self.volname)
        ret, pids = quota_fetch_daemon_pid(nodes)
        self.assertTrue(ret, ("Failed to validate quotad presence on the nodes"
                              " from %s", pids))
        g.log.info("Successful in getting pids %s", pids)
        for node in pids:
            self.assertNotEqual(pids[node][0], -1,
                                ("Failed to validate "
                                 "quotad on the node %s" % node))
        g.log.info(
            "EXPECTED: One quota daemon process running after enabling "
            "quota on the volume %s", self.volname)

        # Disable Quota
        g.log.info("Disabling quota on the volume %s", self.volname)
        ret, _, _ = quota_disable(self.mnode, self.volname)
        self.assertEqual(
            ret, 0, ("Failed to disable quota on the volume %s", self.volname))
        g.log.info("Successfully disabled quota on the volume %s",
                   self.volname)

        # Check for quota-deem-statfs on the volume
        g.log.info("Validating features.quota-deem-statfs on the volume %s",
                   self.volname)
        ret = quota_check_deem_statfs(self.mnode, self.volname)
        self.assertFalse(
            ret, "Failed to validate volume option "
            "'features.quota-deem-statfs' on the volume %s" % self.volname)

        # Check for the quota daemon on all nodes
        g.log.info(
            "Validating presence of quota daemon process on all the "
            "nodes belonging to volume %s", self.volname)
        ret, pids = quota_fetch_daemon_pid(nodes)
        self.assertFalse(ret, ("ONE quota daemon process running on one or "
                               "more nodes : %s" % pids))
        for node in pids:
            self.assertEqual(pids[node][0], -1, ("Quota daemon still running "
                                                 "on the node %s even after "
                                                 "disabling quota on the "
                                                 "volume" % node))
        g.log.info(
            "EXPECTED: NO Quota daemon process is running after "
            "disabling quota on the Volume %s", self.volname)
Esempio n. 3
0
    def test_quota_enable_disable_enable_when_io_in_progress(self):
        """Enable, Disable and Re-enable Quota on the volume when IO is
            in progress.
        """
        # Enable Quota
        g.log.info("Enabling quota on the volume %s", self.volname)
        ret, _, _ = quota_enable(self.mnode, self.volname)
        self.assertEqual(ret, 0, ("Failed to enable quota on the volume %s",
                                  self.volname))
        g.log.info("Successfully enabled quota on the volume %s", self.volname)

        # Check if quota is enabled
        g.log.info("Validate Quota is enabled on the volume %s", self.volname)
        ret = is_quota_enabled(self.mnode, self.volname)
        self.assertTrue(ret, ("Quota is not enabled on the volume %s",
                              self.volname))
        g.log.info("Successfully Validated quota is enabled on volume %s",
                   self.volname)

        # Path to set quota limit
        path = "/"

        # Set Quota limit on the root of the volume
        g.log.info("Set Quota Limit on the path %s of the volume %s",
                   path, self.volname)
        ret, _, _ = quota_limit_usage(self.mnode, self.volname,
                                      path=path, limit="1GB")
        self.assertEqual(ret, 0, ("Failed to set quota limit on path %s of "
                                  " the volume %s", path, self.volname))
        g.log.info("Successfully set the Quota limit on %s of the volume %s",
                   path, self.volname)

        # quota_fetch_list
        g.log.info("Get Quota list for path %s of the volume %s",
                   path, self.volname)
        quota_list = quota_fetch_list(self.mnode, self.volname, path=path)
        self.assertIsNotNone(quota_list, ("Failed to get the quota list for "
                                          "path %s of the volume %s",
                                          path, self.volname))
        self.assertIn(path, quota_list.keys(),
                      ("%s not part of the ""quota list %s even if "
                       "it is set on the volume %s", path,
                       quota_list, self.volname))
        g.log.info("Successfully listed path %s in the quota list %s of the "
                   "volume %s", path, quota_list, self.volname)

        # Disable quota
        g.log.info("Disable quota on the volume %s", self.volname)
        ret, _, _ = quota_disable(self.mnode, self.volname)
        self.assertEqual(ret, 0, ("Failed to disable quota on the volume %s",
                                  self.volname))
        g.log.info("Successfully disabled quota on the volume %s",
                   self.volname)

        # Check if quota is still enabled (expected : Disabled)
        g.log.info("Validate Quota is enabled on the volume %s", self.volname)
        ret = is_quota_enabled(self.mnode, self.volname)
        self.assertFalse(ret, ("Quota is still enabled on the volume %s "
                               "(expected: Disable) ", self.volname))
        g.log.info("Successfully Validated quota is disabled on volume %s",
                   self.volname)

        # Enable Quota
        g.log.info("Enabling quota on the volume %s", self.volname)
        ret, _, _ = quota_enable(self.mnode, self.volname)
        self.assertEqual(ret, 0, ("Failed to enable quota on the volume %s",
                                  self.volname))
        g.log.info("Successfully enabled quota on the volume %s", self.volname)

        # Check if quota is enabled
        g.log.info("Validate Quota is enabled on the volume %s", self.volname)
        ret = is_quota_enabled(self.mnode, self.volname)
        self.assertTrue(ret, ("Quota is not enabled on the volume %s",
                              self.volname))
        g.log.info("Successfully Validated quota is enabled on volume %s",
                   self.volname)

        # quota_fetch_list
        g.log.info("Get Quota list for path %s of the volume %s",
                   path, self.volname)
        quota_list = quota_fetch_list(self.mnode, self.volname, path=path)
        self.assertIsNotNone(quota_list, ("Failed to get the quota list for "
                                          "path %s of the volume %s",
                                          path, self.volname))
        self.assertIn(path, quota_list.keys(),
                      ("%s not part of the quota list %s even if "
                       "it is set on the volume %s", path,
                       quota_list, self.volname))
        g.log.info("Successfully listed path %s in the quota list %s of the "
                   "volume %s", path, quota_list, self.volname)

        # Validate IO
        ret = validate_io_procs(self.all_mounts_procs, self.mounts)
        self.io_validation_complete = True
        self.assertTrue(ret, "IO failed on some of the clients")

        # List all files and dirs created
        g.log.info("List all files and directories:")
        ret = list_all_files_and_dirs_mounts(self.mounts)
        self.assertTrue(ret, "Failed to list all files and dirs")
        g.log.info("Listing all files and directories is successful")