blob: 87f7d8a493ce49936023bde4a1c3b3891e09c53e [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
Sean Dague1937d092013-05-17 16:36:38 -040016from tempest.api.compute import base
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000017from tempest import config
Ken'ichi Ohmichi757833a2017-03-10 10:30:30 -080018from tempest.lib.common.utils import data_utils
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080019from tempest.lib import decorators
Andrea Frittoli (andreaf)db9672e2016-02-23 14:07:24 -050020from tempest.lib import exceptions as lib_exc
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053021
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000022CONF = config.CONF
23
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053024
ivan-zhuf2b00502013-10-18 10:06:52 +080025class VolumesNegativeTest(base.BaseV2ComputeTest):
Attila Fazekas19044d52013-02-16 07:35:06 +010026
Felipe Monteiroa40e9b72017-05-05 17:47:10 +010027 # These tests will fail with a 404 starting from microversion 2.36. For
28 # more information, see:
29 # https://developer.openstack.org/api-ref/compute/#volume-extension-os-volumes-os-snapshots-deprecated
30 max_microversion = '2.35'
31
Attila Fazekas19044d52013-02-16 07:35:06 +010032 @classmethod
Emily Hugenbruch8284a342014-12-11 22:04:55 +000033 def skip_checks(cls):
34 super(VolumesNegativeTest, cls).skip_checks()
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000035 if not CONF.service_available.cinder:
Matthew Treinish4c412922013-07-16 15:27:42 -040036 skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
37 raise cls.skipException(skip_msg)
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053038
Emily Hugenbruch8284a342014-12-11 22:04:55 +000039 @classmethod
40 def setup_clients(cls):
41 super(VolumesNegativeTest, cls).setup_clients()
42 cls.client = cls.volumes_extensions_client
43
Jordan Pittier3b46d272017-04-12 16:17:28 +020044 @decorators.attr(type=['negative'])
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080045 @decorators.idempotent_id('c03ea686-905b-41a2-8748-9635154b7c57')
nayna-patel179077c2014-01-15 12:27:16 +000046 def test_volume_get_nonexistent_volume_id(self):
47 # Negative: Should not be able to get details of nonexistent volume
48 # Creating a nonexistent volume id
49 # Trying to GET a non existent volume
Ken'ichi Ohmichi5f448a52015-07-01 06:26:30 +000050 self.assertRaises(lib_exc.NotFound, self.client.show_volume,
Ken'ichi Ohmichid079c892016-04-19 11:23:36 -070051 data_utils.rand_uuid())
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053052
Jordan Pittier3b46d272017-04-12 16:17:28 +020053 @decorators.attr(type=['negative'])
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080054 @decorators.idempotent_id('54a34226-d910-4b00-9ef8-8683e6c55846')
nayna-patel179077c2014-01-15 12:27:16 +000055 def test_volume_delete_nonexistent_volume_id(self):
56 # Negative: Should not be able to delete nonexistent Volume
57 # Creating nonexistent volume id
58 # Trying to DELETE a non existent volume
Masayuki Igawabfa07602015-01-20 18:47:17 +090059 self.assertRaises(lib_exc.NotFound, self.client.delete_volume,
Ken'ichi Ohmichid079c892016-04-19 11:23:36 -070060 data_utils.rand_uuid())
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053061
Jordan Pittier3b46d272017-04-12 16:17:28 +020062 @decorators.attr(type=['negative'])
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080063 @decorators.idempotent_id('5125ae14-152b-40a7-b3c5-eae15e9022ef')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053064 def test_create_volume_with_invalid_size(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050065 # Negative: Should not be able to create volume with invalid size
66 # in request
zhuflc6ce5392016-08-17 14:34:37 +080067 v_name = data_utils.rand_name(self.__class__.__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
Jordan Pittier3b46d272017-04-12 16:17:28 +020072 @decorators.attr(type=['negative'])
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080073 @decorators.idempotent_id('131cb3a1-75cc-4d40-b4c3-1317f64719b0')
zhufle2fb43e2016-11-24 10:52:16 +080074 def test_create_volume_without_passing_size(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050075 # Negative: Should not be able to create volume without passing size
76 # in request
zhuflc6ce5392016-08-17 14:34:37 +080077 v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053078 metadata = {'Type': 'work'}
Masayuki Igawa4b29e472015-02-16 10:41:54 +090079 self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103080 size='', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053081
Jordan Pittier3b46d272017-04-12 16:17:28 +020082 @decorators.attr(type=['negative'])
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080083 @decorators.idempotent_id('8cce995e-0a83-479a-b94d-e1e40b8a09d1')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053084 def test_create_volume_with_size_zero(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050085 # Negative: Should not be able to create volume with size zero
zhuflc6ce5392016-08-17 14:34:37 +080086 v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053087 metadata = {'Type': 'work'}
Masayuki Igawa4b29e472015-02-16 10:41:54 +090088 self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103089 size='0', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053090
Jordan Pittier3b46d272017-04-12 16:17:28 +020091 @decorators.attr(type=['negative'])
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080092 @decorators.idempotent_id('62bab09a-4c03-4617-8cca-8572bc94af9b')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053093 def test_get_volume_without_passing_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050094 # Negative: Should not be able to get volume when empty ID is passed
Ken'ichi Ohmichi5f448a52015-07-01 06:26:30 +000095 self.assertRaises(lib_exc.NotFound, self.client.show_volume, '')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053096
Jordan Pittier3b46d272017-04-12 16:17:28 +020097 @decorators.attr(type=['negative'])
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080098 @decorators.idempotent_id('62972737-124b-4513-b6cf-2f019f178494')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053099 def test_delete_invalid_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -0500100 # Negative: Should not be able to delete volume when invalid ID is
101 # passed
Masayuki Igawabfa07602015-01-20 18:47:17 +0900102 self.assertRaises(lib_exc.NotFound,
ghanshyam9e294c42017-01-12 06:52:41 +0000103 self.client.delete_volume,
104 data_utils.rand_name('invalid'))
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +0530105
Jordan Pittier3b46d272017-04-12 16:17:28 +0200106 @decorators.attr(type=['negative'])
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -0800107 @decorators.idempotent_id('0d1417c5-4ae8-4c2c-adc5-5f0b864253e5')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +0530108 def test_delete_volume_without_passing_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -0500109 # Negative: Should not be able to delete volume when empty ID is passed
Masayuki Igawabfa07602015-01-20 18:47:17 +0900110 self.assertRaises(lib_exc.NotFound, self.client.delete_volume, '')