ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 2 | # 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 Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 16 | import uuid |
| 17 | |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 18 | from tempest_lib import exceptions as lib_exc |
| 19 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 20 | from tempest.api.volume import base |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 21 | from tempest.common.utils import data_utils |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 22 | from tempest import test |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 23 | |
| 24 | |
Zhi Kun Liu | 3d6d986 | 2014-06-16 16:43:59 +0800 | [diff] [blame] | 25 | class VolumesV2NegativeTest(base.BaseVolumeTest): |
Attila Fazekas | 3dcdae1 | 2013-02-14 12:50:04 +0100 | [diff] [blame] | 26 | |
| 27 | @classmethod |
Andrea Frittoli | 61a12e2 | 2014-09-15 13:14:54 +0100 | [diff] [blame] | 28 | def resource_setup(cls): |
| 29 | super(VolumesV2NegativeTest, cls).resource_setup() |
Attila Fazekas | 3dcdae1 | 2013-02-14 12:50:04 +0100 | [diff] [blame] | 30 | cls.client = cls.volumes_client |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 31 | |
Zhi Kun Liu | 3d6d986 | 2014-06-16 16:43:59 +0800 | [diff] [blame] | 32 | cls.name_field = cls.special_fields['name_field'] |
| 33 | |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 34 | # Create a test shared instance and volume for attach/detach tests |
Ken'ichi Ohmichi | 5687d55 | 2013-12-26 19:00:12 +0900 | [diff] [blame] | 35 | cls.volume = cls.create_volume() |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 36 | cls.mountpoint = "/dev/vdc" |
| 37 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 38 | @test.attr(type=['negative', 'gate']) |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 39 | def test_volume_get_nonexistent_volume_id(self): |
| 40 | # Should not be able to get a non-existent volume |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 41 | self.assertRaises(lib_exc.NotFound, self.client.get_volume, |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 42 | str(uuid.uuid4())) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 43 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 44 | @test.attr(type=['negative', 'gate']) |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 45 | def test_volume_delete_nonexistent_volume_id(self): |
| 46 | # Should not be able to delete a non-existent Volume |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 47 | self.assertRaises(lib_exc.NotFound, self.client.delete_volume, |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 48 | str(uuid.uuid4())) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 49 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 50 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 51 | def test_create_volume_with_invalid_size(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 52 | # Should not be able to create volume with invalid size |
| 53 | # in request |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 54 | v_name = data_utils.rand_name('Volume-') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 55 | metadata = {'Type': 'work'} |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 56 | self.assertRaises(lib_exc.BadRequest, self.client.create_volume, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 57 | size='#$%', display_name=v_name, metadata=metadata) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 58 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 59 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 60 | def test_create_volume_with_out_passing_size(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 61 | # Should not be able to create volume without passing size |
| 62 | # in request |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 63 | v_name = data_utils.rand_name('Volume-') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 64 | metadata = {'Type': 'work'} |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 65 | self.assertRaises(lib_exc.BadRequest, self.client.create_volume, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 66 | size='', display_name=v_name, metadata=metadata) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 67 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 68 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 69 | def test_create_volume_with_size_zero(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 70 | # Should not be able to create volume with size zero |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 71 | v_name = data_utils.rand_name('Volume-') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 72 | metadata = {'Type': 'work'} |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 73 | self.assertRaises(lib_exc.BadRequest, self.client.create_volume, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 74 | size='0', display_name=v_name, metadata=metadata) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 75 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 76 | @test.attr(type=['negative', 'gate']) |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 77 | def test_create_volume_with_size_negative(self): |
| 78 | # Should not be able to create volume with size negative |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 79 | v_name = data_utils.rand_name('Volume-') |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 80 | metadata = {'Type': 'work'} |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 81 | self.assertRaises(lib_exc.BadRequest, self.client.create_volume, |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 82 | size='-1', display_name=v_name, metadata=metadata) |
| 83 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 84 | @test.attr(type=['negative', 'gate']) |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 85 | def test_create_volume_with_nonexistent_volume_type(self): |
| 86 | # Should not be able to create volume with non-existent volume type |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 87 | v_name = data_utils.rand_name('Volume-') |
zhangyanzi | b866f05 | 2013-10-12 11:41:32 +0800 | [diff] [blame] | 88 | metadata = {'Type': 'work'} |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 89 | self.assertRaises(lib_exc.NotFound, self.client.create_volume, |
zhangyanzi | b866f05 | 2013-10-12 11:41:32 +0800 | [diff] [blame] | 90 | size='1', volume_type=str(uuid.uuid4()), |
| 91 | display_name=v_name, metadata=metadata) |
| 92 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 93 | @test.attr(type=['negative', 'gate']) |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 94 | def test_create_volume_with_nonexistent_snapshot_id(self): |
| 95 | # Should not be able to create volume with non-existent snapshot |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 96 | v_name = data_utils.rand_name('Volume-') |
zhangyanzi | b866f05 | 2013-10-12 11:41:32 +0800 | [diff] [blame] | 97 | metadata = {'Type': 'work'} |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 98 | self.assertRaises(lib_exc.NotFound, self.client.create_volume, |
zhangyanzi | b866f05 | 2013-10-12 11:41:32 +0800 | [diff] [blame] | 99 | size='1', snapshot_id=str(uuid.uuid4()), |
| 100 | display_name=v_name, metadata=metadata) |
| 101 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 102 | @test.attr(type=['negative', 'gate']) |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 103 | def test_create_volume_with_nonexistent_source_volid(self): |
| 104 | # Should not be able to create volume with non-existent source volume |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 105 | v_name = data_utils.rand_name('Volume-') |
zhangyanzi | b866f05 | 2013-10-12 11:41:32 +0800 | [diff] [blame] | 106 | metadata = {'Type': 'work'} |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 107 | self.assertRaises(lib_exc.NotFound, self.client.create_volume, |
zhangyanzi | b866f05 | 2013-10-12 11:41:32 +0800 | [diff] [blame] | 108 | size='1', source_volid=str(uuid.uuid4()), |
| 109 | display_name=v_name, metadata=metadata) |
| 110 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 111 | @test.attr(type=['negative', 'gate']) |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 112 | def test_update_volume_with_nonexistent_volume_id(self): |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 113 | v_name = data_utils.rand_name('Volume-') |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 114 | metadata = {'Type': 'work'} |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 115 | self.assertRaises(lib_exc.NotFound, self.client.update_volume, |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 116 | volume_id=str(uuid.uuid4()), display_name=v_name, |
| 117 | metadata=metadata) |
| 118 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 119 | @test.attr(type=['negative', 'gate']) |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 120 | def test_update_volume_with_invalid_volume_id(self): |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 121 | v_name = data_utils.rand_name('Volume-') |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 122 | metadata = {'Type': 'work'} |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 123 | self.assertRaises(lib_exc.NotFound, self.client.update_volume, |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 124 | volume_id='#$%%&^&^', display_name=v_name, |
| 125 | metadata=metadata) |
| 126 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 127 | @test.attr(type=['negative', 'gate']) |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 128 | def test_update_volume_with_empty_volume_id(self): |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 129 | v_name = data_utils.rand_name('Volume-') |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 130 | metadata = {'Type': 'work'} |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 131 | self.assertRaises(lib_exc.NotFound, self.client.update_volume, |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 132 | volume_id='', display_name=v_name, |
| 133 | metadata=metadata) |
| 134 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 135 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 136 | def test_get_invalid_volume_id(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 137 | # Should not be able to get volume with invalid id |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 138 | self.assertRaises(lib_exc.NotFound, self.client.get_volume, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 139 | '#$%%&^&^') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 140 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 141 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 142 | def test_get_volume_without_passing_volume_id(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 143 | # Should not be able to get volume when empty ID is passed |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 144 | self.assertRaises(lib_exc.NotFound, self.client.get_volume, '') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 145 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 146 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 147 | def test_delete_invalid_volume_id(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 148 | # Should not be able to delete volume when invalid ID is passed |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 149 | self.assertRaises(lib_exc.NotFound, self.client.delete_volume, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 150 | '!@#$%^&*()') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 151 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 152 | @test.attr(type=['negative', 'gate']) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 153 | def test_delete_volume_without_passing_volume_id(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 154 | # Should not be able to delete volume when empty ID is passed |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 155 | self.assertRaises(lib_exc.NotFound, self.client.delete_volume, '') |
Matthew Treinish | 9854d5b | 2012-09-20 10:22:13 -0400 | [diff] [blame] | 156 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 157 | @test.attr(type=['negative', 'gate']) |
Matthew Treinish | 7ea69e6 | 2014-06-03 17:23:50 -0400 | [diff] [blame] | 158 | @test.services('compute') |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 159 | def test_attach_volumes_with_nonexistent_volume_id(self): |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 160 | srv_name = data_utils.rand_name('Instance-') |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 161 | server = self.servers_client.create_server(srv_name, |
| 162 | self.image_ref, |
| 163 | self.flavor_ref) |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 164 | self.addCleanup(self.servers_client.delete_server, server['id']) |
| 165 | self.servers_client.wait_for_server_status(server['id'], 'ACTIVE') |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 166 | self.assertRaises(lib_exc.NotFound, |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 167 | self.client.attach_volume, |
| 168 | str(uuid.uuid4()), |
| 169 | server['id'], |
| 170 | self.mountpoint) |
| 171 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 172 | @test.attr(type=['negative', 'gate']) |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 173 | def test_detach_volumes_with_invalid_volume_id(self): |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 174 | self.assertRaises(lib_exc.NotFound, |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 175 | self.client.detach_volume, |
| 176 | 'xxx') |
| 177 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 178 | @test.attr(type=['negative', 'gate']) |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 179 | def test_volume_extend_with_size_smaller_than_original_size(self): |
| 180 | # Extend volume with smaller size than original size. |
| 181 | extend_size = 0 |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 182 | self.assertRaises(lib_exc.BadRequest, self.client.extend_volume, |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 183 | self.volume['id'], extend_size) |
| 184 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 185 | @test.attr(type=['negative', 'gate']) |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 186 | def test_volume_extend_with_non_number_size(self): |
| 187 | # Extend volume when size is non number. |
| 188 | extend_size = 'abc' |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 189 | self.assertRaises(lib_exc.BadRequest, self.client.extend_volume, |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 190 | self.volume['id'], extend_size) |
| 191 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 192 | @test.attr(type=['negative', 'gate']) |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 193 | def test_volume_extend_with_None_size(self): |
| 194 | # Extend volume with None size. |
| 195 | extend_size = None |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 196 | self.assertRaises(lib_exc.BadRequest, self.client.extend_volume, |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 197 | self.volume['id'], extend_size) |
| 198 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 199 | @test.attr(type=['negative', 'gate']) |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 200 | def test_volume_extend_with_nonexistent_volume_id(self): |
| 201 | # Extend volume size when volume is nonexistent. |
| 202 | extend_size = int(self.volume['size']) + 1 |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 203 | self.assertRaises(lib_exc.NotFound, self.client.extend_volume, |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 204 | str(uuid.uuid4()), extend_size) |
| 205 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 206 | @test.attr(type=['negative', 'gate']) |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 207 | def test_volume_extend_without_passing_volume_id(self): |
| 208 | # Extend volume size when passing volume id is None. |
| 209 | extend_size = int(self.volume['size']) + 1 |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 210 | self.assertRaises(lib_exc.NotFound, self.client.extend_volume, |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 211 | None, extend_size) |
| 212 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 213 | @test.attr(type=['negative', 'gate']) |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 214 | def test_reserve_volume_with_nonexistent_volume_id(self): |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 215 | self.assertRaises(lib_exc.NotFound, |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 216 | self.client.reserve_volume, |
| 217 | str(uuid.uuid4())) |
| 218 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 219 | @test.attr(type=['negative', 'gate']) |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 220 | def test_unreserve_volume_with_nonexistent_volume_id(self): |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 221 | self.assertRaises(lib_exc.NotFound, |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 222 | self.client.unreserve_volume, |
| 223 | str(uuid.uuid4())) |
| 224 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 225 | @test.attr(type=['negative', 'gate']) |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 226 | def test_reserve_volume_with_negative_volume_status(self): |
| 227 | # Mark volume as reserved. |
Joseph Lanoux | 6809bab | 2014-12-18 14:57:18 +0000 | [diff] [blame] | 228 | self.client.reserve_volume(self.volume['id']) |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 229 | # Mark volume which is marked as reserved before |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 230 | self.assertRaises(lib_exc.BadRequest, |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 231 | self.client.reserve_volume, |
| 232 | self.volume['id']) |
| 233 | # Unmark volume as reserved. |
Joseph Lanoux | 6809bab | 2014-12-18 14:57:18 +0000 | [diff] [blame] | 234 | self.client.unreserve_volume(self.volume['id']) |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 235 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 236 | @test.attr(type=['negative', 'gate']) |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 237 | def test_list_volumes_with_nonexistent_name(self): |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 238 | v_name = data_utils.rand_name('Volume-') |
Zhi Kun Liu | 3d6d986 | 2014-06-16 16:43:59 +0800 | [diff] [blame] | 239 | params = {self.name_field: v_name} |
Joseph Lanoux | 6809bab | 2014-12-18 14:57:18 +0000 | [diff] [blame] | 240 | fetched_volume = self.client.list_volumes(params) |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 241 | self.assertEqual(0, len(fetched_volume)) |
| 242 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 243 | @test.attr(type=['negative', 'gate']) |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 244 | def test_list_volumes_detail_with_nonexistent_name(self): |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 245 | v_name = data_utils.rand_name('Volume-') |
Zhi Kun Liu | 3d6d986 | 2014-06-16 16:43:59 +0800 | [diff] [blame] | 246 | params = {self.name_field: v_name} |
Joseph Lanoux | 6809bab | 2014-12-18 14:57:18 +0000 | [diff] [blame] | 247 | fetched_volume = \ |
| 248 | self.client.list_volumes_with_detail(params) |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 249 | self.assertEqual(0, len(fetched_volume)) |
| 250 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 251 | @test.attr(type=['negative', 'gate']) |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 252 | def test_list_volumes_with_invalid_status(self): |
| 253 | params = {'status': 'null'} |
Joseph Lanoux | 6809bab | 2014-12-18 14:57:18 +0000 | [diff] [blame] | 254 | fetched_volume = self.client.list_volumes(params) |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 255 | self.assertEqual(0, len(fetched_volume)) |
| 256 | |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 257 | @test.attr(type=['negative', 'gate']) |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 258 | def test_list_volumes_detail_with_invalid_status(self): |
| 259 | params = {'status': 'null'} |
Joseph Lanoux | 6809bab | 2014-12-18 14:57:18 +0000 | [diff] [blame] | 260 | fetched_volume = \ |
| 261 | self.client.list_volumes_with_detail(params) |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 262 | self.assertEqual(0, len(fetched_volume)) |
| 263 | |
Matthew Treinish | 9854d5b | 2012-09-20 10:22:13 -0400 | [diff] [blame] | 264 | |
Zhi Kun Liu | 3d6d986 | 2014-06-16 16:43:59 +0800 | [diff] [blame] | 265 | class VolumesV1NegativeTest(VolumesV2NegativeTest): |
| 266 | _api_version = 1 |
| 267 | _name = 'display_name' |