blob: 2df952383b79c2479a5e45ef8766dd87691554a3 [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
Andrea Frittoli (andreaf)db9672e2016-02-23 14:07:24 -050016from tempest.lib import exceptions as lib_exc
Masayuki Igawa1edf94f2014-03-04 18:34:16 +090017from tempest import test
wanghao1850c5f2013-10-08 11:51:29 +080018
JordanPbce55532014-03-19 12:10:32 +010019CONF = config.CONF
20
wanghao1850c5f2013-10-08 11:51:29 +080021
Zhi Kun Liu38641c62014-07-10 20:12:48 +080022class VolumesV2SnapshotNegativeTestJSON(base.BaseVolumeTest):
wanghao1850c5f2013-10-08 11:51:29 +080023
JordanPbce55532014-03-19 12:10:32 +010024 @classmethod
Rohan Kanade05749152015-01-30 17:15:18 +053025 def skip_checks(cls):
26 super(VolumesV2SnapshotNegativeTestJSON, cls).skip_checks()
JordanPbce55532014-03-19 12:10:32 +010027 if not CONF.volume_feature_enabled.snapshot:
28 raise cls.skipException("Cinder volume snapshots are disabled")
29
Sean Dague639f2fa2015-04-27 09:00:33 -040030 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080031 @test.idempotent_id('e3e466af-70ab-4f4b-a967-ab04e3532ea7')
wanghao1850c5f2013-10-08 11:51:29 +080032 def test_create_snapshot_with_nonexistent_volume_id(self):
33 # Create a snapshot with nonexistent volume id
34 s_name = data_utils.rand_name('snap')
Masayuki Igawabfa07602015-01-20 18:47:17 +090035 self.assertRaises(lib_exc.NotFound,
wanghao1850c5f2013-10-08 11:51:29 +080036 self.snapshots_client.create_snapshot,
Ken'ichi Ohmichid079c892016-04-19 11:23:36 -070037 volume_id=data_utils.rand_uuid(),
38 display_name=s_name)
wanghao1850c5f2013-10-08 11:51:29 +080039
Sean Dague639f2fa2015-04-27 09:00:33 -040040 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080041 @test.idempotent_id('bb9da53e-d335-4309-9c15-7e76fd5e4d6d')
wanghao1850c5f2013-10-08 11:51:29 +080042 def test_create_snapshot_without_passing_volume_id(self):
43 # Create a snapshot without passing volume id
44 s_name = data_utils.rand_name('snap')
Masayuki Igawabfa07602015-01-20 18:47:17 +090045 self.assertRaises(lib_exc.NotFound,
wanghao1850c5f2013-10-08 11:51:29 +080046 self.snapshots_client.create_snapshot,
Ghanshyam0b75b632015-12-11 15:08:28 +090047 volume_id=None, display_name=s_name)
wanghao1850c5f2013-10-08 11:51:29 +080048
Erlon R. Cruz8dbbc292016-06-17 15:40:36 -030049 @test.idempotent_id('677863d1-34f9-456d-b6ac-9924f667a7f4')
50 def test_volume_from_snapshot_decreasing_size(self):
51 # Creates a volume a snapshot passing a size different from the source
52 src_size = CONF.volume.volume_size + 1
53
54 src_vol = self.create_volume(size=src_size)
55 src_snap = self.create_snapshot(src_vol['id'])
56
57 # Destination volume smaller than source
58 self.assertRaises(lib_exc.BadRequest,
59 self.volumes_client.create_volume,
60 size=src_size - 1,
61 snapshot_id=src_snap['id'])
62
wanghao1850c5f2013-10-08 11:51:29 +080063
Zhi Kun Liu38641c62014-07-10 20:12:48 +080064class VolumesV1SnapshotNegativeTestJSON(VolumesV2SnapshotNegativeTestJSON):
65 _api_version = 1