blob: 01ce394e691ba53424a0eafc555559b7bee7f3da [file] [log] [blame]
rajalakshmi-ganesanb4465572012-03-22 01:22:50 +05301from nose.plugins.attrib import attr
2import unittest2 as unittest
3from tempest import openstack
4from tempest.common.utils.data_utils import rand_name
5
6
7class VolumesTest(unittest.TestCase):
8
9 @classmethod
10 def setUpClass(cls):
11 cls.os = openstack.Manager()
12 cls.client = cls.os.volumes_client
13 #Create 3 Volumes
14 cls.volume_list = list()
15 cls.volume_id_list = list()
16 for i in range(3):
17 v_name = rand_name('Name-')
18 metadata = {'Type': 'work'}
19 resp, volume = cls.client.create_volume(size=1,
20 display_name=v_name,
21 metadata=metadata)
22 cls.client.wait_for_volume_status(volume['id'],
23 'available')
24 resp, volume = cls.client.get_volume(volume['id'])
25 cls.volume_list.append(volume)
26 cls.volume_id_list.append(volume['id'])
27
saradpatel629c7442012-04-26 00:13:42 -070028 @classmethod
29 def tearDownClass(cls):
rajalakshmi-ganesanb4465572012-03-22 01:22:50 +053030 #Delete the created Volumes
31 for i in range(3):
32 resp, _ = cls.client.delete_volume(cls.volume_id_list[i])
33
34 @attr(type='smoke')
35 def test_volume_list(self):
36 """Should return the list of Volumes"""
37 #Fetch all Volumes
38 resp, fetched_list = self.client.list_volumes()
39 self.assertEqual(200, resp.status)
40 #Now check if all the Volumes created in setup are in fetched list
41 missing_volumes =\
42 [v for v in self.volume_list if v not in fetched_list]
43 self.assertFalse(missing_volumes,
44 "Failed to find volume %s in fetched list"
45 % ', '.join(m_vol['displayName']
46 for m_vol in missing_volumes))
47
48 @attr(type='smoke')
49 def test_volume_list_with_details(self):
50 """Should return the list of Volumes with details"""
51 #Fetch all Volumes
52 resp, fetched_list = self.client.list_volumes_with_detail()
53 self.assertEqual(200, resp.status)
54 #Now check if all the Volumes created in setup are in fetched list
55 missing_volumes =\
56 [v for v in self.volume_list if v not in fetched_list]
57 self.assertFalse(missing_volumes,
58 "Failed to find volume %s in fetched list"
59 % ', '.join(m_vol['displayName']
60 for m_vol in missing_volumes))