From cb1a4b1612b241e00ec9f5f627059a7d351325c8 Mon Sep 17 00:00:00 2001 From: caixiaoyu Date: Fri, 16 Nov 2018 21:15:46 +0800 Subject: [PATCH] Add test case: clone volume with bad size This patch add test case: volume can't be created from a source volume with bad volume size. Change-Id: Id968cd73acf80e58b21335320021345428e6ac5e --- cinder/tests/unit/volume/test_volume.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cinder/tests/unit/volume/test_volume.py b/cinder/tests/unit/volume/test_volume.py index 7b1d39d7dd7..80ff5bf9812 100644 --- a/cinder/tests/unit/volume/test_volume.py +++ b/cinder/tests/unit/volume/test_volume.py @@ -2601,6 +2601,21 @@ class VolumeTestCase(base.BaseVolumeTestCase): self.volume.delete_volume(self.context, volume_dst) self.volume.delete_volume(self.context, volume_src) + def test_create_volume_from_sourcevol_fail_bad_size(self): + """Test cannot clone volume with bad volume size.""" + volume_src = tests_utils.create_volume(self.context, + size=3, + status='available', + host=CONF.host) + + self.assertRaises(exception.InvalidInput, + self.volume_api.create, + self.context, + size=1, + name='fake_name', + description='fake_desc', + source_volume=volume_src) + @mock.patch('cinder.volume.api.API.list_availability_zones', return_value=({'name': 'nova', 'available': True}, {'name': 'az2', 'available': True}))