Merge "Fix container cleanup in test_account_bulk"
This commit is contained in:
commit
1b8f6f00ee
@ -25,6 +25,38 @@ import tempest.test
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
def delete_containers(containers, container_client, object_client):
|
||||
"""Remove containers and all objects in them.
|
||||
|
||||
The containers should be visible from the container_client given.
|
||||
Will not throw any error if the containers don't exist.
|
||||
Will not check that object and container deletions succeed.
|
||||
After delete all the objects from a container, it will wait 2
|
||||
seconds before delete the container itself, in order to deployments
|
||||
using HA proxy sync the deletion properly, otherwise, the container
|
||||
might fail to be deleted because it's not empty.
|
||||
|
||||
:param containers: List of containers to be deleted
|
||||
:param container_client: Client to be used to delete containers
|
||||
:param object_client: Client to be used to delete objects
|
||||
"""
|
||||
for cont in containers:
|
||||
try:
|
||||
params = {'limit': 9999, 'format': 'json'}
|
||||
resp, objlist = container_client.list_container_contents(
|
||||
cont, params)
|
||||
# delete every object in the container
|
||||
for obj in objlist:
|
||||
test_utils.call_and_ignore_notfound_exc(
|
||||
object_client.delete_object, cont, obj['name'])
|
||||
# sleep 2 seconds to sync the deletion of the objects
|
||||
# in HA deployment
|
||||
time.sleep(2)
|
||||
container_client.delete_container(cont)
|
||||
except lib_exc.NotFound:
|
||||
pass
|
||||
|
||||
|
||||
class BaseObjectTest(tempest.test.BaseTestCase):
|
||||
|
||||
credentials = [['operator', CONF.object_storage.operator_role]]
|
||||
@ -98,42 +130,12 @@ class BaseObjectTest(tempest.test.BaseTestCase):
|
||||
return object_name, data
|
||||
|
||||
@classmethod
|
||||
def delete_containers(cls, container_client=None,
|
||||
object_client=None):
|
||||
"""Remove containers and all objects in them.
|
||||
|
||||
The containers should be visible from the container_client given.
|
||||
Will not throw any error if the containers don't exist.
|
||||
Will not check that object and container deletions succeed.
|
||||
After delete all the objects from a container, it will wait 2
|
||||
seconds before delete the container itself, in order to deployments
|
||||
using HA proxy sync the deletion properly, otherwise, the container
|
||||
might fail to be deleted because it's not empty.
|
||||
|
||||
:param container_client: if None, use cls.container_client, this means
|
||||
that the default testing user will be used (see 'username' in
|
||||
'etc/tempest.conf')
|
||||
:param object_client: if None, use cls.object_client
|
||||
"""
|
||||
def delete_containers(cls, container_client=None, object_client=None):
|
||||
if container_client is None:
|
||||
container_client = cls.container_client
|
||||
if object_client is None:
|
||||
object_client = cls.object_client
|
||||
for cont in cls.containers:
|
||||
try:
|
||||
params = {'limit': 9999, 'format': 'json'}
|
||||
resp, objlist = container_client.list_container_contents(
|
||||
cont, params)
|
||||
# delete every object in the container
|
||||
for obj in objlist:
|
||||
test_utils.call_and_ignore_notfound_exc(
|
||||
object_client.delete_object, cont, obj['name'])
|
||||
# sleep 2 seconds to sync the deletion of the objects
|
||||
# in HA deployment
|
||||
time.sleep(2)
|
||||
container_client.delete_container(cont)
|
||||
except lib_exc.NotFound:
|
||||
pass
|
||||
delete_containers(cls.containers, container_client, object_client)
|
||||
|
||||
def assertHeaders(self, resp, target, method):
|
||||
"""Check the existence and the format of response headers"""
|
||||
|
@ -27,7 +27,10 @@ class BulkTest(base.BaseObjectTest):
|
||||
self.containers = []
|
||||
|
||||
def tearDown(self):
|
||||
self.delete_containers()
|
||||
# NOTE(andreaf) BulkTests needs to cleanup containers after each
|
||||
# test is executed.
|
||||
base.delete_containers(self.containers, self.container_client,
|
||||
self.object_client)
|
||||
super(BulkTest, self).tearDown()
|
||||
|
||||
def _create_archive(self):
|
||||
|
Loading…
Reference in New Issue
Block a user