Split tests between the two current CloudKitty API versions
For convenience we split the tests between the two current versions of CloudKitty. Change-Id: Ib10a6ffe9e0dd6c628f05588b463230139bf42c8 Story: 2006578 Task: 36895
This commit is contained in:
parent
e13403b9fb
commit
0d0a5a7e4a
|
@ -25,12 +25,9 @@ from tempest import manager
|
|||
|
||||
CONF = config.CONF
|
||||
|
||||
CLOUDKITTY_API_VERSION = 'v1'
|
||||
|
||||
|
||||
class RatingClient(rest_client.RestClient):
|
||||
"""Implementation of cloudkittyclient for testing purposes"""
|
||||
api_version = 'v1'
|
||||
class BaseRatingClient(rest_client.RestClient):
|
||||
"""Base class for cloudkittyclient implementations"""
|
||||
|
||||
@staticmethod
|
||||
def deserialize(body):
|
||||
|
@ -50,6 +47,12 @@ class RatingClient(rest_client.RestClient):
|
|||
body = dict(body=body) if isinstance(body, list) else body
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
|
||||
class RatingClientV1(BaseRatingClient):
|
||||
"""Implementation of cloudkittyclient for v1 endpoints"""
|
||||
|
||||
api_version = 'v1'
|
||||
|
||||
def get_collector_mappings(self, service=None):
|
||||
uri = '/collector/mappings/'
|
||||
if service:
|
||||
|
@ -389,21 +392,10 @@ class RatingClient(rest_client.RestClient):
|
|||
expected_code=204)
|
||||
|
||||
|
||||
class Manager(manager.Manager):
|
||||
class RatingClientV2(RatingClientV1):
|
||||
"""Implementation of cloudkittyclient for v2 endpoints"""
|
||||
|
||||
rating_params = {
|
||||
'service': CONF.rating_plugin.service_name,
|
||||
'region': CONF.identity.region,
|
||||
'endpoint_type': CONF.rating_plugin.endpoint_type,
|
||||
}
|
||||
|
||||
def __init__(self, credentials=None, service=None):
|
||||
super(Manager, self).__init__(credentials)
|
||||
self.set_rating_client()
|
||||
|
||||
def set_rating_client(self):
|
||||
self.rating_client = RatingClient(self.auth_provider,
|
||||
**self.rating_params)
|
||||
api_version = 'v2'
|
||||
|
||||
|
||||
class CustomIdentityClient(object):
|
||||
|
@ -453,3 +445,24 @@ class CustomIdentityClient(object):
|
|||
return getattr(
|
||||
self._find_item(roles, 'name', 'rating'), 'id', None,
|
||||
)
|
||||
|
||||
|
||||
class Manager(manager.Manager):
|
||||
rating_params = {
|
||||
'service': CONF.rating_plugin.service_name,
|
||||
'region': CONF.identity.region,
|
||||
'endpoint_type': CONF.rating_plugin.endpoint_type,
|
||||
}
|
||||
|
||||
def __init__(self, credentials=None, service=None):
|
||||
super(Manager, self).__init__(credentials)
|
||||
self.rating_clients = {
|
||||
'v1': RatingClientV1(self.auth_provider, **self.rating_params),
|
||||
'v2': RatingClientV2(self.auth_provider, **self.rating_params),
|
||||
}
|
||||
|
||||
def get_rating_client(self, api_version='v2'):
|
||||
if api_version not in self.rating_clients:
|
||||
raise ValueError('API version must be one of the following: {}',
|
||||
list(self.rating_client.keys()))
|
||||
return self.rating_clients[api_version]
|
||||
|
|
|
@ -37,14 +37,14 @@ def skipIf(flag, reason):
|
|||
|
||||
class BaseRatingTest(tempest.test.BaseTestCase):
|
||||
"""Base test class for all Rating API tests."""
|
||||
|
||||
client_manager = client.Manager
|
||||
|
||||
@classmethod
|
||||
def setup_clients(cls):
|
||||
super(BaseRatingTest, cls).setup_clients()
|
||||
os_var = 'os_{}'.format(cls.credentials[0])
|
||||
cls.rating_client = getattr(cls, os_var).rating_client
|
||||
cls.rating_client = getattr(cls, os_var).get_rating_client(
|
||||
getattr(cls, 'api_version'))
|
||||
|
||||
@classmethod
|
||||
def setup_credentials(cls):
|
||||
|
|
|
@ -22,7 +22,7 @@ from cloudkitty_tempest_plugin.tests.api import base
|
|||
|
||||
|
||||
class CloudkittyAdminAPITest(base.BaseRatingTest):
|
||||
|
||||
api_version = 'v1'
|
||||
credentials = ['admin']
|
||||
|
||||
@decorators.idempotent_id('9c1d4c27-6e7c-42d7-b663-d88f097b7131')
|
||||
|
@ -128,7 +128,7 @@ class CloudkittyAdminAPITest(base.BaseRatingTest):
|
|||
|
||||
|
||||
class CloudkittyPrimaryAPITest(base.BaseRatingTest):
|
||||
|
||||
api_version = 'v1'
|
||||
credentials = ['primary']
|
||||
|
||||
@decorators.idempotent_id('3285bccf-d043-4ad1-b64f-af4db8317cf9')
|
|
@ -20,7 +20,7 @@ from cloudkitty_tempest_plugin.tests.api import base
|
|||
|
||||
|
||||
class CloudkittyHashmapAPITest(base.BaseRatingTest):
|
||||
|
||||
api_version = 'v1'
|
||||
credentials = ['admin']
|
||||
|
||||
@decorators.idempotent_id('7037a3f8-b462-4243-a0bc-ffa3b4700397')
|
|
@ -35,7 +35,7 @@ data = dumbfunc() + 2
|
|||
|
||||
|
||||
class CloudkittyPyscriptAPITest(base.BaseRatingTest):
|
||||
|
||||
api_version = 'v1'
|
||||
credentials = ['admin']
|
||||
|
||||
@decorators.idempotent_id('2015c966-b707-40f7-b84d-9aa6550b9e41')
|
||||
|
@ -69,7 +69,7 @@ class CloudkittyPyscriptAPITest(base.BaseRatingTest):
|
|||
|
||||
|
||||
class CloudkittyPyscriptAPITestNegative(base.BaseRatingTest):
|
||||
|
||||
api_version = 'v1'
|
||||
credentials = ['admin']
|
||||
|
||||
@decorators.idempotent_id('999c97cc-1d71-43b8-988f-d89b8fac4040')
|
Loading…
Reference in New Issue