Migrate object_storage API tests to resource_* fixtures

Partially-implements bp resource-cleanup

Change-Id: If8398052f2bf50694deeb3ac9edf677a51c6fd6c
This commit is contained in:
Andrea Frittoli 2014-09-15 13:14:54 +01:00
parent 69a6b6312b
commit 5f13f71ff2
17 changed files with 60 additions and 68 deletions

View File

@ -28,9 +28,9 @@ CONF = config.CONF
class BaseObjectTest(tempest.test.BaseTestCase): class BaseObjectTest(tempest.test.BaseTestCase):
@classmethod @classmethod
def setUpClass(cls): def resource_setup(cls):
cls.set_network_resources() cls.set_network_resources()
super(BaseObjectTest, cls).setUpClass() super(BaseObjectTest, cls).resource_setup()
if not CONF.service_available.swift: if not CONF.service_available.swift:
skip_msg = ("%s skipped as swift is not available" % cls.__name__) skip_msg = ("%s skipped as swift is not available" % cls.__name__)
raise cls.skipException(skip_msg) raise cls.skipException(skip_msg)
@ -72,10 +72,10 @@ class BaseObjectTest(tempest.test.BaseTestCase):
cls.data = SwiftDataGenerator(cls.identity_admin_client) cls.data = SwiftDataGenerator(cls.identity_admin_client)
@classmethod @classmethod
def tearDownClass(cls): def resource_cleanup(cls):
cls.data.teardown_all() cls.data.teardown_all()
cls.isolated_creds.clear_isolated_creds() cls.isolated_creds.clear_isolated_creds()
super(BaseObjectTest, cls).tearDownClass() super(BaseObjectTest, cls).resource_cleanup()
@classmethod @classmethod
def delete_containers(cls, containers, container_client=None, def delete_containers(cls, containers, container_client=None,

View File

@ -26,9 +26,8 @@ CONF = config.CONF
class AccountQuotasTest(base.BaseObjectTest): class AccountQuotasTest(base.BaseObjectTest):
@classmethod @classmethod
@test.safe_setup def resource_setup(cls):
def setUpClass(cls): super(AccountQuotasTest, cls).resource_setup()
super(AccountQuotasTest, cls).setUpClass()
cls.container_name = data_utils.rand_name(name="TestContainer") cls.container_name = data_utils.rand_name(name="TestContainer")
cls.container_client.create_container(cls.container_name) cls.container_client.create_container(cls.container_name)
@ -71,10 +70,10 @@ class AccountQuotasTest(base.BaseObjectTest):
super(AccountQuotasTest, self).tearDown() super(AccountQuotasTest, self).tearDown()
@classmethod @classmethod
def tearDownClass(cls): def resource_cleanup(cls):
if hasattr(cls, "container_name"): if hasattr(cls, "container_name"):
cls.delete_containers([cls.container_name]) cls.delete_containers([cls.container_name])
super(AccountQuotasTest, cls).tearDownClass() super(AccountQuotasTest, cls).resource_cleanup()
@test.attr(type="smoke") @test.attr(type="smoke")
@test.requires_ext(extension='account_quotas', service='object') @test.requires_ext(extension='account_quotas', service='object')

View File

@ -27,9 +27,8 @@ CONF = config.CONF
class AccountQuotasNegativeTest(base.BaseObjectTest): class AccountQuotasNegativeTest(base.BaseObjectTest):
@classmethod @classmethod
@test.safe_setup def resource_setup(cls):
def setUpClass(cls): super(AccountQuotasNegativeTest, cls).resource_setup()
super(AccountQuotasNegativeTest, cls).setUpClass()
cls.container_name = data_utils.rand_name(name="TestContainer") cls.container_name = data_utils.rand_name(name="TestContainer")
cls.container_client.create_container(cls.container_name) cls.container_client.create_container(cls.container_name)
@ -71,10 +70,10 @@ class AccountQuotasNegativeTest(base.BaseObjectTest):
super(AccountQuotasNegativeTest, self).tearDown() super(AccountQuotasNegativeTest, self).tearDown()
@classmethod @classmethod
def tearDownClass(cls): def resource_cleanup(cls):
if hasattr(cls, "container_name"): if hasattr(cls, "container_name"):
cls.delete_containers([cls.container_name]) cls.delete_containers([cls.container_name])
super(AccountQuotasNegativeTest, cls).tearDownClass() super(AccountQuotasNegativeTest, cls).resource_cleanup()
@test.attr(type=["negative", "smoke"]) @test.attr(type=["negative", "smoke"])
@test.requires_ext(extension='account_quotas', service='object') @test.requires_ext(extension='account_quotas', service='object')

View File

@ -32,9 +32,8 @@ class AccountTest(base.BaseObjectTest):
containers = [] containers = []
@classmethod @classmethod
@test.safe_setup def resource_setup(cls):
def setUpClass(cls): super(AccountTest, cls).resource_setup()
super(AccountTest, cls).setUpClass()
for i in moves.xrange(ord('a'), ord('f') + 1): for i in moves.xrange(ord('a'), ord('f') + 1):
name = data_utils.rand_name(name='%s-' % chr(i)) name = data_utils.rand_name(name='%s-' % chr(i))
cls.container_client.create_container(name) cls.container_client.create_container(name)
@ -42,9 +41,9 @@ class AccountTest(base.BaseObjectTest):
cls.containers_count = len(cls.containers) cls.containers_count = len(cls.containers)
@classmethod @classmethod
def tearDownClass(cls): def resource_cleanup(cls):
cls.delete_containers(cls.containers) cls.delete_containers(cls.containers)
super(AccountTest, cls).tearDownClass() super(AccountTest, cls).resource_cleanup()
@test.attr(type='smoke') @test.attr(type='smoke')
def test_list_containers(self): def test_list_containers(self):

View File

@ -21,8 +21,8 @@ from tempest import test
class ObjectTestACLs(base.BaseObjectTest): class ObjectTestACLs(base.BaseObjectTest):
@classmethod @classmethod
def setUpClass(cls): def resource_setup(cls):
super(ObjectTestACLs, cls).setUpClass() super(ObjectTestACLs, cls).resource_setup()
cls.data.setup_test_user() cls.data.setup_test_user()
test_os = clients.Manager(cls.data.test_credentials) test_os = clients.Manager(cls.data.test_credentials)
cls.test_auth_data = test_os.auth_provider.auth_data cls.test_auth_data = test_os.auth_provider.auth_data

View File

@ -23,8 +23,8 @@ from tempest import test
class ObjectACLsNegativeTest(base.BaseObjectTest): class ObjectACLsNegativeTest(base.BaseObjectTest):
@classmethod @classmethod
def setUpClass(cls): def resource_setup(cls):
super(ObjectACLsNegativeTest, cls).setUpClass() super(ObjectACLsNegativeTest, cls).resource_setup()
cls.data.setup_test_user() cls.data.setup_test_user()
test_os = clients.Manager(cls.data.test_credentials) test_os = clients.Manager(cls.data.test_credentials)
cls.test_auth_data = test_os.auth_provider.auth_data cls.test_auth_data = test_os.auth_provider.auth_data

View File

@ -23,9 +23,8 @@ from tempest import test
class StaticWebTest(base.BaseObjectTest): class StaticWebTest(base.BaseObjectTest):
@classmethod @classmethod
@test.safe_setup def resource_setup(cls):
def setUpClass(cls): super(StaticWebTest, cls).resource_setup()
super(StaticWebTest, cls).setUpClass()
cls.container_name = data_utils.rand_name(name="TestContainer") cls.container_name = data_utils.rand_name(name="TestContainer")
# This header should be posted on the container before every test # This header should be posted on the container before every test
@ -45,10 +44,10 @@ class StaticWebTest(base.BaseObjectTest):
metadata_prefix="X-Container-") metadata_prefix="X-Container-")
@classmethod @classmethod
def tearDownClass(cls): def resource_cleanup(cls):
if hasattr(cls, "container_name"): if hasattr(cls, "container_name"):
cls.delete_containers([cls.container_name]) cls.delete_containers([cls.container_name])
super(StaticWebTest, cls).tearDownClass() super(StaticWebTest, cls).resource_cleanup()
@test.requires_ext(extension='staticweb', service='object') @test.requires_ext(extension='staticweb', service='object')
@test.attr('gate') @test.attr('gate')

