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) if CONFIG.white_box: instance_info.nova_client = create_nova_client(instance_info.user) instance_info.volume_client = create_nova_client( instance_info.user, service_type=CONFIG.nova_client['volume_service_type']) global dbaas dbaas = instance_info.dbaas if CONFIG.white_box: user = instance_info.user.auth_user tenant = instance_info.user.tenant instance_info.user_context = context.RequestContext(user, tenant)
def setUp(self): self.dbaas = util.create_dbaas_client(instance_info.user) self.dbaas_admin = util.create_dbaas_client(instance_info.admin_user) databases = [{"name": self.db1, "charset": "latin2", "collate": "latin2_general_ci"}, {"name": self.db2}] try: self.dbaas.databases.create(instance_info.id, databases) except exceptions.BadRequest: pass # If the db already exists that's OK. if not FAKE: time.sleep(5)
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 "reddwarf_max_instances_per_user": 55, "reddwarf_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, 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): users = [ { "auth_user": "******", "auth_key": "password", "tenant": "4000", "requirements": { "is_admin": False, "services": ["reddwarf"] } }, { "auth_user": "******", "auth_key": "password", "tenant": "4050", "requirements": { "is_admin": False, "services": ["reddwarf"] } }] self._users = Users(users) rate_user = self._get_user('rate_limit') self.rd_client = create_dbaas_client(rate_user)
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) if CONFIG.reddwarf_volume_support: 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 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 setUp(self): rd_user = test_config.users.find_user(Requirements(is_admin=False, services=["reddwarf"])) self.rd_client = create_dbaas_client(rd_user) if test_config.nova_client is not None: nova_user = test_config.users.find_user(Requirements(is_admin=False, services=["nova"])) self.nova_client = create_nova_client(nova_user)
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 setUp(self): rd_user = test_config.users.find_user( Requirements(is_admin=False, services=["reddwarf"])) self.rd_client = create_dbaas_client(rd_user) if test_config.nova_client is not None: nova_user = test_config.users.find_user( Requirements(is_admin=False, services=["nova"])) self.nova_client = create_nova_client(nova_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) self.instance = self.dbaas.instances.create( name="qe_instance", flavor_id=1, volume={"size": 1}, databases=[{"name": "firstdb", "character_set": "latin2", "collate": "latin2_general_ci"}])
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.reddwarf_volume_support: instance.has_field('volume', dict, volume_check) else: instance.has_field('volume', None) #TODO: 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.reddwarf_volume_support and CONFIG.reddwarf_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): self.user = test_config.users.find_user(Requirements(is_admin=True)) self.client = create_dbaas_client(self.user) self.name = 'test_SERVER_ERROR' # Create an instance with a broken compute instance. self.response = self.client.instances.create(self.name, 1, {'size': 1}, []) poll_until(lambda: self.client.instances.get(self.response.id), lambda instance: instance.status == 'ERROR', time_out=10) self.instance = self.client.instances.get(self.response.id) print "Status: %s" % self.instance.status msg = "Instance did not drop to error after server prov failure." assert_equal(self.instance.status, "ERROR", msg)
def setUp(self): self.reqs = Requirements(is_admin=False) self.user = CONFIG.users.find_user(self.reqs) self.dbaas = create_dbaas_client(self.user) self.instance = self.dbaas.instances.create(name="qe_instance", flavor_id=1, volume={"size": 1}, databases=[{ "name": "firstdb", "character_set": "latin2", "collate": "latin2_general_ci" }])
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 setUp(self): users = [{ "auth_user": "******", "auth_key": "password", "tenant": "4000", "requirements": { "is_admin": False, "services": ["reddwarf"] } }, { "auth_user": "******", "auth_key": "password", "tenant": "4050", "requirements": { "is_admin": False, "services": ["reddwarf"] } }] self._users = Users(users) rate_user = self._get_user('rate_limit') self.rd_client = create_dbaas_client(rate_user)
def set_up(self): reqs = Requirements(is_admin=True) self.user = test_config.users.find_user(reqs) self.dbaas = create_dbaas_client(self.user)
def setUp(self): self.user = test_config.users.find_user(Requirements(is_admin=True)) self.client = create_dbaas_client(self.user)
def _create_instances_for_users(self): for user in self.users: user_client = create_dbaas_client(user) for index in range(self.max): name = "instance-%s-%03d" % (user.auth_user, index) user_client.instances.create(name, 1, {'size': 1}, [], [])
def setUp(self): """Sets up the client.""" user = test_config.users.find_user(Requirements(is_admin=False)) self.client = create_dbaas_client(user)
def setUp(self): """Create client for mgmt instance test.""" reqs = Requirements(is_admin=True) self.user = CONFIG.users.find_user(reqs) self.client = create_dbaas_client(self.user)
def setUp(self): self.dbaas = util.create_dbaas_client(instance_info.user) self.dbaas_admin = util.create_dbaas_client(instance_info.admin_user)
def setUp(self): reqs = Requirements(is_admin=False) self.other_user = CONFIG.users.find_user( reqs, black_list=[instance_info.user.auth_user]) self.other_client = create_dbaas_client(self.other_user)
def set_up(self): self.dbaas = util.create_dbaas_client(instance_info.user)
def set_up(self): self.dbaas = util.create_dbaas_client(instance_info.user) self.users = ["test_access_user"] self.databases = [("test_access_db%02i" % i) for i in range(4)]
def setUp(self): """ Create the user and client for use in the subsequent tests.""" self.user = test_config.users.find_user(Requirements(is_admin=False)) self.dbaas = create_dbaas_client(self.user)
def __init__(self): self.status = None self.backup_id = None self.dbaas = util.create_dbaas_client(instance_info.user)