Beispiel #1
0
    def validate_vdisk_clone(cls,
                             amount_vdisks=AMOUNT_VDISKS,
                             amount_to_write=AMOUNT_TO_WRITE):
        """
        Validate if vdisk deployment works via various ways
        INFO: 1 vPool should be available on 2 storagerouters

        :return:
        """

        cls.LOGGER.info("Starting to regress template memleak vdisks")

        vpools = VPoolHelper.get_vpools()
        assert len(vpools) >= 1, "Not enough vPools to test"

        try:
            vpool = next(
                (vpool for vpool in vpools if len(vpool.storagedrivers) >= 2))
        except StopIteration:
            assert False, "Not enough Storagedrivers to test"

        # setup base information
        storagedriver_source = vpool.storagedrivers[0]
        client = SSHClient(storagedriver_source.storage_ip, username='******')

        # create required vdisk for test
        vdisk_name = VDiskTemplateChecks.PREFIX + '1'
        assert VDiskSetup.create_vdisk(
            vdisk_name=vdisk_name + '.raw',
            vpool_name=vpool.name,
            size=VDiskTemplateChecks.VDISK_SIZE,
            storagerouter_ip=storagedriver_source.storagerouter.ip) is not None
        time.sleep(VDiskTemplateChecks.TEMPLATE_SLEEP_AFTER_CREATE)

        ##################
        # template vdisk #
        ##################

        VDiskSetup.set_vdisk_as_template(vdisk_name=vdisk_name + '.raw',
                                         vpool_name=vpool.name)
        time.sleep(VDiskTemplateChecks.TEMPLATE_SLEEP_AFTER_CREATE)

        ######################
        # log current memory #
        ######################

        memory_usage_beginning = StatisticsHelper.get_current_memory_usage(
            storagedriver_source.storage_ip)
        cls.LOGGER.info("Starting memory usage monitor: {0}/{1}".format(
            memory_usage_beginning[0], memory_usage_beginning[1]))
        pid = int(
            client.run(
                "pgrep -a volumedriver | grep {0} | cut -d ' ' -f 1".format(
                    vpool.name),
                allow_insecure=True))
        cls.LOGGER.info(
            "Starting extended memory monitor on pid {0}: \n{1}".format(
                pid,
                StatisticsHelper.get_current_memory_usage_of_process(
                    storagedriver_source.storage_ip, pid)))

        ##################################################################
        # create vdisks from template, perform fio and delete them again #
        ##################################################################

        for vdisk in xrange(amount_vdisks):
            # create vdisk from template
            clone_vdisk_name = vdisk_name + '-template-' + str(vdisk)
            VDiskSetup.create_from_template(
                vdisk_name=vdisk_name + '.raw',
                vpool_name=vpool.name,
                new_vdisk_name=clone_vdisk_name + '.raw',
                storagerouter_ip=storagedriver_source.storagerouter.ip)
            # perform fio test
            client.run([
                "fio", "--name=test",
                "--filename=/mnt/{0}/{1}.raw".format(vpool.name,
                                                     clone_vdisk_name),
                "--ioengine=libaio", "--iodepth=4", "--rw=write", "--bs=4k",
                "--direct=1", "--size={0}M".format(amount_to_write),
                "--output-format=json", "--output={0}.json".format(vdisk_name)
            ])
            # delete vdisk
            time.sleep(cls.TEMPLATE_SLEEP_BEFORE_DELETE)
            VDiskRemover.remove_vdisk_by_name(vdisk_name=clone_vdisk_name,
                                              vpool_name=vpool.name)

        ###################
        # remove template #
        ###################

        time.sleep(cls.TEMPLATE_SLEEP_BEFORE_DELETE)
        VDiskRemover.remove_vtemplate_by_name(vdisk_name=vdisk_name,
                                              vpool_name=vpool.name)

        ######################
        # log current memory #
        ######################

        memory_usage_ending = StatisticsHelper.get_current_memory_usage(
            storagedriver_source.storage_ip)
        cls.LOGGER.info("Finished memory usage monitor: {0}/{1}".format(
            memory_usage_ending[0], memory_usage_ending[1]))
        pid = int(
            client.run(
                "pgrep -a volumedriver | grep {0} | cut -d ' ' -f 1".format(
                    vpool.name),
                allow_insecure=True))
        cls.LOGGER.info(
            "Finished extended memory monitor on pid {0}: \n{1}".format(
                pid,
                StatisticsHelper.get_current_memory_usage_of_process(
                    storagedriver_source.storage_ip, pid)))

        cls.LOGGER.info("Finished to regress template memleak vdisks")
