blob: 5dfbad7aeb41189dec2a8e80dcf162d3d226d272 [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2012 OpenStack Foundation
Jay Pipes13b479b2012-06-11 14:52:27 -04002# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090016import uuid
17
Sean Dague1937d092013-05-17 16:36:38 -040018from tempest.api.compute import base
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090019from tempest.common.utils import data_utils
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000020from tempest import config
Matthew Treinisha83a16e2012-12-07 13:44:02 -050021from tempest import exceptions
Matthew Treinish5c660ab2014-05-18 21:14:36 -040022from tempest import test
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053023
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000024CONF = config.CONF
25
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053026
ivan-zhuf2b00502013-10-18 10:06:52 +080027class VolumesNegativeTest(base.BaseV2ComputeTest):
Attila Fazekas19044d52013-02-16 07:35:06 +010028
29 @classmethod
30 def setUpClass(cls):
31 super(VolumesNegativeTest, cls).setUpClass()
32 cls.client = cls.volumes_extensions_client
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000033 if not CONF.service_available.cinder:
Matthew Treinish4c412922013-07-16 15:27:42 -040034 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
Matthew Treinish5c660ab2014-05-18 21:14:36 -040037 @test.attr(type=['negative', 'gate'])
nayna-patel179077c2014-01-15 12:27:16 +000038 def test_volume_get_nonexistent_volume_id(self):
39 # Negative: Should not be able to get details of nonexistent volume
40 # Creating a nonexistent volume id
41 # Trying to GET a non existent volume
Chris Yeohe04628e2013-02-25 17:12:21 +103042 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
Matthew Treinish5c660ab2014-05-18 21:14:36 -040045 @test.attr(type=['negative', 'gate'])
nayna-patel179077c2014-01-15 12:27:16 +000046 def test_volume_delete_nonexistent_volume_id(self):
47 # Negative: Should not be able to delete nonexistent Volume
48 # Creating nonexistent volume id
49 # Trying to DELETE a non existent volume
Chris Yeohe04628e2013-02-25 17:12:21 +103050 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
Matthew Treinish5c660ab2014-05-18 21:14:36 -040053 @test.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
Matthew Treinish5c660ab2014-05-18 21:14:36 -040062 @test.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
Matthew Treinish5c660ab2014-05-18 21:14:36 -040071 @test.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
Matthew Treinish5c660ab2014-05-18 21:14:36 -040079 @test.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
Matthew Treinish5c660ab2014-05-18 21:14:36 -040085 @test.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
Matthew Treinish5c660ab2014-05-18 21:14:36 -040090 @test.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
Matthew Treinish5c660ab2014-05-18 21:14:36 -040097 @test.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"