Merge "Migrate identity API tests to resource_* fixtures"
diff --git a/tempest/api/identity/admin/test_roles.py b/tempest/api/identity/admin/test_roles.py
index 492d56f..d87d5c1 100644
--- a/tempest/api/identity/admin/test_roles.py
+++ b/tempest/api/identity/admin/test_roles.py
@@ -24,9 +24,8 @@
     _interface = 'json'
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(RolesTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(RolesTestJSON, cls).resource_setup()
         for _ in moves.xrange(5):
             role_name = data_utils.rand_name(name='role-')
             _, role = cls.client.create_role(role_name)
diff --git a/tempest/api/identity/admin/test_users.py b/tempest/api/identity/admin/test_users.py
index d3ac6dd..66a1737 100644
--- a/tempest/api/identity/admin/test_users.py
+++ b/tempest/api/identity/admin/test_users.py
@@ -24,8 +24,8 @@
     _interface = 'json'
 
     @classmethod
-    def setUpClass(cls):
-        super(UsersTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(UsersTestJSON, cls).resource_setup()
         cls.alt_user = data_utils.rand_name('test_user_')
         cls.alt_password = data_utils.rand_name('pass_')
         cls.alt_email = cls.alt_user + '@testmail.tm'
diff --git a/tempest/api/identity/admin/test_users_negative.py b/tempest/api/identity/admin/test_users_negative.py
index a584a7b..bad2b89 100644
--- a/tempest/api/identity/admin/test_users_negative.py
+++ b/tempest/api/identity/admin/test_users_negative.py
@@ -25,8 +25,8 @@
     _interface = 'json'
 
     @classmethod
-    def setUpClass(cls):
-        super(UsersNegativeTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(UsersNegativeTestJSON, cls).resource_setup()
         cls.alt_user = data_utils.rand_name('test_user_')
         cls.alt_password = data_utils.rand_name('pass_')
         cls.alt_email = cls.alt_user + '@testmail.tm'
diff --git a/tempest/api/identity/admin/v3/test_credentials.py b/tempest/api/identity/admin/v3/test_credentials.py
index 433eaed..7a0edb0 100644
--- a/tempest/api/identity/admin/v3/test_credentials.py
+++ b/tempest/api/identity/admin/v3/test_credentials.py
@@ -22,9 +22,8 @@
     _interface = 'json'
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(CredentialsTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(CredentialsTestJSON, cls).resource_setup()
         cls.projects = list()
         cls.creds_list = [['project_id', 'user_id', 'id'],
                           ['access', 'secret']]
@@ -43,11 +42,11 @@
             email=u_email, project_id=cls.projects[0])
 
     @classmethod
-    def tearDownClass(cls):
+    def resource_cleanup(cls):
         cls.client.delete_user(cls.user_body['id'])
         for p in cls.projects:
             cls.client.delete_project(p)
-        super(CredentialsTestJSON, cls).tearDownClass()
+        super(CredentialsTestJSON, cls).resource_cleanup()
 
     def _delete_credential(self, cred_id):
         self.creds_client.delete_credential(cred_id)
diff --git a/tempest/api/identity/admin/v3/test_endpoints.py b/tempest/api/identity/admin/v3/test_endpoints.py
index ad46af2..f1f1eb6 100644
--- a/tempest/api/identity/admin/v3/test_endpoints.py
+++ b/tempest/api/identity/admin/v3/test_endpoints.py
@@ -22,9 +22,8 @@
     _interface = 'json'
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(EndPointsTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(EndPointsTestJSON, cls).resource_setup()
         cls.identity_client = cls.client
         cls.client = cls.endpoints_client
         cls.service_ids = list()
@@ -47,12 +46,12 @@
             cls.setup_endpoints.append(endpoint)
 
     @classmethod
-    def tearDownClass(cls):
+    def resource_cleanup(cls):
         for e in cls.setup_endpoints:
             cls.client.delete_endpoint(e['id'])
         for s in cls.service_ids:
             cls.service_client.delete_service(s)
-        super(EndPointsTestJSON, cls).tearDownClass()
+        super(EndPointsTestJSON, cls).resource_cleanup()
 
     @test.attr(type='gate')
     def test_list_endpoints(self):
diff --git a/tempest/api/identity/admin/v3/test_endpoints_negative.py b/tempest/api/identity/admin/v3/test_endpoints_negative.py
index d728b1d..b987d12 100644
--- a/tempest/api/identity/admin/v3/test_endpoints_negative.py
+++ b/tempest/api/identity/admin/v3/test_endpoints_negative.py
@@ -25,8 +25,8 @@
     _interface = 'json'
 
     @classmethod
-    def setUpClass(cls):
-        super(EndpointsNegativeTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(EndpointsNegativeTestJSON, cls).resource_setup()
         cls.identity_client = cls.client
         cls.client = cls.endpoints_client
         cls.service_ids = list()
@@ -40,10 +40,10 @@
         cls.service_ids.append(cls.service_id)
 
     @classmethod
-    def tearDownClass(cls):
+    def resource_cleanup(cls):
         for s in cls.service_ids:
             cls.service_client.delete_service(s)
-        super(EndpointsNegativeTestJSON, cls).tearDownClass()
+        super(EndpointsNegativeTestJSON, cls).resource_cleanup()
 
     @test.attr(type=['negative', 'gate'])
     def test_create_with_enabled_False(self):
diff --git a/tempest/api/identity/admin/v3/test_groups.py b/tempest/api/identity/admin/v3/test_groups.py
index 4d2cc46..987a9d5 100644
--- a/tempest/api/identity/admin/v3/test_groups.py
+++ b/tempest/api/identity/admin/v3/test_groups.py
@@ -22,8 +22,8 @@
     _interface = 'json'
 
     @classmethod
-    def setUpClass(cls):
-        super(GroupsV3TestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(GroupsV3TestJSON, cls).resource_setup()
 
     @test.attr(type='smoke')
     def test_group_create_update_get(self):
diff --git a/tempest/api/identity/admin/v3/test_list_projects.py b/tempest/api/identity/admin/v3/test_list_projects.py
index a3944e2..be06c7f 100644
--- a/tempest/api/identity/admin/v3/test_list_projects.py
+++ b/tempest/api/identity/admin/v3/test_list_projects.py
@@ -22,8 +22,8 @@
     _interface = 'json'
 
     @classmethod
-    def setUpClass(cls):
-        super(ListProjectsTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(ListProjectsTestJSON, cls).resource_setup()
         cls.project_ids = list()
         cls.data.setup_test_domain()
         # Create project with domain
diff --git a/tempest/api/identity/admin/v3/test_list_users.py b/tempest/api/identity/admin/v3/test_list_users.py
index 497c5ea..903ad5c 100644
--- a/tempest/api/identity/admin/v3/test_list_users.py
+++ b/tempest/api/identity/admin/v3/test_list_users.py
@@ -32,8 +32,8 @@
                          map(lambda x: x[key], body))
 
     @classmethod
-    def setUpClass(cls):
-        super(UsersV3TestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(UsersV3TestJSON, cls).resource_setup()
         alt_user = data_utils.rand_name('test_user')
         alt_password = data_utils.rand_name('pass')
         cls.alt_email = alt_user + '@testmail.tm'
diff --git a/tempest/api/identity/admin/v3/test_regions.py b/tempest/api/identity/admin/v3/test_regions.py
index 8fc0e22..c5d5824 100644
--- a/tempest/api/identity/admin/v3/test_regions.py
+++ b/tempest/api/identity/admin/v3/test_regions.py
@@ -23,9 +23,8 @@
     _interface = 'json'
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(RegionsTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(RegionsTestJSON, cls).resource_setup()
         cls.setup_regions = list()
         cls.client = cls.region_client
         for i in range(2):
@@ -34,10 +33,10 @@
             cls.setup_regions.append(region)
 
     @classmethod
-    def tearDownClass(cls):
+    def resource_cleanup(cls):
         for r in cls.setup_regions:
             cls.client.delete_region(r['id'])
-        super(RegionsTestJSON, cls).tearDownClass()
+        super(RegionsTestJSON, cls).resource_cleanup()
 
     def _delete_region(self, region_id):
         self.client.delete_region(region_id)
diff --git a/tempest/api/identity/admin/v3/test_roles.py b/tempest/api/identity/admin/v3/test_roles.py
index 1f7cf48..5e14a04 100644
--- a/tempest/api/identity/admin/v3/test_roles.py
+++ b/tempest/api/identity/admin/v3/test_roles.py
@@ -22,9 +22,8 @@
     _interface = 'json'
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(RolesV3TestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(RolesV3TestJSON, cls).resource_setup()
         for _ in range(3):
             role_name = data_utils.rand_name(name='role-')
             _, role = cls.client.create_role(role_name)
@@ -52,7 +51,7 @@
             data_utils.rand_name('Role-'))
 
     @classmethod
-    def tearDownClass(cls):
+    def resource_cleanup(cls):
         cls.client.delete_role(cls.role['id'])
         cls.client.delete_group(cls.group_body['id'])
         cls.client.delete_user(cls.user_body['id'])
@@ -61,7 +60,7 @@
         # before deleting,or else it would result in unauthorized error
         cls.client.update_domain(cls.domain['id'], enabled=False)
         cls.client.delete_domain(cls.domain['id'])
-        super(RolesV3TestJSON, cls).tearDownClass()
+        super(RolesV3TestJSON, cls).resource_cleanup()
 
     def _list_assertions(self, body, fetched_role_ids, role_id):
         self.assertEqual(len(body), 1)
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index 3996cc1..a225f12 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -29,8 +29,8 @@
 class BaseIdentityAdminTest(tempest.test.BaseTestCase):
 
     @classmethod
-    def setUpClass(cls):
-        super(BaseIdentityAdminTest, cls).setUpClass()
+    def resource_setup(cls):
+        super(BaseIdentityAdminTest, cls).resource_setup()
         cls.os_adm = clients.AdminManager(interface=cls._interface)
         cls.os = clients.Manager(interface=cls._interface)
 
@@ -72,10 +72,10 @@
 class BaseIdentityV2AdminTest(BaseIdentityAdminTest):
 
     @classmethod
-    def setUpClass(cls):
+    def resource_setup(cls):
         if not CONF.identity_feature_enabled.api_v2:
             raise cls.skipException("Identity api v2 is not enabled")
-        super(BaseIdentityV2AdminTest, cls).setUpClass()
+        super(BaseIdentityV2AdminTest, cls).resource_setup()
         cls.client = cls.os_adm.identity_client
         cls.token_client = cls.os_adm.token_client
         if not cls.client.has_admin_extensions():
@@ -84,18 +84,18 @@
         cls.non_admin_client = cls.os.identity_client
 
     @classmethod
-    def tearDownClass(cls):
+    def resource_cleanup(cls):
         cls.data.teardown_all()
-        super(BaseIdentityV2AdminTest, cls).tearDownClass()
+        super(BaseIdentityV2AdminTest, cls).resource_cleanup()
 
 
 class BaseIdentityV3AdminTest(BaseIdentityAdminTest):
 
     @classmethod
-    def setUpClass(cls):
+    def resource_setup(cls):
         if not CONF.identity_feature_enabled.api_v3:
             raise cls.skipException("Identity api v3 is not enabled")
-        super(BaseIdentityV3AdminTest, cls).setUpClass()
+        super(BaseIdentityV3AdminTest, cls).resource_setup()
         cls.client = cls.os_adm.identity_v3_client
         cls.token = cls.os_adm.token_v3_client
         cls.endpoints_client = cls.os_adm.endpoints_client
@@ -108,9 +108,9 @@
         cls.non_admin_client = cls.os.identity_v3_client
 
     @classmethod
-    def tearDownClass(cls):
+    def resource_cleanup(cls):
         cls.data.teardown_all()
-        super(BaseIdentityV3AdminTest, cls).tearDownClass()
+        super(BaseIdentityV3AdminTest, cls).resource_cleanup()
 
 
 class DataGenerator(object):