blob: 785902eb2afeb4a333646ec4bb147d266b5e38ce [file] [log] [blame]
Jay Pipes13b479b2012-06-11 14:52:27 -04001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
ZhiQiang Fan39f97222013-09-20 04:49:44 +08003# Copyright 2012 OpenStack Foundation
Jay Pipes13b479b2012-06-11 14:52:27 -04004# 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
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090018import uuid
19
Sean Dague1937d092013-05-17 16:36:38 -040020from tempest.api.compute import base
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090021from tempest.common.utils import data_utils
Matthew Treinisha83a16e2012-12-07 13:44:02 -050022from tempest import exceptions
Giampaolo Lauriae9c77022013-05-22 01:23:58 -040023from tempest.test import attr
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053024
25
ivan-zhuf2b00502013-10-18 10:06:52 +080026class VolumesNegativeTest(base.BaseV2ComputeTest):
Attila Fazekas19044d52013-02-16 07:35:06 +010027 _interface = 'json'
28
29 @classmethod
30 def setUpClass(cls):
31 super(VolumesNegativeTest, cls).setUpClass()
32 cls.client = cls.volumes_extensions_client
Matthew Treinish4c412922013-07-16 15:27:42 -040033 if not cls.config.service_available.cinder:
34 skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
35 raise cls.skipException(skip_msg)
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053036
Anju Tiwaribeab8262013-07-29 10:33:52 +053037 @attr(type=['negative', 'gate'])
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053038 def test_volume_get_nonexistant_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050039 # Negative: Should not be able to get details of nonexistant volume
Attila Fazekasf7f34f92013-08-01 17:01:44 +020040 # Creating a nonexistant volume id
Chris Yeohe04628e2013-02-25 17:12:21 +103041 # Trying to GET a non existant volume
42 self.assertRaises(exceptions.NotFound, self.client.get_volume,
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090043 str(uuid.uuid4()))
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053044
Anju Tiwaribeab8262013-07-29 10:33:52 +053045 @attr(type=['negative', 'gate'])
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053046 def test_volume_delete_nonexistant_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050047 # Negative: Should not be able to delete nonexistant Volume
Chris Yeohe04628e2013-02-25 17:12:21 +103048 # Creating nonexistant volume id
Chris Yeohe04628e2013-02-25 17:12:21 +103049 # Trying to DELETE a non existant volume
50 self.assertRaises(exceptions.NotFound, self.client.delete_volume,
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090051 str(uuid.uuid4()))
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053052
Anju Tiwaribeab8262013-07-29 10:33:52 +053053 @attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053054 def test_create_volume_with_invalid_size(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050055 # Negative: Should not be able to create volume with invalid size
56 # in request
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090057 v_name = data_utils.rand_name('Volume-')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053058 metadata = {'Type': 'work'}
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103059 self.assertRaises(exceptions.BadRequest, self.client.create_volume,
60 size='#$%', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053061
Anju Tiwaribeab8262013-07-29 10:33:52 +053062 @attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053063 def test_create_volume_with_out_passing_size(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050064 # Negative: Should not be able to create volume without passing size
65 # in request
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090066 v_name = data_utils.rand_name('Volume-')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053067 metadata = {'Type': 'work'}
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103068 self.assertRaises(exceptions.BadRequest, self.client.create_volume,
69 size='', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053070
Anju Tiwaribeab8262013-07-29 10:33:52 +053071 @attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053072 def test_create_volume_with_size_zero(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050073 # Negative: Should not be able to create volume with size zero
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090074 v_name = data_utils.rand_name('Volume-')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053075 metadata = {'Type': 'work'}
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103076 self.assertRaises(exceptions.BadRequest, self.client.create_volume,
77 size='0', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053078
Anju Tiwaribeab8262013-07-29 10:33:52 +053079 @attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053080 def test_get_invalid_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050081 # Negative: Should not be able to get volume with invalid id
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103082 self.assertRaises(exceptions.NotFound,
83 self.client.get_volume, '#$%%&^&^')
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_get_volume_without_passing_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050087 # Negative: Should not be able to get volume when empty ID is passed
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103088 self.assertRaises(exceptions.NotFound, self.client.get_volume, '')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053089
Anju Tiwaribeab8262013-07-29 10:33:52 +053090 @attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053091 def test_delete_invalid_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050092 # Negative: Should not be able to delete volume when invalid ID is
93 # passed
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103094 self.assertRaises(exceptions.NotFound,
95 self.client.delete_volume, '!@#$%^&*()')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053096
Anju Tiwaribeab8262013-07-29 10:33:52 +053097 @attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053098 def test_delete_volume_without_passing_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050099 # Negative: Should not be able to delete volume when empty ID is passed
Chris Yeoh8b4eaa52013-02-06 18:03:10 +1030100 self.assertRaises(exceptions.NotFound, self.client.delete_volume, '')
Matthew Treinish9e1eb972012-08-17 17:53:41 -0400101
102
Attila Fazekas19044d52013-02-16 07:35:06 +0100103class VolumesNegativeTestXML(VolumesNegativeTest):
104 _interface = "xml"