summaryrefslogtreecommitdiffstats
path: root/tests/functional/quota/test_deem_statfs_quotad.py
blob: 06e87f7e83ebad0c28712912d3609cbf0ffa216b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#  Copyright (C) 2015-2020 Red Hat, Inc. <http://www.redhat.com>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License along
#  with this program; if not, write to the Free Software Foundation, Inc.,
#  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

from glusto.core import Glusto as g
from glustolibs.gluster.gluster_base_class import (GlusterBaseClass,
                                                   runs_on)
from glustolibs.gluster.quota_ops import (quota_enable, quota_disable,
                                          quota_check_deem_statfs)
from glustolibs.gluster.quota_libs import quota_fetch_daemon_pid
from glustolibs.gluster.exceptions import ExecutionError


@runs_on([['distributed-replicated', 'replicated', 'dispersed', 'distributed',
           'distributed-dispersed'],
          ['glusterfs']])
class QuotaDeemStatfsAndQuotad(GlusterBaseClass):

    @classmethod
    def setUpClass(cls):
        """
        setup volume and initialize necessary variables
        """
        cls.get_super_method(cls, 'setUpClass')()
        g.log.info("Starting to Setup Volume")
        ret = cls.setup_volume()
        if not ret:
            raise ExecutionError("Failed to Setup_Volume")
        g.log.info("Successful in Setup Volume")

    def tearDown(self):

        # Unmount and cleanup original volume
        g.log.info("Starting to Cleanup Volume")
        ret = self.cleanup_volume()
        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)