Refactor volume clone tests
Creating a common method 'volume_clone_verification' in order to reduce a duplicated code. Change-Id: If73ab72d0ce3218a6a3ba8b5a5c812507d800a21
This commit is contained in:
parent
7f10bfbcb0
commit
5dcb541d8c
@ -30,6 +30,18 @@ class VolumesCloneTest(base.BaseVolumeTest):
|
|||||||
if not CONF.volume_feature_enabled.clone:
|
if not CONF.volume_feature_enabled.clone:
|
||||||
raise cls.skipException("Cinder volume clones are disabled")
|
raise cls.skipException("Cinder volume clones are disabled")
|
||||||
|
|
||||||
|
def _verify_volume_clone(self, source_volume, cloned_volume,
|
||||||
|
bootable='false', extra_size=0):
|
||||||
|
|
||||||
|
cloned_vol_details = self.volumes_client.show_volume(
|
||||||
|
cloned_volume['id'])['volume']
|
||||||
|
|
||||||
|
self.assertEqual(source_volume['id'],
|
||||||
|
cloned_vol_details['source_volid'])
|
||||||
|
self.assertEqual(source_volume['size'] + extra_size,
|
||||||
|
cloned_vol_details['size'])
|
||||||
|
self.assertEqual(bootable, cloned_vol_details['bootable'])
|
||||||
|
|
||||||
@decorators.idempotent_id('9adae371-a257-43a5-9555-dc7c88e66e0e')
|
@decorators.idempotent_id('9adae371-a257-43a5-9555-dc7c88e66e0e')
|
||||||
def test_create_from_volume(self):
|
def test_create_from_volume(self):
|
||||||
# Creates a volume from another volume passing a size different from
|
# Creates a volume from another volume passing a size different from
|
||||||
@ -41,10 +53,7 @@ class VolumesCloneTest(base.BaseVolumeTest):
|
|||||||
dst_vol = self.create_volume(source_volid=src_vol['id'],
|
dst_vol = self.create_volume(source_volid=src_vol['id'],
|
||||||
size=src_size + 1)
|
size=src_size + 1)
|
||||||
|
|
||||||
volume = self.volumes_client.show_volume(dst_vol['id'])['volume']
|
self._verify_volume_clone(src_vol, dst_vol, extra_size=1)
|
||||||
# Should allow
|
|
||||||
self.assertEqual(volume['source_volid'], src_vol['id'])
|
|
||||||
self.assertEqual(volume['size'], src_size + 1)
|
|
||||||
|
|
||||||
@decorators.idempotent_id('cbbcd7c6-5a6c-481a-97ac-ca55ab715d16')
|
@decorators.idempotent_id('cbbcd7c6-5a6c-481a-97ac-ca55ab715d16')
|
||||||
@test.services('image')
|
@test.services('image')
|
||||||
@ -55,10 +64,5 @@ class VolumesCloneTest(base.BaseVolumeTest):
|
|||||||
|
|
||||||
# Create a volume from the bootable volume
|
# Create a volume from the bootable volume
|
||||||
cloned_vol = self.create_volume(source_volid=src_vol['id'])
|
cloned_vol = self.create_volume(source_volid=src_vol['id'])
|
||||||
cloned_vol_details = self.volumes_client.show_volume(
|
|
||||||
cloned_vol['id'])['volume']
|
|
||||||
|
|
||||||
# Verify cloned volume creation as expected
|
self._verify_volume_clone(src_vol, cloned_vol, bootable='true')
|
||||||
self.assertEqual('true', cloned_vol_details['bootable'])
|
|
||||||
self.assertEqual(src_vol['id'], cloned_vol_details['source_volid'])
|
|
||||||
self.assertEqual(src_vol['size'], cloned_vol_details['size'])
|
|
||||||
|
Loading…
Reference in New Issue
Block a user