From 9b42a30f1545608adbfe8ed73d4f9716c74e4cef Mon Sep 17 00:00:00 2001 From: Ollie Leahy Date: Thu, 24 Nov 2011 15:56:08 +0000 Subject: [PATCH] Fixes bug 888649 Change exception.VolumeIsBusy to derive from NovaException instead of Error, so that an 'unexpected keyword' exception is not thrown when the exception is raised with keyword parameters. Add unit test to confirm that the 'unexpected keyword' exception is not thrown when the exception is raised by nova.volume.driver.VolumeDriver Responded to reviewer observations, fix pep8 errors in tset_volume.py, added email address to Authors file. Change-Id: I15464cb0cf72a2c71f430e4c8c5c2b27cd4e2ef9 --- Authors | 1 + nova/tests/test_volume.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Authors b/Authors index 36ec620c..633677d8 100644 --- a/Authors +++ b/Authors @@ -103,6 +103,7 @@ Nachi Ueno Naveed Massjouni Nikolay Sokolov Nirmal Ranganathan +Ollie Leahy Paul Voccio Renuka Apte Ricardo Carrillo Cruz diff --git a/nova/tests/test_volume.py b/nova/tests/test_volume.py index 588b7a32..6c81facf 100644 --- a/nova/tests/test_volume.py +++ b/nova/tests/test_volume.py @@ -294,6 +294,34 @@ class DriverTestCase(test.TestCase): self.volume.delete_volume(self.context, volume_id) +class VolumeDriverTestCase(DriverTestCase): + """Test case for VolumeDriver""" + driver_name = "nova.volume.driver.VolumeDriver" + + def setUp(self): + super(VolumeDriverTestCase, self).setUp() + + def tearDown(self): + super(VolumeDriverTestCase, self).tearDown() + + def test_delete_busy_volume(self): + """Test deleting a busy volume.""" + self.stubs.Set(self.volume.driver, '_volume_not_present', + lambda x: False) + self.stubs.Set(self.volume.driver, '_delete_volume', + lambda x, y: False) + # Want DriverTestCase._fake_execute to return 'o' so that + # volume.driver.delete_volume() raises the VolumeIsBusy exception. + self.output = 'o' + self.assertRaises(exception.VolumeIsBusy, + self.volume.driver.delete_volume, + {'name': 'test1', 'size': 1024}) + # when DriverTestCase._fake_execute returns something other than + # 'o' volume.driver.delete_volume() does not raise an exception. + self.output = 'x' + self.volume.driver.delete_volume({'name': 'test1', 'size': 1024}) + + class ISCSITestCase(DriverTestCase): """Test Case for ISCSIDriver""" driver_name = "nova.volume.driver.ISCSIDriver"