Keep full service type url lookup dict

This makes it easier to access all services from all tests.
This commit is contained in:
Chris Dent 2017-07-30 20:42:07 +00:00
parent 887bd69417
commit e3e2912b80
1 changed files with 12 additions and 11 deletions

View File

@ -40,11 +40,13 @@ class GenericGabbiTest(tempest.test.BaseTestCase):
@classmethod @classmethod
def resource_setup(cls): def resource_setup(cls):
super(GenericGabbiTest, cls).resource_setup() super(GenericGabbiTest, cls).resource_setup()
endpoints, token = cls._get_service_auth([cls.service_type]) endpoints, token = cls._get_service_auth()
# Set test ENVIRON substitutions.
for service_type, url in endpoints.items(): for service_type, url in endpoints.items():
name = '%s_SERVICE' % service_type.upper() name = '%s_SERVICE' % service_type.upper()
os.environ[name] = url os.environ[name] = url
os.environ['SERVICE_TOKEN'] = token
if cls.service_type in endpoints: if cls.service_type in endpoints:
host = None host = None
@ -60,8 +62,6 @@ class GenericGabbiTest(tempest.test.BaseTestCase):
test_loader_name='tempest.scenario.%s.%s' % ( test_loader_name='tempest.scenario.%s.%s' % (
cls.__name__, cls.service_type)) cls.__name__, cls.service_type))
os.environ['SERVICE_TOKEN'] = token
@classmethod @classmethod
def clear_credentials(cls): def clear_credentials(cls):
# FIXME(sileht): We don't want the token to be invalided, but # FIXME(sileht): We don't want the token to be invalided, but
@ -79,20 +79,21 @@ class GenericGabbiTest(tempest.test.BaseTestCase):
self.tearDown() self.tearDown()
@classmethod @classmethod
def _get_service_auth(cls, service_types): def _get_service_auth(cls):
interface = 'public' interface = 'public'
auth = cls.os_admin.auth_provider.get_auth() auth = cls.os_admin.auth_provider.get_auth()
token = auth[0] token = auth[0]
catalog = auth[1]['catalog'] catalog = auth[1]['catalog']
endpoints = {} endpoint_lookup = {}
for service_type in service_types: for entry in catalog:
result = jsonhandler.JSONHandler.extract_json_path_value(catalog, service_type = entry['type']
'$[?type = "%s"].endpoints[?interface = "%s"].url' % endpoints = entry['endpoints']
(service_type, interface)) for endpoint in endpoints:
endpoints[service_type] = result if endpoint['interface'] == interface:
endpoint_lookup[service_type] = endpoint['url']
return endpoints, token return endpoint_lookup, token
def test_fake(self): def test_fake(self):
# NOTE(sileht): A fake test is needed to have the class loaded # NOTE(sileht): A fake test is needed to have the class loaded