Cleanup try/except/finally blocks in several tests

There are several tests that have large try/except blocks which catch
Exception and then log their own error message but don't include the
original exception message. Some of these also have finally blocks doing
cleanup which could be performed with a call to self.addCleanup in the
test itself. Since this patch removes the useless self.fail with a
custom message masking the original exception, I also refactored the
finally blocks to use addCleanup instead.

Fixes bug 1207893

Change-Id: I6e9532e5067bbc0458ed3dc3faac58151aa696a0
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index 4e42dd0..156274d 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -84,24 +84,14 @@
                          'key_pairs': 200, 'injected_file_path_bytes': 512,
                          'instances': 20, 'security_group_rules': 20,
                          'cores': 2, 'security_groups': 20}
-        try:
-            # Update limits for all quota resources
-            resp, quota_set = self.adm_client.update_quota_set(
-                self.demo_tenant_id,
-                **new_quota_set)
-            self.addCleanup(self.adm_client.update_quota_set,
-                            self.demo_tenant_id, **self.default_quota_set)
-            self.assertEqual(200, resp.status)
-            self.assertEqual(new_quota_set, quota_set)
-        except Exception:
-            self.fail("Admin could not update quota set for the tenant")
-        finally:
-            # Reset quota resource limits to default values
-            resp, quota_set = self.adm_client.update_quota_set(
-                self.demo_tenant_id,
-                **self.default_quota_set)
-            self.assertEqual(200, resp.status, "Failed to reset quota "
-                             "defaults")
+        # Update limits for all quota resources
+        resp, quota_set = self.adm_client.update_quota_set(
+            self.demo_tenant_id,
+            **new_quota_set)
+        self.addCleanup(self.adm_client.update_quota_set,
+                        self.demo_tenant_id, **self.default_quota_set)
+        self.assertEqual(200, resp.status)
+        self.assertEqual(new_quota_set, quota_set)
 
     # TODO(afazekas): merge these test cases
     @attr(type='gate')
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index e756870..a3b051e 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2012 IBM Corp.
+# Copyright 2013 IBM Corp.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -42,10 +42,11 @@
             raise cls.skipException(skip_msg)
 
     def _detach(self, server_id, volume_id):
-        self.servers_client.detach_volume(server_id, volume_id)
-        self.volumes_client.wait_for_volume_status(volume_id, 'available')
+        if self.attached:
+            self.servers_client.detach_volume(server_id, volume_id)
+            self.volumes_client.wait_for_volume_status(volume_id, 'available')
 
-    def _delete(self, volume):
+    def _delete_volume(self):
         if self.volume:
             self.volumes_client.delete_volume(self.volume['id'])
             self.volume = None
@@ -63,6 +64,7 @@
         resp, volume = self.volumes_client.create_volume(1,
                                                          display_name='test')
         self.volume = volume
+        self.addCleanup(self._delete_volume)
         self.volumes_client.wait_for_volume_status(volume['id'], 'available')
 
         # Attach the volume to the server
@@ -71,49 +73,41 @@
         self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
 
         self.attached = True
+        self.addCleanup(self._detach, server['id'], volume['id'])
 
     @testtools.skipIf(not run_ssh, 'SSH required for this test')
     @attr(type='gate')
     def test_attach_detach_volume(self):
         # Stop and Start a server with an attached volume, ensuring that
         # the volume remains attached.
-        try:
-            self._create_and_attach()
-            server = self.server
-            volume = self.volume
+        self._create_and_attach()
+        server = self.server
+        volume = self.volume
 
-            self.servers_client.stop(server['id'])
-            self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')
+        self.servers_client.stop(server['id'])
+        self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')
 
-            self.servers_client.start(server['id'])
-            self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+        self.servers_client.start(server['id'])
+        self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
 
-            linux_client = RemoteClient(server,
-                                        self.ssh_user, server['adminPass'])
-            partitions = linux_client.get_partitions()
-            self.assertIn(self.device, partitions)
+        linux_client = RemoteClient(server,
+                                    self.ssh_user, server['adminPass'])
+        partitions = linux_client.get_partitions()
+        self.assertIn(self.device, partitions)
 
-            self._detach(server['id'], volume['id'])
-            self.attached = False
+        self._detach(server['id'], volume['id'])
+        self.attached = False
 
