Skip to content

Commit

Permalink
Fixes bug 888649
Browse files Browse the repository at this point in the history
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
  • Loading branch information
leahyo committed Nov 28, 2011
1 parent 43bb342 commit e0ef89f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions Authors
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Nachi Ueno <ueno.nachi@lab.ntt.co.jp>
Naveed Massjouni <naveedm9@gmail.com>
Nikolay Sokolov <nsokolov@griddynamics.com>
Nirmal Ranganathan <nirmal.ranganathan@rackspace.com>
Ollie Leahy <oliver.leahy@hp.com>
Paul Voccio <paul@openstack.org>
Renuka Apte <renuka.apte@citrix.com>
Ricardo Carrillo Cruz <emaildericky@gmail.com>
Expand Down
2 changes: 1 addition & 1 deletion nova/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class SnapshotNotFound(NotFound):
message = _("Snapshot %(snapshot_id)s could not be found.")


class VolumeIsBusy(Error):
class VolumeIsBusy(NovaException):
message = _("deleting volume %(volume_name)s that has snapshot")


Expand Down
28 changes: 28 additions & 0 deletions nova/tests/test_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,34 @@ def _detach_volume(self, volume_id_list):
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"
Expand Down

0 comments on commit e0ef89f

Please sign in to comment.