diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-03-30 16:38:27 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-03-30 16:38:27 +0000 |
| commit | ad4e65a6688fceecac3f44f9d8eb46e35b6ed6d8 (patch) | |
| tree | 073fe7b615a5adeaf82c81adbf18aa1d11fc8ab5 /nova/tests | |
| parent | 0a6ffe3f2a570aa222814efa149882edf8a7b224 (diff) | |
| parent | 43c63d11417de8624d120ca78a9849d09ffa8cf6 (diff) | |
Merge "Check that volume has no snapshots before deletion"
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_volume.py | 23 |
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.""" |