-            self.servers_client.stop(server['id'])
-            self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')
+        self.servers_client.stop(server['id'])
+        self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')
 
-            self.servers_client.start(server['id'])
-            self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+        self.servers_client.start(server['id'])
+        self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
 
-            linux_client = RemoteClient(server,
-                                        self.ssh_user, server['adminPass'])
-            partitions = linux_client.get_partitions()
-            self.assertNotIn(self.device, partitions)
-        except Exception:
-            self.fail("The test_attach_detach_volume is faild!")
-        finally:
-            if self.attached:
-                self._detach(server['id'], volume['id'])
-            # NOTE(maurosr): here we do the cleanup for volume, servers are
-            # dealt on BaseComputeTest.tearDownClass
-            self._delete(self.volume)
+        linux_client = RemoteClient(server,
+                                    self.ssh_user, server['adminPass'])
+        partitions = linux_client.get_partitions()
+        self.assertNotIn(self.device, partitions)
 
 
 class AttachVolumeTestXML(AttachVolumeTestJSON):
diff --git a/tempest/api/volume/admin/test_multi_backend.py b/tempest/api/volume/admin/test_multi_backend.py
index b64a324..797aa71 100644
--- a/tempest/api/volume/admin/test_multi_backend.py
+++ b/tempest/api/volume/admin/test_multi_backend.py
@@ -81,8 +81,8 @@
                 cls.volume_id_list.append(cls.volume2['id'])
                 cls.volume_client.wait_for_volume_status(cls.volume2['id'],
                                                          'available')
-        except Exception:
-            LOG.exception("setup failed")
+        except Exception as e:
+            LOG.exception("setup failed: %s" % e)
             cls.tearDownClass()
             raise
 
diff --git a/tempest/api/volume/admin/test_volume_types.py b/tempest/api/volume/admin/test_volume_types.py
index 27caaad..822f691 100644
--- a/tempest/api/volume/admin/test_volume_types.py
+++ b/tempest/api/volume/admin/test_volume_types.py
@@ -38,126 +38,111 @@
                                                                auth_url,
                                                                adm_tenant)
 
+    def _delete_volume(self, volume_id):
+        resp, _ = self.volumes_client.delete_volume(volume_id)
+        self.assertEqual(202, resp.status)
+
+    def _delete_volume_type(self, volume_type_id):
+        resp, _ = self.client.delete_volume_type(volume_type_id)
+        self.assertEqual(202, resp.status)
+
     @attr(type='smoke')
     def test_volume_type_list(self):
         # List Volume types.
-        try:
-            resp, body = self.client.list_volume_types()
-            self.assertEqual(200, resp.status)
-            self.assertTrue(type(body), list)
-        except Exception:
-            self.fail("Could not list volume types")
+        resp, body = self.client.list_volume_types()
+        self.assertEqual(200, resp.status)
+        self.assertTrue(type(body), list)
 
     @attr(type='smoke')
     def test_create_get_delete_volume_with_volume_type_and_extra_specs(self):
         # Create/get/delete volume with volume_type and extra spec.
