Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
| 3 | # Copyright 2012 OpenStack, LLC |
| 4 | # All Rights Reserved. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. You may obtain |
| 8 | # a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | # License for the specific language governing permissions and limitations |
| 16 | # under the License. |
| 17 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 18 | from tempest.api.compute import base |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 19 | from tempest.common.utils.data_utils import rand_name |
Matthew Treinish | a83a16e | 2012-12-07 13:44:02 -0500 | [diff] [blame] | 20 | from tempest import exceptions |
Giampaolo Lauria | e9c7702 | 2013-05-22 01:23:58 -0400 | [diff] [blame] | 21 | from tempest.test import attr |
rajalakshmi-ganesan | ddd9e0e | 2012-03-21 00:49:22 +0530 | [diff] [blame] | 22 | |
| 23 | |
Attila Fazekas | 19044d5 | 2013-02-16 07:35:06 +0100 | [diff] [blame] | 24 | class VolumesNegativeTest(base.BaseComputeTest): |
| 25 | _interface = 'json' |
| 26 | |
| 27 | @classmethod |
| 28 | def setUpClass(cls): |
| 29 | super(VolumesNegativeTest, cls).setUpClass() |
| 30 | cls.client = cls.volumes_extensions_client |
Matthew Treinish | 4c41292 | 2013-07-16 15:27:42 -0400 | [diff] [blame] | 31 | if not cls.config.service_available.cinder: |
| 32 | skip_msg = ("%s skipped as Cinder is not available" % cls.__name__) |
| 33 | raise cls.skipException(skip_msg) |
rajalakshmi-ganesan | ddd9e0e | 2012-03-21 00:49:22 +0530 | [diff] [blame] | 34 | |
Anju Tiwari | beab826 | 2013-07-29 10:33:52 +0530 | [diff] [blame^] | 35 | @attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | ddd9e0e | 2012-03-21 00:49:22 +0530 | [diff] [blame] | 36 | def test_volume_get_nonexistant_volume_id(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 37 | # Negative: Should not be able to get details of nonexistant volume |
rajalakshmi-ganesan | ddd9e0e | 2012-03-21 00:49:22 +0530 | [diff] [blame] | 38 | #Creating a nonexistant volume id |
| 39 | volume_id_list = list() |
| 40 | resp, body = self.client.list_volumes() |
| 41 | for i in range(len(body)): |
| 42 | volume_id_list.append(body[i]['id']) |
| 43 | while True: |
| 44 | non_exist_id = rand_name('999') |
| 45 | if non_exist_id not in volume_id_list: |
| 46 | break |
Chris Yeoh | e04628e | 2013-02-25 17:12:21 +1030 | [diff] [blame] | 47 | # Trying to GET a non existant volume |
| 48 | self.assertRaises(exceptions.NotFound, self.client.get_volume, |
| 49 | non_exist_id) |
rajalakshmi-ganesan | ddd9e0e | 2012-03-21 00:49:22 +0530 | [diff] [blame] | 50 | |
Anju Tiwari | beab826 | 2013-07-29 10:33:52 +0530 | [diff] [blame^] | 51 | @attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | ddd9e0e | 2012-03-21 00:49:22 +0530 | [diff] [blame] | 52 | def test_volume_delete_nonexistant_volume_id(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 53 | # Negative: Should not be able to delete nonexistant Volume |
Chris Yeoh | e04628e | 2013-02-25 17:12:21 +1030 | [diff] [blame] | 54 | # Creating nonexistant volume id |
rajalakshmi-ganesan | ddd9e0e | 2012-03-21 00:49:22 +0530 | [diff] [blame] | 55 | volume_id_list = list() |
| 56 | resp, body = self.client.list_volumes() |
| 57 | for i in range(len(body)): |
| 58 | volume_id_list.append(body[i]['id']) |
| 59 | while True: |
| 60 | non_exist_id = rand_name('999') |
| 61 | if non_exist_id not in volume_id_list: |
| 62 | break |
Chris Yeoh | e04628e | 2013-02-25 17:12:21 +1030 | [diff] [blame] | 63 | # Trying to DELETE a non existant volume |
| 64 | self.assertRaises(exceptions.NotFound, self.client.delete_volume, |
| 65 | non_exist_id) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 66 | |
Anju Tiwari | beab826 | 2013-07-29 10:33:52 +0530 | [diff] [blame^] | 67 | @attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 68 | def test_create_volume_with_invalid_size(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 69 | # Negative: Should not be able to create volume with invalid size |
| 70 | # in request |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 71 | v_name = rand_name('Volume-') |
| 72 | metadata = {'Type': 'work'} |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 73 | self.assertRaises(exceptions.BadRequest, self.client.create_volume, |
| 74 | size='#$%', display_name=v_name, metadata=metadata) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 75 | |
Anju Tiwari | beab826 | 2013-07-29 10:33:52 +0530 | [diff] [blame^] | 76 | @attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 77 | def test_create_volume_with_out_passing_size(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 78 | # Negative: Should not be able to create volume without passing size |
| 79 | # in request |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 80 | v_name = rand_name('Volume-') |
| 81 | metadata = {'Type': 'work'} |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 82 | self.assertRaises(exceptions.BadRequest, self.client.create_volume, |
| 83 | size='', display_name=v_name, metadata=metadata) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 84 | |
Anju Tiwari | beab826 | 2013-07-29 10:33:52 +0530 | [diff] [blame^] | 85 | @attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 86 | def test_create_volume_with_size_zero(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 87 | # Negative: Should not be able to create volume with size zero |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 88 | v_name = rand_name('Volume-') |
| 89 | metadata = {'Type': 'work'} |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 90 | self.assertRaises(exceptions.BadRequest, self.client.create_volume, |
| 91 | size='0', display_name=v_name, metadata=metadata) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 92 | |
Anju Tiwari | beab826 | 2013-07-29 10:33:52 +0530 | [diff] [blame^] | 93 | @attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 94 | def test_get_invalid_volume_id(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 95 | # Negative: Should not be able to get volume with invalid id |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 96 | self.assertRaises(exceptions.NotFound, |
| 97 | self.client.get_volume, '#$%%&^&^') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 98 | |
Anju Tiwari | beab826 | 2013-07-29 10:33:52 +0530 | [diff] [blame^] | 99 | @attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 100 | def test_get_volume_without_passing_volume_id(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 101 | # Negative: Should not be able to get volume when empty ID is passed |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 102 | self.assertRaises(exceptions.NotFound, self.client.get_volume, '') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 103 | |
Anju Tiwari | beab826 | 2013-07-29 10:33:52 +0530 | [diff] [blame^] | 104 | @attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 105 | def test_delete_invalid_volume_id(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 106 | # Negative: Should not be able to delete volume when invalid ID is |
| 107 | # passed |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 108 | self.assertRaises(exceptions.NotFound, |
| 109 | self.client.delete_volume, '!@#$%^&*()') |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 110 | |
Anju Tiwari | beab826 | 2013-07-29 10:33:52 +0530 | [diff] [blame^] | 111 | @attr(type=['negative', 'gate']) |
rajalakshmi-ganesan | 5894d51 | 2012-05-31 19:00:36 +0530 | [diff] [blame] | 112 | def test_delete_volume_without_passing_volume_id(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 113 | # Negative: Should not be able to delete volume when empty ID is passed |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 114 | self.assertRaises(exceptions.NotFound, self.client.delete_volume, '') |
Matthew Treinish | 9e1eb97 | 2012-08-17 17:53:41 -0400 | [diff] [blame] | 115 | |
| 116 | |
Attila Fazekas | 19044d5 | 2013-02-16 07:35:06 +0100 | [diff] [blame] | 117 | class VolumesNegativeTestXML(VolumesNegativeTest): |
| 118 | _interface = "xml" |