blob: de214fca484d0fbdf785f0f28b24fc9c272ef450 [file] [log] [blame]
Jay Pipes13b479b2012-06-11 14:52:27 -04001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2012 OpenStack, LLC
4# 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
Sean Dague1937d092013-05-17 16:36:38 -040018from tempest.api.compute import base
Jay Pipes13b479b2012-06-11 14:52:27 -040019from tempest.common.utils.data_utils import rand_name
Matthew Treinisha83a16e2012-12-07 13:44:02 -050020from tempest import exceptions
Giampaolo Lauriae9c77022013-05-22 01:23:58 -040021from tempest.test import attr
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053022
23
Attila Fazekas19044d52013-02-16 07:35:06 +010024class VolumesNegativeTest(base.BaseComputeTest):
25 _interface = 'json'
26
27 @classmethod
28 def setUpClass(cls):
29 super(VolumesNegativeTest, cls).setUpClass()
30 cls.client = cls.volumes_extensions_client
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053031
Giampaolo Lauriae9c77022013-05-22 01:23:58 -040032 @attr(type='gate')
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053033 def test_volume_get_nonexistant_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050034 # Negative: Should not be able to get details of nonexistant volume
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053035 #Creating a nonexistant volume id
36 volume_id_list = list()
37 resp, body = self.client.list_volumes()
38 for i in range(len(body)):
39 volume_id_list.append(body[i]['id'])
40 while True:
41 non_exist_id = rand_name('999')
42 if non_exist_id not in volume_id_list:
43 break
Chris Yeohe04628e2013-02-25 17:12:21 +103044 # Trying to GET a non existant volume
45 self.assertRaises(exceptions.NotFound, self.client.get_volume,
46 non_exist_id)
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053047
Giampaolo Lauriae9c77022013-05-22 01:23:58 -040048 @attr(type='gate')
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053049 def test_volume_delete_nonexistant_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050050 # Negative: Should not be able to delete nonexistant Volume
Chris Yeohe04628e2013-02-25 17:12:21 +103051 # Creating nonexistant volume id
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +053052 volume_id_list = list()
53 resp, body = self.client.list_volumes()
54 for i in range(len(body)):
55 volume_id_list.append(body[i]['id'])
56 while True:
57 non_exist_id = rand_name('999')
58 if non_exist_id not in volume_id_list:
59 break
Chris Yeohe04628e2013-02-25 17:12:21 +103060 # Trying to DELETE a non existant volume
61 self.assertRaises(exceptions.NotFound, self.client.delete_volume,
62 non_exist_id)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053063
Giampaolo Lauriae9c77022013-05-22 01:23:58 -040064 @attr(type='gate')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053065 def test_create_volume_with_invalid_size(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050066 # Negative: Should not be able to create volume with invalid size
67 # in request
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053068 v_name = rand_name('Volume-')
69 metadata = {'Type': 'work'}
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103070 self.assertRaises(exceptions.BadRequest, self.client.create_volume,
71 size='#$%', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053072
Giampaolo Lauriae9c77022013-05-22 01:23:58 -040073 @attr(type='gate')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053074 def test_create_volume_with_out_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
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053077 v_name = rand_name('Volume-')
78 metadata = {'Type': 'work'}
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103079 self.assertRaises(exceptions.BadRequest, self.client.create_volume,
80 size='', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053081
Giampaolo Lauriae9c77022013-05-22 01:23:58 -040082 @attr(type='gate')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053083 def test_create_volume_with_size_zero(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050084 # Negative: Should not be able to create volume with size zero
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053085 v_name = rand_name('Volume-')
86 metadata = {'Type': 'work'}
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103087 self.assertRaises(exceptions.BadRequest, self.client.create_volume,
88 size='0', display_name=v_name, metadata=metadata)
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053089
Giampaolo Lauriae9c77022013-05-22 01:23:58 -040090 @attr(type='gate')
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
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103093 self.assertRaises(exceptions.NotFound,
94 self.client.get_volume, '#$%%&^&^')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053095
Giampaolo Lauriae9c77022013-05-22 01:23:58 -040096 @attr(type='gate')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053097 def test_get_volume_without_passing_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050098 # Negative: Should not be able to get volume when empty ID is passed
Chris Yeoh8b4eaa52013-02-06 18:03:10 +103099 self.assertRaises(exceptions.NotFound, self.client.get_volume, '')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +0530100
Giampaolo Lauriae9c77022013-05-22 01:23:58 -0400101 @attr(type='gate')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +0530102 def test_delete_invalid_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -0500103 # Negative: Should not be able to delete volume when invalid ID is
104 # passed
Chris Yeoh8b4eaa52013-02-06 18:03:10 +1030105 self.assertRaises(exceptions.NotFound,
106 self.client.delete_volume, '!@#$%^&*()')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +0530107
Giampaolo Lauriae9c77022013-05-22 01:23:58 -0400108 @attr(type='gate')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +0530109 def test_delete_volume_without_passing_volume_id(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -0500110 # Negative: Should not be able to delete volume when empty ID is passed
Chris Yeoh8b4eaa52013-02-06 18:03:10 +1030111 self.assertRaises(exceptions.NotFound, self.client.delete_volume, '')
Matthew Treinish9e1eb972012-08-17 17:53:41 -0400112
113
Attila Fazekas19044d52013-02-16 07:35:06 +0100114class VolumesNegativeTestXML(VolumesNegativeTest):
115 _interface = "xml"