-        try:
-            volume = {}
-            vol_name = rand_name("volume-")
-            vol_type_name = rand_name("volume-type-")
-            proto = self.config.volume.storage_protocol
-            vendor = self.config.volume.vendor_name
-            extra_specs = {"storage_protocol": proto,
-                           "vendor_name": vendor}
-            body = {}
-            resp, body = self.client.create_volume_type(
-                vol_type_name,
-                extra_specs=extra_specs)
-            self.assertEqual(200, resp.status)
-            self.assertIn('id', body)
-            self.assertIn('name', body)
-            resp, volume = self.volumes_client.create_volume(
-                size=1, display_name=vol_name,
-                volume_type=vol_type_name)
-            self.assertEqual(200, resp.status)
-            self.assertIn('id', volume)
-            self.assertIn('display_name', volume)
-            self.assertEqual(volume['display_name'], vol_name,
-                             "The created volume name is not equal "
-                             "to the requested name")
-            self.assertTrue(volume['id'] is not None,
-                            "Field volume id is empty or not found.")
-            self.volumes_client.wait_for_volume_status(volume['id'],
-                                                       'available')
-            resp, fetched_volume = self.volumes_client.get_volume(volume['id'])
-            self.assertEqual(200, resp.status)
-            self.assertEqual(vol_name, fetched_volume['display_name'],
-                             'The fetched Volume is different '
-                             'from the created Volume')
-            self.assertEqual(volume['id'], fetched_volume['id'],
-                             'The fetched Volume is different '
-                             'from the created Volume')
-            self.assertEqual(vol_type_name, fetched_volume['volume_type'],
-                             'The fetched Volume is different '
-                             'from the created Volume')
-        except Exception:
-            self.fail("Could not create correct volume with volume_type")
-        finally:
-            if volume:
-                # Delete the Volume if it was created
-                resp, _ = self.volumes_client.delete_volume(volume['id'])
-                self.assertEqual(202, resp.status)
-
-            if body:
-                resp, _ = self.client.delete_volume_type(body['id'])
-                self.assertEqual(202, resp.status)
+        volume = {}
+        vol_name = rand_name("volume-")
+        vol_type_name = rand_name("volume-type-")
+        proto = self.config.volume.storage_protocol
+        vendor = self.config.volume.vendor_name
+        extra_specs = {"storage_protocol": proto,
+                       "vendor_name": vendor}
+        body = {}
+        resp, body = self.client.create_volume_type(
+            vol_type_name,
+            extra_specs=extra_specs)
+        self.assertEqual(200, resp.status)
+        self.assertIn('id', body)
+        self.addCleanup(self._delete_volume_type, body['id'])
+        self.assertIn('name', body)
+        resp, volume = self.volumes_client.create_volume(
+            size=1, display_name=vol_name,
+            volume_type=vol_type_name)
+        self.assertEqual(200, resp.status)
+        self.assertIn('id', volume)
+        self.addCleanup(self._delete_volume, volume['id'])
+        self.assertIn('display_name', volume)
+        self.assertEqual(volume['display_name'], vol_name,
+                         "The created volume name is not equal "
+                         "to the requested name")
+        self.assertTrue(volume['id'] is not None,
+                        "Field volume id is empty or not found.")
+        self.volumes_client.wait_for_volume_status(volume['id'],
+                                                   'available')
+        resp, fetched_volume = self.volumes_client.get_volume(volume['id'])
+        self.assertEqual(200, resp.status)
+        self.assertEqual(vol_name, fetched_volume['display_name'],
+                         'The fetched Volume is different '
+                         'from the created Volume')
+        self.assertEqual(volume['id'], fetched_volume['id'],
+                         'The fetched Volume is different '
+                         'from the created Volume')
+        self.assertEqual(vol_type_name, fetched_volume['volume_type'],
+                         'The fetched Volume is different '
+                         'from the created Volume')
 
     @attr(type='smoke')
     def test_volume_type_create_delete(self):
         # Create/Delete volume type.
-        try:
-            name = rand_name("volume-type-")
-            extra_specs = {"storage_protocol": "iSCSI",
-                           "vendor_name": "Open Source"}
-            resp, body = self.client.create_volume_type(
-                name,
-                extra_specs=extra_specs)
-            self.assertEqual(200, resp.status)
-            self.assertIn('id', body)
-            self.assertIn('name', body)
-            self.assertEqual(body['name'], name,
-                             "The created volume_type name is not equal "
-                             "to the requested name")
-            self.assertTrue(body['id'] is not None,
-                            "Field volume_type id is empty or not found.")
-            resp, _ = self.client.delete_volume_type(body['id'])
-            self.assertEqual(202, resp.status)
-        except Exception:
-            self.fail("Could not create a volume_type")
+        name = rand_name("volume-type-")
+        extra_specs = {"storage_protocol": "iSCSI",
+                       "vendor_name": "Open Source"}
+        resp, body = self.client.create_volume_type(
+            name,
+            extra_specs=extra_specs)
+        self.assertEqual(200, resp.status)
+        self.assertIn('id', body)
+        self.addCleanup(self._delete_volume_type, body['id'])
+        self.assertIn('name', body)
+        self.assertEqual(body['name'], name,
+                         "The created volume_type name is not equal "
+                         "to the requested name")
+        self.assertTrue(body['id'] is not None,
+                        "Field volume_type id is empty or not found.")
 
     @attr(type='smoke')
     def test_volume_type_create_get(self):
         # Create/get volume type.
