Exemple #1
0
 def wait_for_migration_completed(self,
                                  share_id,
                                  dest_host,
                                  version=LATEST_MICROVERSION):
     """Waits for a share to migrate to a certain host."""
     share = self.get_share(share_id, version=version)
     migration_timeout = CONF.share.migration_timeout
     start = int(time.time())
     while share['task_state'] != 'migration_success':
         time.sleep(self.build_interval)
         share = self.get_share(share_id, version=version)
         if share['task_state'] == 'migration_success':
             return share
         elif share['task_state'] == 'migration_error':
             raise share_exceptions.ShareMigrationException(
                 share_id=share['id'], src=share['host'], dest=dest_host)
         elif int(time.time()) - start >= migration_timeout:
             message = ('Share %(share_id)s failed to migrate from '
                        'host %(src)s to host %(dest)s within the required '
                        'time %(timeout)s.' % {
                            'src': share['host'],
                            'dest': dest_host,
                            'share_id': share['id'],
                            'timeout': self.build_timeout
                        })
             raise exceptions.TimeoutException(message)
Exemple #2
0
    def resource_setup(cls):
        super(MigrationTest, cls).resource_setup()
        if cls.protocol not in CONF.share.enable_protocols:
            message = "%s tests are disabled." % cls.protocol
            raise cls.skipException(message)
        if not (CONF.share.run_host_assisted_migration_tests
                or CONF.share.run_driver_assisted_migration_tests):
            raise cls.skipException("Share migration tests are disabled.")

        pools = cls.shares_client.list_pools(detail=True)['pools']

        if len(pools) < 2:
            raise cls.skipException("At least two different pool entries "
                                    "are needed to run share migration tests.")

        cls.share = cls.create_share(cls.protocol)
        cls.share = cls.shares_client.get_share(cls.share['id'])

        default_type = cls.shares_v2_client.list_share_types(
            default=True)['share_type']

        dest_pool = utils.choose_matching_backend(cls.share, pools,
                                                  default_type)

        if not dest_pool or dest_pool.get('name') is None:
            raise share_exceptions.ShareMigrationException(
                "No valid pool entries to run share migration tests.")

        cls.dest_pool = dest_pool['name']

        cls.new_type_invalid = cls.create_share_type(
            name=data_utils.rand_name('new_invalid_share_type_for_migration'),
            cleanup_in_class=True,
            extra_specs=utils.get_configured_extra_specs(variation='invalid'))
def wait_for_migration_status(client,
                              share_id,
                              dest_host,
                              status_to_wait,
                              version=LATEST_MICROVERSION):
    """Waits for a share to migrate to a certain host."""
    statuses = ((status_to_wait, )
                if not isinstance(status_to_wait,
                                  (tuple, list, set)) else status_to_wait)
    share = client.get_share(share_id, version=version)['share']
    migration_timeout = CONF.share.migration_timeout
    start = int(time.time())
    while share['task_state'] not in statuses:
        time.sleep(client.build_interval)
        share = client.get_share(share_id, version=version)['share']
        if share['task_state'] in statuses:
            break
        elif share['task_state'] == 'migration_error':
            raise share_exceptions.ShareMigrationException(
                share_id=share['id'], src=share['host'], dest=dest_host)
        elif int(time.time()) - start >= migration_timeout:
            message = ('Share %(share_id)s failed to reach a status in'
                       '%(status)s when migrating from host %(src)s to '
                       'host %(dest)s within the required time '
                       '%(timeout)s.' % {
                           'src': share['host'],
                           'dest': dest_host,
                           'share_id': share['id'],
                           'timeout': client.build_timeout,
                           'status': str(statuses),
                       })
            raise exceptions.TimeoutException(message)
    return share
    def resource_setup(cls):
        super(MigrationNegativeTest, cls).resource_setup()
        if cls.protocol not in CONF.share.enable_protocols:
            message = "%s tests are disabled." % cls.protocol
            raise cls.skipException(message)
        if not (CONF.share.run_host_assisted_migration_tests
                or CONF.share.run_driver_assisted_migration_tests):
            raise cls.skipException("Share migration tests are disabled.")

        pools = cls.shares_client.list_pools(detail=True)['pools']

        if len(pools) < 2:
            raise cls.skipException("At least two different pool entries "
                                    "are needed to run share migration tests.")

        # create share type (generic)
        extra_specs = {}

        if CONF.share.capability_snapshot_support:
            extra_specs.update({'snapshot_support': True})
        cls.share_type = cls.create_share_type(extra_specs=extra_specs)
        cls.share_type_id = cls.share_type['id']

        # create share
        cls.share = cls.create_share(cls.protocol,
                                     size=CONF.share.share_size + 1,
                                     share_type_id=cls.share_type_id)
        cls.share = cls.shares_client.get_share(cls.share['id'])['share']

        dest_pool = utils.choose_matching_backend(cls.share, pools,
                                                  cls.share_type)

        if not dest_pool or dest_pool.get('name') is None:
            raise share_exceptions.ShareMigrationException(
                "No valid pool entries to run share migration tests.")

        cls.dest_pool = dest_pool['name']

        cls.new_type_invalid = cls.create_share_type(
            name=data_utils.rand_name('new_invalid_share_type_for_migration'),
            cleanup_in_class=True,
            extra_specs=utils.get_configured_extra_specs(variation='invalid'))