summaryrefslogtreecommitdiffstats
path: root/tests/functional/disperse/test_ec_validate_volume_creation.py
blob: b18198097e65c887c7ca10b3c03937b021354a39 (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#  Copyright (C) 2019  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.
"""
EcValidateVolumeCreate:

    This module tries to create and validate EC volume
    with various combinations of input parameters.
"""
from glusto.core import Glusto as g
from glustolibs.gluster.gluster_base_class import (GlusterBaseClass, runs_on)


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

    # Method to setup the environment for test case
    def setUp(self):
        # Initialize the input parameters
        self.volume['voltype']['redundancy_count'] = 0
        self.volume['voltype']['disperse_count'] = 0

    # Verify volume creation with insufficient bricks
    def test_insufficient_brick_servers(self):
        # Setup input parameters
        self.volume['voltype']['redundancy_count'] = 2
        self.volume['voltype']['disperse_count'] = 6

        # Restrict the brick servers to data brick count
        default_servers = self.volume['servers']
        data_brick_count = (self.volume['voltype']['disperse_count'] -
                            self.volume['voltype']['redundancy_count'])
        self.volume['servers'] = self.servers[0:data_brick_count]

        # Setup Volume and Mount Volume without force
        ret = self.setup_volume_and_mount_volume(mounts=self.mounts)
        self.assertFalse(ret, ("Volume setup is not failing "
                               "for volume %s", self.volname))
        g.log.info("Successfully verified volume setup with insufficient "
                   "brick servers witout force option")

        # Setup Volume and Mount Volume with force
        ret = self.setup_volume_and_mount_volume(mounts=self.mounts,
                                                 volume_create_force=True)
        self.assertTrue(ret, ("Volume Setup and Mount failed for "
                              "volume %s", self.volname))
        g.log.info("Successfully verified volume setup with insufficient "
                   "brick servers with force option")

        # Stopping the volume
        g.log.info("Starting to Unmount Volume and Cleanup Volume")
        ret = self.unmount_volume_and_cleanup_volume(mounts=self.mounts)
        self.assertTrue(ret, ("Failed to Unmount Volume and Cleanup Volume"))
        g.log.info("Successful in Unmount Volume and Cleanup Volume")

        # Restore the default server list
        self.volume['servers'] = default_servers

    # Test cases to verify valid input combinations.
    def test_valid_usecase_one(self):
        # Setup input parameters
        self.volume['voltype']['redundancy_count'] = 2
        self.volume['voltype']['disperse_count'] = 6

        # Setup Volume and Mount Volume
        g.log.info("Starting to Setup Volume and Mount Volume")
        ret = self.setup_volume_and_mount_volume(mounts=self.mounts)
        self.assertTrue(ret, ("Volume Setup and Mount failed for volume %s",
                              self.volname))

        # Stopping the volume
        g.log.info("Starting to Unmount Volume and Cleanup Volume")
        ret = self.unmount_volume_and_cleanup_volume(mounts=self.mounts)
        self.assertTrue(ret, ("Failed to Unmount Volume and "
                              "Cleanup Volume"))
        g.log.info("Successful in Unmount Volume and Cleanup Volume")

    # Test cases to verify invalid input combinations.
    def test_invalid_usecase_one(self):
        # Setup input parameters
        self.volume['voltype']['redundancy_count'] = 0
        self.volume['voltype']['disperse_count'] = 6

        # Setup Volume and Mount Volume
        g.log.info("Starting to Setup Volume and Mount Volume")
        ret = self.setup_volume_and_mount_volume(mounts=self.mounts)
        self.assertFalse(ret, ("Volume Setup and Mount succeeded"
                               " for volume %s", self.volname))
        g.log.info("Successfully verified invalid input parameters")

    def test_invalid_usecase_two(self):
        # Setup input parameters
        self.volume['voltype']['redundancy_count'] = 3
        self.volume['voltype']['disperse_count'] = 6

        # Setup Volume and Mount Volume
        g.log.info("Starting to Setup Volume and Mount Volume")
        ret = self.setup_volume_and_mount_volume(mounts=self.mounts)
        self.assertFalse(ret, ("Volume Setup and Mount succeeded for volume "
                               "%s", self.volname))
        g.log.info("Successfully verified invalid input parameters")

    def test_invalid_usecase_three(self):
        # Setup input parameters
        self.volume['voltype']['redundancy_count'] = 4
        self.volume['voltype']['disperse_count'] = 6

        # Setup Volume and Mount Volume
        g.log.info("Starting to Setup Volume and Mount Volume")
        ret = self.setup_volume_and_mount_volume(mounts=self.mounts)
        self.assertFalse(ret, ("Volume Setup and Mount succeeded for volume "
                               "%s", self.volname))
        g.log.info("Successfully verified invalid input parameters")

    def test_invalid_usecase_four(self):
        # Setup input parameters
        self.volume['voltype']['redundancy_count'] = 6
        self.volume['voltype']['disperse_count'] = 6

        # Setup Volume and Mount Volume
        g.log.info("Starting to Setup Volume and Mount Volume")
        ret = self.setup_volume_and_mount_volume(mounts=self.mounts)
        self.assertFalse(ret, ("Volume Setup and Mount succeeded for volume "
                               "%s", self.volname))
        g.log.info("Successfully verified invalid input parameters")

    def test_invalid_usecase_five(self):
        # Setup input parameters
        self.volume['voltype']['disperse_data_count'] = 6
        self.volume['voltype']['disperse_count'] = 6

        # Setup Volume and Mount Volume
        g.log.info("Starting to Setup Volume and Mount Volume")
        ret = self.setup_volume_and_mount_volume(mounts=self.mounts)
        self.assertFalse(ret, ("Volume Setup and Mount succeeded for volume "
                               "%s", self.volname))
        g.log.info("Successfully verified invalid input parameters")

    def test_invalid_usecase_six(self):
        # Setup input parameters
        self.volume['voltype']['disperse_data_count'] = 4
        self.volume['voltype']['disperse_count'] = 4

        # Setup Volume and Mount Volume
        g.log.info("Starting to Setup Volume and Mount Volume")
        ret = self.setup_volume_and_mount_volume(mounts=self.mounts)
        self.assertFalse(ret, ("Volume Setup and Mount succeeded for volume "
                               "%s", self.volname))
        g.log.info("Successfully verified invalid input parameters")

    def test_invalid_usecase_seven(self):
        # Setup input parameters
        self.volume['voltype']['redundancy_count'] = -2
        self.volume['voltype']['disperse_count'] = 6

        # Setup Volume and Mount Volume
        g.log.info("Starting to Setup Volume and Mount Volume")
        ret = self.setup_volume_and_mount_volume(mounts=self.mounts)
        self.assertFalse(ret, ("Volume Setup and Mount succeeded for volume "
                               "%s", self.volname))
        g.log.info("Successfully verified invalid input parameters")

    def test_invalid_usecase_eight(self):
        # Setup input parameters
        self.volume['voltype']['redundancy_count'] = -2
        self.volume['voltype']['disperse_count'] = -4

        # Setup Volume and Mount Volume
        g.log.info("Starting to Setup Volume and Mount Volume")
        ret = self.setup_volume_and_mount_volume(mounts=self.mounts)
        self.assertFalse(ret, ("Volume Setup and Mount succeeded for volume "
                               "%s", self.volname))
        g.log.info("Successfully verified invalid input parameters")

    def test_invalid_usecase_nine(self):
        # Setup input parameters
        self.volume['voltype']['redundancy_count'] = 2
        self.volume['voltype']['disperse_count'] = -4

        # Setup Volume and Mount Volume
        g.log.info("Starting to Setup Volume and Mount Volume")
        ret = self.setup_volume_and_mount_volume(mounts=self.mounts)
        self.assertFalse(ret, ("Volume Setup and Mount succeeded for volume "
                               "%s", self.volname))
        g.log.info("Successfully verified invalid input parameters")

    def test_invalid_usecase_ten(self):
        # Setup input parameters
        self.volume['voltype']['redundancy_count'] = 2
        self.volume['voltype']['disperse_count'] = 0

        # Setup Volume and Mount Volume
        g.log.info("Starting to Setup Volume and Mount Volume")
        ret = self.setup_volume_and_mount_volume(mounts=self.mounts)
        self.assertFalse(ret, ("Volume Setup and Mount succeeded for volume "
                               "%s", self.volname))
        g.log.info("Successfully verified invalid input parameters")