예제 #1
0
    def tearDown(self):
        # Calling GlusterBaseClass tearDown
        GlusterBaseClass.tearDown.im_func(self)

        # disabling auto-delete
        cmd = "gluster snapshot config auto-delete disable"
        ret = g.run(self.mnode, cmd)
        self.assertTrue(ret, ("Failed to disable auto-delete snapshot"
                              "config option"))
        g.log.info("Snapshot auto-delete Successfully disabled")

        # deleting created snapshots
        ret = snap_delete_all(self.mnode)
        self.assertTrue(ret, ("Failed to delete snapshot of volume"
                              "%s" % self.volname))
        g.log.info("Successfully deleted snapshots of volume %s" %
                   self.volname)

        # setting back default max-soft-limit to 90%
        option = {'snap-max-soft-limit': '90'}
        ret = set_snap_config(self.mnode, option)
        self.assertTrue(ret, ("Failed to set snap-max-soft-limit"
                              "config option"))
        g.log.info("snap-max-soft-limit config option Successfully set")

        # cleanup-volume
        ret = self.cleanup_volume()
        if not ret:
            raise ExecutionError("Failed to Cleanup Volume")
        g.log.info("Cleanup volume %s Completed Successfully" % self.volname)
    def tearDown(self):
        """
        tearDown for every test
        """
        ret, _, _ = snap_delete_all(self.mnode)
        if ret != 0:
            raise ExecutionError("Snapshot Delete Failed")
        ret, _, _ = set_snap_config(self.mnode, self.option_disable)
        if ret != 0:
            raise ExecutionError("Failed to execute set_snap_config")
        ret = get_snap_config(self.mnode, self.volname)
        if ret is None:
            raise ExecutionError("Failed to execute get_snap_config")
        if 'disable' not in ret['systemConfig']['activateOnCreate']:
            raise ExecutionError("Failed to disable activate-on-create")
        g.log.info("set_snap_config Success to disable "
                   "activate-on-create")

        # Cleanup-volume
        ret = self.cleanup_volume()
        if not ret:
            raise ExecutionError("Failed to Cleanup Volume")
        g.log.info("Successful in Cleanup Volume")

        # Calling GlusterBaseClass tearDown
        self.get_super_method(self, 'tearDown')()
