Replace volume size with configured value

Use configured value as volume size unit when
create and extend volume.

NOTE: Some backends don't support the case of "size+1"
(VMAX only works in 8G increments) and the cloud providers
may have their own operation strategies to decide the
allowed input for volume size, such as minimum, maximum,
size unit,  etc.

Change-Id: I2c0e662229aba2281733d092f6b1ca6acea237ee
This commit is contained in:
TommyLike 2018-01-18 15:25:12 +08:00
parent 6175b2d3c4
commit fcda77b45b
3 changed files with 10 additions and 7 deletions

View File

@ -33,7 +33,7 @@ class VolumesExtendTest(base.BaseVolumeTest):
def test_volume_extend(self):
# Extend Volume Test.
volume = self.create_volume(image_ref=self.image_ref)
extend_size = volume['size'] + 1
extend_size = volume['size'] * 2
self.volumes_client.extend_volume(volume['id'],
new_size=extend_size)
waiters.wait_for_volume_resource_status(self.volumes_client,
@ -48,7 +48,7 @@ class VolumesExtendTest(base.BaseVolumeTest):
volume = self.create_volume()
self.create_snapshot(volume['id'])
extend_size = volume['size'] + 1
extend_size = volume['size'] * 2
self.volumes_client.extend_volume(volume['id'], new_size=extend_size)
waiters.wait_for_volume_resource_status(self.volumes_client,

View File

@ -103,21 +103,24 @@ class VolumesNegativeTest(base.BaseVolumeTest):
def test_create_volume_with_nonexistent_volume_type(self):
# Should not be able to create volume with non-existent volume type
self.assertRaises(lib_exc.NotFound, self.volumes_client.create_volume,
size='1', volume_type=data_utils.rand_uuid())
size=CONF.volume.volume_size,
volume_type=data_utils.rand_uuid())
@decorators.attr(type=['negative'])
@decorators.idempotent_id('0c36f6ae-4604-4017-b0a9-34fdc63096f9')
def test_create_volume_with_nonexistent_snapshot_id(self):
# Should not be able to create volume with non-existent snapshot
self.assertRaises(lib_exc.NotFound, self.volumes_client.create_volume,
size='1', snapshot_id=data_utils.rand_uuid())
size=CONF.volume.volume_size,
snapshot_id=data_utils.rand_uuid())
@decorators.attr(type=['negative'])
@decorators.idempotent_id('47c73e08-4be8-45bb-bfdf-0c4e79b88344')
def test_create_volume_with_nonexistent_source_volid(self):
# Should not be able to create volume with non-existent source volume
self.assertRaises(lib_exc.NotFound, self.volumes_client.create_volume,
size='1', source_volid=data_utils.rand_uuid())
size=CONF.volume.volume_size,
source_volid=data_utils.rand_uuid())
@decorators.attr(type=['negative'])
@decorators.idempotent_id('0186422c-999a-480e-a026-6a665744c30c')

View File

@ -50,7 +50,7 @@ class VolumesSnapshotNegativeTestJSON(base.BaseVolumeTest):
@decorators.idempotent_id('677863d1-34f9-456d-b6ac-9924f667a7f4')
def test_volume_from_snapshot_decreasing_size(self):
# Creates a volume a snapshot passing a size different from the source
src_size = CONF.volume.volume_size + 1
src_size = CONF.volume.volume_size * 2
src_vol = self.create_volume(size=src_size)
src_snap = self.create_snapshot(src_vol['id'])
@ -58,7 +58,7 @@ class VolumesSnapshotNegativeTestJSON(base.BaseVolumeTest):
# Destination volume smaller than source
self.assertRaises(lib_exc.BadRequest,
self.volumes_client.create_volume,
size=src_size - 1,
size=CONF.volume.volume_size,
snapshot_id=src_snap['id'])
@decorators.attr(type=['negative'])