diff options
| author | Stephen Finucane <sfinucan@redhat.com> | 2021-07-23 12:48:23 +0100 |
|---|---|---|
| committer | Stephen Finucane <sfinucan@redhat.com> | 2021-07-23 12:51:30 +0100 |
| commit | c1209601b4f4b81690a186e51aa819c783367fae (patch) | |
| tree | e95db46512897968331a62a02606914963ac5ba2 /openstackclient/tests/functional/base.py | |
| parent | 4891bb38208fdcd1a2ae60e47b056841e14fbdf7 (diff) | |
| download | python-openstackclient-c1209601b4f4b81690a186e51aa819c783367fae.tar.gz | |
tests: Handle removal of block-storage v2 API
Cinder recently removed their v2 API [1] which is causing the functional
tests to fail. Improve our 'is_service_enabled' test helper to use the
'versions show' command, which queries the service catalog and can give
us information about the service version as well as answer the more
general "is this service available" question. We also resolve a
long-standing TODO in the process.
[1] https://review.opendev.org/c/openstack/cinder/+/792299
Change-Id: I381069357aa008344e15327adf3a863c0c2e1f04
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Diffstat (limited to 'openstackclient/tests/functional/base.py')
| -rw-r--r-- | openstackclient/tests/functional/base.py | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/openstackclient/tests/functional/base.py b/openstackclient/tests/functional/base.py index 3542a827..0ed7dff8 100644 --- a/openstackclient/tests/functional/base.py +++ b/openstackclient/tests/functional/base.py @@ -68,17 +68,24 @@ class TestCase(testtools.TestCase): ) @classmethod - def is_service_enabled(cls, service): - """Ask client cloud if service is available""" - cmd = ('service show -f value -c enabled {service}' - .format(service=service)) - try: - return "True" in cls.openstack(cmd) - except exceptions.CommandFailed as e: - if "No service with a type, name or ID of" in str(e): - return False - else: - raise # Unable to determine if service is enabled + def is_service_enabled(cls, service, version=None): + """Ask client cloud if service is available + + :param service: The service name or type. This should be either an + exact match to what is in the catalog or a known official value or + alias from service-types-authority + :param version: Optional version. This should be a major version, e.g. + '2.0' + :returns: True if the service is enabled and optionally provides the + specified API version, else False + """ + ret = cls.openstack( + f'versions show --service {service} -f value -c Version' + ).splitlines() + if version: + return version in ret + + return bool(ret) @classmethod def is_extension_enabled(cls, alias): |