-        try:
-            body = {}
-            name = rand_name("volume-type-")
-            extra_specs = {"storage_protocol": "iSCSI",
-                           "vendor_name": "Open Source"}
-            resp, body = self.client.create_volume_type(
-                name,
-                extra_specs=extra_specs)
-            self.assertEqual(200, resp.status)
-            self.assertIn('id', body)
-            self.assertIn('name', body)
-            self.assertEqual(body['name'], name,
-                             "The created volume_type name is not equal "
-                             "to the requested name")
-            self.assertTrue(body['id'] is not None,
-                            "Field volume_type id is empty or not found.")
-            resp, fetched_volume_type = self.client.get_volume_type(body['id'])
-            self.assertEqual(200, resp.status)
-            self.assertEqual(name, fetched_volume_type['name'],
-                             'The fetched Volume_type is different '
-                             'from the created Volume_type')
-            self.assertEqual(str(body['id']), fetched_volume_type['id'],
-                             'The fetched Volume_type is different '
-                             'from the created Volume_type')
-            self.assertEqual(extra_specs, fetched_volume_type['extra_specs'],
-                             'The fetched Volume_type is different '
-                             'from the created Volume_type')
-        except Exception:
-            self.fail("Could not create a volume_type")
-        finally:
-            if body:
-                resp, _ = self.client.delete_volume_type(body['id'])
-                self.assertEqual(202, resp.status)
+        body = {}
+        name = rand_name("volume-type-")
+        extra_specs = {"storage_protocol": "iSCSI",
+                       "vendor_name": "Open Source"}
+        resp, body = self.client.create_volume_type(
+            name,
+            extra_specs=extra_specs)
+        self.assertEqual(200, resp.status)
+        self.assertIn('id', body)
+        self.addCleanup(self._delete_volume_type, body['id'])
+        self.assertIn('name', body)
+        self.assertEqual(body['name'], name,
+                         "The created volume_type name is not equal "
+                         "to the requested name")
+        self.assertTrue(body['id'] is not None,
+                        "Field volume_type id is empty or not found.")
+        resp, fetched_volume_type = self.client.get_volume_type(body['id'])
+        self.assertEqual(200, resp.status)
+        self.assertEqual(name, fetched_volume_type['name'],
+                         'The fetched Volume_type is different '
+                         'from the created Volume_type')
+        self.assertEqual(str(body['id']), fetched_volume_type['id'],
+                         'The fetched Volume_type is different '
+                         'from the created Volume_type')
+        self.assertEqual(extra_specs, fetched_volume_type['extra_specs'],
+                         'The fetched Volume_type is different '
+                         'from the created Volume_type')
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs.py b/tempest/api/volume/admin/test_volume_types_extra_specs.py
index 417f296..7d94f58 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs.py
@@ -37,68 +37,59 @@
     @attr(type='smoke')
     def test_volume_type_extra_specs_list(self):
         # List Volume types extra specs.
-        try:
-            extra_specs = {"spec1": "val1"}
-            resp, body = self.client.create_volume_type_extra_specs(
-                self.volume_type['id'], extra_specs)
-            self.assertEqual(200, resp.status)
-            self.assertEqual(extra_specs, body,
-                             "Volume type extra spec incorrectly created")
-            resp, body = self.client.list_volume_types_extra_specs(
-                self.volume_type['id'])
-            self.assertEqual(200, resp.status)
-            self.assertTrue(type(body), dict)
-            self.assertTrue('spec1' in body, "Incorrect volume type extra"
-                            " spec returned")
-        except Exception:
-            self.fail("Could not list volume types extra specs")
+        extra_specs = {"spec1": "val1"}
+        resp, body = self.client.create_volume_type_extra_specs(
+            self.volume_type['id'], extra_specs)
+        self.assertEqual(200, resp.status)
+        self.assertEqual(extra_specs, body,
+                         "Volume type extra spec incorrectly created")
+        resp, body = self.client.list_volume_types_extra_specs(
+            self.volume_type['id'])
+        self.assertEqual(200, resp.status)
+        self.assertTrue(type(body), dict)
+        self.assertTrue('spec1' in body, "Incorrect volume type extra"
+                        " spec returned")
 
     @attr(type='gate')
     def test_volume_type_extra_specs_update(self):
         # Update volume type extra specs
