blob: 0a095a93e415e316ce77460efa39bcc8a21e7141 [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2012 OpenStack Foundation
Rohit Karajgidd47d7e2012-07-31 04:11:01 -07002# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
Sean Dague1937d092013-05-17 16:36:38 -040016from tempest.api.volume import base
Fei Long Wangd39431f2015-05-14 11:30:48 +120017from tempest.common.utils import data_utils
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080018from tempest.lib import decorators
Andrea Frittoli (andreaf)db9672e2016-02-23 14:07:24 -050019from tempest.lib import exceptions as lib_exc
Masayuki Igawa1edf94f2014-03-04 18:34:16 +090020from tempest import test
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070021
22
Zhi Kun Liu3d6d9862014-06-16 16:43:59 +080023class VolumesV2NegativeTest(base.BaseVolumeTest):
Attila Fazekas3dcdae12013-02-14 12:50:04 +010024
25 @classmethod
Andrea Frittoli61a12e22014-09-15 13:14:54 +010026 def resource_setup(cls):
27 super(VolumesV2NegativeTest, cls).resource_setup()
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070028
Zhi Kun Liu3d6d9862014-06-16 16:43:59 +080029 cls.name_field = cls.special_fields['name_field']
30
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +080031 # Create a test shared instance and volume for attach/detach tests
Ken'ichi Ohmichi5687d552013-12-26 19:00:12 +090032 cls.volume = cls.create_volume()
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +080033 cls.mountpoint = "/dev/vdc"
34
Sean Dague639f2fa2015-04-27 09:00:33 -040035 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080036 @decorators.idempotent_id('f131c586-9448-44a4-a8b0-54ca838aa43e')
nayna-patel179077c2014-01-15 12:27:16 +000037 def test_volume_get_nonexistent_volume_id(self):
38 # Should not be able to get a non-existent volume
lkuchlanb21fc572016-11-28 12:25:22 +020039 self.assertRaises(lib_exc.NotFound, self.volumes_client.show_volume,
Ken'ichi Ohmichid079c892016-04-19 11:23:36 -070040 data_utils.rand_uuid())
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070041
Sean Dague639f2fa2015-04-27 09:00:33 -040042 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080043 @decorators.idempotent_id('555efa6e-efcd-44ef-8a3b-4a7ca4837a29')
nayna-patel179077c2014-01-15 12:27:16 +000044 def test_volume_delete_nonexistent_volume_id(self):
45 # Should not be able to delete a non-existent Volume
lkuchlanb21fc572016-11-28 12:25:22 +020046 self.assertRaises(lib_exc.NotFound, self.volumes_client.delete_volume,
Ken'ichi Ohmichid079c892016-04-19 11:23:36 -070047 data_utils.rand_uuid())
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070048
Sean Dague639f2fa2015-04-27 09:00:33 -040049 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080050 @decorators.idempotent_id('1ed83a8a-682d-4dfb-a30e-ee63ffd6c049')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070051 def test_create_volume_with_invalid_size(self):
Sean Dague72a00382013-01-03 17:53:38 -050052 # Should not be able to create volume with invalid size
53 # in request
zhuflc6ce5392016-08-17 14:34:37 +080054 v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
lkuchlan92392842017-02-01 10:24:25 +020055 params = {self.name_field: v_name}
lkuchlanb21fc572016-11-28 12:25:22 +020056 self.assertRaises(lib_exc.BadRequest,
57 self.volumes_client.create_volume,
lkuchlan92392842017-02-01 10:24:25 +020058 size='#$%', params=params)
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070059
Sean Dague639f2fa2015-04-27 09:00:33 -040060 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080061 @decorators.idempotent_id('9387686f-334f-4d31-a439-33494b9e2683')
zhufle2fb43e2016-11-24 10:52:16 +080062 def test_create_volume_without_passing_size(self):
Sean Dague72a00382013-01-03 17:53:38 -050063 # Should not be able to create volume without passing size
64 # in request
zhuflc6ce5392016-08-17 14:34:37 +080065 v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
lkuchlan92392842017-02-01 10:24:25 +020066 params = {self.name_field: v_name}
lkuchlanb21fc572016-11-28 12:25:22 +020067 self.assertRaises(lib_exc.BadRequest,
68 self.volumes_client.create_volume,
lkuchlan92392842017-02-01 10:24:25 +020069 size='', params=params)
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070070
Sean Dague639f2fa2015-04-27 09:00:33 -040071 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080072 @decorators.idempotent_id('41331caa-eaf4-4001-869d-bc18c1869360')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070073 def test_create_volume_with_size_zero(self):
Sean Dague72a00382013-01-03 17:53:38 -050074 # Should not be able to create volume with size zero
zhuflc6ce5392016-08-17 14:34:37 +080075 v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
lkuchlan92392842017-02-01 10:24:25 +020076 params = {self.name_field: v_name}
lkuchlanb21fc572016-11-28 12:25:22 +020077 self.assertRaises(lib_exc.BadRequest,
78 self.volumes_client.create_volume,
lkuchlan92392842017-02-01 10:24:25 +020079 size='0', params=params)
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070080
Sean Dague639f2fa2015-04-27 09:00:33 -040081 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080082 @decorators.idempotent_id('8b472729-9eba-446e-a83b-916bdb34bef7')
wanghaoc2abb6c2013-09-29 19:14:09 +080083 def test_create_volume_with_size_negative(self):
84 # Should not be able to create volume with size negative
zhuflc6ce5392016-08-17 14:34:37 +080085 v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
lkuchlan92392842017-02-01 10:24:25 +020086 params = {self.name_field: v_name}
lkuchlanb21fc572016-11-28 12:25:22 +020087 self.assertRaises(lib_exc.BadRequest,
88 self.volumes_client.create_volume,
lkuchlan92392842017-02-01 10:24:25 +020089 size='-1', params=params)
wanghaoc2abb6c2013-09-29 19:14:09 +080090
Sean Dague639f2fa2015-04-27 09:00:33 -040091 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080092 @decorators.idempotent_id('10254ed8-3849-454e-862e-3ab8e6aa01d2')
nayna-patel179077c2014-01-15 12:27:16 +000093 def test_create_volume_with_nonexistent_volume_type(self):
94 # Should not be able to create volume with non-existent volume type
zhuflc6ce5392016-08-17 14:34:37 +080095 v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
lkuchlan92392842017-02-01 10:24:25 +020096 params = {self.name_field: v_name}
lkuchlanb21fc572016-11-28 12:25:22 +020097 self.assertRaises(lib_exc.NotFound, self.volumes_client.create_volume,
Ken'ichi Ohmichid079c892016-04-19 11:23:36 -070098 size='1', volume_type=data_utils.rand_uuid(),
lkuchlan92392842017-02-01 10:24:25 +020099 params=params)
zhangyanzib866f052013-10-12 11:41:32 +0800100
Sean Dague639f2fa2015-04-27 09:00:33 -0400101 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800102 @decorators.idempotent_id('0c36f6ae-4604-4017-b0a9-34fdc63096f9')
nayna-patel179077c2014-01-15 12:27:16 +0000103 def test_create_volume_with_nonexistent_snapshot_id(self):
104 # Should not be able to create volume with non-existent snapshot
zhuflc6ce5392016-08-17 14:34:37 +0800105 v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
lkuchlan92392842017-02-01 10:24:25 +0200106 params = {self.name_field: v_name}
lkuchlanb21fc572016-11-28 12:25:22 +0200107 self.assertRaises(lib_exc.NotFound, self.volumes_client.create_volume,
Ken'ichi Ohmichid079c892016-04-19 11:23:36 -0700108 size='1', snapshot_id=data_utils.rand_uuid(),
lkuchlan92392842017-02-01 10:24:25 +0200109 params=params)
zhangyanzib866f052013-10-12 11:41:32 +0800110
Sean Dague639f2fa2015-04-27 09:00:33 -0400111 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800112 @decorators.idempotent_id('47c73e08-4be8-45bb-bfdf-0c4e79b88344')
nayna-patel179077c2014-01-15 12:27:16 +0000113 def test_create_volume_with_nonexistent_source_volid(self):
114 # Should not be able to create volume with non-existent source volume
zhuflc6ce5392016-08-17 14:34:37 +0800115 v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
lkuchlan92392842017-02-01 10:24:25 +0200116 params = {self.name_field: v_name}
lkuchlanb21fc572016-11-28 12:25:22 +0200117 self.assertRaises(lib_exc.NotFound, self.volumes_client.create_volume,
Ken'ichi Ohmichid079c892016-04-19 11:23:36 -0700118 size='1', source_volid=data_utils.rand_uuid(),
lkuchlan92392842017-02-01 10:24:25 +0200119 params=params)
zhangyanzib866f052013-10-12 11:41:32 +0800120
Sean Dague639f2fa2015-04-27 09:00:33 -0400121 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800122 @decorators.idempotent_id('0186422c-999a-480e-a026-6a665744c30c')
nayna-patel179077c2014-01-15 12:27:16 +0000123 def test_update_volume_with_nonexistent_volume_id(self):
zhuflc6ce5392016-08-17 14:34:37 +0800124 v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
lkuchlan92392842017-02-01 10:24:25 +0200125 params = {self.name_field: v_name}
lkuchlanb21fc572016-11-28 12:25:22 +0200126 self.assertRaises(lib_exc.NotFound, self.volumes_client.update_volume,
lkuchlan92392842017-02-01 10:24:25 +0200127 volume_id=data_utils.rand_uuid(), params=params)
wanghaoc2abb6c2013-09-29 19:14:09 +0800128
Sean Dague639f2fa2015-04-27 09:00:33 -0400129 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800130 @decorators.idempotent_id('e66e40d6-65e6-4e75-bdc7-636792fa152d')
wanghaoc2abb6c2013-09-29 19:14:09 +0800131 def test_update_volume_with_invalid_volume_id(self):
zhuflc6ce5392016-08-17 14:34:37 +0800132 v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
lkuchlan92392842017-02-01 10:24:25 +0200133 params = {self.name_field: v_name}
lkuchlanb21fc572016-11-28 12:25:22 +0200134 self.assertRaises(lib_exc.NotFound, self.volumes_client.update_volume,
ghanshyam9e294c42017-01-12 06:52:41 +0000135 volume_id=data_utils.rand_name('invalid'),
lkuchlan92392842017-02-01 10:24:25 +0200136 params=params)
wanghaoc2abb6c2013-09-29 19:14:09 +0800137
Sean Dague639f2fa2015-04-27 09:00:33 -0400138 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800139 @decorators.idempotent_id('72aeca85-57a5-4c1f-9057-f320f9ea575b')
wanghaoc2abb6c2013-09-29 19:14:09 +0800140 def test_update_volume_with_empty_volume_id(self):
zhuflc6ce5392016-08-17 14:34:37 +0800141 v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
lkuchlan92392842017-02-01 10:24:25 +0200142 params = {self.name_field: v_name}
lkuchlanb21fc572016-11-28 12:25:22 +0200143 self.assertRaises(lib_exc.NotFound, self.volumes_client.update_volume,
lkuchlan92392842017-02-01 10:24:25 +0200144 volume_id='', params=params)
wanghaoc2abb6c2013-09-29 19:14:09 +0800145
Sean Dague639f2fa2015-04-27 09:00:33 -0400146 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800147 @decorators.idempotent_id('30799cfd-7ee4-446c-b66c-45b383ed211b')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700148 def test_get_invalid_volume_id(self):
Sean Dague72a00382013-01-03 17:53:38 -0500149 # Should not be able to get volume with invalid id
lkuchlanb21fc572016-11-28 12:25:22 +0200150 self.assertRaises(lib_exc.NotFound, self.volumes_client.show_volume,
ghanshyam9e294c42017-01-12 06:52:41 +0000151 data_utils.rand_name('invalid'))
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700152
Sean Dague639f2fa2015-04-27 09:00:33 -0400153 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800154 @decorators.idempotent_id('c6c3db06-29ad-4e91-beb0-2ab195fe49e3')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700155 def test_get_volume_without_passing_volume_id(self):
Sean Dague72a00382013-01-03 17:53:38 -0500156 # Should not be able to get volume when empty ID is passed
lkuchlanb21fc572016-11-28 12:25:22 +0200157 self.assertRaises(lib_exc.NotFound,
158 self.volumes_client.show_volume, '')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700159
Sean Dague639f2fa2015-04-27 09:00:33 -0400160 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800161 @decorators.idempotent_id('1f035827-7c32-4019-9240-b4ec2dbd9dfd')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700162 def test_delete_invalid_volume_id(self):
Sean Dague72a00382013-01-03 17:53:38 -0500163 # Should not be able to delete volume when invalid ID is passed
lkuchlanb21fc572016-11-28 12:25:22 +0200164 self.assertRaises(lib_exc.NotFound, self.volumes_client.delete_volume,
ghanshyam9e294c42017-01-12 06:52:41 +0000165 data_utils.rand_name('invalid'))
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700166
Sean Dague639f2fa2015-04-27 09:00:33 -0400167 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800168 @decorators.idempotent_id('441a1550-5d44-4b30-af0f-a6d402f52026')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700169 def test_delete_volume_without_passing_volume_id(self):
Sean Dague72a00382013-01-03 17:53:38 -0500170 # Should not be able to delete volume when empty ID is passed
lkuchlanb21fc572016-11-28 12:25:22 +0200171 self.assertRaises(lib_exc.NotFound,
172 self.volumes_client.delete_volume, '')
Matthew Treinish9854d5b2012-09-20 10:22:13 -0400173
Sean Dague639f2fa2015-04-27 09:00:33 -0400174 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800175 @decorators.idempotent_id('f5e56b0a-5d02-43c1-a2a7-c9b792c2e3f6')
Matthew Treinish7ea69e62014-06-03 17:23:50 -0400176 @test.services('compute')
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +0800177 def test_attach_volumes_with_nonexistent_volume_id(self):
zhufl7867a6e2016-10-18 15:37:12 +0800178 server = self.create_server(wait_until='ACTIVE')
Joseph Lanouxa074c012015-08-04 15:44:07 +0000179
Masayuki Igawabfa07602015-01-20 18:47:17 +0900180 self.assertRaises(lib_exc.NotFound,
lkuchlanb21fc572016-11-28 12:25:22 +0200181 self.volumes_client.attach_volume,
Ken'ichi Ohmichid079c892016-04-19 11:23:36 -0700182 data_utils.rand_uuid(),
Ghanshyam8fc0ed22015-12-18 10:25:14 +0900183 instance_uuid=server['id'],
184 mountpoint=self.mountpoint)
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +0800185
Sean Dague639f2fa2015-04-27 09:00:33 -0400186 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800187 @decorators.idempotent_id('9f9c24e4-011d-46b5-b992-952140ce237a')
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +0800188 def test_detach_volumes_with_invalid_volume_id(self):
Masayuki Igawabfa07602015-01-20 18:47:17 +0900189 self.assertRaises(lib_exc.NotFound,
lkuchlanb21fc572016-11-28 12:25:22 +0200190 self.volumes_client.detach_volume,
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +0800191 'xxx')
192
Sean Dague639f2fa2015-04-27 09:00:33 -0400193 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800194 @decorators.idempotent_id('e0c75c74-ee34-41a9-9288-2a2051452854')
wanghao5b981752013-10-22 11:41:41 +0800195 def test_volume_extend_with_size_smaller_than_original_size(self):
196 # Extend volume with smaller size than original size.
197 extend_size = 0
lkuchlanb21fc572016-11-28 12:25:22 +0200198 self.assertRaises(lib_exc.BadRequest,
199 self.volumes_client.extend_volume,
Ghanshyam58a9e872015-12-18 10:46:07 +0900200 self.volume['id'], new_size=extend_size)
wanghao5b981752013-10-22 11:41:41 +0800201
Sean Dague639f2fa2015-04-27 09:00:33 -0400202 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800203 @decorators.idempotent_id('5d0b480d-e833-439f-8a5a-96ad2ed6f22f')
wanghao5b981752013-10-22 11:41:41 +0800204 def test_volume_extend_with_non_number_size(self):
205 # Extend volume when size is non number.
206 extend_size = 'abc'
lkuchlanb21fc572016-11-28 12:25:22 +0200207 self.assertRaises(lib_exc.BadRequest,
208 self.volumes_client.extend_volume,
Ghanshyam58a9e872015-12-18 10:46:07 +0900209 self.volume['id'], new_size=extend_size)
wanghao5b981752013-10-22 11:41:41 +0800210
Sean Dague639f2fa2015-04-27 09:00:33 -0400211 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800212 @decorators.idempotent_id('355218f1-8991-400a-a6bb-971239287d92')
wanghao5b981752013-10-22 11:41:41 +0800213 def test_volume_extend_with_None_size(self):
214 # Extend volume with None size.
215 extend_size = None
lkuchlanb21fc572016-11-28 12:25:22 +0200216 self.assertRaises(lib_exc.BadRequest,
217 self.volumes_client.extend_volume,
Ghanshyam58a9e872015-12-18 10:46:07 +0900218 self.volume['id'], new_size=extend_size)
wanghao5b981752013-10-22 11:41:41 +0800219
Sean Dague639f2fa2015-04-27 09:00:33 -0400220 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800221 @decorators.idempotent_id('8f05a943-013c-4063-ac71-7baf561e82eb')
wanghao5b981752013-10-22 11:41:41 +0800222 def test_volume_extend_with_nonexistent_volume_id(self):
223 # Extend volume size when volume is nonexistent.
224 extend_size = int(self.volume['size']) + 1
lkuchlanb21fc572016-11-28 12:25:22 +0200225 self.assertRaises(lib_exc.NotFound, self.volumes_client.extend_volume,
Ken'ichi Ohmichid079c892016-04-19 11:23:36 -0700226 data_utils.rand_uuid(), new_size=extend_size)
wanghao5b981752013-10-22 11:41:41 +0800227
Sean Dague639f2fa2015-04-27 09:00:33 -0400228 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800229 @decorators.idempotent_id('aff8ba64-6d6f-4f2e-bc33-41a08ee9f115')
wanghao5b981752013-10-22 11:41:41 +0800230 def test_volume_extend_without_passing_volume_id(self):
231 # Extend volume size when passing volume id is None.
232 extend_size = int(self.volume['size']) + 1
lkuchlanb21fc572016-11-28 12:25:22 +0200233 self.assertRaises(lib_exc.NotFound, self.volumes_client.extend_volume,
Ghanshyam58a9e872015-12-18 10:46:07 +0900234 None, new_size=extend_size)
wanghao5b981752013-10-22 11:41:41 +0800235
Sean Dague639f2fa2015-04-27 09:00:33 -0400236 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800237 @decorators.idempotent_id('ac6084c0-0546-45f9-b284-38a367e0e0e2')
zhangyanzi6b632432013-10-24 19:08:50 +0800238 def test_reserve_volume_with_nonexistent_volume_id(self):
Masayuki Igawabfa07602015-01-20 18:47:17 +0900239 self.assertRaises(lib_exc.NotFound,
lkuchlanb21fc572016-11-28 12:25:22 +0200240 self.volumes_client.reserve_volume,
Ken'ichi Ohmichid079c892016-04-19 11:23:36 -0700241 data_utils.rand_uuid())
zhangyanzi6b632432013-10-24 19:08:50 +0800242
Sean Dague639f2fa2015-04-27 09:00:33 -0400243 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800244 @decorators.idempotent_id('eb467654-3dc1-4a72-9b46-47c29d22654c')
zhangyanzi6b632432013-10-24 19:08:50 +0800245 def test_unreserve_volume_with_nonexistent_volume_id(self):
Masayuki Igawabfa07602015-01-20 18:47:17 +0900246 self.assertRaises(lib_exc.NotFound,
lkuchlanb21fc572016-11-28 12:25:22 +0200247 self.volumes_client.unreserve_volume,
Ken'ichi Ohmichid079c892016-04-19 11:23:36 -0700248 data_utils.rand_uuid())
zhangyanzi6b632432013-10-24 19:08:50 +0800249
Sean Dague639f2fa2015-04-27 09:00:33 -0400250 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800251 @decorators.idempotent_id('449c4ed2-ecdd-47bb-98dc-072aeccf158c')
zhangyanzi6b632432013-10-24 19:08:50 +0800252 def test_reserve_volume_with_negative_volume_status(self):
253 # Mark volume as reserved.
lkuchlanb21fc572016-11-28 12:25:22 +0200254 self.volumes_client.reserve_volume(self.volume['id'])
zhangyanzi6b632432013-10-24 19:08:50 +0800255 # Mark volume which is marked as reserved before
Masayuki Igawa4b29e472015-02-16 10:41:54 +0900256 self.assertRaises(lib_exc.BadRequest,
lkuchlanb21fc572016-11-28 12:25:22 +0200257 self.volumes_client.reserve_volume,
zhangyanzi6b632432013-10-24 19:08:50 +0800258 self.volume['id'])
259 # Unmark volume as reserved.
lkuchlanb21fc572016-11-28 12:25:22 +0200260 self.volumes_client.unreserve_volume(self.volume['id'])
zhangyanzi6b632432013-10-24 19:08:50 +0800261
Sean Dague639f2fa2015-04-27 09:00:33 -0400262 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800263 @decorators.idempotent_id('0f4aa809-8c7b-418f-8fb3-84c7a5dfc52f')
Zhi Kun Liu42403182013-10-11 18:05:08 +0800264 def test_list_volumes_with_nonexistent_name(self):
zhuflc6ce5392016-08-17 14:34:37 +0800265 v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
Zhi Kun Liu3d6d9862014-06-16 16:43:59 +0800266 params = {self.name_field: v_name}
lkuchlanb21fc572016-11-28 12:25:22 +0200267 fetched_volume = self.volumes_client.list_volumes(
268 params=params)['volumes']
Zhi Kun Liu42403182013-10-11 18:05:08 +0800269 self.assertEqual(0, len(fetched_volume))
270
Sean Dague639f2fa2015-04-27 09:00:33 -0400271 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800272 @decorators.idempotent_id('9ca17820-a0e7-4cbd-a7fa-f4468735e359')
Zhi Kun Liu42403182013-10-11 18:05:08 +0800273 def test_list_volumes_detail_with_nonexistent_name(self):
zhuflc6ce5392016-08-17 14:34:37 +0800274 v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
Zhi Kun Liu3d6d9862014-06-16 16:43:59 +0800275 params = {self.name_field: v_name}
Joseph Lanoux6809bab2014-12-18 14:57:18 +0000276 fetched_volume = \
lkuchlanb21fc572016-11-28 12:25:22 +0200277 self.volumes_client.list_volumes(
278 detail=True, params=params)['volumes']
Zhi Kun Liu42403182013-10-11 18:05:08 +0800279 self.assertEqual(0, len(fetched_volume))
280
Sean Dague639f2fa2015-04-27 09:00:33 -0400281 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800282 @decorators.idempotent_id('143b279b-7522-466b-81be-34a87d564a7c')
Zhi Kun Liu42403182013-10-11 18:05:08 +0800283 def test_list_volumes_with_invalid_status(self):
284 params = {'status': 'null'}
lkuchlanb21fc572016-11-28 12:25:22 +0200285 fetched_volume = self.volumes_client.list_volumes(
286 params=params)['volumes']
Zhi Kun Liu42403182013-10-11 18:05:08 +0800287 self.assertEqual(0, len(fetched_volume))
288
Sean Dague639f2fa2015-04-27 09:00:33 -0400289 @test.attr(type=['negative'])
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -0800290 @decorators.idempotent_id('ba94b27b-be3f-496c-a00e-0283b373fa75')
Zhi Kun Liu42403182013-10-11 18:05:08 +0800291 def test_list_volumes_detail_with_invalid_status(self):
292 params = {'status': 'null'}
Joseph Lanoux6809bab2014-12-18 14:57:18 +0000293 fetched_volume = \
lkuchlanb21fc572016-11-28 12:25:22 +0200294 self.volumes_client.list_volumes(detail=True,
295 params=params)['volumes']
Zhi Kun Liu42403182013-10-11 18:05:08 +0800296 self.assertEqual(0, len(fetched_volume))
297
Matthew Treinish9854d5b2012-09-20 10:22:13 -0400298
Zhi Kun Liu3d6d9862014-06-16 16:43:59 +0800299class VolumesV1NegativeTest(VolumesV2NegativeTest):
300 _api_version = 1