def setUp(self): self.user = test_config.users.find_user(Requirements(is_admin=True)) self.client = create_dbaas_client(self.user)
def setUp(self): self.user = CONFIG.users.find_user(Requirements(is_admin=True)) self.client = create_dbaas_client(self.user) self.host = None
def _create_admin_client(self): """Create a client from an admin user.""" requirements = Requirements(is_admin=True, services=["swift"]) admin_user = CONFIG.users.find_user(requirements) return create_dbaas_client(admin_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 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('datastore', dict, datastore_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. if api_instance.server is not None: print("the real content of server: %s" % dir(api_instance.server)) print("the type of server: %s" % type(api_instance.server)) print("the real content of api_instance: %s" % dir(api_instance)) print("the type of api_instance: %s" % type(api_instance)) print(hasattr(api_instance, "server")) 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): """Sets up the client.""" user = test_config.users.find_user(Requirements(is_admin=False)) self.client = create_dbaas_client(user)
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 _create_other_client(self): if not self.other_client: requirements = Requirements(is_admin=False) other_user = CONFIG.users.find_user( requirements, black_list=[self.instance_info.user.auth_user]) self.other_client = create_dbaas_client(other_user)
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 if not CONFIG.fake_mode: 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): self.user = test_config.users.find_user(Requirements(is_admin=True)) self.admin_client = create_dbaas_client(self.user) self.datastore_version_id = self.admin_client.datastore_versions.get( "mysql", "5.5").id
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): 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 setUp(self): rd_user = test_config.users.find_user( Requirements(is_admin=False, services=["trove"])) self.rd_client = create_dbaas_client(rd_user)
def set_up(self): """Create a ton of instances.""" reqs = Requirements(is_admin=False) self.user = CONFIG.users.find_user(reqs) self.dbaas = create_dbaas_client(self.user)