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 | |
Masayuki Igawa | a2ccca0 | 2013-09-17 15:32:46 +0900 | [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.compute import base |
Masayuki Igawa | a2ccca0 | 2013-09-17 15:32:46 +0900 | [diff] [blame] | 21 | from tempest.common.utils import data_utils |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 22 | from tempest import config |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [diff] [blame] | 23 | from tempest import test |
rajalakshmi-ganesan | ddd9e0e | 2012-03-21 00:49:22 +0530 | [diff] [blame] | 24 | |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 25 | CONF = config.CONF |
| 26 | |
rajalakshmi-ganesan | ddd9e0e | 2012-03-21 00:49:22 +0530 | [diff] [blame] | 27 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 28 | class VolumesNegativeTest(base.BaseV2ComputeTest): |
Attila Fazekas | 19044d5 | 2013-02-16 07:35:06 +0100 | [diff] [blame] | 29 | |
| 30 | @classmethod |
Andrea Frittoli | 50bb80d | 2014-09-15 12:34:27 +0100 | [diff] [blame] | 31 | def resource_setup(cls): |
| 32 | super(VolumesNegativeTest, cls).resource_setup() |
Attila Fazekas | 19044d5 | 2013-02-16 07:35:06 +0100 | [diff] [blame] | 33 | cls.client = cls.volumes_extensions_client |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 34 | if not CONF.service_available.cinder: |
Matthew Treinish | 4c41292 | 2013-07-16 15:27:42 -0400 | [diff] [blame] | 35 | skip_msg = ("%s skipped as Cinder is not available" % cls.__name__) |
| 36 | raise cls.skipException(skip_msg) |
rajalakshmi-ganesan | ddd9e0e | 2012-03-21 00:49:22 +0530 | [diff] [blame] | 37 | |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [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 | # Negative: Should not be able to get details of nonexistent volume |
| 41 | # Creating a nonexistent volume id |
| 42 | # Trying to GET a non existent volume |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 43 | self.assertRaises(lib_exc.NotFound, self.client.get_volume, |
Masayuki Igawa | a2ccca0 | 2013-09-17 15:32:46 +0900 | [diff] [blame] | 44 | str(uuid.uuid4())) |
rajalakshmi-ganesan | ddd9e0e | 2012-03-21 00:49:22 +0530 | [diff] [blame] | 45 | |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [diff] [blame] | 46 | @test.attr(type=['negative', 'gate']) |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 47 | def test_volume_delete_nonexistent_volume_id(self): |
| 48 | # Negative: Should not be able to delete nonexistent Volume |
| 49 | # Creating nonexistent volume id |
| 50 | # Trying to DELETE a non existent volume |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 51 | self.assertRaises(lib_exc.NotFound, self.client.delete_volume, |
Masayuki Igawa | a2ccca0 | 2013-09-17 15:32:46 +0900 | [diff] [blame] | 52 | str(uuid.uuid4())) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 53 | |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [diff] [blame] | 54 | @test.attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 55 | def test_create_volume_with_invalid_size(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 56 | # Negative: Should not be able to create volume with invalid size |
| 57 | # in request |
Masayuki Igawa | a2ccca0 | 2013-09-17 15:32:46 +0900 | [diff] [blame] | 58 | v_name = data_utils.rand_name('Volume-') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 59 | metadata = {'Type': 'work'} |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 60 | self.assertRaises(lib_exc.BadRequest, self.client.create_volume, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 61 | size='#$%', display_name=v_name, metadata=metadata) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 62 | |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [diff] [blame] | 63 | @test.attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 64 | def test_create_volume_with_out_passing_size(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 65 | # Negative: Should not be able to create volume without passing size |
| 66 | # in request |
Masayuki Igawa | a2ccca0 | 2013-09-17 15:32:46 +0900 | [diff] [blame] | 67 | v_name = data_utils.rand_name('Volume-') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 68 | metadata = {'Type': 'work'} |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 69 | self.assertRaises(lib_exc.BadRequest, self.client.create_volume, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 70 | size='', display_name=v_name, metadata=metadata) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 71 | |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [diff] [blame] | 72 | @test.attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 73 | def test_create_volume_with_size_zero(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 74 | # Negative: Should not be able to create volume with size zero |
Masayuki Igawa | a2ccca0 | 2013-09-17 15:32:46 +0900 | [diff] [blame] | 75 | v_name = data_utils.rand_name('Volume-') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 76 | metadata = {'Type': 'work'} |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 77 | self.assertRaises(lib_exc.BadRequest, self.client.create_volume, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 78 | size='0', display_name=v_name, metadata=metadata) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 79 | |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [diff] [blame] | 80 | @test.attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 81 | def test_get_invalid_volume_id(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 82 | # Negative: Should not be able to get volume with invalid id |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 83 | self.assertRaises(lib_exc.NotFound, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 84 | self.client.get_volume, '#$%%&^&^') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 85 | |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [diff] [blame] | 86 | @test.attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 87 | def test_get_volume_without_passing_volume_id(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 88 | # Negative: Should not be able to get volume when empty ID is passed |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 89 | self.assertRaises(lib_exc.NotFound, self.client.get_volume, '') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 90 | |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [diff] [blame] | 91 | @test.attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 92 | def test_delete_invalid_volume_id(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 93 | # Negative: Should not be able to delete volume when invalid ID is |
| 94 | # passed |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 95 | self.assertRaises(lib_exc.NotFound, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 96 | self.client.delete_volume, '!@#$%^&*()') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 97 | |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [diff] [blame] | 98 | @test.attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 99 | def test_delete_volume_without_passing_volume_id(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 100 | # 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] | 101 | self.assertRaises(lib_exc.NotFound, self.client.delete_volume, '') |