summaryrefslogtreecommitdiffstats
path: root/tests/functional/snapshot/test_snap_invalid_cases.py
blob: 6bbd8a20d7676a6e2c13bc7b137815922a2d26e0 (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
#  Copyright (C) 2017-2018  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.

"""
Description:

Test Cases in this module tests the
snapshot Status and Info for Invalid cases.

"""
from glusto.core import Glusto as g
from glustolibs.gluster.exceptions import ExecutionError
from glustolibs.gluster.gluster_base_class import GlusterBaseClass
from glustolibs.gluster.gluster_base_class import runs_on
from glustolibs.gluster.snap_ops import (snap_create,
                                         snap_status, snap_info)


@runs_on([['distributed-replicated', 'replicated', 'distributed',
           'distributed-dispersed', 'dispersed'],
          ['glusterfs', 'nfs', 'cifs']])
class SnapshotstatusInvalidcases(GlusterBaseClass):
    """
    1. Create volumes
    2. create multiple snapshots
    3. Show status of non existing snapshots
    4. Show info of non existing snapshots
    5. Show status of snaps of non-existing volumes
    6. Show info of snaps of non-existing volume
    7. status of snapshots with invalid command
    8. Info of snapshots with invalid command
    """

    @classmethod
    def setUpClass(cls):
        GlusterBaseClass.setUpClass.im_func(cls)
        cls.snap5 = "snap5"
        cls.snap1 = "snap1"
        cls.volname1 = "volume1"

    def setUp(self):

        # SettingUp volume and Mounting the volume
        GlusterBaseClass.setUpClass.im_func(self)
        g.log.info("Starting to SetUp Volume")
        ret = self.setup_volume_and_mount_volume(mounts=self.mounts)
        if not ret:
            raise ExecutionError("Failed to setup volume %s" % self.volname)
        g.log.info("Volume %s has been setup successfully", self.volname)

    def test_snap_invalid_case(self):

        # Creating snapshot:
        g.log.info("Starting to Create snapshot")
        for count in range(1, 3):
            self.snap = "snap%s" % count
            ret = snap_create(self.mnode, self.volname, self.snap)
            self.assertTrue(ret, ("Failed to create snapshot for volume %s"
                                  % self.volname))
        g.log.info("Snapshot %s created successfully"
                   " for volume %s", self.snap, self.volname)

        # Check snapshot info for non-existing snapshot
        g.log.info("Checking snapshot info")
        ret, _, _ = snap_info(self.mnode, self.snap5)
        self.assertEqual(ret, 1, "Unexpected: Successful in "
                         "getting information for"
                         "non-existing %s snapshot" % self.snap5)
        g.log.info("Expected result: failed to get information"
                   " for non-existing %s snapshot", self.snap5)

        # Check snapshot status for non-existing snapshot
        g.log.info("Checking snapshot status")
        ret, _, _ = snap_status(self.mnode, self.snap5)
        self.assertEqual(ret, 1, "Unexpected: Successful in getting "
                         "status for non-existing "
                         "%s snapshot" % self.snap5)
        g.log.info("Expected result: failed to get status"
                   " for non-existing %s snapshot", self.snap5)

        # Check snapshot info for non-existing volume
        g.log.info("Checking snapshot info")
        ret, _, _ = snap_info(self.mnode, self.volname1)
        self.assertEqual(ret, 1, "Unexpected: Successful in getting "
                         "information for"
                         "non-existing %s volume" % self.volname1)
        g.log.info("Expected result: failed to get information"
                   " for non-existing %s volume", self.volname1)

        # Check snapshot status for non-existing volume
        g.log.info("Checking snapshot status")
        ret, _, _ = snap_info(self.mnode, self.volname1)
        self.assertEqual(ret, 1, "Unexpected: Successful in getting "
                         "status for non-existing "
                         "%s volume" % self.volname1)
        g.log.info("Expected result: Need to fail to get status"
                   " for non-existing %s volume", self.volname1)

        # Invalid command
        g.log.info("Passing invalid status command")
        cmd = "gluster snapshot snap1 status"
        ret, _, _ = g.run(self.mnode, cmd)
        self.assertEqual(ret, 1, "Unexpected: Snapshot status"
                         " command Successful even with Invalid"
                         " command")
        g.log.info("Expected result: snapshot status command failed")

        # Invalid command
        g.log.info("Passing invalid info command")
        cmd = "gluster snapshot snap1 info"
        ret, _, _ = g.run(self.mnode, cmd)
        self.assertEqual(ret, 1, "Unexpected: Snapshot info "
                         "command Successful even with Invalid "
                         " command")
        g.log.info("Expected result: snapshot information command Failed")

    def tearDown(self):

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