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 |
Fei Long Wang | d39431f | 2015-05-14 11:30:48 +1200 | [diff] [blame] | 21 | from tempest.common.utils import data_utils |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 22 | from tempest.common import waiters |
Masayuki Igawa | 1edf94f | 2014-03-04 18:34:16 +0900 | [diff] [blame] | 23 | from tempest import test |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 24 | |
| 25 | |
Zhi Kun Liu | 3d6d986 | 2014-06-16 16:43:59 +0800 | [diff] [blame] | 26 | class VolumesV2NegativeTest(base.BaseVolumeTest): |
Attila Fazekas | 3dcdae1 | 2013-02-14 12:50:04 +0100 | [diff] [blame] | 27 | |
| 28 | @classmethod |
Rohan Kanade | 0574915 | 2015-01-30 17:15:18 +0530 | [diff] [blame] | 29 | def setup_clients(cls): |
| 30 | super(VolumesV2NegativeTest, cls).setup_clients() |
| 31 | cls.client = cls.volumes_client |
| 32 | |
| 33 | @classmethod |
Andrea Frittoli | 61a12e2 | 2014-09-15 13:14:54 +0100 | [diff] [blame] | 34 | def resource_setup(cls): |
| 35 | super(VolumesV2NegativeTest, cls).resource_setup() |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 36 | |
Zhi Kun Liu | 3d6d986 | 2014-06-16 16:43:59 +0800 | [diff] [blame] | 37 | cls.name_field = cls.special_fields['name_field'] |
| 38 | |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 39 | # Create a test shared instance and volume for attach/detach tests |
Ken'ichi Ohmichi | 5687d55 | 2013-12-26 19:00:12 +0900 | [diff] [blame] | 40 | cls.volume = cls.create_volume() |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 41 | cls.mountpoint = "/dev/vdc" |
| 42 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 43 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 44 | @test.idempotent_id('f131c586-9448-44a4-a8b0-54ca838aa43e') |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 45 | def test_volume_get_nonexistent_volume_id(self): |
| 46 | # Should not be able to get a non-existent volume |
Ken'ichi Ohmichi | 35798fb | 2015-04-06 01:22:41 +0000 | [diff] [blame] | 47 | self.assertRaises(lib_exc.NotFound, self.client.show_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 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 50 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 51 | @test.idempotent_id('555efa6e-efcd-44ef-8a3b-4a7ca4837a29') |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 52 | def test_volume_delete_nonexistent_volume_id(self): |
| 53 | # Should not be able to delete a non-existent Volume |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 54 | self.assertRaises(lib_exc.NotFound, self.client.delete_volume, |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 55 | str(uuid.uuid4())) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 56 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 57 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 58 | @test.idempotent_id('1ed83a8a-682d-4dfb-a30e-ee63ffd6c049') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 59 | def test_create_volume_with_invalid_size(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 60 | # Should not be able to create volume with invalid size |
| 61 | # in request |
Ken'ichi Ohmichi | 07308f1 | 2015-03-23 00:24:28 +0000 | [diff] [blame] | 62 | v_name = data_utils.rand_name('Volume') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 63 | metadata = {'Type': 'work'} |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 64 | self.assertRaises(lib_exc.BadRequest, self.client.create_volume, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 65 | size='#$%', display_name=v_name, metadata=metadata) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 66 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 67 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 68 | @test.idempotent_id('9387686f-334f-4d31-a439-33494b9e2683') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 69 | def test_create_volume_with_out_passing_size(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 70 | # Should not be able to create volume without passing size |
| 71 | # in request |
Ken'ichi Ohmichi | 07308f1 | 2015-03-23 00:24:28 +0000 | [diff] [blame] | 72 | v_name = data_utils.rand_name('Volume') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 73 | metadata = {'Type': 'work'} |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 74 | self.assertRaises(lib_exc.BadRequest, self.client.create_volume, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 75 | size='', display_name=v_name, metadata=metadata) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 76 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 77 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 78 | @test.idempotent_id('41331caa-eaf4-4001-869d-bc18c1869360') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 79 | def test_create_volume_with_size_zero(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 80 | # Should not be able to create volume with size zero |
Ken'ichi Ohmichi | 07308f1 | 2015-03-23 00:24:28 +0000 | [diff] [blame] | 81 | v_name = data_utils.rand_name('Volume') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 82 | metadata = {'Type': 'work'} |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 83 | self.assertRaises(lib_exc.BadRequest, self.client.create_volume, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 84 | size='0', display_name=v_name, metadata=metadata) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 85 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 86 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 87 | @test.idempotent_id('8b472729-9eba-446e-a83b-916bdb34bef7') |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 88 | def test_create_volume_with_size_negative(self): |
| 89 | # Should not be able to create volume with size negative |
Ken'ichi Ohmichi | 07308f1 | 2015-03-23 00:24:28 +0000 | [diff] [blame] | 90 | v_name = data_utils.rand_name('Volume') |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 91 | metadata = {'Type': 'work'} |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 92 | self.assertRaises(lib_exc.BadRequest, self.client.create_volume, |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 93 | size='-1', display_name=v_name, metadata=metadata) |
| 94 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 95 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 96 | @test.idempotent_id('10254ed8-3849-454e-862e-3ab8e6aa01d2') |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 97 | def test_create_volume_with_nonexistent_volume_type(self): |
| 98 | # Should not be able to create volume with non-existent volume type |
Ken'ichi Ohmichi | 07308f1 | 2015-03-23 00:24:28 +0000 | [diff] [blame] | 99 | v_name = data_utils.rand_name('Volume') |
zhangyanzi | b866f05 | 2013-10-12 11:41:32 +0800 | [diff] [blame] | 100 | metadata = {'Type': 'work'} |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 101 | self.assertRaises(lib_exc.NotFound, self.client.create_volume, |
zhangyanzi | b866f05 | 2013-10-12 11:41:32 +0800 | [diff] [blame] | 102 | size='1', volume_type=str(uuid.uuid4()), |
| 103 | display_name=v_name, metadata=metadata) |
| 104 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 105 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 106 | @test.idempotent_id('0c36f6ae-4604-4017-b0a9-34fdc63096f9') |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 107 | def test_create_volume_with_nonexistent_snapshot_id(self): |
| 108 | # Should not be able to create volume with non-existent snapshot |
Ken'ichi Ohmichi | 07308f1 | 2015-03-23 00:24:28 +0000 | [diff] [blame] | 109 | v_name = data_utils.rand_name('Volume') |
zhangyanzi | b866f05 | 2013-10-12 11:41:32 +0800 | [diff] [blame] | 110 | metadata = {'Type': 'work'} |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 111 | self.assertRaises(lib_exc.NotFound, self.client.create_volume, |
zhangyanzi | b866f05 | 2013-10-12 11:41:32 +0800 | [diff] [blame] | 112 | size='1', snapshot_id=str(uuid.uuid4()), |
| 113 | display_name=v_name, metadata=metadata) |
| 114 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 115 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 116 | @test.idempotent_id('47c73e08-4be8-45bb-bfdf-0c4e79b88344') |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 117 | def test_create_volume_with_nonexistent_source_volid(self): |
| 118 | # Should not be able to create volume with non-existent source volume |
Ken'ichi Ohmichi | 07308f1 | 2015-03-23 00:24:28 +0000 | [diff] [blame] | 119 | v_name = data_utils.rand_name('Volume') |
zhangyanzi | b866f05 | 2013-10-12 11:41:32 +0800 | [diff] [blame] | 120 | metadata = {'Type': 'work'} |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 121 | self.assertRaises(lib_exc.NotFound, self.client.create_volume, |
zhangyanzi | b866f05 | 2013-10-12 11:41:32 +0800 | [diff] [blame] | 122 | size='1', source_volid=str(uuid.uuid4()), |
| 123 | display_name=v_name, metadata=metadata) |
| 124 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 125 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 126 | @test.idempotent_id('0186422c-999a-480e-a026-6a665744c30c') |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 127 | def test_update_volume_with_nonexistent_volume_id(self): |
Ken'ichi Ohmichi | 07308f1 | 2015-03-23 00:24:28 +0000 | [diff] [blame] | 128 | v_name = data_utils.rand_name('Volume') |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 129 | metadata = {'Type': 'work'} |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 130 | self.assertRaises(lib_exc.NotFound, self.client.update_volume, |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 131 | volume_id=str(uuid.uuid4()), display_name=v_name, |
| 132 | metadata=metadata) |
| 133 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 134 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 135 | @test.idempotent_id('e66e40d6-65e6-4e75-bdc7-636792fa152d') |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 136 | def test_update_volume_with_invalid_volume_id(self): |
Ken'ichi Ohmichi | 07308f1 | 2015-03-23 00:24:28 +0000 | [diff] [blame] | 137 | v_name = data_utils.rand_name('Volume') |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 138 | metadata = {'Type': 'work'} |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 139 | self.assertRaises(lib_exc.NotFound, self.client.update_volume, |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 140 | volume_id='#$%%&^&^', display_name=v_name, |
| 141 | metadata=metadata) |
| 142 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 143 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 144 | @test.idempotent_id('72aeca85-57a5-4c1f-9057-f320f9ea575b') |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 145 | def test_update_volume_with_empty_volume_id(self): |
Ken'ichi Ohmichi | 07308f1 | 2015-03-23 00:24:28 +0000 | [diff] [blame] | 146 | v_name = data_utils.rand_name('Volume') |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 147 | metadata = {'Type': 'work'} |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 148 | self.assertRaises(lib_exc.NotFound, self.client.update_volume, |
wanghao | c2abb6c | 2013-09-29 19:14:09 +0800 | [diff] [blame] | 149 | volume_id='', display_name=v_name, |
| 150 | metadata=metadata) |
| 151 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 152 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 153 | @test.idempotent_id('30799cfd-7ee4-446c-b66c-45b383ed211b') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 154 | def test_get_invalid_volume_id(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 155 | # Should not be able to get volume with invalid id |
Ken'ichi Ohmichi | 35798fb | 2015-04-06 01:22:41 +0000 | [diff] [blame] | 156 | self.assertRaises(lib_exc.NotFound, self.client.show_volume, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 157 | '#$%%&^&^') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 158 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 159 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 160 | @test.idempotent_id('c6c3db06-29ad-4e91-beb0-2ab195fe49e3') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 161 | def test_get_volume_without_passing_volume_id(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 162 | # Should not be able to get volume when empty ID is passed |
Ken'ichi Ohmichi | 35798fb | 2015-04-06 01:22:41 +0000 | [diff] [blame] | 163 | self.assertRaises(lib_exc.NotFound, self.client.show_volume, '') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 164 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 165 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 166 | @test.idempotent_id('1f035827-7c32-4019-9240-b4ec2dbd9dfd') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 167 | def test_delete_invalid_volume_id(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 168 | # Should not be able to delete volume when invalid ID is passed |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 169 | self.assertRaises(lib_exc.NotFound, self.client.delete_volume, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 170 | '!@#$%^&*()') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 171 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 172 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 173 | @test.idempotent_id('441a1550-5d44-4b30-af0f-a6d402f52026') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 174 | def test_delete_volume_without_passing_volume_id(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 175 | # Should not be able to delete volume when empty ID is passed |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 176 | self.assertRaises(lib_exc.NotFound, self.client.delete_volume, '') |
Matthew Treinish | 9854d5b | 2012-09-20 10:22:13 -0400 | [diff] [blame] | 177 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 178 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 179 | @test.idempotent_id('f5e56b0a-5d02-43c1-a2a7-c9b792c2e3f6') |
Matthew Treinish | 7ea69e6 | 2014-06-03 17:23:50 -0400 | [diff] [blame] | 180 | @test.services('compute') |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 181 | def test_attach_volumes_with_nonexistent_volume_id(self): |
Ken'ichi Ohmichi | 07308f1 | 2015-03-23 00:24:28 +0000 | [diff] [blame] | 182 | srv_name = data_utils.rand_name('Instance') |
Rohan Kanade | 9ce97df | 2013-12-10 18:59:35 +0530 | [diff] [blame] | 183 | server = self.create_server(srv_name) |
Ken'ichi Ohmichi | e91a0c6 | 2015-08-13 02:09:16 +0000 | [diff] [blame] | 184 | self.addCleanup(waiters.wait_for_server_termination, |
| 185 | self.servers_client, server['id']) |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 186 | self.addCleanup(self.servers_client.delete_server, server['id']) |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 187 | waiters.wait_for_server_status(self.servers_client, server['id'], |
| 188 | 'ACTIVE') |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 189 | self.assertRaises(lib_exc.NotFound, |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 190 | self.client.attach_volume, |
| 191 | str(uuid.uuid4()), |
| 192 | server['id'], |
| 193 | self.mountpoint) |
| 194 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 195 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 196 | @test.idempotent_id('9f9c24e4-011d-46b5-b992-952140ce237a') |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 197 | def test_detach_volumes_with_invalid_volume_id(self): |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 198 | self.assertRaises(lib_exc.NotFound, |
Zhi Kun Liu | 3bdfe09 | 2013-09-02 01:31:58 +0800 | [diff] [blame] | 199 | self.client.detach_volume, |
| 200 | 'xxx') |
| 201 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 202 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 203 | @test.idempotent_id('e0c75c74-ee34-41a9-9288-2a2051452854') |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 204 | def test_volume_extend_with_size_smaller_than_original_size(self): |
| 205 | # Extend volume with smaller size than original size. |
| 206 | extend_size = 0 |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 207 | self.assertRaises(lib_exc.BadRequest, self.client.extend_volume, |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 208 | self.volume['id'], extend_size) |
| 209 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 210 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 211 | @test.idempotent_id('5d0b480d-e833-439f-8a5a-96ad2ed6f22f') |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 212 | def test_volume_extend_with_non_number_size(self): |
| 213 | # Extend volume when size is non number. |
| 214 | extend_size = 'abc' |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 215 | self.assertRaises(lib_exc.BadRequest, self.client.extend_volume, |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 216 | self.volume['id'], extend_size) |
| 217 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 218 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 219 | @test.idempotent_id('355218f1-8991-400a-a6bb-971239287d92') |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 220 | def test_volume_extend_with_None_size(self): |
| 221 | # Extend volume with None size. |
| 222 | extend_size = None |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 223 | self.assertRaises(lib_exc.BadRequest, self.client.extend_volume, |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 224 | self.volume['id'], extend_size) |
| 225 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 226 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 227 | @test.idempotent_id('8f05a943-013c-4063-ac71-7baf561e82eb') |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 228 | def test_volume_extend_with_nonexistent_volume_id(self): |
| 229 | # Extend volume size when volume is nonexistent. |
| 230 | extend_size = int(self.volume['size']) + 1 |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 231 | self.assertRaises(lib_exc.NotFound, self.client.extend_volume, |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 232 | str(uuid.uuid4()), extend_size) |
| 233 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 234 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 235 | @test.idempotent_id('aff8ba64-6d6f-4f2e-bc33-41a08ee9f115') |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 236 | def test_volume_extend_without_passing_volume_id(self): |
| 237 | # Extend volume size when passing volume id is None. |
| 238 | extend_size = int(self.volume['size']) + 1 |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 239 | self.assertRaises(lib_exc.NotFound, self.client.extend_volume, |
wanghao | 5b98175 | 2013-10-22 11:41:41 +0800 | [diff] [blame] | 240 | None, extend_size) |
| 241 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 242 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 243 | @test.idempotent_id('ac6084c0-0546-45f9-b284-38a367e0e0e2') |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 244 | def test_reserve_volume_with_nonexistent_volume_id(self): |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 245 | self.assertRaises(lib_exc.NotFound, |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 246 | self.client.reserve_volume, |
| 247 | str(uuid.uuid4())) |
| 248 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 249 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 250 | @test.idempotent_id('eb467654-3dc1-4a72-9b46-47c29d22654c') |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 251 | def test_unreserve_volume_with_nonexistent_volume_id(self): |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 252 | self.assertRaises(lib_exc.NotFound, |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 253 | self.client.unreserve_volume, |
| 254 | str(uuid.uuid4())) |
| 255 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 256 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 257 | @test.idempotent_id('449c4ed2-ecdd-47bb-98dc-072aeccf158c') |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 258 | def test_reserve_volume_with_negative_volume_status(self): |
| 259 | # Mark volume as reserved. |
Joseph Lanoux | 6809bab | 2014-12-18 14:57:18 +0000 | [diff] [blame] | 260 | self.client.reserve_volume(self.volume['id']) |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 261 | # Mark volume which is marked as reserved before |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 262 | self.assertRaises(lib_exc.BadRequest, |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 263 | self.client.reserve_volume, |
| 264 | self.volume['id']) |
| 265 | # Unmark volume as reserved. |
Joseph Lanoux | 6809bab | 2014-12-18 14:57:18 +0000 | [diff] [blame] | 266 | self.client.unreserve_volume(self.volume['id']) |
zhangyanzi | 6b63243 | 2013-10-24 19:08:50 +0800 | [diff] [blame] | 267 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 268 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 269 | @test.idempotent_id('0f4aa809-8c7b-418f-8fb3-84c7a5dfc52f') |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 270 | def test_list_volumes_with_nonexistent_name(self): |
Ken'ichi Ohmichi | 07308f1 | 2015-03-23 00:24:28 +0000 | [diff] [blame] | 271 | v_name = data_utils.rand_name('Volume') |
Zhi Kun Liu | 3d6d986 | 2014-06-16 16:43:59 +0800 | [diff] [blame] | 272 | params = {self.name_field: v_name} |
Ken'ichi Ohmichi | 35798fb | 2015-04-06 01:22:41 +0000 | [diff] [blame] | 273 | fetched_volume = self.client.list_volumes(params=params) |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 274 | self.assertEqual(0, len(fetched_volume)) |
| 275 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 276 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 277 | @test.idempotent_id('9ca17820-a0e7-4cbd-a7fa-f4468735e359') |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 278 | def test_list_volumes_detail_with_nonexistent_name(self): |
Ken'ichi Ohmichi | 07308f1 | 2015-03-23 00:24:28 +0000 | [diff] [blame] | 279 | v_name = data_utils.rand_name('Volume') |
Zhi Kun Liu | 3d6d986 | 2014-06-16 16:43:59 +0800 | [diff] [blame] | 280 | params = {self.name_field: v_name} |
Joseph Lanoux | 6809bab | 2014-12-18 14:57:18 +0000 | [diff] [blame] | 281 | fetched_volume = \ |
Ken'ichi Ohmichi | 35798fb | 2015-04-06 01:22:41 +0000 | [diff] [blame] | 282 | self.client.list_volumes(detail=True, params=params) |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 283 | self.assertEqual(0, len(fetched_volume)) |
| 284 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 285 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 286 | @test.idempotent_id('143b279b-7522-466b-81be-34a87d564a7c') |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 287 | def test_list_volumes_with_invalid_status(self): |
| 288 | params = {'status': 'null'} |
Ken'ichi Ohmichi | 35798fb | 2015-04-06 01:22:41 +0000 | [diff] [blame] | 289 | fetched_volume = self.client.list_volumes(params=params) |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 290 | self.assertEqual(0, len(fetched_volume)) |
| 291 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 292 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 293 | @test.idempotent_id('ba94b27b-be3f-496c-a00e-0283b373fa75') |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 294 | def test_list_volumes_detail_with_invalid_status(self): |
| 295 | params = {'status': 'null'} |
Joseph Lanoux | 6809bab | 2014-12-18 14:57:18 +0000 | [diff] [blame] | 296 | fetched_volume = \ |
Ken'ichi Ohmichi | 35798fb | 2015-04-06 01:22:41 +0000 | [diff] [blame] | 297 | self.client.list_volumes(detail=True, params=params) |
Zhi Kun Liu | 4240318 | 2013-10-11 18:05:08 +0800 | [diff] [blame] | 298 | self.assertEqual(0, len(fetched_volume)) |
| 299 | |
Matthew Treinish | 9854d5b | 2012-09-20 10:22:13 -0400 | [diff] [blame] | 300 | |
Zhi Kun Liu | 3d6d986 | 2014-06-16 16:43:59 +0800 | [diff] [blame] | 301 | class VolumesV1NegativeTest(VolumesV2NegativeTest): |
| 302 | _api_version = 1 |
| 303 | _name = 'display_name' |