Adds clone/snapshot volume test for create volume
Cinder supports creation of volume from snapshot, image, or another volume as
source. In the case of snapshots and volume sources, its allowed that the
created volumes are bigger than the source. Cinder has had several backends
that has this checking broken. We need to have this tempest test running in
Cinder CIs to identify possible bugs and test submitted fixes that meant to fix
those bugs.
Co-Authored-By: Marcus V R Nascimento <marcusvrn@gmail.com>
Change-Id: I829c0e6f99fff0ec0bd5366c9d2e79b1b073f0a3
diff --git a/tempest/api/volume/test_volumes_clone.py b/tempest/api/volume/test_volumes_clone.py
new file mode 100644
index 0000000..f38a068
--- /dev/null
+++ b/tempest/api/volume/test_volumes_clone.py
@@ -0,0 +1,44 @@
+# Copyright 2016 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.volume import base
+from tempest import config
+from tempest import test
+
+
+CONF = config.CONF
+
+
+class VolumesCloneTest(base.BaseVolumeTest):
+
+ @test.idempotent_id('9adae371-a257-43a5-9555-dc7c88e66e0e')
+ def test_create_from_volume(self):
+ # Creates a volume from another volume passing a size different from
+ # the source volume.
+ src_size = CONF.volume.volume_size
+
+ src_vol = self.create_volume(size=src_size)
+ # Destination volume bigger than source
+ 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(int(volume['size']), src_size + 1)
+
+
+class VolumesV1CloneTest(VolumesCloneTest):
+ _api_version = 1
diff --git a/tempest/api/volume/test_volumes_clone_negative.py b/tempest/api/volume/test_volumes_clone_negative.py
new file mode 100644
index 0000000..ee51e00
--- /dev/null
+++ b/tempest/api/volume/test_volumes_clone_negative.py
@@ -0,0 +1,42 @@
+# Copyright 2016 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.volume import base
+from tempest import config
+from tempest.lib import exceptions
+from tempest import test
+
+
+CONF = config.CONF
+
+
+class VolumesCloneTest(base.BaseVolumeTest):
+
+ @test.idempotent_id('9adae371-a257-43a5-459a-dc7c88e66e0e')
+ def test_create_from_volume_decreasing_size(self):
+ # Creates a volume from another volume passing a size different from
+ # the source volume.
+ src_size = CONF.volume.volume_size + 1
+ src_vol = self.create_volume(size=src_size)
+
+ # Destination volume smaller than source
+ self.assertRaises(exceptions.BadRequest,
+ self.volumes_client.create_volume,
+ size=src_size - 1,
+ source_volid=src_vol['id'])
+
+
+class VolumesV1CloneTest(VolumesCloneTest):
+ _api_version = 1
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 0f7c4f6..c7f1e6e 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -178,16 +178,19 @@
@test.idempotent_id('677863d1-3142-456d-b6ac-9924f667a7f4')
def test_volume_from_snapshot(self):
- # Create a temporary snap using wrapper method from base, then
- # create a snap based volume and deletes it
- snapshot = self.create_snapshot(self.volume_origin['id'])
- # NOTE(gfidente): size is required also when passing snapshot_id
- volume = self.volumes_client.create_volume(
- snapshot_id=snapshot['id'])['volume']
- waiters.wait_for_volume_status(self.volumes_client,
- volume['id'], 'available')
- self.delete_volume(self.volumes_client, volume['id'])
- self.cleanup_snapshot(snapshot)
+ # Creates a volume a snapshot passing a size different from the source
+ src_size = CONF.volume.volume_size
+
+ src_vol = self.create_volume(size=src_size)
+ src_snap = self.create_snapshot(src_vol['id'])
+ # Destination volume bigger than source snapshot
+ dst_vol = self.create_volume(snapshot_id=src_snap['id'],
+ size=src_size + 1)
+
+ volume = self.volumes_client.show_volume(dst_vol['id'])['volume']
+ # Should allow
+ self.assertEqual(volume['snapshot_id'], src_snap['id'])
+ self.assertEqual(int(volume['size']), src_size + 1)
@test.idempotent_id('db4d8e0a-7a2e-41cc-a712-961f6844e896')
def test_snapshot_list_param_limit(self):
diff --git a/tempest/api/volume/test_volumes_snapshots_negative.py b/tempest/api/volume/test_volumes_snapshots_negative.py
index 374979c..2df9523 100644
--- a/tempest/api/volume/test_volumes_snapshots_negative.py
+++ b/tempest/api/volume/test_volumes_snapshots_negative.py
@@ -46,6 +46,20 @@
self.snapshots_client.create_snapshot,
volume_id=None, display_name=s_name)
+ @test.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_vol = self.create_volume(size=src_size)
+ src_snap = self.create_snapshot(src_vol['id'])
+
+ # Destination volume smaller than source
+ self.assertRaises(lib_exc.BadRequest,
+ self.volumes_client.create_volume,
+ size=src_size - 1,
+ snapshot_id=src_snap['id'])
+
class VolumesV1SnapshotNegativeTestJSON(VolumesV2SnapshotNegativeTestJSON):
_api_version = 1