From ef89161e20c6ff3ec002bc94cd94edd7030e0476 Mon Sep 17 00:00:00 2001 From: caixiaoyu Date: Thu, 20 Jun 2019 10:54:51 +0800 Subject: [PATCH] Add case: volume can't be reverted in in-use status This patch add test case: volume can't be reverted to snapshot in in-use status. Change-Id: I9047876ee8225cdd21acddd8a05db5cbab3d3365 --- cinder/tests/unit/volume/test_volume.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cinder/tests/unit/volume/test_volume.py b/cinder/tests/unit/volume/test_volume.py index 3e6c1e4b1c7..0f5c5c5d0cd 100644 --- a/cinder/tests/unit/volume/test_volume.py +++ b/cinder/tests/unit/volume/test_volume.py @@ -2118,6 +2118,20 @@ class VolumeTestCase(base.BaseVolumeTestCase): self.assertEqual('available', fake_snapshot['status']) self.assertEqual(2, fake_volume['size']) + def test_cannot_revert_to_snapshot_in_use(self): + """Test volume can't be reverted to snapshot in in-use status.""" + fake_volume = tests_utils.create_volume(self.context, + status='in-use') + fake_snapshot = tests_utils.create_snapshot(self.context, + fake_volume.id, + status='available') + + self.assertRaises(exception.InvalidVolume, + self.volume_api.revert_to_snapshot, + self.context, + fake_volume, + fake_snapshot) + def test_cannot_delete_volume_with_snapshots(self): """Test volume can't be deleted with dependent snapshots.""" volume = tests_utils.create_volume(self.context, **self.volume_params)