Add test case: delete snapshot when driver not initialized

This patch add test case: when deleting snapshot, volume driver is
not ready, the snapshot status will be set 'error_deleting'.

Change-Id: I71b6071026b3b60c5fb3a0d72149f2f3c529af68
This commit is contained in:
caixiaoyu 2018-11-20 16:24:02 +08:00 committed by Jiao Pengju
parent da34b35579
commit 26bce3edd9
1 changed files with 13 additions and 0 deletions

View File

@ -583,3 +583,16 @@ class SnapshotTestCase(base.BaseVolumeTestCase):
self.volume.manage_existing_snapshot,
self.context,
snap)
def test_delete_snapshot_driver_not_initialized(self):
volume = tests_utils.create_volume(self.context, **self.volume_params)
snapshot = tests_utils.create_snapshot(self.context, volume.id)
self.volume.driver._initialized = False
self.assertRaises(exception.DriverNotInitialized,
self.volume.delete_snapshot,
self.context, snapshot)
snapshot.refresh()
self.assertEqual(fields.SnapshotStatus.ERROR_DELETING,
snapshot.status)