blob: a47e96468378703f0a457db34a38f9368b75d5ee [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')
Rohan Kanade9ce97df2013-12-10 18:59:35 +0530182 server = self.create_server(srv_name)
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +0800183 self.addCleanup(self.servers_client.delete_server, server['id'])
184 self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
Masayuki Igawabfa07602015-01-20 18:47:17 +0900185 self.assertRaises(lib_exc.NotFound,
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +0800186 self.client.attach_volume,
187 str(uuid.uuid4()),
188 server['id'],
189 self.mountpoint)
190
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900191 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800192 @test.idempotent_id('9f9c24e4-011d-46b5-b992-952140ce237a')
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +0800193 def test_detach_volumes_with_invalid_volume_id(self):
Masayuki Igawabfa07602015-01-20 18:47:17 +0900194 self.assertRaises(lib_exc.NotFound,
Zhi Kun Liu3bdfe092013-09-02 01:31:58 +0800195 self.client.detach_volume,
196 'xxx')
197
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900198 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800199 @test.idempotent_id('e0c75c74-ee34-41a9-9288-2a2051452854')
wanghao5b981752013-10-22 11:41:41 +0800200 def test_volume_extend_with_size_smaller_than_original_size(self):
201 # Extend volume with smaller size than original size.
202 extend_size = 0
Masayuki Igawa4b29e472015-02-16 10:41:54 +0900203 self.assertRaises(lib_exc.BadRequest, self.client.extend_volume,
wanghao5b981752013-10-22 11:41:41 +0800204 self.volume['id'], extend_size)
205
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900206 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800207 @test.idempotent_id('5d0b480d-e833-439f-8a5a-96ad2ed6f22f')
wanghao5b981752013-10-22 11:41:41 +0800208 def test_volume_extend_with_non_number_size(self):
209 # Extend volume when size is non number.
210 extend_size = 'abc'
Masayuki Igawa4b29e472015-02-16 10:41:54 +0900211 self.assertRaises(lib_exc.BadRequest, self.client.extend_volume,
wanghao5b981752013-10-22 11:41:41 +0800212 self.volume['id'], extend_size)
213
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900214 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800215 @test.idempotent_id('355218f1-8991-400a-a6bb-971239287d92')
wanghao5b981752013-10-22 11:41:41 +0800216 def test_volume_extend_with_None_size(self):
217 # Extend volume with None size.
218 extend_size = None
Masayuki Igawa4b29e472015-02-16 10:41:54 +0900219 self.assertRaises(lib_exc.BadRequest, self.client.extend_volume,
wanghao5b981752013-10-22 11:41:41 +0800220 self.volume['id'], extend_size)
221
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900222 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800223 @test.idempotent_id('8f05a943-013c-4063-ac71-7baf561e82eb')
wanghao5b981752013-10-22 11:41:41 +0800224 def test_volume_extend_with_nonexistent_volume_id(self):
225 # Extend volume size when volume is nonexistent.
226 extend_size = int(self.volume['size']) + 1
Masayuki Igawabfa07602015-01-20 18:47:17 +0900227 self.assertRaises(lib_exc.NotFound, self.client.extend_volume,
wanghao5b981752013-10-22 11:41:41 +0800228 str(uuid.uuid4()), extend_size)
229
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900230 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800231 @test.idempotent_id('aff8ba64-6d6f-4f2e-bc33-41a08ee9f115')
wanghao5b981752013-10-22 11:41:41 +0800232 def test_volume_extend_without_passing_volume_id(self):
233 # Extend volume size when passing volume id is None.
234 extend_size = int(self.volume['size']) + 1
Masayuki Igawabfa07602015-01-20 18:47:17 +0900235 self.assertRaises(lib_exc.NotFound, self.client.extend_volume,
wanghao5b981752013-10-22 11:41:41 +0800236 None, extend_size)
237
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900238 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800239 @test.idempotent_id('ac6084c0-0546-45f9-b284-38a367e0e0e2')
zhangyanzi6b632432013-10-24 19:08:50 +0800240 def test_reserve_volume_with_nonexistent_volume_id(self):
Masayuki Igawabfa07602015-01-20 18:47:17 +0900241 self.assertRaises(lib_exc.NotFound,
zhangyanzi6b632432013-10-24 19:08:50 +0800242 self.client.reserve_volume,
243 str(uuid.uuid4()))
244
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900245 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800246 @test.idempotent_id('eb467654-3dc1-4a72-9b46-47c29d22654c')
zhangyanzi6b632432013-10-24 19:08:50 +0800247 def test_unreserve_volume_with_nonexistent_volume_id(self):
Masayuki Igawabfa07602015-01-20 18:47:17 +0900248 self.assertRaises(lib_exc.NotFound,
zhangyanzi6b632432013-10-24 19:08:50 +0800249 self.client.unreserve_volume,
250 str(uuid.uuid4()))
251
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900252 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800253 @test.idempotent_id('449c4ed2-ecdd-47bb-98dc-072aeccf158c')
zhangyanzi6b632432013-10-24 19:08:50 +0800254 def test_reserve_volume_with_negative_volume_status(self):
255 # Mark volume as reserved.
Joseph Lanoux6809bab2014-12-18 14:57:18 +0000256 self.client.reserve_volume(self.volume['id'])
zhangyanzi6b632432013-10-24 19:08:50 +0800257 # Mark volume which is marked as reserved before
Masayuki Igawa4b29e472015-02-16 10:41:54 +0900258 self.assertRaises(lib_exc.BadRequest,
zhangyanzi6b632432013-10-24 19:08:50 +0800259 self.client.reserve_volume,
260 self.volume['id'])
261 # Unmark volume as reserved.
Joseph Lanoux6809bab2014-12-18 14:57:18 +0000262 self.client.unreserve_volume(self.volume['id'])
zhangyanzi6b632432013-10-24 19:08:50 +0800263
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900264 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800265 @test.idempotent_id('0f4aa809-8c7b-418f-8fb3-84c7a5dfc52f')
Zhi Kun Liu42403182013-10-11 18:05:08 +0800266 def test_list_volumes_with_nonexistent_name(self):
Ken'ichi Ohmichi07308f12015-03-23 00:24:28 +0000267 v_name = data_utils.rand_name('Volume')
Zhi Kun Liu3d6d9862014-06-16 16:43:59 +0800268 params = {self.name_field: v_name}
Joseph Lanoux6809bab2014-12-18 14:57:18 +0000269 fetched_volume = self.client.list_volumes(params)
Zhi Kun Liu42403182013-10-11 18:05:08 +0800270 self.assertEqual(0, len(fetched_volume))
271
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900272 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800273 @test.idempotent_id('9ca17820-a0e7-4cbd-a7fa-f4468735e359')
Zhi Kun Liu42403182013-10-11 18:05:08 +0800274 def test_list_volumes_detail_with_nonexistent_name(self):
Ken'ichi Ohmichi07308f12015-03-23 00:24:28 +0000275 v_name = data_utils.rand_name('Volume')
Zhi Kun Liu3d6d9862014-06-16 16:43:59 +0800276 params = {self.name_field: v_name}
Joseph Lanoux6809bab2014-12-18 14:57:18 +0000277 fetched_volume = \
278 self.client.list_volumes_with_detail(params)
Zhi Kun Liu42403182013-10-11 18:05:08 +0800279 self.assertEqual(0, len(fetched_volume))
280
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900281 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800282 @test.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'}
Joseph Lanoux6809bab2014-12-18 14:57:18 +0000285 fetched_volume = self.client.list_volumes(params)
Zhi Kun Liu42403182013-10-11 18:05:08 +0800286 self.assertEqual(0, len(fetched_volume))
287
Masayuki Igawa1edf94f2014-03-04 18:34:16 +0900288 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800289 @test.idempotent_id('ba94b27b-be3f-496c-a00e-0283b373fa75')
Zhi Kun Liu42403182013-10-11 18:05:08 +0800290 def test_list_volumes_detail_with_invalid_status(self):
291 params = {'status': 'null'}
Joseph Lanoux6809bab2014-12-18 14:57:18 +0000292 fetched_volume = \
293 self.client.list_volumes_with_detail(params)
Zhi Kun Liu42403182013-10-11 18:05:08 +0800294 self.assertEqual(0, len(fetched_volume))
295
Matthew Treinish9854d5b2012-09-20 10:22:13 -0400296
Zhi Kun Liu3d6d9862014-06-16 16:43:59 +0800297class VolumesV1NegativeTest(VolumesV2NegativeTest):
298 _api_version = 1
299 _name = 'display_name'