-        try:
-            extra_specs = {"spec2": "val1"}
-            resp, body = self.client.create_volume_type_extra_specs(
-                self.volume_type['id'], extra_specs)
-            self.assertEqual(200, resp.status)
-            self.assertEqual(extra_specs, body,
-                             "Volume type extra spec incorrectly created")
+        extra_specs = {"spec2": "val1"}
+        resp, body = self.client.create_volume_type_extra_specs(
+            self.volume_type['id'], extra_specs)
+        self.assertEqual(200, resp.status)
+        self.assertEqual(extra_specs, body,
+                         "Volume type extra spec incorrectly created")
 
-            extra_spec = {"spec2": "val2"}
-            resp, body = self.client.update_volume_type_extra_specs(
-                self.volume_type['id'],
-                extra_spec.keys()[0],
-                extra_spec)
-            self.assertEqual(200, resp.status)
-            self.assertTrue('spec2' in body,
-                            "Volume type extra spec incorrectly updated")
-            self.assertEqual(extra_spec['spec2'], body['spec2'],
-                             "Volume type extra spec incorrectly updated")
-        except Exception:
-            self.fail("Couldnt update volume type extra spec")
+        extra_spec = {"spec2": "val2"}
+        resp, body = self.client.update_volume_type_extra_specs(
+            self.volume_type['id'],
+            extra_spec.keys()[0],
+            extra_spec)
+        self.assertEqual(200, resp.status)
+        self.assertTrue('spec2' in body,
+                        "Volume type extra spec incorrectly updated")
+        self.assertEqual(extra_spec['spec2'], body['spec2'],
+                         "Volume type extra spec incorrectly updated")
 
     @attr(type='smoke')
     def test_volume_type_extra_spec_create_get_delete(self):
         # Create/Get/Delete volume type extra spec.
-        try:
-            extra_specs = {"spec3": "val1"}
-            resp, body = self.client.create_volume_type_extra_specs(
-                self.volume_type['id'],
-                extra_specs)
-            self.assertEqual(200, resp.status)
-            self.assertEqual(extra_specs, body,
-                             "Volume type extra spec incorrectly created")
+        extra_specs = {"spec3": "val1"}
+        resp, body = self.client.create_volume_type_extra_specs(
+            self.volume_type['id'],
+            extra_specs)
+        self.assertEqual(200, resp.status)
+        self.assertEqual(extra_specs, body,
+                         "Volume type extra spec incorrectly created")
 
-            resp, _ = self.client.get_volume_type_extra_specs(
-                self.volume_type['id'],
-                extra_specs.keys()[0])
-            self.assertEqual(200, resp.status)
-            self.assertEqual(extra_specs, body,
-                             "Volume type extra spec incorrectly fetched")
+        resp, _ = self.client.get_volume_type_extra_specs(
+            self.volume_type['id'],
+            extra_specs.keys()[0])
+        self.assertEqual(200, resp.status)
+        self.assertEqual(extra_specs, body,
+                         "Volume type extra spec incorrectly fetched")
 
-            resp, _ = self.client.delete_volume_type_extra_specs(
-                self.volume_type['id'],
-                extra_specs.keys()[0])
-            self.assertEqual(202, resp.status)
-        except Exception:
-            self.fail("Could not create a volume_type extra spec")
+        resp, _ = self.client.delete_volume_type_extra_specs(
+            self.volume_type['id'],
+            extra_specs.keys()[0])
+        self.assertEqual(202, resp.status)
diff --git a/tempest/api/volume/test_volumes_get.py b/tempest/api/volume/test_volumes_get.py
index 39f61f3..2e90f16 100644
--- a/tempest/api/volume/test_volumes_get.py
+++ b/tempest/api/volume/test_volumes_get.py
@@ -28,76 +28,65 @@
         super(VolumesGetTest, cls).setUpClass()
         cls.client = cls.volumes_client
 
+    def _delete_volume(self, volume_id):
+        resp, _ = self.client.delete_volume(volume_id)
+        self.assertEqual(202, resp.status)
+        self.client.wait_for_resource_deletion(volume_id)
+
     def _volume_create_get_delete(self, **kwargs):
         # Create a volume, Get it's details and Delete the volume