예제 #3
0
    def tearDown(self):

        # disabling auto-delete
        g.log.info("Disabling auto-delete")
        cmd = "gluster snapshot config auto-delete disable"
        ret, _, _ = g.run(self.mnode, cmd)
        if ret != 0:
            raise ExecutionError("Failed to disable auto-delete snapshot"
                                 "config option")
        g.log.info("Snapshot auto-delete Successfully disabled")

        # deleting created snapshots
        g.log.info("Deleting all created snapshots")
        ret, _, _ = snap_delete_all(self.mnode)
        if ret != 0:
            raise ExecutionError("Failed to delete snapshot of volume"
                                 "%s" % self.volname)
        g.log.info("Successfully deleted snapshots of"
                   "volume %s", self.volname)

        # setting back default max-soft-limit to 90%
        g.log.info("Setting max-soft-limit to default")
        cmd = {'snap-max-soft-limit': '90'}
        ret, _, _ = set_snap_config(self.mnode, cmd)
        if ret != 0:
            raise ExecutionError("Failed to set snap-max-soft-limit"
                                 "config option")
        g.log.info("snap-max-soft-limit config option Successfully set")

        # Unmount and cleanup-volume
        g.log.info("Starting to 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("Successful in Unmount Volume and Cleanup Volume")
예제 #4
0
    def tearDown(self):
        # Calling GlusterBaseClass tearDown
        self.get_super_method(self, 'tearDown')()

        # setting back default max-soft-limit to 90%
        ret, _, _ = set_snap_config(self.mnode, self.def_conf_softlim)
        if ret:
            raise ExecutionError("Failed to set the default config options "
                                 "for snap-max-soft-limit")
        g.log.info("Successfully set the snapshot config options to default")

        # setting back default value for auto-delete config option
        ret, _, _ = set_snap_config(self.mnode, self.def_conf_autodel)
        if ret:
            raise ExecutionError("Failed to set the default config option for "
                                 "auto-delete")
        g.log.info("Successfully set the snapshot config options to default")
    def tearDown(self):
        # Calling GlusterBaseClass teardown
        self.get_super_method(self, 'tearDown')()

        # delete created snapshots
        g.log.info("starting to delete all created snapshots")
        ret, _, _ = snap_delete_all(self.mnode)
        self.assertEqual(ret, 0, "Failed to delete all snapshots")
        g.log.info("Successfully deleted all snapshots")

        # Disable Activate on create
        option = {'activate-on-create': 'disable'}
        ret, _, _ = set_snap_config(self.mnode, option)
        if ret != 0:
            raise ExecutionError("Failed to set activateOnCreate"
                                 "config option")
        g.log.info("ActivateOnCreate config option Successfully set")

        # umount clone volume
        g.log.info("Unmounting clone volume")
        ret, _, _ = umount_volume(self.clients[0], self.mpoint1)
        if ret != 0:
            raise ExecutionError("Failed to unmount clone "
                                 "volume %s" % self.clone1)
        g.log.info("Successfully unmounted clone volume %s", self.clone1)

        ret, _, _ = umount_volume(self.clients[0], self.mpoint2)
        if ret != 0:
            raise ExecutionError("Failed to unmount clone "
                                 "volume %s" % self.clone2)
        g.log.info("Successfully unmounted clone volume %s", self.clone2)

        # cleanup volume
        g.log.info("starting to cleanup volume")
        ret1 = cleanup_volume(self.mnode, self.clone1)
        ret2 = cleanup_volume(self.mnode, self.clone2)
        if not ret1:
            raise ExecutionError("Failed to cleanup %s clone "
                                 "volume" % self.clone1)
        if not ret2:
            raise ExecutionError("Failed to cleanup %s clone "
                                 "volume" % self.clone2)
        g.log.info("Successfully cleanedup cloned volumes")

        # Unmount and cleanup-volume
        g.log.info("Starting to 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("Successful in Unmount Volume and Cleanup Volume")
    def tearDown(self):
        """
        tearDown for every test
        """
        ret, _, _ = snap_delete_all(self.mnode)
        self.assertEqual(ret, 0, "Snapshot Delete Failed")
        ret, _, _ = set_snap_config(self.mnode, self.option_disable)
        self.assertEqual(ret, 0, "Failed to execute set_snap_config")
        ret = get_snap_config(self.mnode, self.volname)
        if ret is None:
            raise ExecutionError("Failed to execute get_snap_config")
        if 'disable' not in ret['systemConfig']['activateOnCreate']:
            raise ExecutionError("Failed to disable activate-on-create")
        g.log.info("set_snap_config Success to disable " "activate-on-create")

        # Calling GlusterBaseClass tearDown
        GlusterBaseClass.tearDown.im_func(self)
예제 #7
0
    def tearDown(self):
        # Calling GlusterBaseClass teardown
        GlusterBaseClass.tearDown.im_func(self)

        # Disable Activate on create
        option = {'activate-on-create': 'disable'}
        ret, _, _ = set_snap_config(self.mnode, option)
        if ret != 0:
            raise ExecutionError("Failed to set activateOnCreate"
                                 "config option")
        g.log.info("ActivateOnCreate config option Successfully set")

        # umount clone volume
        g.log.info("Unmounting clone volume")
        ret, _, _ = umount_volume(self.mounts[0].client_system, self.mpoint1)
        if ret != 0:
            raise ExecutionError("Failed to unmount clone "
                                 "volume %s" % self.clone1)
        g.log.info("Successfully unmounted clone volume %s", self.clone1)

        ret, _, _ = umount_volume(self.mounts[0].client_system, self.mpoint2)
        if ret != 0:
            raise ExecutionError("Failed to unmount clone "
                                 "volume %s" % self.clone2)
        g.log.info("Successfully unmounted clone volume %s", self.clone2)

        # cleanup volume
        g.log.info("starting to cleanup volume")
        ret1 = cleanup_volume(self.mnode, self.clone1)
        ret2 = cleanup_volume(self.mnode, self.clone2)
        if not ret1:
            raise ExecutionError("Failed to cleanup %s clone "
                                 "volume" % self.clone1)
        if not ret2:
            raise ExecutionError("Failed to cleanup %s clone "
                                 "volume" % self.clone2)
        g.log.info("Successfully cleanedup cloned volumes")

        # Unmount and cleanup-volume
        g.log.info("Starting to 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("Successful in Unmount Volume and Cleanup Volume")
예제 #8
0
    def test_snap_delete_multiple(self):
        # pylint: disable=too-many-statements
        """
        Steps:

        1. create and mount volume
        2. Create 20 snapshots
        3. Clone one of the snapshot
        4. mount the clone volume
        5. Perform I/O on mounts
        6. Create 10 more snapshots
        7. create Clone volume from latest snapshot
           and Mount it
        8. Perform I/O
        9. Create 10 more snapshot
        10. Validate total number of
            snapshots created.
        11. Delete all created snapshots.

        """

        # Perform I/O
        def io_operation():
            g.log.info("Starting to Perform I/O")
            all_mounts_procs = []
            for mount_obj in self.mounts:
                g.log.info("Generating data for %s:%s",
                           mount_obj.client_system, mount_obj.mountpoint)
                # Create files
                g.log.info('Creating files...')
                command = ("python %s create_files -f 100 --fixed-file-size"
                           " 1k %s" %
                           (self.script_upload_path, mount_obj.mountpoint))
                proc = g.run_async(mount_obj.client_system,
                                   command,
                                   user=mount_obj.user)
                all_mounts_procs.append(proc)
            self.io_validation_complete = False

            # Validate IO
            g.log.info("Wait for IO to complete and validate IO ...")
            ret = validate_io_procs(all_mounts_procs, self.mounts)
            self.assertTrue(ret, "IO failed on some of the clients")
            self.io_validation_complete = True
            g.log.info("IO is successful on all mounts")
            return 0

        # Enable Activate on create
        g.log.info("Enabling activate-on-create")
        option = {'activate-on-create': 'enable'}
        ret, _, _ = set_snap_config(self.mnode, option)
        self.assertEqual(ret, 0, ("Failed to set activateOnCreate"
                                  "config option"))
        g.log.info("Activate-on-Create config option Successfully set")

        def create_snap(value, volname, snap, clone, counter):
            # Creating snapshots
            g.log.info("Starting to Create snapshot")
            for snap_count in value:
                ret, _, _ = snap_create(self.mnode, volname,
                                        "snap%s" % snap_count)
                self.assertEqual(ret, 0, ("Failed to create "
                                          "snapshot for volume %s" % volname))
                g.log.info(
                    "Snapshot snap%s created successfully"
                    " for volume %s", snap_count, volname)

            # Validate snapshot list
            g.log.info("Starting to list all snapshots")
            ret, out, _ = snap_list(self.mnode)
            self.assertEqual(
                ret, 0, ("Failed to list snapshot of volume %s" % volname))
            v_list = out.strip().split('\n')
            self.assertEqual(len(v_list), counter, "Failed to validate "
                             "all snapshots")
            g.log.info(
                "Snapshot listed and  Validated for volume %s"
                " successfully", volname)
            if counter == 40:
                return 0

            # Creating a Clone of snapshot:
            g.log.info("Starting to Clone Snapshot")
            ret, _, _ = snap_clone(self.mnode, snap, clone)
            self.assertEqual(ret, 0, "Failed to clone %s" % clone)
            g.log.info("Clone volume %s created successfully", clone)

            # Start cloned volumes
            g.log.info("starting to Validate clone volumes are started")
            ret, _, _ = volume_start(self.mnode, clone)
            self.assertEqual(ret, 0, "Failed to start %s" % clone)
            g.log.info("%s started successfully", clone)

            # log Cloned Volume information
            g.log.info("Logging Volume info and Volume status")
            ret = log_volume_info_and_status(self.mnode, clone)
            self.assertTrue("Failed to Log Info and Status of Volume %s" %
                            clone)
            g.log.info("Successfully Logged Info and Status")
            return counter + 10

        def mount_clone_and_io(clone, mpoint):
            # define mounts
            self.mount_points = []
            self.mounts_dict_list = []
            for client in self.all_clients_info:
                mount = {
                    'protocol': self.mount_type,
                    'server': self.mnode,
                    'volname': clone,
                    'client': self.all_clients_info[client],
                    'mountpoint': (os.path.join("%s" % mpoint)),
                    'options': ''
                }
                self.mounts_dict_list.append(mount)
            self.mounts1 = create_mount_objs(self.mounts_dict_list)
            g.log.info("Successfully made entry in self.mounts")
            # Mounting a volume
            g.log.info("Starting to mount volume")
            ret = mount_volume(clone, self.mount_type, mpoint, self.mnode,
                               self.clients[0])
            self.assertTrue(ret, "Volume mount failed for clone1")
            g.log.info("%s mounted Successfully", clone)

            # Checking volume mounted or not
            ret = is_mounted(clone, mpoint, self.mnode, self.clients[0],
                             self.mount_type)
            self.assertTrue(ret,
                            "Volume not mounted on mount point: %s" % mpoint)
            g.log.info("Volume %s mounted on %s", clone, mpoint)
            return 0

        value1 = range(0, 20)
        value2 = range(20, 30)
        value3 = range(30, 40)
        ret1 = create_snap(value1,
                           self.volname,
                           self.snap1,
                           self.clone1,
                           counter=20)
        self.assertEqual(ret1, 30, "Failed")
        ret2 = mount_clone_and_io(self.clone1, self.mpoint1)
        self.assertEqual(ret2, 0, "Failed to mount volume")
        ret = io_operation()
        self.assertEqual(ret, 0, "Failed to perform io")
        ret3 = create_snap(value2, self.clone1, self.snap2, self.clone2, ret1)
        self.assertEqual(ret3, 40, "Failed")
        ret4 = mount_clone_and_io(self.clone2, self.mpoint2)
        self.assertEqual(ret4, 0, "Failed to mount volume")
        ret = io_operation()
        self.assertEqual(ret, 0, "Failed to perform io")
        ret1 = create_snap(value3, self.clone2, self.snap2, self.clone2, ret3)
        self.assertEqual(ret1, 0, "Failed to create snapshots")

        # delete created snapshots
        g.log.info("starting to delete all created snapshots")
        ret, _, _ = snap_delete_all(self.mnode)
        self.assertEqual(ret, 0, "Failed to delete all snapshots")
        g.log.info("Successfully deleted all snapshots")
예제 #9
0
    def test_validate_snaps_restore(self):
        # pylint: disable=too-many-statements
        # Start IO on all mounts.
        all_mounts_procs = []
        count = 1
        for mount_obj in self.mounts:
            g.log.info("Starting IO on %s:%s", mount_obj.client_system,
                       mount_obj.mountpoint)
            cmd = ("python %s create_deep_dirs_with_files "
                   "--dirname-start-num %d "
                   "--dir-depth 2 "
                   "--dir-length 10 "
                   "--max-num-of-dirs 5 "
                   "--num-of-files 5 %s" %
                   (self.script_upload_path, count, mount_obj.mountpoint))
            proc = g.run_async(mount_obj.client_system,
                               cmd,
                               user=mount_obj.user)
            all_mounts_procs.append(proc)
            count = count + 10

        # Validate IO
        g.log.info("Validating IO's")
        ret = validate_io_procs(all_mounts_procs, self.mounts)
        self.assertTrue(ret, "IO failed on some of the clients")
        g.log.info("Successfully validated all io's")

        # Get stat of all the files/dirs created.
        g.log.info("Get stat of all the files/dirs created.")
        ret = get_mounts_stat(self.mounts)
        self.assertTrue(ret, "Stat failed on some of the clients")
        g.log.info("Successfully got stat of all files/dirs created")

        # Setting some volume option related to snapshot
        option_before_restore = {
            'volumeConfig': [{
                'softLimit': '100',
                'effectiveHardLimit': '200',
                'hardLimit': '256'
            }],
            'systemConfig': {
                'softLimit': '90%',
                'activateOnCreate': 'disable',
                'hardLimit': '256',
                'autoDelete': 'disable'
            }
        }
        ret = set_snap_config(self.mnode, option_before_restore)
        self.assertTrue(ret,
                        ("Failed to set vol option on  %s" % self.volname))
        g.log.info("Volume options for%s is set successfully", self.volname)

        # Get brick list before taking snap_restore
        bricks_before_snap_restore = get_all_bricks(self.mnode, self.volname)
        g.log.info("Brick List before snap restore "
                   "volume: %s", bricks_before_snap_restore)

        # Creating snapshot
        ret = snap_create(self.mnode, self.volname, "snap1")
        self.assertTrue(ret,
                        ("Failed to create snapshot for %s" % self.volname))
        g.log.info("Snapshot snap1 created successfully for volume  %s",
                   self.volname)

        # Again start IO on all mounts.
        all_mounts_procs = []
        count = 1000
        for mount_obj in self.mounts:
            g.log.info("Starting IO on %s:%s", mount_obj.client_system,
                       mount_obj.mountpoint)
            cmd = ("python %s create_deep_dirs_with_files "
                   "--dirname-start-num %d "
                   "--dir-depth 2 "
                   "--dir-length 10 "
                   "--max-num-of-dirs 5 "
                   "--num-of-files 5 %s" %
                   (self.script_upload_path, count, mount_obj.mountpoint))
            proc = g.run_async(mount_obj.client_system,
                               cmd,
                               user=mount_obj.user)
            all_mounts_procs.append(proc)
            count = count + 10

        # Validate IO
        g.log.info("Validating IO's")
        ret = validate_io_procs(all_mounts_procs, self.mounts)
        self.assertTrue(ret, "IO failed on some of the clients")
        g.log.info("Successfully validated all io's")

        # Get stat of all the files/dirs created.
        g.log.info("Get stat of all the files/dirs created.")
        ret = get_mounts_stat(self.mounts)
        self.assertTrue(ret, "Stat failed on some of the clients")
        g.log.info("Successfully got stat of all files/dirs created")

        # Reset volume to make sure volume options will reset
        ret = volume_reset(self.mnode, self.volname, force=False)
        self.assertTrue(ret, ("Failed to reset %s" % self.volname))
        g.log.info("Reset Volume %s is Successful", self.volname)

        # Removing one brick
        g.log.info("Starting volume shrink")
        ret = shrink_volume(self.mnode, self.volname, force=True)
        self.assertTrue(ret, ("Failed to shrink the volume on "
                              "volume %s", self.volname))
        g.log.info("Shrinking volume is successful on "
                   "volume %s", self.volname)

        # Restore snapshot
        ret = snap_restore_complete(self.mnode, self.volname, "snap1")
        self.assertTrue(ret, ("Failed to restore snap snap1 on the "
                              "volume %s", self.volname))
        g.log.info(
            "Restore of volume is successful from snap1 on "
            "volume  %s", self.volname)

        # Validate volume is up and running
        g.log.info("Verifying volume is up and process are online")
        ret = verify_all_process_of_volume_are_online(self.mnode, self.volname)
        self.assertTrue(
            ret, ("Volume %s : All process are not online", self.volname))
        g.log.info("Volume %s : All process are online", self.volname)

        # Get volume options post restore
        option_after_restore = get_snap_config(self.mnode)
        # Compare volume options
        self.assertNotEqual(option_before_restore, option_after_restore,
                            "Volume Options are not same after snap restore")

        # Get brick list post restore
        bricks_after_snap_restore = get_all_bricks(self.mnode, self.volname)
        g.log.info("Brick List after snap restore "
                   "volume: %s", bricks_after_snap_restore)
        # Compare brick_list
        self.assertNotEqual(bricks_before_snap_restore,
                            bricks_after_snap_restore,
                            "Bricks are not same after snap restore")

        # Creating snapshot
        ret = snap_create(self.mnode, self.volname, "snap2")
        self.assertTrue(ret,
                        ("Failed to create snapshot for %s" % self.volname))
        g.log.info("Snapshot snap2 created successfully for volume  %s",
                   self.volname)

        # Again start IO on all mounts after restore
        all_mounts_procs = []
        count = 1000
        for mount_obj in self.mounts:
            g.log.info("Starting IO on %s:%s", mount_obj.client_system,
                       mount_obj.mountpoint)
            cmd = ("python %s create_deep_dirs_with_files "
                   "--dirname-start-num %d "
                   "--dir-depth 2 "
                   "--dir-length 10 "
                   "--max-num-of-dirs 5 "
                   "--num-of-files 5 %s" %
                   (self.script_upload_path, count, mount_obj.mountpoint))
            proc = g.run_async(mount_obj.client_system,
                               cmd,
                               user=mount_obj.user)
            all_mounts_procs.append(proc)
            count = count + 10

        # Validate IO
        g.log.info("Validating IO's")
        ret = validate_io_procs(all_mounts_procs, self.mounts)
        self.assertTrue(ret, "IO failed on some of the clients")
        g.log.info("Successfully validated all io's")

        # Get stat of all the files/dirs created.
        g.log.info("Get stat of all the files/dirs created.")
        ret = get_mounts_stat(self.mounts)
        self.assertTrue(ret, "Stat failed on some of the clients")
        g.log.info("Successfully got stat of all files/dirs created")
예제 #10
0
    def test_snap_auto_delete(self):
        """
        Verifying snapshot auto-delete config option

        * Enable auto-delete snapshot
        * Set snap-max-hard limit and snap-max-soft-limit
        * Validate snap-max-hard-limit and snap-max-soft-limit
        * Verify the limits by creating another 20 snapshots
        * Oldest of newly created snapshots will be deleted
        * Retaining the latest 8 (softlimit) snapshots
        * Cleanup snapshots and volumes
        """

        # pylint: disable=too-many-statements
        # Enable auto-delete snapshot config option
        ret, _, _ = set_snap_config(self.mnode, self.autodel_enable)
        self.assertEqual(ret, 0, ("Failed to enable auto-delete snapshot "
                                  "config option on volume %s", self.volname))
        g.log.info("Successfully enabled snapshot auto-delete")

        # Set snap-max-hard-limit snapshot config option for volume
        max_hard_limit = {'snap-max-hard-limit': '10'}
        ret, _, _ = set_snap_config(self.mnode, max_hard_limit, self.volname)
        self.assertEqual(ret, 0, ("Failed to set snap-max-hard-limit"
                                  "config option for volume %s", self.volname))
        g.log.info(
            "Successfully set snap-max-hard-limit config option for"
            "volume %s", self.volname)

        # Validate snap-max-hard-limit snapshot config option
        hard_limit_val = get_snap_config(self.mnode)
        self.assertEqual(hard_limit_val['volumeConfig'][0]['hardLimit'], '10',
                         ("Failed to Validate snap-max-hard-limit"))
        g.log.info("Successfully validated snap-max-hard-limit")

        # Set snap-max-soft-limit snapshot config option
        max_soft_limit = {'snap-max-soft-limit': '80'}
        ret, _, _ = set_snap_config(self.mnode, max_soft_limit)
        self.assertEqual(ret, 0, ("Failed to set snap-max-soft-limit"
                                  "config option"))
        g.log.info("Successfully set snap-max-soft-limit config option")

        # Validate snap-max-soft-limit snapshot config option
        soft_limit_val = get_snap_config(self.mnode)
        self.assertEqual(soft_limit_val['volumeConfig'][0]['softLimit'], '8',
                         ("Failed to Validate max-soft-limit"))
        g.log.info("Successfully validated snap-max-soft-limit")

        # Create 20 snapshots. As the count of snapshots crosses the
        # soft-limit the oldest of newly created snapshot should
        # be deleted and only the latest 8 snapshots must remain.
        for snapname in self.snapshots:
            ret, _, _ = snap_create(self.mnode,
                                    self.volname,
                                    snapname,
                                    description="This is the Description wit#"
                                    " ($p3c1al) ch@r@cters!")
            self.assertEqual(ret, 0, ("Failed to create snapshot %s for "
                                      "volume %s", snapname, self.volname))
            g.log.info("Snapshot snap%s of volume %s created successfully",
                       snapname, self.volname)

        # Perform snapshot list to get total number of snaps after auto-delete
        # Validate the existence of the snapshots using the snapname
        snaplist = get_snap_list(self.mnode)
        self.assertEqual(len(snaplist), 8,
                         ("Failed: The snapshot count is not as expected"))
        for snapname in self.snapshots[-8:]:
            self.assertIn(
                snapname, snaplist, "Failed to validate snapshot "
                "existence for the snapshot %s" % snapname)
        g.log.info("Successful in validating the Snapshot count and existence "
                   "by snapname")
예제 #11
0
    def test_auto_delete_snap(self):
        """
        * enabling auto-delete snapshot
        * Setting max-hard limit and max-soft-limit
        * Validating max-hard-limit and max-soft-limit
        * Verify the limits by creating another 20 snapshots
        * Oldest of newly created snapshots will be deleted
        * Retaining the latest 8(softlimit) snapshots
        * cleanup snapshots and volumes
        """
        # Setup volume
        ret = self.setup_volume()
        if not ret:
            raise ExecutionError("Failed to setup volume %s" % self.volname)
        g.log.info("Volume %s has been setup successfully" % self.volname)

        # enabling auto-delete
        cmd = "gluster snapshot config auto-delete enable"
        ret = g.run(self.mnode, cmd)
        self.assertTrue(ret, ("Failed to enable auto-delete snapshot config"
                              "option on volume % s" % self.volname))
        g.log.info("Snapshot auto-delete Successfully enabled")

        # setting max-hard-limit
        option = {'snap-max-hard-limit': '10'}
        ret = set_snap_config(self.mnode, option, self.volname)
        self.assertTrue(ret, ("Failed to set snap-max-hardlimit"
                              "config option for volume %s" % self.volname))
        g.log.info("snap-max-hardlimit config option Successfully set for"
                   "volume %s" % self.volname)

        # Validating max-hard-limit
        hardlimit = get_snap_config(self.mnode)
        get_hardlimit = hardlimit['volumeConfig'][0]['hardLimit']
        if get_hardlimit != '10':
            self.assertTrue(ret, ("Failed to Validate max-hard-limit"))
        g.log.info("Successfully validated max-hard-limit")

        # setting max-soft-limit
        option = {'snap-max-soft-limit': '80'}
        ret = set_snap_config(self.mnode, option)
        self.assertTrue(ret, ("Failed to set snap-max-soft-limit"
                              "config option"))
        g.log.info("snap-max-soft-limit config option Successfully set")

        # Validating max-soft-limit
        softlimit = get_snap_config(self.mnode)
        get_softlimit = softlimit['volumeConfig'][0]['softLimit']
        if get_softlimit != '8':
            self.assertTrue(ret, ("Failed to Validate max-soft-limit"))
        g.log.info("Successfully validated max-soft-limit")

        # creating 20 snapshots. As the count
        # of snapshots crosses the
        # soft-limit the oldest of newly created snapshot should
        # be deleted only latest 8 snapshots
        # should remain.

        # creating 20 more snapshots
        for snap_count in range(10, 30):
            ret = snap_create(
                self.mnode, self.volname, "snap%s" % snap_count, False,
                "This is the Description with $p3c1al"
                "characters!")
            self.assertTrue(ret, ("Failed to create snapshot snap%s for volume"
                                  "%s" % (snap_count, self.volname)))
            g.log.info("Snapshot snap%s of volume %s created successfully")

        # snapshot list to list total number of snaps after auto-delete
        cmd = "gluster snapshot list | wc -l"
        ret, out, _ = g.run(self.mnode, cmd)
        self.assertEqual(
            ret, 0, ("Failed to list snapshot of volume %s" % self.volname))
        g.log.info("Total number of snapshots created after auto-delete"
                   "enabled is %s" % out)
        if out != 8:
            g.log.info("Failed to validate snapshots with expected"
                       "number of snapshots")
        g.log.info("Snapshot Validation Successful")
        g.log.info("Snapshot list command for volume %s was successful" %
                   self.volname)
예제 #12
0
    def test_snap_delete(self):
        # pylint: disable=too-many-statements
        """
        Delete a snapshot of a volume

        * Creating and deleting 10 snapshots
        * deleting previously created 10 snapshots
        * enabling auto-delete snapshot
        * Setting max-hard limit and max-soft-limit
        * Verify the limits by creating another 20 snapshots
        * Oldest of newly created snapshots will be deleted
        * Retaining the latest 8(softlimit) snapshots
        * cleanup snapshots and volumes
        """

        # creating 10 snapshots
        g.log.info("Creating 10 snapshots")
        for snap_count in range(0, 10):
            ret, _, _ = snap_create(self.mnode, self.volname,
                                    "snap%s" % snap_count, False,
                                    "Description with $p3c1al characters!")
            self.assertEqual(ret, 0, ("Failed to create snapshot"
                                      "snap%s" % snap_count))
            g.log.info("Snapshot snap%s of volume %s created"
                       "successfully.", snap_count, self.volname)

        # snapshot list
        g.log.info("Starting to list all snapshots")
        ret, _, _ = snap_list(self.mnode)
        self.assertEqual(ret, 0, ("Failed to list snapshot"
                                  "of volume %s" % self.volname))
        g.log.info("Snapshot list command for volume %s"
                   "was successful", self.volname)

        # deleting all 10 snapshots from the volume
        g.log.info("Starting to Delete 10 created snapshots")
        ret, _, _ = snap_delete_by_volumename(self.mnode, self.volname)
        self.assertEqual(ret, 0, ("Failed to delete"
                                  "snapshot of volume %s" % self.volname))
        g.log.info("Snapshots of volume %s deleted Successfully", self.volname)

        # enabling auto-delete
        g.log.info("Enabling auto-delete")
        cmd = "gluster snapshot config auto-delete enable"
        ret, _, _ = g.run(self.mnode, cmd)
        self.assertEqual(ret, 0, ("Failed to enable auto-delete"
                                  "snapshot config"
                                  "option on volume % s" % self.volname))
        g.log.info("Snapshot auto-delete Successfully enabled")

        # setting max-hard-limit
        g.log.info("Setting max-hard-limit")
        option = {'snap-max-hard-limit': '10'}
        ret, _, _ = set_snap_config(self.mnode, option, self.volname)
        self.assertEqual(ret, 0, ("Failed to set snap-max-hardlimit"
                                  "config option for"
                                  "volume %s" % self.volname))
        g.log.info(
            "snap-max-hardlimit config option Successfully set for"
            "volume %s", self.volname)

        # Validating max-hard-limit
        g.log.info("Validating max-hard-limit")
        hardlimit = get_snap_config(self.mnode)
        self.assertIsNotNone(hardlimit, "Failed to get snap config")
        get_hardlimit = hardlimit['volumeConfig'][0]['hardLimit']
        self.assertEqual(get_hardlimit, '10', ("Failed to Validate"
                                               "max-hard-limit"))
        g.log.info("Successfully validated max-hard-limit")

        # setting max-soft-limit
        g.log.info("Setting max-soft-limit")
        option = {'snap-max-soft-limit': '80'}
        ret, _, _ = set_snap_config(self.mnode, option)
        self.assertEqual(ret, 0, ("Failed to set snap-max-soft-limit"
                                  "config option"))
        g.log.info("snap-max-soft-limit config option Successfully set")

        # Validating max-soft-limit
        g.log.info("Validating max-soft-limit")
        softlimit = get_snap_config(self.mnode)
        self.assertIsNotNone(softlimit, "Failed to get snap config")
        get_softlimit = softlimit['volumeConfig'][0]['softLimit']
        self.assertEqual(get_softlimit, '8', ("Failed to Validate"
                                              "max-soft-limit"))
        g.log.info("Successfully validated max-soft-limit")

        # creating 20 more snapshots. As the count
        # of snapshots crosses the
        # soft-limit the oldest of newly created snapshot should
        # be deleted only latest 8(softlimit) snapshots
        # should remain
        g.log.info("Starting to create 20 more snapshots")
        for snap_count in range(10, 30):
            ret, _, _ = snap_create(
                self.mnode, self.volname, "snap%s" % snap_count, False,
                "This is the Description with $p3c1al"
                "characters!")
            self.assertEqual(ret, 0, ("Failed to create snapshot snap%s"
                                      "for volume"
                                      "%s" % (snap_count, self.volname)))
            g.log.info("Snapshot snap%s of volume"
                       "%s created successfully.", snap_count, self.volname)

        # snapshot list to list total number of snaps after auto-delete
        g.log.info("validate total no.of snapshots after auto-delete enable")
        cmd = "gluster snapshot list | wc -l"
        ret, out, _ = g.run(self.mnode, cmd)
        tot = out.strip().split('\n')
        self.assertEqual(
            ret, 0, ("Failed to list snapshot of volume %s" % self.volname))
        g.log.info(
            "Total number of snapshots created after auto-delete"
            "enabled is %s", tot[0])
        self.assertEqual(tot[0], '8', ("Failed to validate snapshots with"
                                       "expected number of snapshots "))
        g.log.info("Successfully validated snapshots with expected"
                   "number of snapshots")
    def test_activate_on_create(self):
        # pylint: disable=too-many-branches, too-many-statements
        """
        Verifying Snapshot activate on create

        * Create a default snapshot
        * Enable activate-on-create snapshot config option
        * Create more snapshots
            * Validate snapshot info after snapshot create. It should be in
              started state.
            * Validate snapshot status after snapshot create. It should be in
              started state.
        * Validate the default snapshot info and status. It should be in
          stopped state
        """

        # Create Default Snapshot
        g.log.info("Starting to Create Snapshot one")
        snap_default = "snap_%s" % self.volname
        ret, _, _ = snap_create(self.mnode, self.volname, snap_default)
        self.assertEqual(ret, 0, ("Snapshot Creation failed for %s",
                                  snap_default))
        g.log.info("Successfully created Snapshot %s of volume %s",
                   snap_default, self.volname)

        # Enable activate_on_create snapshot
        g.log.info("Enabling snapshot activate-on-create config option")
        ret, _, _ = set_snap_config(self.mnode, self.option_enable)
        self.assertEqual(ret, 0, "Failed to execute set_snap_config")
        g.log.info("Validating the value of activate-on-create")
        ret = get_snap_config(self.mnode, self.volname)
        self.assertIsNotNone(ret, ("Failed to execute get_snap_config"))
        self.assertIn('enable', (ret['systemConfig']['activateOnCreate']),
                      ("Failed to validate activate-on-create value as "
                       "'enabled'"))
        g.log.info("Successfully enabled activate-on-create")

        # Create Snapshots after enabling activate-on-create
        g.log.info("Starting to Create Snapshots")
        for snap_count in range(1, 5):
            snap_name = "snap_%s" % snap_count
            ret, _, _ = snap_create(self.mnode, self.volname, snap_name)
            self.assertEqual(ret, 0, ("Snapshot Creation failed for %s",
                                      snap_name))
            g.log.info("Successfully created Snapshot %s of volume %s",
                       snap_name, self.volname)

            # Validate Snapshot Info After Snapshot Create
            g.log.info("Validating 'snapshot info' after enabling "
                       "activate-on-create")
            ret = get_snap_info_by_snapname(self.mnode, snap_name)
            self.assertIsNotNone(ret, ("Failed to Fetch Snapshot info after "
                                       "activation for %s", snap_name))
            g.log.info("Snapshot info Success for %s",
                       ret['snapVolume']['status'])
            self.assertEqual(ret['snapVolume']['status'], 'Started',
                             ("Activated Snapshot is in Stopped State %s",
                              (ret['snapVolume']['status'])))
            g.log.info("Snapshot %s is Activated By Default - %s state",
                       snap_name, (ret['snapVolume']['status']))

            # Validate Snaphot Status After Snapshot Create
            g.log.info("Validating 'snapshot status' after enabling "
                       "activate-on-create")
            ret = get_snap_status_by_snapname(self.mnode, snap_name)
            self.assertIsNotNone("Failed to Fetch Snapshot status for %s",
                                 snap_name)
            g.log.info("Snapshot Status Success for %s", snap_name)
            for brick in ret['volume']['brick']:
                self.assertNotEqual(brick['pid'], 'N/A',
                                    ("Brick Path %s  Not Available for "
                                     "Activated Snapshot %s",
                                     (brick['path'], snap_name)))
            g.log.info("Success: Snapshot Brick Path Available")

        # Validate Snapshot Info for the 'default' snapshot
        # Expected to be Stopped
        g.log.info("Validating 'snapshot info' of the 'default' snapshot")
        ret = get_snap_info_by_snapname(self.mnode, snap_default)
        self.assertIsNotNone(ret, ("Failed to Fetch Snapshot info for %s",
                                   snap_default))
        g.log.info("Snapshot info Success for %s", ret['snapVolume']['status'])
        self.assertEqual(ret['snapVolume']['status'], 'Stopped',
                         ("Snapshot Status is not in Stopped State"))
        g.log.info("Snapshot %s is in Stopped state as it "
                   "is not Activated", snap_default)

        # Validate Snapshot Status for the 'default' snapshot
        # Expected to be N/A
        g.log.info("Validating 'snapshot status' of the 'default' snapshot")
        ret = get_snap_status_by_snapname(self.mnode, snap_default)
        self.assertIsNotNone(ret, ("Failed to Fetch Snapshot status for %s",
                                   snap_default))
        g.log.info("Snapshot Status Success for %s", snap_default)
        for brick in ret['volume']['brick']:
            self.assertEqual(brick['pid'], 'N/A',
                             ("Brick Pid available for %s", brick['path']))
        g.log.info("Success: Snapshot %s Brick PID is 'N/A'", snap_default)
예제 #14
0
    def test_validate_snaps_256(self):
        """
        Validate snapshot creation for 256 snapshots

        * Perform some IO
        * Set snapshot config option snap-max-hard-limit to 256
        * Create 256 snapshots
        * Verify 256 created successfully
        * Create 257th snapshot - creation should fail as it will
          exceed the hard-limit
        * Verify snapshot list for 256 snapshots

        """
        # pylint: disable=too-many-statements
        # Start IO on all mounts
        cmd = (
            "/usr/bin/env python %s create_files "
            "-f 10 --base-file-name firstfiles %s"
            % (self.script_upload_path,
               self.mounts[0].mountpoint))
        proc = g.run_async(
            self.mounts[0].client_system, cmd, user=self.mounts[0].user)
        self.all_mounts_procs.append(proc)

        # Wait for IO to complete
        self.assertTrue(
            wait_for_io_to_complete(self.all_mounts_procs, self.mounts[0]),
            "IO failed on %s" % self.mounts[0])
        g.log.info("IO is successful on all mounts")

        # Perform stat on all the files/dirs created
        ret = get_mounts_stat(self.mounts)
        self.assertTrue(ret, "Stat failed on some of the clients")
        g.log.info("Successfully performed stat on all files/dirs created")

        # Set config option snap-max-hard-limit to 256
        # This is to make sure to override
        max_hard_limit = {'snap-max-hard-limit': '256'}
        ret, _, _ = set_snap_config(self.mnode, max_hard_limit)
        self.assertEqual(ret, 0, "Failed to set snapshot config option "
                         "snap-max-hard-limit to 256")
        g.log.info("Successfully set snapshot config option "
                   "snap-max-hard-limit to 256")

        # Create 256 snapshots
        for snapname in self.snapshots:
            ret, _, _ = snap_create(self.mnode, self.volname, snapname)
            self.assertEqual(ret, 0, ("Failed to create snapshot %s for %s"
                                      % (snapname, self.volname)))
            sleep(1)
        g.log.info("Snapshots created successfully for volume %s",
                   self.volname)

        # Validate snapshot list for 256 snapshots
        snap_list = get_snap_list(self.mnode)
        self.assertTrue((len(snap_list) == 256), "Failed: Number of snapshots "
                        "is not consistent for volume %s" % self.volname)
        g.log.info("Successfully validated number of snapshots")

        # Validate snapshot existence using snap-name
        for snapname in self.snapshots:
            self.assertIn(snapname, snap_list,
                          "Failed: Snapshot %s not found" % snapname)
        g.log.info("Successfully validated snapshots existence using "
                   "snap-name")

        # Try to exceed snap-max-hard-limit by creating 257th snapshot
        snap_257 = "snap-test-validate-256-snapshots-%s-257" % (self.volname)
        ret, _, _ = snap_create(self.mnode, self.volname, snap_257)
        self.assertEqual(
            ret, 1, ("Unexpected: Successfully created %s for  volume %s"
                     % (snap_257, self.volname)))
        g.log.info("Snapshot %s not created as it exceeds the "
                   "snap-max-hard-limit", snap_257)

        # Validate snapshot list for 256 snapshots
        snap_list = get_snap_list(self.mnode)
        self.assertEqual(len(snap_list), 256, "Failed: Number of snapshots "
                         "is not consistent for volume %s" % self.volname)
        g.log.info("Successfully validated number of snapshots")
    def test_activate_on_create(self):
        # pylint: disable=too-many-branches
        """
        Verifying Snapshot activate on create
        """
        # Create Default Snapshot
        g.log.info("Starting to Create Snapshot one")
        snap_default = "snap_%s" % self.volname
        ret, _, _ = snap_create(self.mnode, self.volname, snap_default)
        self.assertEqual(ret, 0, "Snapshot Creation failed"
                         " for %s" % snap_default)
        g.log.info("Snapshot %s of volume %s created"
                   " successfully", snap_default, self.volname)

        # Enable activate_on_create snapshot
        ret, _, _ = set_snap_config(self.mnode, self.option_enable)
        self.assertEqual(ret, 0, "Failed to execute set_snap_config")
        ret = get_snap_config(self.mnode, self.volname)
        if ret is None:
            raise ExecutionError("Failed to execute get_snap_config")
        if 'enable' not in ret['systemConfig']['activateOnCreate']:
            raise ExecutionError("Failed to enable activate-on-create")
        g.log.info("set_snap_config Success to enable " "activate-on-create")
        # Create Snapshot Snapshots
        g.log.info("Starting to Create Snapshot two")
        for snap_count in range(1, 5):
            snap_name = "snap_%s" % snap_count
            ret, _, _ = snap_create(self.mnode, self.volname, snap_name)
            self.assertEqual(ret, 0, "Snapshot Creation failed"
                             " for %s" % snap_name)
            g.log.info("Snapshot %s of volume %s created"
                       " successfully", snap_name, self.volname)

            # Validate Snapshot Info After Snapshot Create
            ret = get_snap_info_by_snapname(self.mnode, snap_name)
            if ret is None:
                raise ExecutionError("Failed to Fetch Snapshot"
                                     "info after activate "
                                     "for %s" % snap_name)
            g.log.info("Snapshot info Success "
                       "for %s", ret['snapVolume']['status'])
            if ret['snapVolume']['status'] != 'Started':
                raise ExecutionError("Activated Snapshot is in Stopped "
                                     "State %s" %
                                     (ret['snapVolume']['status']))
            g.log.info("%s Activated By "
                       "Default- %s state", snap_name,
                       (ret['snapVolume']['status']))

            # Validate Snaphot Status After Snapshot Create
            ret = get_snap_status_by_snapname(self.mnode, snap_name)
            if ret is None:
                raise ExecutionError("Failed to Fetch Snapshot"
                                     "status for %s" % snap_name)
            g.log.error("Snapshot Status Success for %s", snap_name)
            for brick in ret['volume']['brick']:
                if brick['pid'] == 'N/A':
                    raise ExecutionError("Brick Path %s  Not Available "
                                         "for Activated Snapshot %s" %
                                         (brick['path'], snap_name))
            g.log.info("snap_2 Snapshot Brick Path Available as Expected")

        # Validate Deactivated Snapshot Info
        # Expected to be Stopped
        ret = get_snap_info_by_snapname(self.mnode, snap_default)
        if ret is None:
            raise ExecutionError("Failed to Fetch Snapshot"
                                 " info for %s" % snap_default)
        g.log.info("Snapshot info Success for %s", ret['snapVolume']['status'])
        if ret['snapVolume']['status'] != 'Stopped':
            raise ExecutionError("Snapshot Status is not in Stopped State")
        g.log.info("Snapshot %s is in Stopped state as it "
                   "is not Activated", snap_default)

        # Validate Deactivated Snapshot status
        # Expected tobe NA
        ret = get_snap_status_by_snapname(self.mnode, snap_default)
        if ret is None:
            raise ExecutionError("Failed to Fetch Snapshot"
                                 "status for %s" % snap_default)
        g.log.info("Snapshot Status Success for %s", snap_default)
        for brick in ret['volume']['brick']:
            if brick['pid'] != 'N/A':
                raise ExecutionError("Brick Pid available for %s" %
                                     brick['path'])
        g.log.info("Deactivated Snapshot Brick PID N/A as Expected")