View File

@ -35,9 +35,8 @@ class ContainerSyncTest(base.BaseObjectTest):
clients = {} clients = {}
@classmethod @classmethod
@test.safe_setup def resource_setup(cls):
def setUpClass(cls): super(ContainerSyncTest, cls).resource_setup()
super(ContainerSyncTest, cls).setUpClass()
cls.containers = [] cls.containers = []
cls.objects = [] cls.objects = []
@ -62,10 +61,10 @@ class ContainerSyncTest(base.BaseObjectTest):
cls.containers.append(cont_name) cls.containers.append(cont_name)
@classmethod @classmethod
def tearDownClass(cls): def resource_cleanup(cls):
for client in cls.clients.values(): for client in cls.clients.values():
cls.delete_containers(cls.containers, client[0], client[1]) cls.delete_containers(cls.containers, client[0], client[1])
super(ContainerSyncTest, cls).tearDownClass() super(ContainerSyncTest, cls).resource_cleanup()
@test.attr(type='slow') @test.attr(type='slow')
@test.skip_because(bug='1317133') @test.skip_because(bug='1317133')

View File

@ -22,8 +22,8 @@ from tempest import test
class CrossdomainTest(base.BaseObjectTest): class CrossdomainTest(base.BaseObjectTest):
@classmethod @classmethod
def setUpClass(cls): def resource_setup(cls):
super(CrossdomainTest, cls).setUpClass() super(CrossdomainTest, cls).resource_setup()
cls.xml_start = '<?xml version="1.0"?>\n' \ cls.xml_start = '<?xml version="1.0"?>\n' \
'<!DOCTYPE cross-domain-policy SYSTEM ' \ '<!DOCTYPE cross-domain-policy SYSTEM ' \

