Stop volume leaking even if an error is occurred

In some test, if an error is occurred in setUpClass(), some resources
are not deleted because of tearDownClass() is not called.
This commit fixes it.

Partially Implements: blueprint stop-leaking

Change-Id: I6839645285da4ecd59e536b6413a67f0acaf7d6c
diff --git a/tempest/api/volume/admin/test_snapshots_actions.py b/tempest/api/volume/admin/test_snapshots_actions.py
index 12fda92..594c703 100644
--- a/tempest/api/volume/admin/test_snapshots_actions.py
+++ b/tempest/api/volume/admin/test_snapshots_actions.py
@@ -15,13 +15,14 @@
 
 from tempest.api.volume import base
 from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
 
 
 class SnapshotsActionsTest(base.BaseVolumeV1AdminTest):
     _interface = "json"
 
     @classmethod
+    @test.safe_setup
     def setUpClass(cls):
         super(SnapshotsActionsTest, cls).setUpClass()
         cls.client = cls.snapshots_client
@@ -80,7 +81,7 @@
     def _get_progress_alias(self):
         return 'os-extended-snapshot-attributes:progress'
 
-    @attr(type='gate')
+    @test.attr(type='gate')
     def test_reset_snapshot_status(self):
         # Reset snapshot status to creating
         status = 'creating'
@@ -92,7 +93,7 @@
         self.assertEqual(200, resp_get.status)
         self.assertEqual(status, snapshot_get['status'])
 
-    @attr(type='gate')
+    @test.attr(type='gate')
     def test_update_snapshot_status(self):
         # Reset snapshot status to creating
         status = 'creating'
@@ -112,22 +113,22 @@
         self.assertEqual(status, snapshot_get['status'])
         self.assertEqual(progress, snapshot_get[progress_alias])
 
-    @attr(type='gate')
+    @test.attr(type='gate')
     def test_snapshot_force_delete_when_snapshot_is_creating(self):
         # test force delete when status of snapshot is creating
         self._create_reset_and_force_delete_temp_snapshot('creating')
 
-    @attr(type='gate')
+    @test.attr(type='gate')
     def test_snapshot_force_delete_when_snapshot_is_deleting(self):
         # test force delete when status of snapshot is deleting
         self._create_reset_and_force_delete_temp_snapshot('deleting')
 
-    @attr(type='gate')
+    @test.attr(type='gate')
     def test_snapshot_force_delete_when_snapshot_is_error(self):
         # test force delete when status of snapshot is error
         self._create_reset_and_force_delete_temp_snapshot('error')
 
-    @attr(type='gate')
+    @test.attr(type='gate')
     def test_snapshot_force_delete_when_snapshot_is_error_deleting(self):
         # test force delete when status of snapshot is error_deleting
         self._create_reset_and_force_delete_temp_snapshot('error_deleting')
diff --git a/tempest/api/volume/admin/test_volumes_actions.py b/tempest/api/volume/admin/test_volumes_actions.py
index 9274fce..4496f18 100644
--- a/tempest/api/volume/admin/test_volumes_actions.py
+++ b/tempest/api/volume/admin/test_volumes_actions.py
@@ -15,13 +15,14 @@
 
 from tempest.api.volume import base
 from tempest.common.utils import data_utils as utils
-from tempest.test import attr
+from tempest import test
 
 
 class VolumesActionsTest(base.BaseVolumeV1AdminTest):
     _interface = "json"
 
     @classmethod
+    @test.safe_setup
     def setUpClass(cls):
         super(VolumesActionsTest, cls).setUpClass()
         cls.client = cls.volumes_client
@@ -75,7 +76,7 @@
         self.assertEqual(202, resp_delete.status)
         self.client.wait_for_resource_deletion(temp_volume['id'])
 
-    @attr(type='gate')
+    @test.attr(type='gate')
     def test_volume_reset_status(self):
         # test volume reset status : available->error->available
         resp, body = self._reset_volume_status(self.volume['id'], 'error')
@@ -84,7 +85,7 @@
             self.volume['id'])
         self.assertEqual('error', volume_get['status'])
 
-    @attr(type='gate')
+    @test.attr(type='gate')
     def test_volume_begin_detaching(self):
         # test volume begin detaching : available -> detaching -> available
         resp, body = self.client.volume_begin_detaching(self.volume['id'])
@@ -92,7 +93,7 @@
         resp_get, volume_get = self.client.get_volume(self.volume['id'])
         self.assertEqual('detaching', volume_get['status'])
 
-    @attr(type='gate')
+    @test.attr(type='gate')
     def test_volume_roll_detaching(self):
         # test volume roll detaching : detaching -> in-use -> available
         resp, body = self.client.volume_begin_detaching(self.volume['id'])
@@ -110,7 +111,7 @@
         # test force delete when status of volume is attaching
         self._create_reset_and_force_delete_temp_volume('attaching')
 
-    @attr(type='gate')
+    @test.attr(type='gate')
     def test_volume_force_delete_when_volume_is_error(self):
         # test force delete when status of volume is error
         self._create_reset_and_force_delete_temp_volume('error')
diff --git a/tempest/api/volume/test_snapshot_metadata.py b/tempest/api/volume/test_snapshot_metadata.py
index 1493b37..d2c4ab7 100644
--- a/tempest/api/volume/test_snapshot_metadata.py
+++ b/tempest/api/volume/test_snapshot_metadata.py
@@ -21,6 +21,7 @@
     _interface = "json"
 
     @classmethod
+    @test.safe_setup
     def setUpClass(cls):
         super(SnapshotMetadataTest, cls).setUpClass()
         cls.client = cls.snapshots_client
diff --git a/tempest/api/volume/test_volumes_actions.py b/tempest/api/volume/test_volumes_actions.py
index a22ad32..9fca807 100644
--- a/tempest/api/volume/test_volumes_actions.py
+++ b/tempest/api/volume/test_volumes_actions.py
@@ -25,6 +25,7 @@
     _interface = "json"
 
     @classmethod
+    @test.safe_setup
     def setUpClass(cls):
         super(VolumesActionsTest, cls).setUpClass()
         cls.client = cls.volumes_client