Merge "Improve cleanup after Swift testing"

This commit is contained in:
Zuul 2021-10-27 18:29:52 +00:00 committed by Gerrit Code Review
commit 2fcd6a2432
4 changed files with 11 additions and 15 deletions

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Improve cleanup after Swift testing. Ensures containers are empty before
deleting to prevent errors due to delayed execution.

View File

@ -29,11 +29,6 @@ def delete_containers(containers, container_client, object_client):
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(or string of a container)
to be deleted

View File

@ -36,6 +36,11 @@ class ContainerNegativeTest(base.BaseObjectTest):
body = cls.capabilities_client.list_capabilities()
cls.constraints = body['swift']
@classmethod
def resource_cleanup(cls):
cls.delete_containers()
super(ContainerNegativeTest, cls).resource_cleanup()
@decorators.attr(type=["negative"])
@decorators.idempotent_id('30686921-4bed-4764-a038-40d741ed4e78')
@testtools.skipUnless(
@ -167,11 +172,7 @@ class ContainerNegativeTest(base.BaseObjectTest):
# create a container and an object within it
# attempt to delete a container that isn't empty.
container_name = self.create_container()
self.addCleanup(self.container_client.delete_container,
container_name)
object_name, _ = self.create_object(container_name)
self.addCleanup(self.object_client.delete_object,
container_name, object_name)
ex = self.assertRaises(exceptions.Conflict,
self.container_client.delete_container,

View File

@ -18,7 +18,6 @@ from oslo_utils.secretutils import md5
from tempest.api.object_storage import base
from tempest.common import utils
from tempest.lib.common.utils import data_utils
from tempest.lib.common.utils import test_utils
from tempest.lib import decorators
# Each segment, except for the final one, must be at least 1 megabyte
@ -34,11 +33,7 @@ class ObjectSloTest(base.BaseObjectTest):
self.objects = []
def tearDown(self):
for obj in self.objects:
test_utils.call_and_ignore_notfound_exc(
self.object_client.delete_object,
self.container_name, obj)
self.container_client.delete_container(self.container_name)
self.delete_containers()
super(ObjectSloTest, self).tearDown()
def _create_object(self, container_name, object_name, data, params=None):