Fix discovery of identity versions

Currently when identity url is not a v2 address, python-tempestconf returns
an empty list of identity versions.
The patch tries to get all versions. If it fails it fails due to the fact that
the query for versions was version specific and therefor the response
contains only data about that version. At this point now the tool will return
a list containing only this version.
Also the patch adds a check if discovered versions' status is stable.

Change-Id: I2ce80eb9210e953586f1fe80deef21aae38c2731
This commit is contained in:
Martin Kopec 2018-02-14 15:57:46 +00:00
parent ebfb56b0b6
commit b031af6b0a
3 changed files with 21 additions and 5 deletions

View File

@ -156,10 +156,17 @@ class IdentityService(VersionedService):
return []
def deserialize_versions(self, body):
if 'v2' in self.service_url:
return map(lambda x: x['id'], body['versions']['values'])
else:
return []
try:
versions = []
for v in body['versions']['values']:
# TripleO is in transition to v3 only, so the environment
# still returns v2 versions even though they're deprecated.
# Therefor pick only versions with stable status.
if v['status'] == 'stable':
versions.append(v['id'])
return versions
except KeyError:
return [body['version']['id']]
def get_versions(self):
return super(IdentityService, self).get_versions(top_level=False)

View File

@ -968,6 +968,8 @@ def create_tempest_networks(clients, conf, has_neutron, public_network_id):
def configure_keystone_feature_flags(conf, services):
"""Set keystone feature flags based upon version ID."""
supported_versions = services.get('identity', {}).get('versions', [])
if len(supported_versions) <= 1:
return
for version in supported_versions:
major, minor = version.split('.')[:2]
# Enable the domain specific roles feature flag. For more information,

View File

@ -138,7 +138,14 @@ class TestIdentityService(BaseServiceTest):
self.FAKE_IDENTITY_EXTENSIONS)
def test_deserialize_versions(self):
expected_resp = ['v3.8', 'v2.0']
expected_resp = ['v3.8']
self._test_deserialize_versions(self.Service,
expected_resp,
self.FAKE_IDENTITY_VERSIONS)
expected_resp = ['v2.1', 'v3.8']
# add not deprecated v2 version to FAKE_IDENTITY_VERSIONS
v2 = {'status': 'stable', 'id': 'v2.1'}
self.FAKE_IDENTITY_VERSIONS['versions']['values'].append(v2)
self._test_deserialize_versions(self.Service,
expected_resp,
self.FAKE_IDENTITY_VERSIONS)