Beispiel #2
0
 def validate_vdisk_clone(cls):
     """
     Validate if vdisk deployment works via various ways
     INFO: 1 vPool should be available on 2 storagerouters
     :return:
     """
     cls.LOGGER.info("Starting to validate template vdisks")
     vpools = VPoolHelper.get_vpools()
     assert len(vpools) >= 1, "Not enough vPools to test"
     try:
         vpool = next(
             (vpool for vpool in vpools if len(vpool.storagedrivers) >= 2))
     except StopIteration:
         assert False, "Not enough Storagedrivers to test"
     # setup base information
     storagedriver_source = vpool.storagedrivers[0]
     vdisks = []
     try:
         # create required vdisk for test
         parent_vdisk_name = '{0}_{1}'.format(cls.PREFIX, str(1).zfill(3))
         parent_vdisk = VDiskHelper.get_vdisk_by_guid(
             VDiskSetup.create_vdisk(
                 vdisk_name=parent_vdisk_name,
                 vpool_name=vpool.name,
                 size=cls.VDISK_SIZE,
                 storagerouter_ip=storagedriver_source.storagerouter.ip))
         vdisks.append(parent_vdisk)
         time.sleep(cls.TEMPLATE_SLEEP_AFTER_CREATE)
         # Create vdisk template  #
         VDiskSetup.set_vdisk_as_template(vdisk_name=parent_vdisk_name,
                                          vpool_name=vpool.name)
         time.sleep(cls.TEMPLATE_SLEEP_AFTER_CREATE)
         clone_vdisk_name = '{0}_from-template'.format(parent_vdisk_name)
         clone_vdisk = VDiskHelper.get_vdisk_by_guid(
             VDiskSetup.create_from_template(
                 vdisk_name=parent_vdisk_name,
                 vpool_name=vpool.name,
                 new_vdisk_name=clone_vdisk_name,
                 storagerouter_ip=storagedriver_source.storagerouter.ip)
             ['vdisk_guid'])
         vdisks.append(clone_vdisk)
         time.sleep(cls.TEMPLATE_SLEEP_BEFORE_DELETE)
         try:
             # try to delete template with clones (should fail) #
             VDiskRemover.remove_vtemplate_by_name(
                 vdisk_name=parent_vdisk_name, vpool_name=vpool.name)
             error_msg = "Removing vtemplate `{0}` should have failed!"
             cls.LOGGER.error(error_msg)
             raise RuntimeError(error_msg)
         except HttpException:
             cls.LOGGER.info(
                 "Removing vtemplate `{0}` has failed as expected (because of leftover clones)!"
                 .format(parent_vdisk_name))
     finally:
         while len(vdisks) > 0:
             vdisk = vdisks.pop()
             VDiskRemover.remove_vdisk(vdisk.guid)
     try:
         # template vdisk from clone (should fail) #
         parent_vdisk = VDiskHelper.get_vdisk_by_guid(
             VDiskSetup.create_vdisk(
                 vdisk_name=parent_vdisk_name,
                 vpool_name=vpool.name,
                 size=cls.VDISK_SIZE,
                 storagerouter_ip=storagedriver_source.storagerouter.ip))
         vdisks.append(parent_vdisk)
         # create a clone from the vdisk
         clone_vdisk_name = '{0}_clone'.format(parent_vdisk_name)
         cloned_vdisk = VDiskHelper.get_vdisk_by_guid(
             VDiskSetup.create_clone(
                 vdisk_name=parent_vdisk_name,
                 vpool_name=vpool.name,
                 new_vdisk_name=clone_vdisk_name,
                 storagerouter_ip=storagedriver_source.storagerouter.ip)
             ['vdisk_guid'])
         vdisks.append(cloned_vdisk)
         # try to create a vTemplate from a clone
         try:
             VDiskSetup.set_vdisk_as_template(vdisk_name=clone_vdisk_name,
                                              vpool_name=vpool.name)
             error_msg = "Setting vdisk `{0}` as template should have failed!".format(
                 clone_vdisk_name)
             cls.LOGGER.error(error_msg)
             raise RuntimeError(error_msg)
         except RuntimeError:
             cls.LOGGER.info(
                 "Setting vdisk `{0}` as template failed as expected (because vdisk is clone)!"
                 .format(clone_vdisk_name))
     finally:
         parent_vdisks = []
         while len(vdisks) > 0:  # Remove clones first
             vdisk = vdisks.pop()
             if vdisk.parent_vdisk_guid is None:
                 parent_vdisks.append(vdisk)
                 continue
             VDiskRemover.remove_vdisk(vdisk.guid)
         for parent_vdisk in parent_vdisks:
             VDiskRemover.remove_vdisk(parent_vdisk.guid)
     cls.LOGGER.info("Finished to validate template vdisks")