From 921eec91abee56ea69e1b8b2bff59379b68bff87 Mon Sep 17 00:00:00 2001 From: Unmesh Gurjar Date: Tue, 11 Dec 2012 03:30:31 -0800 Subject: Fixed deleting instance booted from invalid vol 1. Translated the exception (NotFound) raised from Cinder client to Nova's native exception (VolumeNotFound). 2. Added unit test coverage. Fixes LP: #1087214. Change-Id: I3cee31a9fd068b65a4097f3f3054aebb69d9ba61 --- nova/tests/test_cinder.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/test_cinder.py b/nova/tests/test_cinder.py index 3302aedb8..11d29a3ff 100644 --- a/nova/tests/test_cinder.py +++ b/nova/tests/test_cinder.py @@ -17,7 +17,9 @@ import httplib2 import urlparse +from cinderclient import exceptions as cinder_exception from nova import context +from nova import exception from nova.volume import cinder from nova import test @@ -77,6 +79,9 @@ class FakeHTTPClient(cinder.cinder_client.client.HTTPClient): volume = {'volume': _stub_volume(id='1234')} return (200, volume) + def get_volumes_nonexisting(self, **kw): + raise cinder_exception.NotFound(code=404, message='Resource not found') + class FakeCinderClient(cinder.cinder_client.Client): @@ -146,3 +151,7 @@ class CinderTestCase(test.TestCase): self.assertEquals( self.fake_client_factory.client.client.management_url, 'http://other_host:8776/v1/project_id') + + def test_get_non_existing_volume(self): + self.assertRaises(exception.VolumeNotFound, self.api.get, self.context, + 'nonexisting') -- cgit