summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorRick Harris <rconradharris@gmail.com>2013-02-12 05:29:23 +0000
committerRick Harris <rconradharris@gmail.com>2013-02-12 17:42:02 +0000
commit07cbf72301c5a3e588fc818abcab91f733b87738 (patch)
tree5fb789f228f8540729fa3937162aebdfbf249c96 /nova/tests
parent20424b987946ee56e39f88aed7fddd35c54d7207 (diff)
xenapi: Remove unecessary exception handling
The volume code was catching exceptions from the XenAPI only to re-raise more-generic StorageError exceptions. This practice makes it much more difficult to discover the root-cause of issues in production by making the message in the instance-faults table less useful. The solution is to have the original root-cause exception propogate all the way up to the instance-faults table where the developer will be able to make sense of it. Other cleanups: * Remove useless logging and stop logging opaque-refs in some places * Remove dead code (create_iscsi_storage) * Remove one-off functions (forget_sr_if_present, introduce_sr_unless_present); just use forget_sr and introduce_sr * Removed unused `exception` import * Added Openstack copyright lines Future Work: There are lots of other places where unecessary exception handling is occuring; this patch just addresses this in the attach/detach code-path. Fixes bug 1122733 Change-Id: I8c382fb505303e604ff2e86afcf302efe3d6851d
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/virt/xenapi/test_volumeops.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/nova/tests/virt/xenapi/test_volumeops.py b/nova/tests/virt/xenapi/test_volumeops.py
index 844ae8459..3497babf2 100644
--- a/nova/tests/virt/xenapi/test_volumeops.py
+++ b/nova/tests/virt/xenapi/test_volumeops.py
@@ -14,6 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import collections
+
from nova import test
from nova.tests.xenapi import stubs
from nova.virt.xenapi import volumeops
@@ -125,31 +127,33 @@ class VolumeAttachTestCase(test.TestCase):
vm_ref = 'vm_ref'
dev_number = 1
- called = {'xenapi': False}
+ called = collections.defaultdict(bool)
- def fake_call_xenapi(self, *args, **kwargs):
- # Only used for VBD.plug in this code path.
- called['xenapi'] = True
- raise Exception()
+ def fake_call_xenapi(self, method, *args, **kwargs):
+ called[method] = True
self.stubs.Set(ops._session, 'call_xenapi', fake_call_xenapi)
self.mox.StubOutWithMock(volumeops.volume_utils, 'parse_sr_info')
- self.mox.StubOutWithMock(
- volumeops.volume_utils, 'introduce_sr_unless_present')
- self.mox.StubOutWithMock(volumeops.volume_utils, 'introduce_vdi')
- self.mox.StubOutWithMock(volumeops.vm_utils, 'create_vbd')
-
volumeops.volume_utils.parse_sr_info(
connection_data, sr_label).AndReturn(
tuple([sr_uuid, sr_label, sr_params]))
- volumeops.volume_utils.introduce_sr_unless_present(
+ self.mox.StubOutWithMock(
+ volumeops.volume_utils, 'find_sr_by_uuid')
+ volumeops.volume_utils.find_sr_by_uuid(session, sr_uuid).AndReturn(
+ None)
+
+ self.mox.StubOutWithMock(
+ volumeops.volume_utils, 'introduce_sr')
+ volumeops.volume_utils.introduce_sr(
session, sr_uuid, sr_label, sr_params).AndReturn(sr_ref)
+ self.mox.StubOutWithMock(volumeops.volume_utils, 'introduce_vdi')
volumeops.volume_utils.introduce_vdi(
- session, sr_ref, vdi_uuid, None).AndReturn(vdi_ref)
+ session, sr_ref, vdi_uuid=vdi_uuid).AndReturn(vdi_ref)
+ self.mox.StubOutWithMock(volumeops.vm_utils, 'create_vbd')
volumeops.vm_utils.create_vbd(
session, vm_ref, vdi_ref, dev_number,
bootable=False, osvol=True).AndReturn(vbd_ref)
@@ -157,6 +161,6 @@ class VolumeAttachTestCase(test.TestCase):
self.mox.ReplayAll()
ops._connect_volume(connection_data, dev_number, instance_name,
- vm_ref, hotplug=False)
+ vm_ref, hotplug=False)
- self.assertEquals(False, called['xenapi'])
+ self.assertEquals(False, called['VBD.plug'])