ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [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 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 16 | from tempest.api.compute import base |
Fei Long Wang | d39431f | 2015-05-14 11:30:48 +1200 | [diff] [blame] | 17 | from tempest.common.utils import data_utils |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 18 | from tempest import config |
Andrea Frittoli (andreaf) | db9672e | 2016-02-23 14:07:24 -0500 | [diff] [blame] | 19 | from tempest.lib import exceptions as lib_exc |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [diff] [blame] | 20 | from tempest import test |
rajalakshmi-ganesan | ddd9e0e | 2012-03-21 00:49:22 +0530 | [diff] [blame] | 21 | |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 22 | CONF = config.CONF |
| 23 | |
rajalakshmi-ganesan | ddd9e0e | 2012-03-21 00:49:22 +0530 | [diff] [blame] | 24 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 25 | class VolumesNegativeTest(base.BaseV2ComputeTest): |
Attila Fazekas | 19044d5 | 2013-02-16 07:35:06 +0100 | [diff] [blame] | 26 | |
| 27 | @classmethod |
Emily Hugenbruch | 8284a34 | 2014-12-11 22:04:55 +0000 | [diff] [blame] | 28 | def skip_checks(cls): |
| 29 | super(VolumesNegativeTest, cls).skip_checks() |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 30 | if not CONF.service_available.cinder: |
Matthew Treinish | 4c41292 | 2013-07-16 15:27:42 -0400 | [diff] [blame] | 31 | skip_msg = ("%s skipped as Cinder is not available" % cls.__name__) |
| 32 | raise cls.skipException(skip_msg) |
rajalakshmi-ganesan | ddd9e0e | 2012-03-21 00:49:22 +0530 | [diff] [blame] | 33 | |
Emily Hugenbruch | 8284a34 | 2014-12-11 22:04:55 +0000 | [diff] [blame] | 34 | @classmethod |
| 35 | def setup_clients(cls): |
| 36 | super(VolumesNegativeTest, cls).setup_clients() |
| 37 | cls.client = cls.volumes_extensions_client |
| 38 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 39 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 40 | @test.idempotent_id('c03ea686-905b-41a2-8748-9635154b7c57') |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 41 | def test_volume_get_nonexistent_volume_id(self): |
| 42 | # Negative: Should not be able to get details of nonexistent volume |
| 43 | # Creating a nonexistent volume id |
| 44 | # Trying to GET a non existent volume |
Ken'ichi Ohmichi | 5f448a5 | 2015-07-01 06:26:30 +0000 | [diff] [blame] | 45 | self.assertRaises(lib_exc.NotFound, self.client.show_volume, |
Ken'ichi Ohmichi | d079c89 | 2016-04-19 11:23:36 -0700 | [diff] [blame] | 46 | data_utils.rand_uuid()) |
rajalakshmi-ganesan | ddd9e0e | 2012-03-21 00:49:22 +0530 | [diff] [blame] | 47 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 48 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 49 | @test.idempotent_id('54a34226-d910-4b00-9ef8-8683e6c55846') |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 50 | def test_volume_delete_nonexistent_volume_id(self): |
| 51 | # Negative: Should not be able to delete nonexistent Volume |
| 52 | # Creating nonexistent volume id |
| 53 | # Trying 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, |
Ken'ichi Ohmichi | d079c89 | 2016-04-19 11:23:36 -0700 | [diff] [blame] | 55 | data_utils.rand_uuid()) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [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('5125ae14-152b-40a7-b3c5-eae15e9022ef') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 59 | def test_create_volume_with_invalid_size(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 60 | # Negative: Should not be able to create volume with invalid size |
| 61 | # in request |
zhufl | c6ce539 | 2016-08-17 14:34:37 +0800 | [diff] [blame^] | 62 | v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [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) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [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('131cb3a1-75cc-4d40-b4c3-1317f64719b0') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 69 | def test_create_volume_with_out_passing_size(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 70 | # Negative: Should not be able to create volume without passing size |
| 71 | # in request |
zhufl | c6ce539 | 2016-08-17 14:34:37 +0800 | [diff] [blame^] | 72 | v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [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) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [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('8cce995e-0a83-479a-b94d-e1e40b8a09d1') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 79 | def test_create_volume_with_size_zero(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 80 | # Negative: Should not be able to create volume with size zero |
zhufl | c6ce539 | 2016-08-17 14:34:37 +0800 | [diff] [blame^] | 81 | v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [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) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [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('f01904f2-e975-4915-98ce-cb5fa27bde4f') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 88 | def test_get_invalid_volume_id(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 89 | # Negative: Should not be able to get volume with invalid id |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 90 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | 5f448a5 | 2015-07-01 06:26:30 +0000 | [diff] [blame] | 91 | self.client.show_volume, '#$%%&^&^') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 92 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 93 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 94 | @test.idempotent_id('62bab09a-4c03-4617-8cca-8572bc94af9b') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 95 | def test_get_volume_without_passing_volume_id(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 96 | # Negative: Should not be able to get volume when empty ID is passed |
Ken'ichi Ohmichi | 5f448a5 | 2015-07-01 06:26:30 +0000 | [diff] [blame] | 97 | self.assertRaises(lib_exc.NotFound, self.client.show_volume, '') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 98 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 99 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 100 | @test.idempotent_id('62972737-124b-4513-b6cf-2f019f178494') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 101 | def test_delete_invalid_volume_id(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 102 | # Negative: Should not be able to delete volume when invalid ID is |
| 103 | # passed |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 104 | self.assertRaises(lib_exc.NotFound, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 105 | self.client.delete_volume, '!@#$%^&*()') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 106 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 107 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 108 | @test.idempotent_id('0d1417c5-4ae8-4c2c-adc5-5f0b864253e5') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 109 | def test_delete_volume_without_passing_volume_id(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 110 | # Negative: Should not be able to delete volume when empty ID is passed |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 111 | self.assertRaises(lib_exc.NotFound, self.client.delete_volume, '') |