wanghao | 1850c5f | 2013-10-08 11:51:29 +0800 | [diff] [blame] | 1 | # 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 | |
wanghao | 1850c5f | 2013-10-08 11:51:29 +0800 | [diff] [blame] | 13 | from tempest.api.volume import base |
Fei Long Wang | d39431f | 2015-05-14 11:30:48 +1200 | [diff] [blame] | 14 | from tempest.common.utils import data_utils |
JordanP | bce5553 | 2014-03-19 12:10:32 +0100 | [diff] [blame] | 15 | from tempest import config |
Ken'ichi Ohmichi | 6b279c7 | 2017-01-27 18:26:59 -0800 | [diff] [blame] | 16 | from tempest.lib import decorators |
Andrea Frittoli (andreaf) | db9672e | 2016-02-23 14:07:24 -0500 | [diff] [blame] | 17 | from tempest.lib import exceptions as lib_exc |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 18 | from tempest import test |
wanghao | 1850c5f | 2013-10-08 11:51:29 +0800 | [diff] [blame] | 19 | |
JordanP | bce5553 | 2014-03-19 12:10:32 +0100 | [diff] [blame] | 20 | CONF = config.CONF |
| 21 | |
wanghao | 1850c5f | 2013-10-08 11:51:29 +0800 | [diff] [blame] | 22 | |
Zhi Kun Liu | 38641c6 | 2014-07-10 20:12:48 +0800 | [diff] [blame] | 23 | class VolumesV2SnapshotNegativeTestJSON(base.BaseVolumeTest): |
wanghao | 1850c5f | 2013-10-08 11:51:29 +0800 | [diff] [blame] | 24 | |
JordanP | bce5553 | 2014-03-19 12:10:32 +0100 | [diff] [blame] | 25 | @classmethod |
Rohan Kanade | 0574915 | 2015-01-30 17:15:18 +0530 | [diff] [blame] | 26 | def skip_checks(cls): |
| 27 | super(VolumesV2SnapshotNegativeTestJSON, cls).skip_checks() |
JordanP | bce5553 | 2014-03-19 12:10:32 +0100 | [diff] [blame] | 28 | if not CONF.volume_feature_enabled.snapshot: |
| 29 | raise cls.skipException("Cinder volume snapshots are disabled") |
| 30 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 31 | @test.attr(type=['negative']) |
Ken'ichi Ohmichi | 6b279c7 | 2017-01-27 18:26:59 -0800 | [diff] [blame] | 32 | @decorators.idempotent_id('e3e466af-70ab-4f4b-a967-ab04e3532ea7') |
wanghao | 1850c5f | 2013-10-08 11:51:29 +0800 | [diff] [blame] | 33 | def test_create_snapshot_with_nonexistent_volume_id(self): |
| 34 | # Create a snapshot with nonexistent volume id |
zhufl | c6ce539 | 2016-08-17 14:34:37 +0800 | [diff] [blame] | 35 | s_name = data_utils.rand_name(self.__class__.__name__ + '-snap') |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 36 | self.assertRaises(lib_exc.NotFound, |
wanghao | 1850c5f | 2013-10-08 11:51:29 +0800 | [diff] [blame] | 37 | self.snapshots_client.create_snapshot, |
Ken'ichi Ohmichi | d079c89 | 2016-04-19 11:23:36 -0700 | [diff] [blame] | 38 | volume_id=data_utils.rand_uuid(), |
| 39 | display_name=s_name) |
wanghao | 1850c5f | 2013-10-08 11:51:29 +0800 | [diff] [blame] | 40 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 41 | @test.attr(type=['negative']) |
Ken'ichi Ohmichi | 6b279c7 | 2017-01-27 18:26:59 -0800 | [diff] [blame] | 42 | @decorators.idempotent_id('bb9da53e-d335-4309-9c15-7e76fd5e4d6d') |
wanghao | 1850c5f | 2013-10-08 11:51:29 +0800 | [diff] [blame] | 43 | def test_create_snapshot_without_passing_volume_id(self): |
| 44 | # Create a snapshot without passing volume id |
zhufl | c6ce539 | 2016-08-17 14:34:37 +0800 | [diff] [blame] | 45 | s_name = data_utils.rand_name(self.__class__.__name__ + '-snap') |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 46 | self.assertRaises(lib_exc.NotFound, |
wanghao | 1850c5f | 2013-10-08 11:51:29 +0800 | [diff] [blame] | 47 | self.snapshots_client.create_snapshot, |
Ghanshyam | 0b75b63 | 2015-12-11 15:08:28 +0900 | [diff] [blame] | 48 | volume_id=None, display_name=s_name) |
wanghao | 1850c5f | 2013-10-08 11:51:29 +0800 | [diff] [blame] | 49 | |
lkuchlan | 291a806 | 2017-02-19 13:21:48 +0200 | [diff] [blame] | 50 | @test.attr(type=['negative']) |
Ken'ichi Ohmichi | 6b279c7 | 2017-01-27 18:26:59 -0800 | [diff] [blame] | 51 | @decorators.idempotent_id('677863d1-34f9-456d-b6ac-9924f667a7f4') |
Erlon R. Cruz | 8dbbc29 | 2016-06-17 15:40:36 -0300 | [diff] [blame] | 52 | 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 | |
wanghao | 1850c5f | 2013-10-08 11:51:29 +0800 | [diff] [blame] | 65 | |
Zhi Kun Liu | 38641c6 | 2014-07-10 20:12:48 +0800 | [diff] [blame] | 66 | class VolumesV1SnapshotNegativeTestJSON(VolumesV2SnapshotNegativeTestJSON): |
| 67 | _api_version = 1 |