View File

@ -23,8 +23,8 @@ from tempest import test
class HealthcheckTest(base.BaseObjectTest): class HealthcheckTest(base.BaseObjectTest):
@classmethod @classmethod
def setUpClass(cls): def resource_setup(cls):
super(HealthcheckTest, cls).setUpClass() super(HealthcheckTest, cls).resource_setup()
def setUp(self): def setUp(self):
super(HealthcheckTest, self).setUp() super(HealthcheckTest, self).setUp()

View File

@ -23,8 +23,8 @@ from tempest import test
class ObjectExpiryTest(base.BaseObjectTest): class ObjectExpiryTest(base.BaseObjectTest):
@classmethod @classmethod
def setUpClass(cls): def resource_setup(cls):
super(ObjectExpiryTest, cls).setUpClass() super(ObjectExpiryTest, cls).resource_setup()
cls.container_name = data_utils.rand_name(name='TestContainer') cls.container_name = data_utils.rand_name(name='TestContainer')
cls.container_client.create_container(cls.container_name) cls.container_client.create_container(cls.container_name)
@ -36,9 +36,9 @@ class ObjectExpiryTest(base.BaseObjectTest):
self.object_name, '') self.object_name, '')
@classmethod @classmethod
def tearDownClass(cls): def resource_cleanup(cls):
cls.delete_containers([cls.container_name]) cls.delete_containers([cls.container_name])
super(ObjectExpiryTest, cls).tearDownClass() super(ObjectExpiryTest, cls).resource_cleanup()
def _test_object_expiry(self, metadata): def _test_object_expiry(self, metadata):
# update object metadata # update object metadata

View File

@ -30,9 +30,8 @@ class ObjectFormPostTest(base.BaseObjectTest):
containers = [] containers = []
@classmethod @classmethod
@test.safe_setup def resource_setup(cls):
def setUpClass(cls): super(ObjectFormPostTest, cls).resource_setup()
super(ObjectFormPostTest, cls).setUpClass()
cls.container_name = data_utils.rand_name(name='TestContainer') cls.container_name = data_utils.rand_name(name='TestContainer')
cls.object_name = data_utils.rand_name(name='ObjectTemp') cls.object_name = data_utils.rand_name(name='ObjectTemp')
@ -56,10 +55,10 @@ class ObjectFormPostTest(base.BaseObjectTest):
self.key) self.key)
@classmethod @classmethod
def tearDownClass(cls): def resource_cleanup(cls):
cls.account_client.delete_account_metadata(metadata=cls.metadata) cls.account_client.delete_account_metadata(metadata=cls.metadata)
cls.delete_containers(cls.containers) cls.delete_containers(cls.containers)
super(ObjectFormPostTest, cls).tearDownClass() super(ObjectFormPostTest, cls).resource_cleanup()
def get_multipart_form(self, expires=600): def get_multipart_form(self, expires=600):
path = "%s/%s/%s" % ( path = "%s/%s/%s" % (

View File

@ -30,9 +30,8 @@ class ObjectFormPostNegativeTest(base.BaseObjectTest):
containers = [] containers = []
@classmethod @classmethod
@test.safe_setup def resource_setup(cls):
def setUpClass(cls): super(ObjectFormPostNegativeTest, cls).resource_setup()
super(ObjectFormPostNegativeTest, cls).setUpClass()
cls.container_name = data_utils.rand_name(name='TestContainer') cls.container_name = data_utils.rand_name(name='TestContainer')
cls.object_name = data_utils.rand_name(name='ObjectTemp') cls.object_name = data_utils.rand_name(name='ObjectTemp')
@ -56,10 +55,10 @@ class ObjectFormPostNegativeTest(base.BaseObjectTest):
self.key) self.key)
@classmethod @classmethod
def tearDownClass(cls): def resource_cleanup(cls):
cls.account_client.delete_account_metadata(metadata=cls.metadata) cls.account_client.delete_account_metadata(metadata=cls.metadata)
cls.delete_containers(cls.containers) cls.delete_containers(cls.containers)
super(ObjectFormPostNegativeTest, cls).tearDownClass() super(ObjectFormPostNegativeTest, cls).resource_cleanup()
def get_multipart_form(self, expires=600): def get_multipart_form(self, expires=600):
path = "%s/%s/%s" % ( path = "%s/%s/%s" % (

View File

@ -30,16 +30,16 @@ from tempest import test
class ObjectTest(base.BaseObjectTest): class ObjectTest(base.BaseObjectTest):
@classmethod @classmethod
def setUpClass(cls): def resource_setup(cls):
super(ObjectTest, cls).setUpClass() super(ObjectTest, cls).resource_setup()
cls.container_name = data_utils.rand_name(name='TestContainer') cls.container_name = data_utils.rand_name(name='TestContainer')
cls.container_client.create_container(cls.container_name) cls.container_client.create_container(cls.container_name)
cls.containers = [cls.container_name] cls.containers = [cls.container_name]
@classmethod @classmethod
def tearDownClass(cls): def resource_cleanup(cls):
cls.delete_containers(cls.containers) cls.delete_containers(cls.containers)
super(ObjectTest, cls).tearDownClass() super(ObjectTest, cls).resource_cleanup()
def _create_object(self, metadata=None): def _create_object(self, metadata=None):
# setup object # setup object

View File

@ -30,8 +30,8 @@ CONF = config.CONF
class ObjectTempUrlTest(base.BaseObjectTest): class ObjectTempUrlTest(base.BaseObjectTest):
@classmethod @classmethod
def setUpClass(cls): def resource_setup(cls):
super(ObjectTempUrlTest, cls).setUpClass() super(ObjectTempUrlTest, cls).resource_setup()
# create a container # create a container
cls.container_name = data_utils.rand_name(name='TestContainer') cls.container_name = data_utils.rand_name(name='TestContainer')
cls.container_client.create_container(cls.container_name) cls.container_client.create_container(cls.container_name)
@ -52,14 +52,14 @@ class ObjectTempUrlTest(base.BaseObjectTest):
cls.object_name, cls.content) cls.object_name, cls.content)
@classmethod @classmethod
def tearDownClass(cls): def resource_cleanup(cls):
for metadata in cls.metadatas: for metadata in cls.metadatas:
cls.account_client.delete_account_metadata( cls.account_client.delete_account_metadata(
metadata=metadata) metadata=metadata)
cls.delete_containers(cls.containers) cls.delete_containers(cls.containers)
super(ObjectTempUrlTest, cls).tearDownClass() super(ObjectTempUrlTest, cls).resource_cleanup()
def setUp(self): def setUp(self):
super(ObjectTempUrlTest, self).setUp() super(ObjectTempUrlTest, self).setUp()

