Add case: force delete snapshot

This patch add test case: snapshot can be forced to delete, when
snapshot's status is error_deleting.

Change-Id: I43fd8185c718f3ce9f24eedd84332e5b578a7d7b
This commit is contained in:
caixiaoyu 2019-06-20 11:26:33 +08:00
parent 4f4de3bfe3
commit f38fbb646f
1 changed files with 21 additions and 0 deletions

View File

@ -555,6 +555,27 @@ class SnapshotTestCase(base.BaseVolumeTestCase):
snapshot_ref.status)
mock_del_snap.assert_called_once_with(snapshot)
def test_force_delete_snapshot(self):
"""Test snapshot can be forced to delete."""
fake_volume = tests_utils.create_volume(self.context)
fake_snapshot = tests_utils.create_snapshot(self.context,
fake_volume.id,
status='error_deleting')
# 'error_deleting' snapshot can't be deleted
self.assertRaises(exception.InvalidSnapshot,
self.volume_api.delete_snapshot,
self.context,
fake_snapshot)
# delete with force
self.volume_api.delete_snapshot(self.context,
fake_snapshot,
force=True)
# status is deleting
fake_snapshot.refresh()
self.assertEqual(fields.SnapshotStatus.DELETING, fake_snapshot.status)
def test_volume_api_update_snapshot(self):
# create raw snapshot
volume = tests_utils.create_volume(self.context, **self.volume_params)