Merge "Use addCleanup when running swift scenario tests"
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index ecca5ee..ea4365e 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -1268,6 +1268,9 @@
# look for the container to assure it is created
self.list_and_check_container_objects(name)
LOG.debug('Container %s created' % (name))
+ self.addCleanup(self.delete_wrapper,
+ self.container_client.delete_container,
+ name)
return name
def delete_container(self, container_name):
@@ -1278,6 +1281,10 @@
obj_name = obj_name or data_utils.rand_name('swift-scenario-object')
obj_data = data_utils.arbitrary_string()
self.object_client.create_object(container_name, obj_name, obj_data)
+ self.addCleanup(self.delete_wrapper,
+ self.object_client.delete_object,
+ container_name,
+ obj_name)
return obj_name, obj_data
def delete_object(self, container_name, filename):
diff --git a/tempest/scenario/test_swift_basic_ops.py b/tempest/scenario/test_swift_basic_ops.py
index 9e0fee0..fcb9505 100644
--- a/tempest/scenario/test_swift_basic_ops.py
+++ b/tempest/scenario/test_swift_basic_ops.py
@@ -44,9 +44,12 @@
self.get_swift_stat()
container_name = self.create_container()
obj_name, obj_data = self.upload_object_to_container(container_name)
- self.list_and_check_container_objects(container_name, [obj_name])
+ self.list_and_check_container_objects(container_name,
+ present_obj=[obj_name])
self.download_and_verify(container_name, obj_name, obj_data)
self.delete_object(container_name, obj_name)
+ self.list_and_check_container_objects(container_name,
+ not_present_obj=[obj_name])
self.delete_container(container_name)
@test.services('object_storage')
@@ -68,5 +71,3 @@
self.change_container_acl(container_name, '.r:*')
resp, _ = http_client.request(obj_url, 'GET')
self.assertEqual(resp.status, 200)
- self.delete_object(container_name, obj_name)
- self.delete_container(container_name)