blob: 50ce19815b6ff75d5c74a3924060f9676259f29d [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
Matthew Treinish01472ff2015-02-20 17:26:52 -050018from tempest_lib.common.utils import data_utils
Masayuki Igawabfa07602015-01-20 18:47:17 +090019from tempest_lib import exceptions as lib_exc
20
Sean Dague1937d092013-05-17 16:36:38 -040021from tempest.api.compute import base
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
Emily Hugenbruch8284a342014-12-11 22:04:55 +000031 def skip_checks(cls):
32 super(VolumesNegativeTest, cls).skip_checks()
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
Emily Hugenbruch8284a342014-12-11 22:04:55 +000037 @classmethod
38 def setup_clients(cls):
39 super(VolumesNegativeTest, cls).setup_clients()
40 cls.client = cls.volumes_extensions_client
41
Matthew Treinish5c660ab2014-05-18 21:14:36 -040042 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080043 @test.idempotent_id('c03ea686-905b-41a2-8748-9635154b7c57')
nayna-patel179077c2014-01-15 12:27:16 +000044 def test_volume_get_nonexistent_volume_id(self):
45 # Negative: Should not be able to get details of nonexistent volume
46 # Creating a nonexistent volume id
47 # Trying to GET a non existent volume
Masayuki Igawabfa07602015-01-20 18:47:17 +090048 self.assertRaises(lib_exc.NotFound, self.client.get_volume,
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090049 str(uuid.uuid4()))
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053050
Matthew Treinish5c660ab2014-05-18 21:14:36 -040051 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080052 @test.idempotent_id('54a34226-d910-4b00-9ef8-8683e6c55846')
nayna-patel179077c2014-01-15 12:27:16 +000053 def test_volume_delete_nonexistent_volume_id(self):
54 # Negative: Should not be able to delete nonexistent Volume
55 # Creating nonexistent volume id
56 # Trying to DELETE a non existent volume
Masayuki Igawabfa07602015-01-20 18:47:17 +090057 self.assertRaises(lib_exc.NotFound, self.client.delete_volume,
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090058 str(uuid.uuid4()))
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053059
Matthew Treinish5c660ab2014-05-18 21:14:36 -040060 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080061 @test.idempotent_id('5125ae14-152b-40a7-b3c5-eae15e9022ef')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053062 def test_create_volume_with_invalid_size(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050063 # Negative: Should not be able to create volume with invalid size
64 # in request
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090065 v_name = data_utils.rand_name('Volume-')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053066 metadata = {'Type': 'work'}
Masayuki Igawa4b29e472015-02-16 10:41:54 +090067 self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103068 size='#$%', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053069
Matthew Treinish5c660ab2014-05-18 21:14:36 -040070 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080071 @test.idempotent_id('131cb3a1-75cc-4d40-b4c3-1317f64719b0')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053072 def test_create_volume_with_out_passing_size(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050073 # Negative: Should not be able to create volume without passing size
74 # in request
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='', 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'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080081 @test.idempotent_id('8cce995e-0a83-479a-b94d-e1e40b8a09d1')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053082 def test_create_volume_with_size_zero(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050083 # Negative: Should not be able to create volume with size zero
Masayuki Igawaa2ccca02013-09-17 15:32:46 +090084 v_name = data_utils.rand_name('Volume-')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053085 metadata = {'Type': 'work'}
Masayuki Igawa4b29e472015-02-16 10:41:54 +090086 self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103087 size='0', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053088
Matthew Treinish5c660ab2014-05-18 21:14:36 -040089 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080090 @test.idempotent_id('f01904f2-e975-4915-98ce-cb5fa27bde4f')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053091 def test_get_invalid_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050092 # Negative: Should not be able to get volume with invalid id
Masayuki Igawabfa07602015-01-20 18:47:17 +090093 self.assertRaises(lib_exc.NotFound,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103094 self.client.get_volume, '#$%%&^&^')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053095
Matthew Treinish5c660ab2014-05-18 21:14:36 -040096 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080097 @test.idempotent_id('62bab09a-4c03-4617-8cca-8572bc94af9b')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053098 def test_get_volume_without_passing_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050099 # Negative: Should not be able to get volume when empty ID is passed
Masayuki Igawabfa07602015-01-20 18:47:17 +0900100 self.assertRaises(lib_exc.NotFound, self.client.get_volume, '')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +0530101
Matthew Treinish5c660ab2014-05-18 21:14:36 -0400102 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800103 @test.idempotent_id('62972737-124b-4513-b6cf-2f019f178494')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +0530104 def test_delete_invalid_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -0500105 # Negative: Should not be able to delete volume when invalid ID is
106 # passed
Masayuki Igawabfa07602015-01-20 18:47:17 +0900107 self.assertRaises(lib_exc.NotFound,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +1030108 self.client.delete_volume, '!@#$%^&*()')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +0530109
Matthew Treinish5c660ab2014-05-18 21:14:36 -0400110 @test.attr(type=['negative', 'gate'])
Chris Hoge7579c1a2015-02-26 14:12:15 -0800111 @test.idempotent_id('0d1417c5-4ae8-4c2c-adc5-5f0b864253e5')
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
Masayuki Igawabfa07602015-01-20 18:47:17 +0900114 self.assertRaises(lib_exc.NotFound, self.client.delete_volume, '')