Fix resource leaks in IdentityPolicyAssociationRbacTest class
The IdentityPolicyAssociationRbacTest, IdentityEndpointsV3RbacTest and EndpointFilterProjectsV3RbacTest test cases were leaking region resources on the endpoint create and just using tempest- in the region description. The following changes to fix the leaks and make them easier to find in the future, if they happen. 1) move setup_test_endpoint to the v3 class to have access to the region client and get the region id created when the endpoint created so I can add it to the resource clean-up. 2) add a rand_name for the region id not just the description so we know that tempest- created it. Change-Id: I3bd5bf02ef6d434ccba65a5a732e550b007a2309
This commit is contained in:
parent
1099cdf21e
commit
cb096146d7
|
@ -27,30 +27,6 @@ LOG = logging.getLogger(__name__)
|
||||||
class BaseIdentityRbacTest(rbac_utils.RbacUtilsMixin,
|
class BaseIdentityRbacTest(rbac_utils.RbacUtilsMixin,
|
||||||
base.BaseIdentityTest):
|
base.BaseIdentityTest):
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setup_test_endpoint(cls, service=None):
|
|
||||||
"""Creates a service and an endpoint for test."""
|
|
||||||
interface = 'public'
|
|
||||||
url = data_utils.rand_url()
|
|
||||||
region_name = data_utils.rand_name(
|
|
||||||
cls.__name__ + '-region')
|
|
||||||
# Endpoint creation requires a service
|
|
||||||
if service is None:
|
|
||||||
service = cls.setup_test_service()
|
|
||||||
params = {
|
|
||||||
'service_id': service['id'],
|
|
||||||
'region': region_name,
|
|
||||||
'interface': interface,
|
|
||||||
'url': url
|
|
||||||
}
|
|
||||||
|
|
||||||
endpoint = cls.endpoints_client.create_endpoint(**params)['endpoint']
|
|
||||||
cls.addClassResourceCleanup(
|
|
||||||
test_utils.call_and_ignore_notfound_exc,
|
|
||||||
cls.endpoints_client.delete_endpoint, endpoint['id'])
|
|
||||||
|
|
||||||
return endpoint
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup_test_role(cls):
|
def setup_test_role(cls):
|
||||||
"""Set up a test role."""
|
"""Set up a test role."""
|
||||||
|
@ -181,6 +157,33 @@ class BaseIdentityV3RbacTest(BaseIdentityRbacTest):
|
||||||
|
|
||||||
super(BaseIdentityV3RbacTest, cls).resource_cleanup()
|
super(BaseIdentityV3RbacTest, cls).resource_cleanup()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setup_test_endpoint(cls, service=None):
|
||||||
|
"""Creates a service and an endpoint for test."""
|
||||||
|
interface = 'public'
|
||||||
|
url = data_utils.rand_url()
|
||||||
|
region_name = data_utils.rand_name(
|
||||||
|
cls.__name__ + '-region')
|
||||||
|
# Endpoint creation requires a service
|
||||||
|
if service is None:
|
||||||
|
service = cls.setup_test_service()
|
||||||
|
params = {
|
||||||
|
'service_id': service['id'],
|
||||||
|
'region': region_name,
|
||||||
|
'interface': interface,
|
||||||
|
'url': url
|
||||||
|
}
|
||||||
|
|
||||||
|
endpoint = cls.endpoints_client.create_endpoint(**params)['endpoint']
|
||||||
|
cls.addClassResourceCleanup(
|
||||||
|
test_utils.call_and_ignore_notfound_exc,
|
||||||
|
cls.regions_client.delete_region, endpoint['region'])
|
||||||
|
cls.addClassResourceCleanup(
|
||||||
|
test_utils.call_and_ignore_notfound_exc,
|
||||||
|
cls.endpoints_client.delete_endpoint, endpoint['id'])
|
||||||
|
|
||||||
|
return endpoint
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup_test_credential(cls, user=None):
|
def setup_test_credential(cls, user=None):
|
||||||
"""Creates a credential for test."""
|
"""Creates a credential for test."""
|
||||||
|
@ -249,8 +252,10 @@ class BaseIdentityV3RbacTest(BaseIdentityRbacTest):
|
||||||
"""Creates a region for test."""
|
"""Creates a region for test."""
|
||||||
description = data_utils.rand_name(
|
description = data_utils.rand_name(
|
||||||
cls.__name__ + '-test_region_desc')
|
cls.__name__ + '-test_region_desc')
|
||||||
|
id = data_utils.rand_name(cls.__name__)
|
||||||
|
|
||||||
region = cls.regions_client.create_region(
|
region = cls.regions_client.create_region(
|
||||||
|
id=id,
|
||||||
description=description)['region']
|
description=description)['region']
|
||||||
cls.regions.append(region)
|
cls.regions.append(region)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue