blob: 5346b06f3047f3498cb9827aaecd1688306221d1 [file] [log] [blame]
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +05301from nose.plugins.attrib import attr
2import unittest2 as unittest
3from tempest import openstack
4from tempest.common.utils.data_utils import rand_name
5from tempest import exceptions
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +05306from nose.tools import raises
rajalakshmi-ganesanddd9e0e2012-03-21 00:49:22 +05307
8
9class VolumesTest(unittest.TestCase):
10
11 @classmethod
12 def setUpClass(cls):
13 cls.os = openstack.Manager()
14 cls.client = cls.os.volumes_client
15
16 @attr(type='negative')
17 def test_volume_get_nonexistant_volume_id(self):
18 """Negative: Should not be able to get details of nonexistant volume"""
19 #Creating a nonexistant volume id
20 volume_id_list = list()
21 resp, body = self.client.list_volumes()
22 for i in range(len(body)):
23 volume_id_list.append(body[i]['id'])
24 while True:
25 non_exist_id = rand_name('999')
26 if non_exist_id not in volume_id_list:
27 break
28 #Trying to GET a non existant volume
29 try:
30 resp, body = self.client.get_volume(non_exist_id)
31 except exceptions.NotFound:
32 pass
33 else:
34 self.fail('Should not be able to GET the details from a '
35 'nonexistant volume')
36
37 @attr(type='negative')
38 def test_volume_delete_nonexistant_volume_id(self):
39 """Negative: Should not be able to delete nonexistant Volume"""
40 #Creating nonexistant volume id
41 volume_id_list = list()
42 resp, body = self.client.list_volumes()
43 for i in range(len(body)):
44 volume_id_list.append(body[i]['id'])
45 while True:
46 non_exist_id = rand_name('999')
47 if non_exist_id not in volume_id_list:
48 break
49 #Trying to DELETE a non existant volume
50 try:
51 resp, body = self.client.delete_volume(non_exist_id)
52 except exceptions.NotFound:
53 pass
54 else:
55 self.fail('Should not be able to DELETE a nonexistant volume')
rajalakshmi-ganesan5894d512012-05-31 19:00:36 +053056
57 @unittest.skip('Until bug 1006857 is fixed.')
58 @raises(exceptions.BadRequest)
59 @attr(type='negative')
60 def test_create_volume_with_invalid_size(self):
61 """
62 Negative: Should not be able to create volume with invalid size
63 in request
64 """
65 v_name = rand_name('Volume-')
66 metadata = {'Type': 'work'}
67 resp, volume = self.client.create_volume(size='#$%',
68 display_name=v_name,
69 metadata=metadata)
70
71 @unittest.skip('Until bug 1006857 is fixed.')
72 @raises(exceptions.BadRequest)
73 @attr(type='negative')
74 def test_create_volume_with_out_passing_size(self):
75 """
76 Negative: Should not be able to create volume without passing size
77 in request
78 """
79 v_name = rand_name('Volume-')
80 metadata = {'Type': 'work'}
81 resp, volume = self.client.create_volume(size='',
82 display_name=v_name,
83 metadata=metadata)
84
85 @unittest.skip('Until bug 1006875 is fixed.')
86 @raises(exceptions.BadRequest)
87 @attr(type='negative')
88 def test_create_volume_with_size_zero(self):
89 """
90 Negative: Should not be able to create volume with size zero
91 """
92 v_name = rand_name('Volume-')
93 metadata = {'Type': 'work'}
94 resp, volume = self.client.create_volume(size='0',
95 display_name=v_name,
96 metadata=metadata)
97
98 @raises(exceptions.NotFound)
99 @attr(type='negative')
100 def test_get_invalid_volume_id(self):
101 """
102 Negative: Should not be able to get volume with invalid id
103 """
104 resp, volume = self.client.get_volume('#$%%&^&^')
105
106 @raises(exceptions.NotFound)
107 @attr(type='negative')
108 def test_get_volume_without_passing_volume_id(self):
109 """
110 Negative: Should not be able to get volume when empty ID is passed
111 """
112 resp, volume = self.client.get_volume('')
113
114 @raises(exceptions.NotFound)
115 @attr(type='negative')
116 def test_delete_invalid_volume_id(self):
117 """
118 Negative: Should not be able to delete volume when invalid ID is passed
119 """
120 resp, volume = self.client.delete_volume('!@#$%^&*()')
121
122 @raises(exceptions.NotFound)
123 @attr(type='negative')
124 def test_delete_volume_without_passing_volume_id(self):
125 """
126 Negative: Should not be able to delete volume when empty ID is passed
127 """
128 resp, volume = self.client.delete_volume('')