blob: af6e24e1b77e158829cd1d5784124a2b7ce36923 [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
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +080016import uuid
17
Matthew Treinish01472ff2015-02-20 17:26:52 -050018from tempest_lib.common.utils import data_utils
Masayuki Igawabfa07602015-01-20 18:47:17 +090019from tempest_lib import exceptions as lib_exc
20
Sean Dague1937d092013-05-17 16:36:38 -040021from tempest.api.volume import base
Masayuki Igawa1edf94f2014-03-04 18:34:16 +090022from tempest import test
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070023
24
Zhi Kun Liu3d6d9862014-06-16 16:43:59 +080025class VolumesV2NegativeTest(base.BaseVolumeTest):
Attila Fazekas3dcdae12013-02-14 12:50:04 +010026
27 @classmethod
Rohan Kanade05749152015-01-30 17:15:18 +053028 def setup_clients(cls):
29 super(VolumesV2NegativeTest, cls).setup_clients()
30 cls.client = cls.volumes_client
31
32 @classmethod
Andrea Frittoli61a12e22014-09-15 13:14:54 +010033 def resource_setup(cls):
34 super(VolumesV2NegativeTest, cls).resource_setup()
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070035
Zhi Kun Liu3d6d9862014-06-16 16:43:59 +080036 cls.name_field = cls.special_fields['name_field']
37
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +080038 # Create a test shared instance and volume for attach/detach tests
Ken'ichi Ohmichi5687d552013-12-26 19:00:12 +090039 cls.volume = cls.create_volume()
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +080040 cls.mountpoint = "/dev/vdc"
41
Masayuki Igawa1edf94f2014-03-04 18:34:16 +090042 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080043 @test.idempotent_id('f131c586-9448-44a4-a8b0-54ca838aa43e')
nayna-patel179077c2014-01-15 12:27:16 +000044 def test_volume_get_nonexistent_volume_id(self):
45 # Should not be able to get a non-existent volume
Masayuki Igawabfa07602015-01-20 18:47:17 +090046 self.assertRaises(lib_exc.NotFound, self.client.get_volume,
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +080047 str(uuid.uuid4()))
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070048
Masayuki Igawa1edf94f2014-03-04 18:34:16 +090049 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080050 @test.idempotent_id('555efa6e-efcd-44ef-8a3b-4a7ca4837a29')
nayna-patel179077c2014-01-15 12:27:16 +000051 def test_volume_delete_nonexistent_volume_id(self):
52 # Should not be able to delete a non-existent Volume
Masayuki Igawabfa07602015-01-20 18:47:17 +090053 self.assertRaises(lib_exc.NotFound, self.client.delete_volume,
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +080054 str(uuid.uuid4()))
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070055
Masayuki Igawa1edf94f2014-03-04 18:34:16 +090056 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080057 @test.idempotent_id('1ed83a8a-682d-4dfb-a30e-ee63ffd6c049')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070058 def test_create_volume_with_invalid_size(self):
Sean Dague72a00382013-01-03 17:53:38 -050059 # Should not be able to create volume with invalid size
60 # in request
Ken'ichi Ohmichi07308f12015-03-23 00:24:28 +000061 v_name = data_utils.rand_name('Volume')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070062 metadata = {'Type': 'work'}
Masayuki Igawa4b29e472015-02-16 10:41:54 +090063 self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103064 size='#$%', display_name=v_name, metadata=metadata)
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070065
Masayuki Igawa1edf94f2014-03-04 18:34:16 +090066 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080067 @test.idempotent_id('9387686f-334f-4d31-a439-33494b9e2683')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070068 def test_create_volume_with_out_passing_size(self):
Sean Dague72a00382013-01-03 17:53:38 -050069 # Should not be able to create volume without passing size
70 # in request
Ken'ichi Ohmichi07308f12015-03-23 00:24:28 +000071 v_name = data_utils.rand_name('Volume')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070072 metadata = {'Type': 'work'}
Masayuki Igawa4b29e472015-02-16 10:41:54 +090073 self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103074 size='', display_name=v_name, metadata=metadata)
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070075
Masayuki Igawa1edf94f2014-03-04 18:34:16 +090076 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080077 @test.idempotent_id('41331caa-eaf4-4001-869d-bc18c1869360')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070078 def test_create_volume_with_size_zero(self):
Sean Dague72a00382013-01-03 17:53:38 -050079 # Should not be able to create volume with size zero
Ken'ichi Ohmichi07308f12015-03-23 00:24:28 +000080 v_name = data_utils.rand_name('Volume')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070081 metadata = {'Type': 'work'}
Masayuki Igawa4b29e472015-02-16 10:41:54 +090082 self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103083 size='0', display_name=v_name, metadata=metadata)
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070084
Masayuki Igawa1edf94f2014-03-04 18:34:16 +090085 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080086 @test.idempotent_id('8b472729-9eba-446e-a83b-916bdb34bef7')
wanghaoc2abb6c2013-09-29 19:14:09 +080087 def test_create_volume_with_size_negative(self):
88 # Should not be able to create volume with size negative
Ken'ichi Ohmichi07308f12015-03-23 00:24:28 +000089 v_name = data_utils.rand_name('Volume')
wanghaoc2abb6c2013-09-29 19:14:09 +080090 metadata = {'Type': 'work'}
Masayuki Igawa4b29e472015-02-16 10:41:54 +090091 self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
wanghaoc2abb6c2013-09-29 19:14:09 +080092 size='-1', display_name=v_name, metadata=metadata)
93
Masayuki Igawa1edf94f2014-03-04 18:34:16 +090094 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080095 @test.idempotent_id('10254ed8-3849-454e-862e-3ab8e6aa01d2')
nayna-patel179077c2014-01-15 12:27:16 +000096 def test_create_volume_with_nonexistent_volume_type(self):
97 # Should not be able to create volume with non-existent volume type
Ken'ichi Ohmichi07308f12015-03-23 00:24:28 +000098 v_name = data_utils.rand_name('Volume')
zhangyanzib866f052013-10-12 11:41:32 +080099 metadata = {'Type': 'work'}
Masayuki Igawabfa07602015-01-20 18:47:17 +0900100 self.assertRaises(lib_exc.NotFound, self.client.create_volume,
zhangyanzib866f052013-10-12 11:41:32 +0800101 size='1', volume_type=str(uuid.uuid4()),
102 display_name=v_name, metadata=metadata)
103
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900104 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800105 @test.idempotent_id('0c36f6ae-4604-4017-b0a9-34fdc63096f9')
nayna-patel179077c2014-01-15 12:27:16 +0000106 def test_create_volume_with_nonexistent_snapshot_id(self):
107 # Should not be able to create volume with non-existent snapshot
Ken'ichi Ohmichi07308f12015-03-23 00:24:28 +0000108 v_name = data_utils.rand_name('Volume')
zhangyanzib866f052013-10-12 11:41:32 +0800109 metadata = {'Type': 'work'}
Masayuki Igawabfa07602015-01-20 18:47:17 +0900110 self.assertRaises(lib_exc.NotFound, self.client.create_volume,
zhangyanzib866f052013-10-12 11:41:32 +0800111 size='1', snapshot_id=str(uuid.uuid4()),
112 display_name=v_name, metadata=metadata)
113
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900114 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800115 @test.idempotent_id('47c73e08-4be8-45bb-bfdf-0c4e79b88344')
nayna-patel179077c2014-01-15 12:27:16 +0000116 def test_create_volume_with_nonexistent_source_volid(self):
117 # Should not be able to create volume with non-existent source volume
Ken'ichi Ohmichi07308f12015-03-23 00:24:28 +0000118 v_name = data_utils.rand_name('Volume')
zhangyanzib866f052013-10-12 11:41:32 +0800119 metadata = {'Type': 'work'}
Masayuki Igawabfa07602015-01-20 18:47:17 +0900120 self.assertRaises(lib_exc.NotFound, self.client.create_volume,
zhangyanzib866f052013-10-12 11:41:32 +0800121 size='1', source_volid=str(uuid.uuid4()),
122 display_name=v_name, metadata=metadata)
123
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900124 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800125 @test.idempotent_id('0186422c-999a-480e-a026-6a665744c30c')
nayna-patel179077c2014-01-15 12:27:16 +0000126 def test_update_volume_with_nonexistent_volume_id(self):
Ken'ichi Ohmichi07308f12015-03-23 00:24:28 +0000127 v_name = data_utils.rand_name('Volume')
wanghaoc2abb6c2013-09-29 19:14:09 +0800128 metadata = {'Type': 'work'}
Masayuki Igawabfa07602015-01-20 18:47:17 +0900129 self.assertRaises(lib_exc.NotFound, self.client.update_volume,
wanghaoc2abb6c2013-09-29 19:14:09 +0800130 volume_id=str(uuid.uuid4()), display_name=v_name,
131 metadata=metadata)
132
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900133 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800134 @test.idempotent_id('e66e40d6-65e6-4e75-bdc7-636792fa152d')
wanghaoc2abb6c2013-09-29 19:14:09 +0800135 def test_update_volume_with_invalid_volume_id(self):
Ken'ichi Ohmichi07308f12015-03-23 00:24:28 +0000136 v_name = data_utils.rand_name('Volume')
wanghaoc2abb6c2013-09-29 19:14:09 +0800137 metadata = {'Type': 'work'}
Masayuki Igawabfa07602015-01-20 18:47:17 +0900138 self.assertRaises(lib_exc.NotFound, self.client.update_volume,
wanghaoc2abb6c2013-09-29 19:14:09 +0800139 volume_id='#$%%&^&^', display_name=v_name,
140 metadata=metadata)
141
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900142 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800143 @test.idempotent_id('72aeca85-57a5-4c1f-9057-f320f9ea575b')
wanghaoc2abb6c2013-09-29 19:14:09 +0800144 def test_update_volume_with_empty_volume_id(self):
Ken'ichi Ohmichi07308f12015-03-23 00:24:28 +0000145 v_name = data_utils.rand_name('Volume')
wanghaoc2abb6c2013-09-29 19:14:09 +0800146 metadata = {'Type': 'work'}
Masayuki Igawabfa07602015-01-20 18:47:17 +0900147 self.assertRaises(lib_exc.NotFound, self.client.update_volume,
wanghaoc2abb6c2013-09-29 19:14:09 +0800148 volume_id='', display_name=v_name,
149 metadata=metadata)
150
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900151 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800152 @test.idempotent_id('30799cfd-7ee4-446c-b66c-45b383ed211b')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700153 def test_get_invalid_volume_id(self):
Sean Dague72a00382013-01-03 17:53:38 -0500154 # Should not be able to get volume with invalid id
Masayuki Igawabfa07602015-01-20 18:47:17 +0900155 self.assertRaises(lib_exc.NotFound, self.client.get_volume,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +1030156 '#$%%&^&^')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700157
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900158 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800159 @test.idempotent_id('c6c3db06-29ad-4e91-beb0-2ab195fe49e3')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700160 def test_get_volume_without_passing_volume_id(self):
Sean Dague72a00382013-01-03 17:53:38 -0500161 # Should not be able to get volume when empty ID is passed
Masayuki Igawabfa07602015-01-20 18:47:17 +0900162 self.assertRaises(lib_exc.NotFound, self.client.get_volume, '')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700163
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900164 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800165 @test.idempotent_id('1f035827-7c32-4019-9240-b4ec2dbd9dfd')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700166 def test_delete_invalid_volume_id(self):
Sean Dague72a00382013-01-03 17:53:38 -0500167 # Should not be able to delete volume when invalid ID is passed
Masayuki Igawabfa07602015-01-20 18:47:17 +0900168 self.assertRaises(lib_exc.NotFound, self.client.delete_volume,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +1030169 '!@#$%^&*()')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700170
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900171 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800172 @test.idempotent_id('441a1550-5d44-4b30-af0f-a6d402f52026')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700173 def test_delete_volume_without_passing_volume_id(self):
Sean Dague72a00382013-01-03 17:53:38 -0500174 # Should not be able to delete volume when empty ID is passed
Masayuki Igawabfa07602015-01-20 18:47:17 +0900175 self.assertRaises(lib_exc.NotFound, self.client.delete_volume, '')
Matthew Treinish9854d5b2012-09-20 10:22:13 -0400176
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900177 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800178 @test.idempotent_id('f5e56b0a-5d02-43c1-a2a7-c9b792c2e3f6')
Matthew Treinish7ea69e62014-06-03 17:23:50 -0400179 @test.services('compute')
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +0800180 def test_attach_volumes_with_nonexistent_volume_id(self):
Ken'ichi Ohmichi07308f12015-03-23 00:24:28 +0000181 srv_name = data_utils.rand_name('Instance')
David Kranz0fb14292015-02-11 15:55:20 -0500182 server = self.servers_client.create_server(srv_name,
183 self.image_ref,
184 self.flavor_ref)
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +0800185 self.addCleanup(self.servers_client.delete_server, server['id'])
186 self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
Masayuki Igawabfa07602015-01-20 18:47:17 +0900187 self.assertRaises(lib_exc.NotFound,
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +0800188 self.client.attach_volume,
189 str(uuid.uuid4()),
190 server['id'],
191 self.mountpoint)
192
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900193 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800194 @test.idempotent_id('9f9c24e4-011d-46b5-b992-952140ce237a')
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +0800195 def test_detach_volumes_with_invalid_volume_id(self):
Masayuki Igawabfa07602015-01-20 18:47:17 +0900196 self.assertRaises(lib_exc.NotFound,
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +0800197 self.client.detach_volume,
198 'xxx')
199
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900200 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800201 @test.idempotent_id('e0c75c74-ee34-41a9-9288-2a2051452854')
wanghao5b981752013-10-22 11:41:41 +0800202 def test_volume_extend_with_size_smaller_than_original_size(self):
203 # Extend volume with smaller size than original size.
204 extend_size = 0
Masayuki Igawa4b29e472015-02-16 10:41:54 +0900205 self.assertRaises(lib_exc.BadRequest, self.client.extend_volume,
wanghao5b981752013-10-22 11:41:41 +0800206 self.volume['id'], extend_size)
207
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900208 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800209 @test.idempotent_id('5d0b480d-e833-439f-8a5a-96ad2ed6f22f')
wanghao5b981752013-10-22 11:41:41 +0800210 def test_volume_extend_with_non_number_size(self):
211 # Extend volume when size is non number.
212 extend_size = 'abc'
Masayuki Igawa4b29e472015-02-16 10:41:54 +0900213 self.assertRaises(lib_exc.BadRequest, self.client.extend_volume,
wanghao5b981752013-10-22 11:41:41 +0800214 self.volume['id'], extend_size)
215
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900216 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800217 @test.idempotent_id('355218f1-8991-400a-a6bb-971239287d92')
wanghao5b981752013-10-22 11:41:41 +0800218 def test_volume_extend_with_None_size(self):
219 # Extend volume with None size.
220 extend_size = None
Masayuki Igawa4b29e472015-02-16 10:41:54 +0900221 self.assertRaises(lib_exc.BadRequest, self.client.extend_volume,
wanghao5b981752013-10-22 11:41:41 +0800222 self.volume['id'], extend_size)
223
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900224 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800225 @test.idempotent_id('8f05a943-013c-4063-ac71-7baf561e82eb')
wanghao5b981752013-10-22 11:41:41 +0800226 def test_volume_extend_with_nonexistent_volume_id(self):
227 # Extend volume size when volume is nonexistent.
228 extend_size = int(self.volume['size']) + 1
Masayuki Igawabfa07602015-01-20 18:47:17 +0900229 self.assertRaises(lib_exc.NotFound, self.client.extend_volume,
wanghao5b981752013-10-22 11:41:41 +0800230 str(uuid.uuid4()), extend_size)
231
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900232 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800233 @test.idempotent_id('aff8ba64-6d6f-4f2e-bc33-41a08ee9f115')
wanghao5b981752013-10-22 11:41:41 +0800234 def test_volume_extend_without_passing_volume_id(self):
235 # Extend volume size when passing volume id is None.
236 extend_size = int(self.volume['size']) + 1
Masayuki Igawabfa07602015-01-20 18:47:17 +0900237 self.assertRaises(lib_exc.NotFound, self.client.extend_volume,
wanghao5b981752013-10-22 11:41:41 +0800238 None, extend_size)
239
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900240 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800241 @test.idempotent_id('ac6084c0-0546-45f9-b284-38a367e0e0e2')
zhangyanzi6b632432013-10-24 19:08:50 +0800242 def test_reserve_volume_with_nonexistent_volume_id(self):
Masayuki Igawabfa07602015-01-20 18:47:17 +0900243 self.assertRaises(lib_exc.NotFound,
zhangyanzi6b632432013-10-24 19:08:50 +0800244 self.client.reserve_volume,
245 str(uuid.uuid4()))
246
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900247 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800248 @test.idempotent_id('eb467654-3dc1-4a72-9b46-47c29d22654c')
zhangyanzi6b632432013-10-24 19:08:50 +0800249 def test_unreserve_volume_with_nonexistent_volume_id(self):
Masayuki Igawabfa07602015-01-20 18:47:17 +0900250 self.assertRaises(lib_exc.NotFound,
zhangyanzi6b632432013-10-24 19:08:50 +0800251 self.client.unreserve_volume,
252 str(uuid.uuid4()))
253
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900254 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800255 @test.idempotent_id('449c4ed2-ecdd-47bb-98dc-072aeccf158c')
zhangyanzi6b632432013-10-24 19:08:50 +0800256 def test_reserve_volume_with_negative_volume_status(self):
257 # Mark volume as reserved.
Joseph Lanoux6809bab2014-12-18 14:57:18 +0000258 self.client.reserve_volume(self.volume['id'])
zhangyanzi6b632432013-10-24 19:08:50 +0800259 # Mark volume which is marked as reserved before
Masayuki Igawa4b29e472015-02-16 10:41:54 +0900260 self.assertRaises(lib_exc.BadRequest,
zhangyanzi6b632432013-10-24 19:08:50 +0800261 self.client.reserve_volume,
262 self.volume['id'])
263 # Unmark volume as reserved.
Joseph Lanoux6809bab2014-12-18 14:57:18 +0000264 self.client.unreserve_volume(self.volume['id'])
zhangyanzi6b632432013-10-24 19:08:50 +0800265
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900266 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800267 @test.idempotent_id('0f4aa809-8c7b-418f-8fb3-84c7a5dfc52f')
Zhi Kun Liu42403182013-10-11 18:05:08 +0800268 def test_list_volumes_with_nonexistent_name(self):
Ken'ichi Ohmichi07308f12015-03-23 00:24:28 +0000269 v_name = data_utils.rand_name('Volume')
Zhi Kun Liu3d6d9862014-06-16 16:43:59 +0800270 params = {self.name_field: v_name}
Joseph Lanoux6809bab2014-12-18 14:57:18 +0000271 fetched_volume = self.client.list_volumes(params)
Zhi Kun Liu42403182013-10-11 18:05:08 +0800272 self.assertEqual(0, len(fetched_volume))
273
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900274 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800275 @test.idempotent_id('9ca17820-a0e7-4cbd-a7fa-f4468735e359')
Zhi Kun Liu42403182013-10-11 18:05:08 +0800276 def test_list_volumes_detail_with_nonexistent_name(self):
Ken'ichi Ohmichi07308f12015-03-23 00:24:28 +0000277 v_name = data_utils.rand_name('Volume')
Zhi Kun Liu3d6d9862014-06-16 16:43:59 +0800278 params = {self.name_field: v_name}
Joseph Lanoux6809bab2014-12-18 14:57:18 +0000279 fetched_volume = \
280 self.client.list_volumes_with_detail(params)
Zhi Kun Liu42403182013-10-11 18:05:08 +0800281 self.assertEqual(0, len(fetched_volume))
282
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900283 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800284 @test.idempotent_id('143b279b-7522-466b-81be-34a87d564a7c')
Zhi Kun Liu42403182013-10-11 18:05:08 +0800285 def test_list_volumes_with_invalid_status(self):
286 params = {'status': 'null'}
Joseph Lanoux6809bab2014-12-18 14:57:18 +0000287 fetched_volume = self.client.list_volumes(params)
Zhi Kun Liu42403182013-10-11 18:05:08 +0800288 self.assertEqual(0, len(fetched_volume))
289
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900290 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800291 @test.idempotent_id('ba94b27b-be3f-496c-a00e-0283b373fa75')
Zhi Kun Liu42403182013-10-11 18:05:08 +0800292 def test_list_volumes_detail_with_invalid_status(self):
293 params = {'status': 'null'}
Joseph Lanoux6809bab2014-12-18 14:57:18 +0000294 fetched_volume = \
295 self.client.list_volumes_with_detail(params)
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
301 _name = 'display_name'