summaryrefslogtreecommitdiffstats
path: root/tests/functional/snapshot
diff options
context:
space:
mode:
authorsrivickynesh <sselvan@redhat.com>2018-06-27 11:08:08 +0530
committerAkarsha Rai <akrai@redhat.com>2018-06-30 14:20:02 +0000
commit2723a20c564a95196145659d42b407a8ba04d3b3 (patch)
tree23f5db20105201338fb4fa5f6d7307ae5560549e /tests/functional/snapshot
parent104afd83858236f86726b9083e20f81ff411e1e8 (diff)
snapshot: Listing Invalid cases
Test Cases in this module tests the snapshot creation and listing Invalid names and parameters. Change-Id: Iab3dd71a83176d850780c0834f95d4e8ac1e8997 Signed-off-by: srivickynesh <sselvan@redhat.com>
Diffstat (limited to 'tests/functional/snapshot')
-rw-r--r--tests/functional/snapshot/test_snap_invalid_names.py117
1 files changed, 117 insertions, 0 deletions
diff --git a/tests/functional/snapshot/test_snap_invalid_names.py b/tests/functional/snapshot/test_snap_invalid_names.py
new file mode 100644
index 0000000..775add5
--- /dev/null
+++ b/tests/functional/snapshot/test_snap_invalid_names.py
@@ -0,0 +1,117 @@
+# 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 creation and listing Invalid names
+and parameters.
+
+"""
+from glusto.core import Glusto as g
+from glustolibs.gluster.exceptions import ExecutionError
+from glustolibs.gluster.gluster_base_class import GlusterBaseClass, runs_on
+from glustolibs.gluster.snap_ops import snap_create, get_snap_list
+
+
+@runs_on([['replicated', 'distributed-replicated', 'dispersed',
+ 'distributed-dispersed', 'distributed'],
+ ['glusterfs']])
+class SnapshotInvalidNames(GlusterBaseClass):
+
+ @classmethod
+ def setUpClass(cls):
+ GlusterBaseClass.setUpClass.im_func(cls)
+ cls.snap1 = "snap1"
+ cls.snapinvalid = "#64^@*)"
+ cls.volname1 = "vola1"
+
+ def setUp(self):
+ # SettingUp volume and Mounting the volume
+ GlusterBaseClass.setUp.im_func(self)
+ g.log.info("Starting to SetUp and Mount 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 tearDown(self):
+ # Calling GlusterBaseClass tearDown
+ GlusterBaseClass.tearDown.im_func(self)
+
+ # Unmount and cleanup-volume
+ g.log.info("Unmount and cleanup-volume")
+ ret = self.unmount_volume_and_cleanup_volume(mounts=self.mounts)
+ if not ret:
+ raise ExecutionError("Failed to Unmount and Cleanup Volume")
+ g.log.info("Cleanup Volume Successfully")
+
+ def test_snap_list_invalid_cases_names(self):
+ """
+ Steps:
+ 1. create volume and mount it
+ 2. create snapshot with invalid snap name
+ should fail
+ 3. create snapshot
+ 4. snapshot list Invalid command should fail
+ 5. snapshot list Invalid parameters with multiple
+ and non-existing volume name should fail
+ """
+ # Creating snapshot with invalid snap name
+ g.log.info("Creating snapshot with invalid snap name")
+ ret, _, _ = snap_create(self.mnode, self.volname, self.snapinvalid)
+ self.assertNotEqual(ret, 0, ("Unexpected: Snapshot %s created "
+ "successfully for volume %s with "
+ "invalid snap name"
+ % (self.snapinvalid, self.volname)))
+ g.log.info("Expected: Failed to create snapshot %s for volume %s"
+ "with invalid snap name", self.snap1, self.volname)
+
+ # Creating snapshot
+ g.log.info("Starting to Create snapshot")
+ ret, _, _ = snap_create(self.mnode, self.volname, self.snap1)
+ self.assertEqual(ret, 0, ("Failed to create snapshot for volume %s",
+ self.volname))
+ g.log.info("Snapshot %s created "
+ "successfully for volume"
+ "%s", self.snapinvalid, self.volname)
+
+ # validate snapshot list with volname
+ g.log.info("validate snapshot list with volname")
+ out = get_snap_list(self.mnode)
+ self.assertIsNotNone(out, "Failed to list all snapshots")
+ self.assertEqual(len(out), 1, "Failed to validate snap_list")
+ g.log.info("Successfully validated snapshot list")
+
+ # listing snapshot with invalid volume name which should fail
+ g.log.info("snapshot list with invalid volume name should fail")
+ cmd = ("gluster snap list %s" % self.volname1)
+ ret, _, _ = g.run(self.mnode, cmd)
+ self.assertNotEqual(ret, 0, "Unexpected: Successfully listed "
+ "all snapshots with invalid volume name "
+ "%s" % self.volname1)
+ g.log.info("Expected to fail listing the snapshot with invalid"
+ "volume name %s", self.volname1)
+
+ # snapshot list with multiple and non-existing volume
+ g.log.info("snapshot list Invalid parameter with "
+ "multiple and non-existing volume name should fail")
+ cmd = ("gluster snap list %s %s"
+ % (self.volname, self.volname1))
+ ret, _, _ = g.run(self.mnode, cmd)
+ self.assertNotEqual(ret, 0, "Unexpected: listed all snapshots")
+ g.log.info("Expected: Failed to list snapshots")