blob: ed54aaf16097fbd5d9be6cee29545185ace2a59c [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
Masayuki Igawabfa07602015-01-20 18:47:17 +090018from tempest_lib import exceptions as lib_exc
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 Treinishb0a78fc2014-01-29 16:49:12 +000022from tempest import config
Matthew Treinish5c660ab2014-05-18 21:14:36 -040023from tempest import test
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053024
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000025CONF = config.CONF
26
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053027
ivan-zhuf2b00502013-10-18 10:06:52 +080028class VolumesNegativeTest(base.BaseV2ComputeTest):
Attila Fazekas19044d52013-02-16 07:35:06 +010029
30 @classmethod
Andrea Frittoli50bb80d2014-09-15 12:34:27 +010031 def resource_setup(cls):
32 super(VolumesNegativeTest, cls).resource_setup()
Attila Fazekas19044d52013-02-16 07:35:06 +010033 cls.client = cls.volumes_extensions_client
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000034 if not CONF.service_available.cinder:
Matthew Treinish4c412922013-07-16 15:27:42 -040035 skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
36 raise cls.skipException(skip_msg)
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053037
Matthew Treinish5c660ab2014-05-18 21:14:36 -040038 @test.attr(type=['negative', 'gate'])
nayna-patel179077c2014-01-15 12:27:16 +000039 def test_volume_get_nonexistent_volume_id(self):
40 # Negative: Should not be able to get details of nonexistent volume
41 # Creating a nonexistent volume id
42 # Trying to GET a non existent volume
Masayuki Igawabfa07602015-01-20 18:47:17 +090043 self.assertRaises(lib_exc.NotFound, self.client.get_volume,
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090044 str(uuid.uuid4()))
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053045
Matthew Treinish5c660ab2014-05-18 21:14:36 -040046 @test.attr(type=['negative', 'gate'])
nayna-patel179077c2014-01-15 12:27:16 +000047 def test_volume_delete_nonexistent_volume_id(self):
48 # Negative: Should not be able to delete nonexistent Volume
49 # Creating nonexistent volume id
50 # Trying to DELETE a non existent volume
Masayuki Igawabfa07602015-01-20 18:47:17 +090051 self.assertRaises(lib_exc.NotFound, self.client.delete_volume,
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090052 str(uuid.uuid4()))
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053053
Matthew Treinish5c660ab2014-05-18 21:14:36 -040054 @test.attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053055 def test_create_volume_with_invalid_size(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050056 # Negative: Should not be able to create volume with invalid size
57 # in request
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090058 v_name = data_utils.rand_name('Volume-')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053059 metadata = {'Type': 'work'}
Masayuki Igawa4b29e472015-02-16 10:41:54 +090060 self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103061 size='#$%', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053062
Matthew Treinish5c660ab2014-05-18 21:14:36 -040063 @test.attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053064 def test_create_volume_with_out_passing_size(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050065 # Negative: Should not be able to create volume without passing size
66 # in request
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090067 v_name = data_utils.rand_name('Volume-')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053068 metadata = {'Type': 'work'}
Masayuki Igawa4b29e472015-02-16 10:41:54 +090069 self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103070 size='', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053071
Matthew Treinish5c660ab2014-05-18 21:14:36 -040072 @test.attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053073 def test_create_volume_with_size_zero(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050074 # Negative: Should not be able to create volume with size zero
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090075 v_name = data_utils.rand_name('Volume-')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053076 metadata = {'Type': 'work'}
Masayuki Igawa4b29e472015-02-16 10:41:54 +090077 self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103078 size='0', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053079
Matthew Treinish5c660ab2014-05-18 21:14:36 -040080 @test.attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053081 def test_get_invalid_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050082 # Negative: Should not be able to get volume with invalid id
Masayuki Igawabfa07602015-01-20 18:47:17 +090083 self.assertRaises(lib_exc.NotFound,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103084 self.client.get_volume, '#$%%&^&^')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053085
Matthew Treinish5c660ab2014-05-18 21:14:36 -040086 @test.attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053087 def test_get_volume_without_passing_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050088 # Negative: Should not be able to get volume when empty ID is passed
Masayuki Igawabfa07602015-01-20 18:47:17 +090089 self.assertRaises(lib_exc.NotFound, self.client.get_volume, '')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053090
Matthew Treinish5c660ab2014-05-18 21:14:36 -040091 @test.attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053092 def test_delete_invalid_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050093 # Negative: Should not be able to delete volume when invalid ID is
94 # passed
Masayuki Igawabfa07602015-01-20 18:47:17 +090095 self.assertRaises(lib_exc.NotFound,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103096 self.client.delete_volume, '!@#$%^&*()')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053097
Matthew Treinish5c660ab2014-05-18 21:14:36 -040098 @test.attr(type=['negative', 'gate'])
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053099 def test_delete_volume_without_passing_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -0500100 # Negative: Should not be able to delete volume when empty ID is passed
Masayuki Igawabfa07602015-01-20 18:47:17 +0900101 self.assertRaises(lib_exc.NotFound, self.client.delete_volume, '')