Refactor volume clone tests
Creating a common method 'volume_clone_verification' in order to
reduce a duplicated code.
Change-Id: If73ab72d0ce3218a6a3ba8b5a5c812507d800a21
diff --git a/tempest/api/volume/test_volumes_clone.py b/tempest/api/volume/test_volumes_clone.py
index 4c13375..927bfa5 100644
--- a/tempest/api/volume/test_volumes_clone.py
+++ b/tempest/api/volume/test_volumes_clone.py
@@ -30,6 +30,18 @@
if not CONF.volume_feature_enabled.clone:
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')
def test_create_from_volume(self):
# Creates a volume from another volume passing a size different from
@@ -41,10 +53,7 @@
dst_vol = self.create_volume(source_volid=src_vol['id'],
size=src_size + 1)
- volume = self.volumes_client.show_volume(dst_vol['id'])['volume']
- # Should allow
- self.assertEqual(volume['source_volid'], src_vol['id'])
- self.assertEqual(volume['size'], src_size + 1)
+ self._verify_volume_clone(src_vol, dst_vol, extra_size=1)
@decorators.idempotent_id('cbbcd7c6-5a6c-481a-97ac-ca55ab715d16')
@test.services('image')
@@ -55,10 +64,5 @@
# Create a volume from the bootable volume
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.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'])
+ self._verify_volume_clone(src_vol, cloned_vol, bootable='true')