summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-03-30 16:38:27 +0000
committerGerrit Code Review <review@openstack.org>2012-03-30 16:38:27 +0000
commitad4e65a6688fceecac3f44f9d8eb46e35b6ed6d8 (patch)
tree073fe7b615a5adeaf82c81adbf18aa1d11fc8ab5 /nova/tests
parent0a6ffe3f2a570aa222814efa149882edf8a7b224 (diff)
parent43c63d11417de8624d120ca78a9849d09ffa8cf6 (diff)
Merge "Check that volume has no snapshots before deletion"
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_volume.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/nova/tests/test_volume.py b/nova/tests/test_volume.py
index caeaa7098..be589d3e2 100644
--- a/nova/tests/test_volume.py
+++ b/nova/tests/test_volume.py
@@ -256,6 +256,29 @@ class VolumeTestCase(test.TestCase):
snapshot_id)
self.volume.delete_volume(self.context, volume['id'])
+ def test_cant_delete_volume_with_snapshots(self):
+ """Test snapshot can be created and deleted."""
+ volume = self._create_volume()
+ self.volume.create_volume(self.context, volume['id'])
+ snapshot_id = self._create_snapshot(volume['id'])
+ self.volume.create_snapshot(self.context, volume['id'], snapshot_id)
+ self.assertEqual(snapshot_id,
+ db.snapshot_get(context.get_admin_context(),
+ snapshot_id).id)
+
+ volume['status'] = 'available'
+ volume['host'] = 'fakehost'
+
+ volume_api = nova.volume.api.API()
+
+ self.assertRaises(exception.InvalidVolume,
+ volume_api.delete,
+ self.context,
+ volume)
+
+ self.volume.delete_snapshot(self.context, snapshot_id)
+ self.volume.delete_volume(self.context, volume['id'])
+
def test_create_snapshot_force(self):
"""Test snapshot in use can be created forcibly."""