blob: a3d91b0931607c74da35d5483727b573b3629f9d [file] [log] [blame]
wanghao1850c5f2013-10-08 11:51:29 +08001# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
wanghao1850c5f2013-10-08 11:51:29 +080013from tempest.api.volume import base
Fei Long Wangd39431f2015-05-14 11:30:48 +120014from tempest.common.utils import data_utils
JordanPbce55532014-03-19 12:10:32 +010015from tempest import config
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080016from tempest.lib import decorators
Andrea Frittoli (andreaf)db9672e2016-02-23 14:07:24 -050017from tempest.lib import exceptions as lib_exc
Masayuki Igawa1edf94f2014-03-04 18:34:16 +090018from tempest import test
wanghao1850c5f2013-10-08 11:51:29 +080019
JordanPbce55532014-03-19 12:10:32 +010020CONF = config.CONF
21
wanghao1850c5f2013-10-08 11:51:29 +080022
Zhi Kun Liu38641c62014-07-10 20:12:48 +080023class VolumesV2SnapshotNegativeTestJSON(base.BaseVolumeTest):
wanghao1850c5f2013-10-08 11:51:29 +080024
JordanPbce55532014-03-19 12:10:32 +010025 @classmethod
Rohan Kanade05749152015-01-30 17:15:18 +053026 def skip_checks(cls):
27 super(VolumesV2SnapshotNegativeTestJSON, cls).skip_checks()
JordanPbce55532014-03-19 12:10:32 +010028 if not CONF.volume_feature_enabled.snapshot:
29 raise cls.skipException("Cinder volume snapshots are disabled")
30
Sean Dague639f2fa2015-04-27 09:00:33 -040031 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080032 @decorators.idempotent_id('e3e466af-70ab-4f4b-a967-ab04e3532ea7')
wanghao1850c5f2013-10-08 11:51:29 +080033 def test_create_snapshot_with_nonexistent_volume_id(self):
34 # Create a snapshot with nonexistent volume id
zhuflc6ce5392016-08-17 14:34:37 +080035 s_name = data_utils.rand_name(self.__class__.__name__ + '-snap')
Masayuki Igawabfa07602015-01-20 18:47:17 +090036 self.assertRaises(lib_exc.NotFound,
wanghao1850c5f2013-10-08 11:51:29 +080037 self.snapshots_client.create_snapshot,
Ken'ichi Ohmichid079c892016-04-19 11:23:36 -070038 volume_id=data_utils.rand_uuid(),
39 display_name=s_name)
wanghao1850c5f2013-10-08 11:51:29 +080040
Sean Dague639f2fa2015-04-27 09:00:33 -040041 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080042 @decorators.idempotent_id('bb9da53e-d335-4309-9c15-7e76fd5e4d6d')
wanghao1850c5f2013-10-08 11:51:29 +080043 def test_create_snapshot_without_passing_volume_id(self):
44 # Create a snapshot without passing volume id
zhuflc6ce5392016-08-17 14:34:37 +080045 s_name = data_utils.rand_name(self.__class__.__name__ + '-snap')
Masayuki Igawabfa07602015-01-20 18:47:17 +090046 self.assertRaises(lib_exc.NotFound,
wanghao1850c5f2013-10-08 11:51:29 +080047 self.snapshots_client.create_snapshot,
Ghanshyam0b75b632015-12-11 15:08:28 +090048 volume_id=None, display_name=s_name)
wanghao1850c5f2013-10-08 11:51:29 +080049
lkuchlan291a8062017-02-19 13:21:48 +020050 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080051 @decorators.idempotent_id('677863d1-34f9-456d-b6ac-9924f667a7f4')
Erlon R. Cruz8dbbc292016-06-17 15:40:36 -030052 def test_volume_from_snapshot_decreasing_size(self):
53 # Creates a volume a snapshot passing a size different from the source
54 src_size = CONF.volume.volume_size + 1
55
56 src_vol = self.create_volume(size=src_size)
57 src_snap = self.create_snapshot(src_vol['id'])
58
59 # Destination volume smaller than source
60 self.assertRaises(lib_exc.BadRequest,
61 self.volumes_client.create_volume,
62 size=src_size - 1,
63 snapshot_id=src_snap['id'])
64
wanghao1850c5f2013-10-08 11:51:29 +080065
Zhi Kun Liu38641c62014-07-10 20:12:48 +080066class VolumesV1SnapshotNegativeTestJSON(VolumesV2SnapshotNegativeTestJSON):
67 _api_version = 1