Add test for create volume from snap without size

If a user creates a volume from a snapshot but does not specify a size,
Cinder will default to creating a volume with the same original size
from when the snapshot was created. We had test coverage for the case of
specifying a larger volume size, but not for this default size. This
adds a single test to verify things work as expected without passing in
a value for the new volume size.

Change-Id: If1704af4c79281df2fc05d8198b30a2653f53d74
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 93638b8..4b97b80 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -155,6 +155,30 @@
         self.assertEqual(volume['snapshot_id'], src_snap['id'])
         self.assertEqual(volume['size'], src_size + 1)
 
+    @decorators.idempotent_id('053d8870-8282-4fff-9dbb-99cb58bb5e0a')
+    def test_volume_from_snapshot_no_size(self):
+        # Creates a volume from a snapshot defaulting to original size
+        src_size = CONF.volume.volume_size
+
+        src_vol = self.create_volume(size=src_size)
+        src_snap = self.create_snapshot(src_vol['id'])
+        # Destination volume without specifying a size
+        dst_vol = self.create_volume(snapshot_id=src_snap['id'])
+
+        # NOTE(zhufl): dst_vol is created based on snapshot, so dst_vol
+        # should be deleted before deleting snapshot, otherwise deleting
+        # snapshot will end with status 'error-deleting'. This depends on
+        # the implementation mechanism of vendors, generally speaking,
+        # some verdors will use "virtual disk clone" which will promote
+        # disk clone speed, and in this situation the "disk clone"
+        # is just a relationship between volume and snapshot.
+        self.addCleanup(self.delete_volume, self.volumes_client, dst_vol['id'])
+
+        volume = self.volumes_client.show_volume(dst_vol['id'])['volume']
+        # Should allow
+        self.assertEqual(volume['snapshot_id'], src_snap['id'])
+        self.assertEqual(volume['size'], src_size)
+
     @decorators.idempotent_id('bbcfa285-af7f-479e-8c1a-8c34fc16543c')
     @testtools.skipUnless(CONF.volume_feature_enabled.backup,
                           "Cinder backup is disabled")