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
This commit is contained in:
caixiaoyu 2018-11-16 21:15:46 +08:00
parent 4529b193da
commit cb1a4b1612

View File

@ -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}))