-        try:
-            volume = {}
-            v_name = rand_name('Volume')
-            metadata = {'Type': 'Test'}
-            # Create a volume
-            resp, volume = self.client.create_volume(size=1,
-                                                     display_name=v_name,
-                                                     metadata=metadata,
-                                                     **kwargs)
-            self.assertEqual(200, resp.status)
-            self.assertIn('id', volume)
-            self.assertIn('display_name', volume)
-            self.assertEqual(volume['display_name'], v_name,
-                             "The created volume name is not equal "
-                             "to the requested name")
-            self.assertTrue(volume['id'] is not None,
-                            "Field volume id is empty or not found.")
-            self.client.wait_for_volume_status(volume['id'], 'available')
-            # Get Volume information
-            resp, fetched_volume = self.client.get_volume(volume['id'])
-            self.assertEqual(200, resp.status)
-            self.assertEqual(v_name,
-                             fetched_volume['display_name'],
-                             'The fetched Volume is different '
-                             'from the created Volume')
-            self.assertEqual(volume['id'],
-                             fetched_volume['id'],
-                             'The fetched Volume is different '
-                             'from the created Volume')
-            self.assertEqual(metadata,
-                             fetched_volume['metadata'],
-                             'The fetched Volume is different '
-                             'from the created Volume')
-        except Exception:
-            self.fail("Could not create a volume")
-        finally:
-            if volume:
-                # Delete the Volume if it was created
-                resp, _ = self.client.delete_volume(volume['id'])
-                self.assertEqual(202, resp.status)
-                self.client.wait_for_resource_deletion(volume['id'])
+        volume = {}
+        v_name = rand_name('Volume')
+        metadata = {'Type': 'Test'}
+        # Create a volume
+        resp, volume = self.client.create_volume(size=1,
+                                                 display_name=v_name,
+                                                 metadata=metadata,
+                                                 **kwargs)
+        self.assertEqual(200, resp.status)
+        self.assertIn('id', volume)
+        self.addCleanup(self._delete_volume, volume['id'])
+        self.assertIn('display_name', volume)
+        self.assertEqual(volume['display_name'], v_name,
+                         "The created volume name is not equal "
+                         "to the requested name")
+        self.assertTrue(volume['id'] is not None,
+                        "Field volume id is empty or not found.")
+        self.client.wait_for_volume_status(volume['id'], 'available')
+        # Get Volume information
+        resp, fetched_volume = self.client.get_volume(volume['id'])
+        self.assertEqual(200, resp.status)
+        self.assertEqual(v_name,
+                         fetched_volume['display_name'],
+                         'The fetched Volume is different '
+                         'from the created Volume')
+        self.assertEqual(volume['id'],
+                         fetched_volume['id'],
+                         'The fetched Volume is different '
+                         'from the created Volume')
+        self.assertEqual(metadata,
+                         fetched_volume['metadata'],
+                         'The fetched Volume is different '
+                         'from the created Volume')
 
     @attr(type='gate')
     def test_volume_get_metadata_none(self):
         # Create a volume without passing metadata, get details, and delete
-        try:
-            volume = {}
-            v_name = rand_name('Volume-')
-            # Create a volume without metadata
-            resp, volume = self.client.create_volume(size=1,
-                                                     display_name=v_name,
-                                                     metadata={})
-            self.assertEqual(200, resp.status)
-            self.assertIn('id', volume)
-            self.assertIn('display_name', volume)
-            self.client.wait_for_volume_status(volume['id'], 'available')
-            # GET Volume
-            resp, fetched_volume = self.client.get_volume(volume['id'])
-            self.assertEqual(200, resp.status)
-            self.assertEqual(fetched_volume['metadata'], {})
-        except Exception:
-            self.fail("Could not get volume metadata")
-        finally:
-            if volume:
-                # Delete the Volume if it was created
-                resp, _ = self.client.delete_volume(volume['id'])
-                self.assertEqual(202, resp.status)
-                self.client.wait_for_resource_deletion(volume['id'])
+        volume = {}
+        v_name = rand_name('Volume-')
+        # Create a volume without metadata
+        resp, volume = self.client.create_volume(size=1,
+                                                 display_name=v_name,
+                                                 metadata={})
+        self.assertEqual(200, resp.status)
+        self.assertIn('id', volume)
+        self.addCleanup(self._delete_volume, volume['id'])
+        self.assertIn('display_name', volume)
+        self.client.wait_for_volume_status(volume['id'], 'available')
+        # GET Volume
+        resp, fetched_volume = self.client.get_volume(volume['id'])
+        self.assertEqual(200, resp.status)
+        self.assertEqual(fetched_volume['metadata'], {})
 
     @attr(type='smoke')
     def test_volume_create_get_delete(self):