Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [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.volume import base |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [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 |
Giulio Fidente | 8b31190 | 2013-05-12 15:40:31 +0200 | [diff] [blame] | 21 | from tempest.test import attr |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 22 | |
| 23 | |
Attila Fazekas | 3dcdae1 | 2013-02-14 12:50:04 +0100 | [diff] [blame] | 24 | class VolumesNegativeTest(base.BaseVolumeTest): |
| 25 | _interface = 'json' |
| 26 | |
| 27 | @classmethod |
| 28 | def setUpClass(cls): |
| 29 | super(VolumesNegativeTest, cls).setUpClass() |
| 30 | cls.client = cls.volumes_client |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 31 | |
Giulio Fidente | 8b31190 | 2013-05-12 15:40:31 +0200 | [diff] [blame] | 32 | @attr(type='gate') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 33 | def test_volume_get_nonexistant_volume_id(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 34 | # Should not be able to get a nonexistant volume |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 35 | #Creating a nonexistant volume id |
| 36 | volume_id_list = [] |
| 37 | resp, volumes = self.client.list_volumes() |
| 38 | for i in range(len(volumes)): |
| 39 | volume_id_list.append(volumes[i]['id']) |
| 40 | while True: |
| 41 | non_exist_id = rand_name('999') |
| 42 | if non_exist_id not in volume_id_list: |
| 43 | break |
| 44 | #Trying to Get a non existant volume |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 45 | self.assertRaises(exceptions.NotFound, self.client.get_volume, |
| 46 | non_exist_id) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 47 | |
Giulio Fidente | 8b31190 | 2013-05-12 15:40:31 +0200 | [diff] [blame] | 48 | @attr(type='gate') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 49 | def test_volume_delete_nonexistant_volume_id(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 50 | # Should not be able to delete a nonexistant Volume |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 51 | # Creating nonexistant volume id |
| 52 | volume_id_list = [] |
| 53 | resp, volumes = self.client.list_volumes() |
| 54 | for i in range(len(volumes)): |
| 55 | volume_id_list.append(volumes[i]['id']) |
| 56 | while True: |
| 57 | non_exist_id = '12345678-abcd-4321-abcd-123456789098' |
| 58 | if non_exist_id not in volume_id_list: |
| 59 | break |
| 60 | # Try to Delete a non existant volume |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 61 | self.assertRaises(exceptions.NotFound, self.client.delete_volume, |
| 62 | non_exist_id) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 63 | |
Giulio Fidente | 8b31190 | 2013-05-12 15:40:31 +0200 | [diff] [blame] | 64 | @attr(type='gate') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 65 | def test_create_volume_with_invalid_size(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 66 | # Should not be able to create volume with invalid size |
| 67 | # in request |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 68 | v_name = rand_name('Volume-') |
| 69 | metadata = {'Type': 'work'} |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 70 | self.assertRaises(exceptions.BadRequest, self.client.create_volume, |
| 71 | size='#$%', display_name=v_name, metadata=metadata) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 72 | |
Giulio Fidente | 8b31190 | 2013-05-12 15:40:31 +0200 | [diff] [blame] | 73 | @attr(type='gate') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 74 | def test_create_volume_with_out_passing_size(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 75 | # Should not be able to create volume without passing size |
| 76 | # in request |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 77 | v_name = rand_name('Volume-') |
| 78 | metadata = {'Type': 'work'} |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 79 | self.assertRaises(exceptions.BadRequest, self.client.create_volume, |
| 80 | size='', display_name=v_name, metadata=metadata) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 81 | |
Giulio Fidente | 8b31190 | 2013-05-12 15:40:31 +0200 | [diff] [blame] | 82 | @attr(type='gate') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 83 | def test_create_volume_with_size_zero(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 84 | # Should not be able to create volume with size zero |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 85 | v_name = rand_name('Volume-') |
| 86 | metadata = {'Type': 'work'} |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 87 | self.assertRaises(exceptions.BadRequest, self.client.create_volume, |
| 88 | size='0', display_name=v_name, metadata=metadata) |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 89 | |
Giulio Fidente | 8b31190 | 2013-05-12 15:40:31 +0200 | [diff] [blame] | 90 | @attr(type='gate') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 91 | def test_get_invalid_volume_id(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 92 | # Should not be able to get volume with invalid id |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 93 | self.assertRaises(exceptions.NotFound, self.client.get_volume, |
| 94 | '#$%%&^&^') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 95 | |
Giulio Fidente | 8b31190 | 2013-05-12 15:40:31 +0200 | [diff] [blame] | 96 | @attr(type='gate') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 97 | def test_get_volume_without_passing_volume_id(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 98 | # Should not be able to get volume when empty ID is passed |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 99 | self.assertRaises(exceptions.NotFound, self.client.get_volume, '') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 100 | |
Giulio Fidente | 8b31190 | 2013-05-12 15:40:31 +0200 | [diff] [blame] | 101 | @attr(type='gate') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 102 | def test_delete_invalid_volume_id(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 103 | # Should not be able to delete volume when invalid ID is passed |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 104 | self.assertRaises(exceptions.NotFound, self.client.delete_volume, |
| 105 | '!@#$%^&*()') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 106 | |
Giulio Fidente | 8b31190 | 2013-05-12 15:40:31 +0200 | [diff] [blame] | 107 | @attr(type='gate') |
Rohit Karajgi | dd47d7e | 2012-07-31 04:11:01 -0700 | [diff] [blame] | 108 | def test_delete_volume_without_passing_volume_id(self): |
Sean Dague | 72a0038 | 2013-01-03 17:53:38 -0500 | [diff] [blame] | 109 | # Should not be able to delete volume when empty ID is passed |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 110 | self.assertRaises(exceptions.NotFound, self.client.delete_volume, '') |
Matthew Treinish | 9854d5b | 2012-09-20 10:22:13 -0400 | [diff] [blame] | 111 | |
| 112 | |
Attila Fazekas | 3dcdae1 | 2013-02-14 12:50:04 +0100 | [diff] [blame] | 113 | class VolumesNegativeTestXML(VolumesNegativeTest): |
| 114 | _interface = 'xml' |