blob: 2ecf3e8af85101d922c30a39438b749670ec35df [file] [log] [blame]
Jay Pipes13b479b2012-06-11 14:52:27 -04001# 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.compute import base
Jay Pipes13b479b2012-06-11 14:52:27 -040019from tempest.common.utils.data_utils import rand_name
Matthew Treinisha83a16e2012-12-07 13:44:02 -050020from tempest import exceptions
Giampaolo Lauriae9c77022013-05-22 01:23:58 -040021from tempest.test import attr
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053022
23
Attila Fazekas19044d52013-02-16 07:35:06 +010024class 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 Treinish4c412922013-07-16 15:27:42 -040031 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-ganesanddd9e0e2012-03-21 00:49:22 +053034
Anju Tiwaribeab8262013-07-29 10:33:52 +053035 @attr(type=['negative', 'gate'])
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053036 def test_volume_get_nonexistant_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050037 # Negative: Should not be able to get details of nonexistant volume
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053038 #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 Yeohe04628e2013-02-25 17:12:21 +103047 # Trying to GET a non existant volume
48 self.assertRaises(exceptions.NotFound, self.client.get_volume,
49 non_exist_id)
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053050
Anju Tiwaribeab8262013-07-29 10:33:52 +053051 @attr(type=['negative', 'gate'])
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053052 def test_volume_delete_nonexistant_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050053 # Negative: Should not be able to delete nonexistant Volume
Chris Yeohe04628e2013-02-25 17:12:21 +103054 # Creating nonexistant volume id
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053055 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 Yeohe04628e2013-02-25 17:12:21 +103063 # Trying to DELETE a non existant volume
64 self.assertRaises(exceptions.NotFound, self.client.delete_volume,
65 non_exist_id)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053066
Anju Tiwaribeab8262013-07-29 10:33:52 +053067 @attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053068 def test_create_volume_with_invalid_size(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050069 # Negative: Should not be able to create volume with invalid size
70 # in request
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053071 v_name = rand_name('Volume-')
72 metadata = {'Type': 'work'}
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103073 self.assertRaises(exceptions.BadRequest, self.client.create_volume,
74 size='#$%', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053075
Anju Tiwaribeab8262013-07-29 10:33:52 +053076 @attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053077 def test_create_volume_with_out_passing_size(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050078 # Negative: Should not be able to create volume without passing size
79 # in request
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053080 v_name = rand_name('Volume-')
81 metadata = {'Type': 'work'}
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103082 self.assertRaises(exceptions.BadRequest, self.client.create_volume,
83 size='', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053084
Anju Tiwaribeab8262013-07-29 10:33:52 +053085 @attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053086 def test_create_volume_with_size_zero(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050087 # Negative: Should not be able to create volume with size zero
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053088 v_name = rand_name('Volume-')
89 metadata = {'Type': 'work'}
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103090 self.assertRaises(exceptions.BadRequest, self.client.create_volume,
91 size='0', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053092
Anju Tiwaribeab8262013-07-29 10:33:52 +053093 @attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053094 def test_get_invalid_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050095 # Negative: Should not be able to get volume with invalid id
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103096 self.assertRaises(exceptions.NotFound,
97 self.client.get_volume, '#$%%&^&^')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053098
Anju Tiwaribeab8262013-07-29 10:33:52 +053099 @attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +0530100 def test_get_volume_without_passing_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -0500101 # Negative: Should not be able to get volume when empty ID is passed
Chris Yeoh8b4eaa52013-02-06 18:03:10 +1030102 self.assertRaises(exceptions.NotFound, self.client.get_volume, '')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +0530103
Anju Tiwaribeab8262013-07-29 10:33:52 +0530104 @attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +0530105 def test_delete_invalid_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -0500106 # Negative: Should not be able to delete volume when invalid ID is
107 # passed
Chris Yeoh8b4eaa52013-02-06 18:03:10 +1030108 self.assertRaises(exceptions.NotFound,
109 self.client.delete_volume, '!@#$%^&*()')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +0530110
Anju Tiwaribeab8262013-07-29 10:33:52 +0530111 @attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +0530112 def test_delete_volume_without_passing_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -0500113 # Negative: Should not be able to delete volume when empty ID is passed
Chris Yeoh8b4eaa52013-02-06 18:03:10 +1030114 self.assertRaises(exceptions.NotFound, self.client.delete_volume, '')
Matthew Treinish9e1eb972012-08-17 17:53:41 -0400115
116
Attila Fazekas19044d52013-02-16 07:35:06 +0100117class VolumesNegativeTestXML(VolumesNegativeTest):
118 _interface = "xml"