def setUp(self): rd_user = test_config.users.find_user( Requirements(is_admin=False, services=["trove"])) rd_admin = test_config.users.find_user( Requirements(is_admin=True, services=["trove"])) self.rd_client = create_dbaas_client(rd_user) self.rd_admin = create_dbaas_client(rd_admin)
def setUp(self): self.orig_conf_value = CONF.root_on_create CONF.root_on_create = True self.dbaas = util.create_dbaas_client(instance_info.user) self.dbaas_admin = util.create_dbaas_client(instance_info.admin_user) self.history = self.dbaas_admin.management.root_enabled_history self.enabled = self.dbaas.root.is_root_enabled
def setUp(self): """Sets up the client.""" reqs = Requirements(is_admin=True) instance_info.admin_user = CONFIG.users.find_user(reqs) instance_info.dbaas_admin = create_dbaas_client( instance_info.admin_user) global dbaas_admin dbaas_admin = instance_info.dbaas_admin # Make sure we create the client as the correct user if we're using # a pre-built instance. if existing_instance(): mgmt_inst = dbaas_admin.mgmt.instances.show(existing_instance()) t_id = mgmt_inst.tenant_id instance_info.user = CONFIG.users.find_user_by_tenant_id(t_id) else: reqs = Requirements(is_admin=False) instance_info.user = CONFIG.users.find_user(reqs) instance_info.dbaas = create_dbaas_client(instance_info.user) instance_info.nova_client = util.create_nova_client(instance_info.user) instance_info.flavors = instance_info.nova_client.flavors.list() global dbaas dbaas = instance_info.dbaas
def mgmt_reset_task_status_clears_backups(self): self.reset_task_status() self._reload_db_info() assert_equal(self.db_info.task_status, InstanceTasks.NONE) user = test_config.users.find_user(Requirements(is_admin=False)) dbaas = create_dbaas_client(user) admin = test_config.users.find_user(Requirements(is_admin=True)) admin_dbaas = create_dbaas_client(admin) result = dbaas.instances.backups(self.db_info.id) assert_equal(0, len(result)) # Create some backups. backup_models.DBBackup.create( name="forever_new", description="forever new", tenant_id=self.tenant_id, state=state.BackupState.NEW, instance_id=self.db_info.id, deleted=False) backup_models.DBBackup.create( name="forever_build", description="forever build", tenant_id=self.tenant_id, state=state.BackupState.BUILDING, instance_id=self.db_info.id, deleted=False) backup_models.DBBackup.create( name="forever_completed", description="forever completed", tenant_id=self.tenant_id, state=state.BackupState.COMPLETED, instance_id=self.db_info.id, deleted=False) # List the backups for this instance. # There ought to be three in the admin tenant, but # none in a different user's tenant. result = dbaas.instances.backups(self.db_info.id) assert_equal(0, len(result)) result = admin_dbaas.instances.backups(self.db_info.id) assert_equal(3, len(result)) self.backups_to_clear = result # Reset the task status. self.reset_task_status() self._reload_db_info() result = admin_dbaas.instances.backups(self.db_info.id) assert_equal(3, len(result)) for backup in result: if backup.name == 'forever_completed': assert_equal(backup.status, state.BackupState.COMPLETED) else: assert_equal(backup.status, state.BackupState.FAILED)
def mgmt_reset_task_status_clears_backups(self): if CONFIG.fake_mode: raise SkipTest("Test requires an instance.") self.reset_task_status() self._reload_db_info() assert_equal(self.db_info.task_status, InstanceTasks.NONE) user = test_config.users.find_user(Requirements(is_admin=False)) dbaas = create_dbaas_client(user) admin = test_config.users.find_user(Requirements(is_admin=True)) admin_dbaas = create_dbaas_client(admin) result = dbaas.instances.backups(self.db_info.id) assert_equal(0, len(result)) # Create some backups. backup_models.DBBackup.create(name="forever_new", description="forever new", tenant_id=self.tenant_id, state=state.BackupState.NEW, instance_id=self.db_info.id, deleted=False) backup_models.DBBackup.create(name="forever_build", description="forever build", tenant_id=self.tenant_id, state=state.BackupState.BUILDING, instance_id=self.db_info.id, deleted=False) backup_models.DBBackup.create(name="forever_completed", description="forever completed", tenant_id=self.tenant_id, state=state.BackupState.COMPLETED, instance_id=self.db_info.id, deleted=False) # List the backups for this instance. # There ought to be three in the admin tenant, but # none in a different user's tenant. result = dbaas.instances.backups(self.db_info.id) assert_equal(0, len(result)) result = admin_dbaas.instances.backups(self.db_info.id) assert_equal(3, len(result)) self.backups_to_clear = result # Reset the task status. self.reset_task_status() self._reload_db_info() result = admin_dbaas.instances.backups(self.db_info.id) assert_equal(3, len(result)) for backup in result: if backup.name == 'forever_completed': assert_equal(backup.status, state.BackupState.COMPLETED) else: assert_equal(backup.status, state.BackupState.FAILED)
def setUp(self): self.user1 = CONFIG.users.find_user(Requirements(is_admin=False)) self.user2 = CONFIG.users.find_user(Requirements(is_admin=False)) assert_not_equal(self.user1.tenant, self.user2.tenant, "Not enough users to run QuotasTest. Needs >=2.") self.client1 = create_dbaas_client(self.user1) self.client2 = create_dbaas_client(self.user2) self.mgmt_client = create_client(is_admin=True) ''' Orig quotas from config "trove_max_instances_per_user": 55, "trove_max_volumes_per_user": 100, ''' self.original_quotas1 = self.mgmt_client.quota.show(self.user1.tenant) self.original_quotas2 = self.mgmt_client.quota.show(self.user2.tenant)
def __init__(self, sleep_time=10, timeout=1200): self.def_sleep_time = sleep_time self.def_timeout = timeout self.instance_info = instance_info self.auth_client = create_dbaas_client(self.instance_info.user) self.unauth_client = None self._test_helper = None
def test_backup_delete(self): """test delete""" # Test to make sure that user in other tenant is not able # to DELETE this backup reqs = Requirements(is_admin=False) other_user = CONFIG.users.find_user( reqs, black_list=[instance_info.user.auth_user]) other_client = create_dbaas_client(other_user) assert_raises(exceptions.NotFound, other_client.backups.delete, backup_info.id) instance_info.dbaas.backups.delete(backup_info.id) assert_equal(202, instance_info.dbaas.last_http_code) def backup_is_gone(): result = instance_info.dbaas.instances.backups(instance_info.id) if len(result) == 0: return True else: return False poll_until(backup_is_gone) assert_raises(exceptions.NotFound, instance_info.dbaas.backups.get, backup_info.id)
def test_backup_get(self): """Test get backup.""" backup = instance_info.dbaas.backups.get(backup_info.id) assert_equal(backup_info.id, backup.id) assert_equal(backup_info.name, backup.name) assert_equal(backup_info.description, backup.description) assert_equal(instance_info.id, backup.instance_id) assert_not_equal(0.0, backup.size) assert_equal('COMPLETED', backup.status) assert_equal(instance_info.dbaas_datastore, backup.datastore['type']) assert_equal(instance_info.dbaas_datastore_version, backup.datastore['version']) datastore_version = instance_info.dbaas.datastore_versions.get( instance_info.dbaas_datastore, instance_info.dbaas_datastore_version) assert_equal(datastore_version.id, backup.datastore['version_id']) # Test to make sure that user in other tenant is not able # to GET this backup reqs = Requirements(is_admin=False) other_user = CONFIG.users.find_user( reqs, black_list=[instance_info.user.auth_user]) other_client = create_dbaas_client(other_user) assert_raises(exceptions.NotFound, other_client.backups.get, backup_info.id)
def test_instance_resize_flavor(self): """Tests the resize instance/flavor API.""" flavor_name = CONFIG.values.get('instance_bigger_flavor_name', 'm1.medium') flavors = self.instance.dbaas.find_flavors_by_name(flavor_name) new_flavor = flavors[0] asserts.assert_true(new_flavor is not None, "Flavor '%s' not found!" % flavor_name) if not getattr(self, 'instance', None): raise SkipTest( "Skipping this test since instance is not available.") self.rd_client = create_dbaas_client(self.instance.user) self.rd_client.instances.resize_instance(self.instance.id, new_flavor.id) asserts.assert_equal(202, self.rd_client.last_http_code) test_instance = self.rd_client.instances.get(self.instance.id) asserts.assert_equal("RESIZE", test_instance.status) poll_until(lambda: self._find_status(self.rd_client, self.instance.id, "ACTIVE"), sleep_time=SLEEP_TIME, time_out=TIMEOUT) test_instance = self.rd_client.instances.get(self.instance.id) asserts.assert_equal(int(test_instance.flavor['id']), new_flavor.id) self.report.log("Resized Flavor for Instance ID: %s to %s." % ( self.instance.id, new_flavor.id))
def test_instance_delete(self): """Tests the instance delete.""" if not getattr(self, 'instance', None): raise SkipTest( "Skipping this test since instance is not available.") self.rd_client = create_dbaas_client(self.instance.user) self.rd_client.instances.delete(self.instance.id) asserts.assert_equal(202, self.rd_client.last_http_code) test_instance = self.rd_client.instances.get(self.instance.id) asserts.assert_equal("SHUTDOWN", test_instance.status) def _poll(): try: instance = self.rd_client.instances.get(self.instance.id) self.report.log("Instance info %s" % instance._info) asserts.assert_equal("SHUTDOWN", instance.status) return False except exceptions.NotFound: self.report.log("Instance has gone.") asserts.assert_equal(404, self.rd_client.last_http_code) return True poll_until(_poll, sleep_time=SLEEP_TIME, time_out=TIMEOUT) self.report.log("Deleted Instance ID: %s " % self.instance.id)
def setUp(self): users = [ { "auth_user": "******", "auth_key": "password", "tenant": "4000", "requirements": { "is_admin": False, "services": ["trove"] } }, { "auth_user": "******", "auth_key": "password", "tenant": "4050", "requirements": { "is_admin": False, "services": ["trove"] } }] self._users = Users(users) rate_user = self._get_user('rate_limit') self.rd_client = create_dbaas_client(rate_user)
def __init__(self, instance_id): self.instance_id = instance_id req_admin = Requirements(is_admin=True) self.user = util.test_config.users.find_user(req_admin) self.dbaas_admin = util.create_dbaas_client(self.user) self.instance = self.dbaas_admin.management.show(self.instance_id) self.instance_local_id = self.instance.server["local_id"]
def setUp(self): rd_user = test_config.users.find_user(Requirements(is_admin=False, services=["trove"])) self.rd_client = create_dbaas_client(rd_user) if test_config.nova_client is not None: nova_user = test_config.users.find_user(Requirements(services=["nova"])) self.nova_client = create_nova_client(nova_user)
def delete_all(): """Delete every single one.""" user = CONFIG.users.find_user(Requirements(is_admin=False)) dbaas = create_dbaas_client(user) instances = dbaas.instances.list() for instance in instances: instance.delete()
def setUp(self): self.instances = [] reqs = Requirements(is_admin=True) self.user = CONFIG.users.find_user( reqs, black_list=[]) self.client = create_dbaas_client(self.user) self.mgmt = self.client.management
def test_instance_resize_volume(self): """Tests the resize volume API.""" old_volume_size = int(instance_info.volume['size']) new_volume_size = old_volume_size + 1 if not getattr(self, 'instance', None): raise SkipTest( "Skipping this test since instance is not available.") self.rd_client = create_dbaas_client(self.instance.user) self.rd_client.instances.resize_volume(self.instance.id, new_volume_size) asserts.assert_equal(202, self.rd_client.last_http_code) test_instance = self.rd_client.instances.get(self.instance.id) asserts.assert_equal("RESIZE", test_instance.status) poll_until(lambda: self._find_status(self.rd_client, self.instance.id, "ACTIVE"), sleep_time=SLEEP_TIME, time_out=TIMEOUT) instance = self.rd_client.instances.get(self.instance.id) asserts.assert_equal(instance.volume['size'], new_volume_size) self.report.log("Resized Volume for Instance ID: %s to %s." % (self.instance.id, new_volume_size))
def test_limits_exception(self): """Test_limits_exception.""" # use a different user to avoid throttling tests run out of order rate_user_exceeded = self._get_user('rate_limit_exceeded') rd_client = create_dbaas_client(rate_user_exceeded) get = None encountered = False for i in xrange(DEFAULT_RATE + 50): try: limits = rd_client.limits.list() d = self._get_limits_as_dict(limits) get = d["GET"] abs_limits = d["ABSOLUTE"] assert_equal(get.verb, "GET") assert_equal(get.unit, "MINUTE") assert_equal(int(abs_limits.max_instances), DEFAULT_MAX_INSTANCES) assert_equal(int(abs_limits.max_backups), DEFAULT_MAX_BACKUPS) assert_equal(int(abs_limits.max_volumes), DEFAULT_MAX_VOLUMES) except exceptions.OverLimit: encountered = True assert_true(encountered) assert_true(int(get.remaining) <= 50)
def _create_unauthorized_client(self): """Create a client from a different 'unauthorized' user to facilitate negative testing. """ requirements = Requirements(is_admin=False) other_user = CONFIG.users.find_user( requirements, black_list=[self.instance_info.user.auth_user]) return create_dbaas_client(other_user)
def test_backup_delete_other(self): """Test another user cannot delete backup.""" # Test to make sure that user in other tenant is not able # to DELETE this backup reqs = Requirements(is_admin=False) other_user = CONFIG.users.find_user(reqs, black_list=[instance_info.user.auth_user]) other_client = create_dbaas_client(other_user) assert_raises(exceptions.NotFound, other_client.backups.delete, backup_info.id)
def setUp(self): rd_user = test_config.users.find_user( Requirements(is_admin=False, services=["trove"])) self.rd_client = create_dbaas_client(rd_user) self.datastore_active = self.rd_client.datastores.get( test_config.dbaas_datastore) self.datastore_version_active = self.rd_client.datastore_versions.list( self.datastore_active.id)[0]
def setUp(self): admin_req = Requirements(is_admin=True) self.admin_user = test_config.users.find_user(admin_req) self.admin_client = create_dbaas_client(self.admin_user) user_req = Requirements(is_admin=False) self.users = test_config.users.find_all_users_who_satisfy(user_req) self.user_tenant_ids = [user.tenant_id for user in self.users] self._create_instances_for_users()
def clear_test_backups(self): for backup in self.backups_to_clear: found_backup = backup_models.DBBackup.find_by(id=backup.id) found_backup.delete() user = test_config.users.find_user(Requirements(is_admin=False)) dbaas = create_dbaas_client(user) result = dbaas.instances.backups(self.db_info.id) assert_equal(0, len(result))
def clear_test_backups(self): for backup in self.backups_to_clear: found_backup = backup_models.DBBackup.find_by(id=backup.id) found_backup.delete() admin = test_config.users.find_user(Requirements(is_admin=True)) admin_dbaas = create_dbaas_client(admin) result = admin_dbaas.instances.backups(self.db_info.id) assert_equal(0, len(result))
def test_configurations_get(self): # test that the instance shows up on the assigned configuration result = instance_info.dbaas.configurations.get(configuration_info.id) assert_equal(configuration_info.id, result.id) assert_equal(configuration_info.name, result.name) assert_equal(configuration_info.description, result.description) # check the result field types with TypeCheck("configuration", result) as check: check.has_field("id", basestring) check.has_field("name", basestring) check.has_field("description", basestring) check.has_field("values", dict) check.has_field("created", basestring) check.has_field("updated", basestring) check.has_field("instance_count", int) print(result.values) # check for valid timestamps assert_true(_is_valid_timestamp(result.created)) assert_true(_is_valid_timestamp(result.updated)) # check that created and updated timestamps differ, since # test_appending_to_existing_configuration should have changed the # updated timestamp assert_not_equal(result.created, result.updated) assert_equal(result.instance_count, 1) with CollectionCheck("configuration_values", result.values) as check: # check each item has the correct type according to the rules for (item_key, item_val) in result.values.iteritems(): print("item_key: %s" % item_key) print("item_val: %s" % item_val) dbaas = instance_info.dbaas param = dbaas.configuration_parameters.get_parameter( instance_info.dbaas_datastore, instance_info.dbaas_datastore_version, item_key ) if param.type == "integer": check.has_element(item_key, int) if param.type == "string": check.has_element(item_key, basestring) if param.type == "boolean": check.has_element(item_key, bool) # Test to make sure that another user is not able to GET this config reqs = Requirements(is_admin=False) test_auth_user = instance_info.user.auth_user other_user = CONFIG.users.find_user(reqs, black_list=[test_auth_user]) other_user_tenant_id = other_user.tenant_id client_tenant_id = instance_info.user.tenant_id if other_user_tenant_id == client_tenant_id: other_user = CONFIG.users.find_user(reqs, black_list=[instance_info.user.auth_user, other_user]) print(other_user) print(other_user.__dict__) other_client = create_dbaas_client(other_user) assert_raises(exceptions.NotFound, other_client.configurations.get, configuration_info.id)
def setUp(self): rd_user = test_config.users.find_user(Requirements(is_admin=False, services=["trove"])) self.rd_client = create_dbaas_client(rd_user) self.datastore = self.rd_client.datastores.get(test_config.dbaas_datastore) self.name1 = "test_instance1" self.name2 = "test_instance2" self.volume = {"size": 2} self.instance_id = None
def setUp(self): rd_user = test_config.users.find_user( Requirements(is_admin=False, services=["trove"])) self.rd_client = create_dbaas_client(rd_user) if test_config.nova_client is not None: nova_user = test_config.users.find_user( Requirements(services=["nova"])) self.nova_client = create_nova_client(nova_user)
def setUp(self): """Create client for tests.""" reqs = Requirements(is_admin=True) self.user = CONFIG.users.find_user(reqs) self.client = create_dbaas_client(self.user) if test_config.nova_client is not None: nova_user = test_config.users.find_user( Requirements(services=["nova"])) self.nova_client = create_nova_client(nova_user) self.images = self.nova_client.images.list()
def __init__(self, instance_id): self.instance_id = instance_id req_admin = Requirements(is_admin=True) self.user = util.test_config.users.find_user(req_admin) self.dbaas_admin = util.create_dbaas_client(self.user) self.instance = self.dbaas_admin.management.show(self.instance_id) self.ip_address = self.instance.ip[0] TROVE_TEST_SSH_USER = os.environ.get('TROVE_TEST_SSH_USER') if TROVE_TEST_SSH_USER and '@' not in self.ip_address: self.ip_address = TROVE_TEST_SSH_USER + '@' + self.ip_address
def test_backup_delete_other(self): """Test another user cannot delete backup.""" # Test to make sure that user in other tenant is not able # to DELETE this backup reqs = Requirements(is_admin=False) other_user = CONFIG.users.find_user( reqs, black_list=[instance_info.user.auth_user]) other_client = create_dbaas_client(other_user) assert_raises(exceptions.NotFound, other_client.backups.delete, backup_info.id)
def mgmt_instance_get(): """ Tests the mgmt instances index method. """ reqs = Requirements(is_admin=True) user = CONFIG.users.find_user(reqs) client = create_dbaas_client(user) mgmt = client.management # Grab the info.id created by the main instance test which is stored in # a global. id = instance_info.id api_instance = mgmt.show(id) # Print out all fields for extra info if the test fails. for name in dir(api_instance): print(str(name) + "=" + str(getattr(api_instance, name))) with TypeCheck("instance", api_instance) as instance: instance.has_field('created', basestring) instance.has_field('deleted', bool) # If the instance hasn't been deleted, this should be false... but # lets avoid creating more ordering work. instance.has_field('deleted_at', (basestring, None)) instance.has_field('flavor', dict, flavor_check) instance.has_field('guest_status', dict, guest_status_check) instance.has_field('id', basestring) instance.has_field('links', list) instance.has_field('name', basestring) #instance.has_field('server_status', basestring) instance.has_field('status', basestring) instance.has_field('tenant_id', basestring) instance.has_field('updated', basestring) # Can be None if no volume is given on this instance. if CONFIG.trove_volume_support: instance.has_field('volume', dict, volume_check) else: instance.has_field('volume', None) #TODO(tim-simpson): Validate additional fields, assert # no extra fields exist. with CollectionCheck("server", api_instance.server) as server: server.has_element("addresses", dict) server.has_element("deleted", bool) server.has_element("deleted_at", (basestring, None)) server.has_element("host", basestring) server.has_element("id", basestring) server.has_element("local_id", int) server.has_element("name", basestring) server.has_element("status", basestring) server.has_element("tenant_id", basestring) if (CONFIG.trove_volume_support and CONFIG.trove_main_instance_has_volume): with CollectionCheck("volume", api_instance.volume) as volume: volume.has_element("attachments", list) volume.has_element("availability_zone", basestring) volume.has_element("created_at", (basestring, None)) volume.has_element("id", basestring) volume.has_element("size", int) volume.has_element("status", basestring)
def setUp(self): rd_user = test_config.users.find_user( Requirements(is_admin=False, services=["trove"])) self.rd_client = create_dbaas_client(rd_user) self.datastore = self.rd_client.datastores.get( test_config.dbaas_datastore) self.name1 = "test_instance1" self.name2 = "test_instance2" self.volume = {'size': 2} self.instance_id = None
def setUp(self): reqs = Requirements(is_admin=True) self.user = test_config.users.find_user(reqs) self.client = create_dbaas_client(self.user) volume = None if VOLUME_SUPPORT: volume = {'size': 1} self.instance = create_instance_blocking( self.client, name="Test Scheduled Task Instance", flavor_id=instance_info.dbaas_flavor_href, volume=volume, databases=[], users=[], ) other_reqs = Requirements(is_admin=False) self.other_user = test_config.users.find_user(other_reqs) self.other_client = create_dbaas_client(self.other_user)
def setUp(self): self.reqs = Requirements(is_admin=False) self.user = CONFIG.users.find_user(self.reqs) self.dbaas = create_dbaas_client(self.user) volume = None if VOLUME_SUPPORT: volume = {"size": 1} self.instance = self.dbaas.instances.create( name="qe_instance", flavor_id=instance_info.dbaas_flavor_href, volume=volume, databases=[{"name": "firstdb", "character_set": "latin2", "collate": "latin2_general_ci"}])
def setUp(self): """Create client for tests.""" reqs = Requirements(is_admin=True) self.user = CONFIG.users.find_user(reqs) self.client = create_dbaas_client(self.user) self.images = [] if test_config.glance_client is not None: glance_user = test_config.users.find_user( Requirements(services=["glance"])) self.glance_client = create_glance_client(glance_user) images = self.glance_client.images.list() for image in images: self.images.append(image.id)
def mgmt_reset_task_status_clears_backups(self): self.reset_task_status() self._reload_db_info() assert_equal(self.db_info.task_status, InstanceTasks.NONE) user = test_config.users.find_user(Requirements(is_admin=False)) dbaas = create_dbaas_client(user) result = dbaas.instances.backups(self.db_info.id) assert_equal(0, len(result)) # Create some backups. forever_new = backup_models.DBBackup.create( name="forever_new", description="forever new", tenant_id=self.tenant_id, state=backup_models.BackupState.NEW, instance_id=self.db_info.id, deleted=False) forever_build = backup_models.DBBackup.create( name="forever_build", description="forever build", tenant_id=self.tenant_id, state=backup_models.BackupState.BUILDING, instance_id=self.db_info.id, deleted=False) forever_saved = backup_models.DBBackup.create( name="forever_completed", description="forever completed", tenant_id=self.tenant_id, state=backup_models.BackupState.COMPLETED, instance_id=self.db_info.id, deleted=False) # List the backups for this instance. There ought to be three! result = dbaas.instances.backups(self.db_info.id) assert_equal(3, len(result)) self.backups_to_clear = result # Reset the task status. self.reset_task_status() self._reload_db_info() result = dbaas.instances.backups(self.db_info.id) assert_equal(3, len(result)) for backup in result: if backup.name == 'forever_completed': assert_equal(backup.status, backup_models.BackupState.COMPLETED) else: assert_equal(backup.status, backup_models.BackupState.FAILED)
def setUp(self): """Sets up the client.""" reqs = Requirements(is_admin=True) instance_info.admin_user = CONFIG.users.find_user(reqs) instance_info.dbaas_admin = create_dbaas_client( instance_info.admin_user) global dbaas_admin dbaas_admin = instance_info.dbaas_admin # Make sure we create the client as the correct user if we're using # a pre-built instance. if existing_instance(): mgmt_inst = dbaas_admin.mgmt.instances.show(existing_instance()) t_id = mgmt_inst.tenant_id instance_info.user = CONFIG.users.find_user_by_tenant_id(t_id) else: reqs = Requirements(is_admin=False) instance_info.user = CONFIG.users.find_user(reqs) instance_info.dbaas = create_dbaas_client(instance_info.user) global dbaas dbaas = instance_info.dbaas
def _delete_instances_for_users(self): for user in self.users: user_client = create_dbaas_client(user) while True: deleted_count = 0 user_instances = user_client.instances.list() for instance in user_instances: try: instance.delete() except exceptions.NotFound: deleted_count += 1 except Exception: print("Failed to delete instance") if deleted_count == len(user_instances): break
def test_create_cluster_with_fewer_instances(self): invalid_request_body_with_few_instances = [ {"flavorRef": 2, "volume": {"size": 1}}] self.rd_client = create_dbaas_client(self.instance.user) asserts.assert_raises( exceptions.BadRequest, self.rd_client.clusters.create, "test_cluster", self.instance.dbaas_datastore, self.instance.dbaas_datastore_version, instances=invalid_request_body_with_few_instances) asserts.assert_equal(400, self.rd_client.last_http_code)
def __init__(self, sleep_time=10, timeout=1200): self.def_sleep_time = sleep_time self.def_timeout = timeout self.instance_info = instance_info instance_info.dbaas_datastore = CONFIG.dbaas_datastore instance_info.dbaas_datastore_version = CONFIG.dbaas_datastore_version if self.VOLUME_SUPPORT: instance_info.volume = {'size': CONFIG.get('trove_volume_size', 1)} else: instance_info.volume = None self.auth_client = create_dbaas_client(self.instance_info.user) self.unauth_client = None self._test_helper = None