View File

@ -31,9 +31,8 @@ class ObjectTempUrlNegativeTest(base.BaseObjectTest):
containers = [] containers = []
@classmethod @classmethod
@test.safe_setup def resource_setup(cls):
def setUpClass(cls): super(ObjectTempUrlNegativeTest, cls).resource_setup()
super(ObjectTempUrlNegativeTest, cls).setUpClass()
cls.container_name = data_utils.rand_name(name='TestContainer') cls.container_name = data_utils.rand_name(name='TestContainer')
cls.container_client.create_container(cls.container_name) cls.container_client.create_container(cls.container_name)
@ -47,13 +46,13 @@ class ObjectTempUrlNegativeTest(base.BaseObjectTest):
cls.account_client.list_account_metadata() cls.account_client.list_account_metadata()
@classmethod @classmethod
def tearDownClass(cls): def resource_cleanup(cls):
resp, _ = cls.account_client.delete_account_metadata( resp, _ = cls.account_client.delete_account_metadata(
metadata=cls.metadata) metadata=cls.metadata)
cls.delete_containers(cls.containers) cls.delete_containers(cls.containers)
super(ObjectTempUrlNegativeTest, cls).tearDownClass() super(ObjectTempUrlNegativeTest, cls).resource_cleanup()
def setUp(self): def setUp(self):
super(ObjectTempUrlNegativeTest, self).setUp() super(ObjectTempUrlNegativeTest, self).setUp()

View File

@ -25,14 +25,14 @@ CONF = config.CONF
class ContainerTest(base.BaseObjectTest): class ContainerTest(base.BaseObjectTest):
@classmethod @classmethod
def setUpClass(cls): def resource_setup(cls):
super(ContainerTest, cls).setUpClass() super(ContainerTest, cls).resource_setup()
cls.containers = [] cls.containers = []
@classmethod @classmethod
def tearDownClass(cls): def resource_cleanup(cls):
cls.delete_containers(cls.containers) cls.delete_containers(cls.containers)
super(ContainerTest, cls).tearDownClass() super(ContainerTest, cls).resource_cleanup()
def assertContainer(self, container, count, byte, versioned): def assertContainer(self, container, count, byte, versioned):
resp, _ = self.container_client.list_container_metadata(container) resp, _ = self.container_client.list_container_metadata(container)