From 49f96f80dbeaa561ac98d174139a567d1f610988 Mon Sep 17 00:00:00 2001 From: Mike Perez Date: Fri, 6 Dec 2013 11:13:09 -0800 Subject: [PATCH] Add RBD test for volume not existing during delete For cases when the volume does not exist in the backend, but Cinder still knows about it, we just return from the rbd driver and let Cinder do its thing. Change-Id: I6150756bdd48259ec8d550fa7a5dc7a9f882ca22 --- cinder/tests/test_rbd.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cinder/tests/test_rbd.py b/cinder/tests/test_rbd.py index c75012e29..7b05ed1ab 100644 --- a/cinder/tests/test_rbd.py +++ b/cinder/tests/test_rbd.py @@ -161,6 +161,24 @@ class RBDTestCase(test.TestCase): self.assertFalse(mock_rbd.Image.unprotect_snap.called) self.assertTrue(_mock_rbd.RBD.remove.called) + @mock.patch('cinder.volume.drivers.rbd.rbd') + def test_delete_volume_not_found(self, _mock_rbd): + name = u'volume-00000001' + volume = dict(name=name) + + class MyMockException(Exception): + pass + + _mock_rbd.RBD = mock_rbd.RBD + _mock_rbd.ImageNotFound = MyMockException + _mock_rbd.Image.side_effect = _mock_rbd.ImageNotFound + + mpo = mock.patch.object + with mpo(self.driver, 'rbd', _mock_rbd): + with mpo(driver, 'RADOSClient'): + self.assertIsNone(self.driver.delete_volume(volume)) + _mock_rbd.Image.assert_called_once() + @mock.patch('cinder.volume.drivers.rbd.rados') @mock.patch('cinder.volume.drivers.rbd.rbd') def test_delete_busy_volume(self, _mock_rbd, _mock_rados): -- 2.45.2