Browse Source

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
changes/83/680283/3
Doug Schveninger 1 week ago
parent
commit
cb096146d7
1 changed files with 29 additions and 24 deletions
  1. 29
    24
      patrole_tempest_plugin/tests/api/identity/rbac_base.py

+ 29
- 24
patrole_tempest_plugin/tests/api/identity/rbac_base.py View File

@@ -27,30 +27,6 @@ LOG = logging.getLogger(__name__)
27 27
 class BaseIdentityRbacTest(rbac_utils.RbacUtilsMixin,
28 28
                            base.BaseIdentityTest):
29 29
 
30
-    @classmethod
31
-    def setup_test_endpoint(cls, service=None):
32
-        """Creates a service and an endpoint for test."""
33
-        interface = 'public'
34
-        url = data_utils.rand_url()
35
-        region_name = data_utils.rand_name(
36
-            cls.__name__ + '-region')
37
-        # Endpoint creation requires a service
38
-        if service is None:
39
-            service = cls.setup_test_service()
40
-        params = {
41
-            'service_id': service['id'],
42
-            'region': region_name,
43
-            'interface': interface,
44
-            'url': url
45
-        }
46
-
47
-        endpoint = cls.endpoints_client.create_endpoint(**params)['endpoint']
48
-        cls.addClassResourceCleanup(
49
-            test_utils.call_and_ignore_notfound_exc,
50
-            cls.endpoints_client.delete_endpoint, endpoint['id'])
51
-
52
-        return endpoint
53
-
54 30
     @classmethod
55 31
     def setup_test_role(cls):
56 32
         """Set up a test role."""
@@ -181,6 +157,33 @@ class BaseIdentityV3RbacTest(BaseIdentityRbacTest):
181 157
 
182 158
         super(BaseIdentityV3RbacTest, cls).resource_cleanup()
183 159
 
160
+    @classmethod
161
+    def setup_test_endpoint(cls, service=None):
162
+        """Creates a service and an endpoint for test."""
163
+        interface = 'public'
164
+        url = data_utils.rand_url()
165
+        region_name = data_utils.rand_name(
166
+            cls.__name__ + '-region')
167
+        # Endpoint creation requires a service
168
+        if service is None:
169
+            service = cls.setup_test_service()
170
+        params = {
171
+            'service_id': service['id'],
172
+            'region': region_name,
173
+            'interface': interface,
174
+            'url': url
175
+        }
176
+
177
+        endpoint = cls.endpoints_client.create_endpoint(**params)['endpoint']
178
+        cls.addClassResourceCleanup(
179
+            test_utils.call_and_ignore_notfound_exc,
180
+            cls.regions_client.delete_region, endpoint['region'])
181
+        cls.addClassResourceCleanup(
182
+            test_utils.call_and_ignore_notfound_exc,
183
+            cls.endpoints_client.delete_endpoint, endpoint['id'])
184
+
185
+        return endpoint
186
+
184 187
     @classmethod
185 188
     def setup_test_credential(cls, user=None):
186 189
         """Creates a credential for test."""
@@ -249,8 +252,10 @@ class BaseIdentityV3RbacTest(BaseIdentityRbacTest):
249 252
         """Creates a region for test."""
250 253
         description = data_utils.rand_name(
251 254
             cls.__name__ + '-test_region_desc')
255
+        id = data_utils.rand_name(cls.__name__)
252 256
 
253 257
         region = cls.regions_client.create_region(
258
+            id=id,
254 259
             description=description)['region']
255 260
         cls.regions.append(region)
256 261
 

Loading…
Cancel
Save