def resource_setup(cls): super(MigrationBase, 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.") cls.pools = cls.shares_v2_client.list_pools(detail=True)['pools'] if len(cls.pools) < 2: raise cls.skipException("At least two different pool entries are " "needed to run share migration tests.") # create share type (generic) cls.share_type = cls.create_share_type( name=data_utils.rand_name('original_share_type_for_migration'), cleanup_in_class=True, extra_specs=utils.get_configured_extra_specs()) cls.share_type_id = cls.share_type['id'] cls.new_type = cls.create_share_type( name=data_utils.rand_name('new_share_type_for_migration'), cleanup_in_class=True, extra_specs=utils.get_configured_extra_specs()) cls.new_type_opposite = cls.create_share_type( name=data_utils.rand_name('new_share_type_for_migration_opposite'), cleanup_in_class=True, extra_specs=utils.get_configured_extra_specs( variation='opposite_driver_modes'))
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 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 resource_setup(cls): super(MigrationNFSTest, 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.") cls.new_type = cls.create_share_type( name=data_utils.rand_name('new_share_type_for_migration'), cleanup_in_class=True, extra_specs=utils.get_configured_extra_specs()) cls.new_type_opposite = cls.create_share_type( name=data_utils.rand_name('new_share_type_for_migration_opposite'), cleanup_in_class=True, extra_specs=utils.get_configured_extra_specs( variation='opposite_driver_modes'))
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'))
def test_migrate_share_opposite_type_share_network_invalid(self): extra_specs = utils.get_configured_extra_specs( variation='opposite_driver_modes') new_type_opposite = self.create_share_type( name=data_utils.rand_name('share_type_migration_negative'), extra_specs=extra_specs) new_share_network_id = None if CONF.share.multitenancy_enabled: new_share_network_id = self.create_share_network( neutron_net_id='fake_net_id', neutron_subnet_id='fake_subnet_id')['id'] self.assertRaises( lib_exc.BadRequest, self.shares_v2_client.migrate_share, self.share['id'], self.dest_pool, new_share_type_id=new_type_opposite['share_type']['id'], new_share_network_id=new_share_network_id)
def test_migrate_share_opposite_type_share_network_invalid(self): extra_specs = utils.get_configured_extra_specs( variation='opposite_driver_modes') new_type_opposite = self.create_share_type( name=data_utils.rand_name('share_type_migration_negative'), extra_specs=extra_specs) new_share_network_id = None if CONF.share.multitenancy_enabled: new_share_network_id = self.create_share_network( neutron_net_id='fake_net_id', neutron_subnet_id='fake_subnet_id')['id'] self.assertRaises(lib_exc.BadRequest, self.shares_v2_client.migrate_share, self.share['id'], self.dest_pool, new_share_type_id=new_type_opposite['id'], new_share_network_id=new_share_network_id)