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>
This commit is contained in:
parent
4891bb3820
commit
c1209601b4
@ -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):
|
||||
|
@ -20,25 +20,14 @@ class BaseVolumeTests(volume_base.BaseVolumeTests):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(BaseVolumeTests, cls).setUpClass()
|
||||
# TODO(dtroyer): This needs to be updated to specifically check for
|
||||
# Volume v1 rather than just 'volume', but for now
|
||||
# that is enough until we get proper version negotiation
|
||||
cls.haz_volume_v1 = cls.is_service_enabled('volume')
|
||||
super().setUpClass()
|
||||
cls.haz_volume_v1 = cls.is_service_enabled('block-storage', '1.0')
|
||||
|
||||
def setUp(self):
|
||||
super(BaseVolumeTests, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
# This class requires Volume v1
|
||||
# if not self.haz_volume_v1:
|
||||
# self.skipTest("No Volume v1 service present")
|
||||
|
||||
# TODO(dtroyer): We really want the above to work but right now
|
||||
# (12Sep2017) DevStack still creates a 'volume'
|
||||
# service type even though there is no service behind
|
||||
# it. Until that is fixed we need to just skip the
|
||||
# volume v1 functional tests in master.
|
||||
self.skipTest("No Volume v1 service present")
|
||||
if not self.haz_volume_v1:
|
||||
self.skipTest("No Volume v1 service present")
|
||||
|
||||
ver_fixture = fixtures.EnvironmentVariable(
|
||||
'OS_VOLUME_API_VERSION', '1'
|
||||
|
@ -18,8 +18,17 @@ from openstackclient.tests.functional.volume import base
|
||||
class BaseVolumeTests(base.BaseVolumeTests):
|
||||
"""Base class for Volume functional tests. """
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.haz_volume_v2 = cls.is_service_enabled('block-storage', '2.0')
|
||||
|
||||
def setUp(self):
|
||||
super(BaseVolumeTests, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
if not self.haz_volume_v2:
|
||||
self.skipTest("No Volume v2 service present")
|
||||
|
||||
ver_fixture = fixtures.EnvironmentVariable(
|
||||
'OS_VOLUME_API_VERSION', '2'
|
||||
)
|
||||
|
@ -18,8 +18,17 @@ from openstackclient.tests.functional.volume import base
|
||||
class BaseVolumeTests(base.BaseVolumeTests):
|
||||
"""Base class for Volume functional tests. """
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.haz_volume_v3 = cls.is_service_enabled('block-storage', '3.0')
|
||||
|
||||
def setUp(self):
|
||||
super(BaseVolumeTests, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
if not self.haz_volume_v3:
|
||||
self.skipTest("No Volume v3 service present")
|
||||
|
||||
ver_fixture = fixtures.EnvironmentVariable(
|
||||
'OS_VOLUME_API_VERSION', '3'
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user