1. Problem
Running tempest.api.object_storage.test_container_sync_middleware.ContainerSyncMiddlewareTest.test_container_synchronization along with all other swift testcases will fail with Unauthorized error, but it can pass when being executed alone.
Traceback (most recent call last):
File "/home/zfl/gx_mtest_node/tempest_m/tempest/common/utils/__init__.py", line 110, in wrapper
return func(*func_args, **func_kwargs)
File "/home/zfl/gx_mtest_node/tempest_m/tempest/api/object_storage/test_container_sync_middleware.py", line 53, in test_container_synchronization
self._test_container_synchronization(make_headers)
File "/home/zfl/gx_mtest_node/tempest_m/tempest/api/object_storage/test_container_sync.py", line 106, in _test_container_synchronization
cont, params=params)
File "/home/zfl/gx_mtest_node/tempest_m/tempest/lib/services/object_storage/container_client.py", line 108, in list_container_objects
resp, body = self.get(url, headers={})
File "/home/zfl/gx_mtest_node/tempest_m/tempest/lib/common/rest_client.py", line 302, in get
return self.request('GET', url, extra_headers, headers)
File "/home/zfl/gx_mtest_node/tempest_m/tempest/lib/common/rest_client.py", line 733, in request
self._error_checker(resp, resp_body)
File "/home/zfl/gx_mtest_node/tempest_m/tempest/lib/common/rest_client.py", line 829, in _error_checker
raise exceptions.Unauthorized(resp_body, resp=resp)
Unauthorized: Unauthorized
Details: <html><h1>Unauthorized</h1><p>This server could not verify that you are authorized to access the document you requested.</p></html>
2. Analysis
When test_container_sync_middleware.ContainerSyncMiddlewareTest.test_container_synchronization is executed along with test_container_sync.ContainerSyncTest, because ContainerSyncMiddlewareTest inherits test_container_sync.ContainerSyncTest, and clients is a class variable, so, when ContainerSyncMiddlewareTest is executed, clients will contain data created in its parent class which will cause trouble when using dynamic credentials because the projects/users created in parent class have been deleted.
3. Solution
Do not use class variable for clients
Fix proposed to branch: master /review. openstack. org/530058
Review: https:/