blob: eea37e0496ad3a9905d6ac63bac3c60ae2c74374 [file] [log] [blame]
Rohit Karajgidd47d7e2012-07-31 04:11:01 -07001# 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 Dague1937d092013-05-17 16:36:38 -040018from tempest.api.volume import base
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070019from tempest.common.utils.data_utils import rand_name
Matthew Treinisha83a16e2012-12-07 13:44:02 -050020from tempest import exceptions
Giulio Fidente8b311902013-05-12 15:40:31 +020021from tempest.test import attr
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070022
23
Attila Fazekas3dcdae12013-02-14 12:50:04 +010024class 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 Karajgidd47d7e2012-07-31 04:11:01 -070031
Giulio Fidente8b311902013-05-12 15:40:31 +020032 @attr(type='gate')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070033 def test_volume_get_nonexistant_volume_id(self):
Sean Dague72a00382013-01-03 17:53:38 -050034 # Should not be able to get a nonexistant volume
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070035 #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 Yeoh8b4eaa52013-02-06 18:03:10 +103045 self.assertRaises(exceptions.NotFound, self.client.get_volume,
46 non_exist_id)
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070047
Giulio Fidente8b311902013-05-12 15:40:31 +020048 @attr(type='gate')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070049 def test_volume_delete_nonexistant_volume_id(self):
Sean Dague72a00382013-01-03 17:53:38 -050050 # Should not be able to delete a nonexistant Volume
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070051 # 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 Yeoh8b4eaa52013-02-06 18:03:10 +103061 self.assertRaises(exceptions.NotFound, self.client.delete_volume,
62 non_exist_id)
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070063
Giulio Fidente8b311902013-05-12 15:40:31 +020064 @attr(type='gate')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070065 def test_create_volume_with_invalid_size(self):
Sean Dague72a00382013-01-03 17:53:38 -050066 # Should not be able to create volume with invalid size
67 # in request
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070068 v_name = rand_name('Volume-')
69 metadata = {'Type': 'work'}
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103070 self.assertRaises(exceptions.BadRequest, self.client.create_volume,
71 size='#$%', display_name=v_name, metadata=metadata)
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070072
Giulio Fidente8b311902013-05-12 15:40:31 +020073 @attr(type='gate')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070074 def test_create_volume_with_out_passing_size(self):
Sean Dague72a00382013-01-03 17:53:38 -050075 # Should not be able to create volume without passing size
76 # in request
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070077 v_name = rand_name('Volume-')
78 metadata = {'Type': 'work'}
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103079 self.assertRaises(exceptions.BadRequest, self.client.create_volume,
80 size='', display_name=v_name, metadata=metadata)
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070081
Giulio Fidente8b311902013-05-12 15:40:31 +020082 @attr(type='gate')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070083 def test_create_volume_with_size_zero(self):
Sean Dague72a00382013-01-03 17:53:38 -050084 # Should not be able to create volume with size zero
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070085 v_name = rand_name('Volume-')
86 metadata = {'Type': 'work'}
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103087 self.assertRaises(exceptions.BadRequest, self.client.create_volume,
88 size='0', display_name=v_name, metadata=metadata)
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070089
Giulio Fidente8b311902013-05-12 15:40:31 +020090 @attr(type='gate')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070091 def test_get_invalid_volume_id(self):
Sean Dague72a00382013-01-03 17:53:38 -050092 # Should not be able to get volume with invalid id
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103093 self.assertRaises(exceptions.NotFound, self.client.get_volume,
94 '#$%%&^&^')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070095
Giulio Fidente8b311902013-05-12 15:40:31 +020096 @attr(type='gate')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -070097 def test_get_volume_without_passing_volume_id(self):
Sean Dague72a00382013-01-03 17:53:38 -050098 # Should not be able to get volume when empty ID is passed
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103099 self.assertRaises(exceptions.NotFound, self.client.get_volume, '')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700100
Giulio Fidente8b311902013-05-12 15:40:31 +0200101 @attr(type='gate')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700102 def test_delete_invalid_volume_id(self):
Sean Dague72a00382013-01-03 17:53:38 -0500103 # Should not be able to delete volume when invalid ID is passed
Chris Yeoh8b4eaa52013-02-06 18:03:10 +1030104 self.assertRaises(exceptions.NotFound, self.client.delete_volume,
105 '!@#$%^&*()')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700106
Giulio Fidente8b311902013-05-12 15:40:31 +0200107 @attr(type='gate')
Rohit Karajgidd47d7e2012-07-31 04:11:01 -0700108 def test_delete_volume_without_passing_volume_id(self):
Sean Dague72a00382013-01-03 17:53:38 -0500109 # Should not be able to delete volume when empty ID is passed
Chris Yeoh8b4eaa52013-02-06 18:03:10 +1030110 self.assertRaises(exceptions.NotFound, self.client.delete_volume, '')
Matthew Treinish9854d5b2012-09-20 10:22:13 -0400111
112
Attila Fazekas3dcdae12013-02-14 12:50:04 +0100113class VolumesNegativeTestXML(VolumesNegativeTest):
114 _interface = 'xml'