Add XML support to the volumes tests.
Change-Id: I3fb52c452d0c8e0472e3791a7c365972b5a3fbf3
Signed-off-by: Matthew Treinish <treinish@linux.vnet.ibm.com>
diff --git a/tempest/tests/compute/test_volumes_get.py b/tempest/tests/compute/test_volumes_get.py
index cda943d..fcdec96 100644
--- a/tempest/tests/compute/test_volumes_get.py
+++ b/tempest/tests/compute/test_volumes_get.py
@@ -18,21 +18,16 @@
from nose.plugins.attrib import attr
from tempest.common.utils.data_utils import rand_name
-from tempest.tests.compute.base import BaseComputeTest
+from tempest.tests.compute import base
-class VolumesGetTest(BaseComputeTest):
-
- @classmethod
- def setUpClass(cls):
- super(VolumesGetTest, cls).setUpClass()
- cls.client = cls.volumes_extensions_client
+class VolumesGetTestBase(object):
@attr(type='smoke')
def test_volume_create_get_delete(self):
"""CREATE, GET, DELETE Volume"""
try:
- v_name = rand_name('Volume-')
+ v_name = rand_name('Volume-%s-') % self._interface
metadata = {'Type': 'work'}
#Create volume
resp, volume = self.client.create_volume(size=1,
@@ -93,3 +88,21 @@
#Delete the Volume created in this method
resp, _ = self.client.delete_volume(volume['id'])
self.assertEqual(202, resp.status)
+ #Checking if the deleted Volume still exists
+ self.client.wait_for_resource_deletion(volume['id'])
+
+
+class VolumesGetTestXML(base.BaseComputeTestXML, VolumesGetTestBase):
+ @classmethod
+ def setUpClass(cls):
+ cls._interface = "xml"
+ super(VolumesGetTestXML, cls).setUpClass()
+ cls.client = cls.volumes_extensions_client
+
+
+class VolumesGetTestJSON(base.BaseComputeTestJSON, VolumesGetTestBase):
+ @classmethod
+ def setUpClass(cls):
+ cls._interface = "json"
+ super(VolumesGetTestJSON, cls).setUpClass()
+ cls.client = cls.volumes_extensions_client
diff --git a/tempest/tests/compute/test_volumes_list.py b/tempest/tests/compute/test_volumes_list.py
index 679a23b..3f03996 100644
--- a/tempest/tests/compute/test_volumes_list.py
+++ b/tempest/tests/compute/test_volumes_list.py
@@ -18,10 +18,10 @@
import nose
from tempest.common.utils.data_utils import rand_name
-from tempest.tests.compute.base import BaseComputeTest
+from tempest.tests.compute import base
-class VolumesListTest(BaseComputeTest):
+class VolumesTestBase(object):
"""
This test creates a number of 1G volumes. To run successfully,
@@ -31,9 +31,40 @@
VOLUME_BACKING_FILE_SIZE is atleast 4G in your localrc
"""
+ def test_volume_list(self):
+ """Should return the list of Volumes"""
+ # Fetch all Volumes
+ resp, fetched_list = self.client.list_volumes()
+ self.assertEqual(200, resp.status)
+ # Now check if all the Volumes created in setup are in fetched list
+ missing_volumes = \
+ [v for v in self.volume_list if v not in fetched_list]
+
+ self.assertFalse(missing_volumes,
+ "Failed to find volume %s in fetched list"
+ % ', '.join(m_vol['displayName']
+ for m_vol in missing_volumes))
+
+ def test_volume_list_with_details(self):
+ """Should return the list of Volumes with details"""
+ #Fetch all Volumes
+ resp, fetched_list = self.client.list_volumes_with_detail()
+ self.assertEqual(200, resp.status)
+ #Now check if all the Volumes created in setup are in fetched list
+ missing_volumes = \
+ [v for v in self.volume_list if v not in fetched_list]
+
+ self.assertFalse(missing_volumes,
+ "Failed to find volume %s in fetched list"
+ % ', '.join(m_vol['displayName']
+ for m_vol in missing_volumes))
+
+
+class VolumesTestXML(base.BaseComputeTestXML, VolumesTestBase):
@classmethod
def setUpClass(cls):
- super(VolumesListTest, cls).setUpClass()
+ cls._interface = 'xml'
+ super(VolumesTestXML, cls).setUpClass()
cls.client = cls.volumes_extensions_client
# Create 3 Volumes
cls.volume_list = list()
@@ -41,10 +72,11 @@
for i in range(3):
v_name = rand_name('volume')
metadata = {'Type': 'work'}
+ v_name += cls._interface
try:
resp, volume = cls.client.create_volume(size=1,
- display_name=v_name,
- metadata=metadata)
+ display_name=v_name,
+ metadata=metadata)
cls.client.wait_for_volume_status(volume['id'],
'available')
resp, volume = cls.client.get_volume(volume['id'])
@@ -71,30 +103,52 @@
# Delete the created Volumes
for volume in cls.volume_list:
resp, _ = cls.client.delete_volume(volume['id'])
- super(VolumesListTest, cls).tearDownClass()
+ cls.client.wait_for_resource_deletion(volume['id'])
+ super(VolumesTestXML, cls).tearDownClass()
- def test_volume_list(self):
- """Should return the list of Volumes"""
- # Fetch all Volumes
- resp, fetched_list = self.client.list_volumes()
- self.assertEqual(200, resp.status)
- # Now check if all the Volumes created in setup are in fetched list
- missing_volumes =\
- [v for v in self.volume_list if v not in fetched_list]
- self.assertFalse(missing_volumes,
- "Failed to find volume %s in fetched list"
- % ', '.join(m_vol['displayName']
- for m_vol in missing_volumes))
- def test_volume_list_with_details(self):
- """Should return the list of Volumes with details"""
- #Fetch all Volumes
- resp, fetched_list = self.client.list_volumes_with_detail()
- self.assertEqual(200, resp.status)
- #Now check if all the Volumes created in setup are in fetched list
- missing_volumes =\
- [v for v in self.volume_list if v not in fetched_list]
- self.assertFalse(missing_volumes,
- "Failed to find volume %s in fetched list"
- % ', '.join(m_vol['displayName']
- for m_vol in missing_volumes))
+class VolumesTestJSON(base.BaseComputeTestJSON, VolumesTestBase):
+ @classmethod
+ def setUpClass(cls):
+ cls._interface = 'json'
+ super(VolumesTestJSON, cls).setUpClass()
+ cls.client = cls.volumes_extensions_client
+ # Create 3 Volumes
+ cls.volume_list = []
+ cls.volume_id_list = []
+ for i in range(3):
+ v_name = rand_name('volume-%s')
+ metadata = {'Type': 'work'}
+ v_name += cls._interface
+ try:
+ resp, volume = cls.client.create_volume(size=1,
+ display_name=v_name,
+ metadata=metadata)
+ cls.client.wait_for_volume_status(volume['id'],
+ 'available')
+ resp, volume = cls.client.get_volume(volume['id'])
+ cls.volume_list.append(volume)
+ cls.volume_id_list.append(volume['id'])
+ except:
+ if cls.volume_list:
+ # We could not create all the volumes, though we were able
+ # to create *some* of the volumes. This is typically
+ # because the backing file size of the volume group is
+ # too small. So, here, we clean up whatever we did manage
+ # to create and raise a SkipTest
+ for volume in cls.volume_list:
+ cls.client.delete_volume(volume)
+ msg = ("Failed to create ALL necessary volumes to run "
+ "test. This typically means that the backing file "
+ "size of the nova-volumes group is too small to "
+ "create the 3 volumes needed by this test case")
+ raise nose.SkipTest(msg)
+ raise
+
+ @classmethod
+ def tearDownClass(cls):
+ # Delete the created Volumes
+ for volume in cls.volume_list:
+ resp, _ = cls.client.delete_volume(volume['id'])
+ cls.client.wait_for_resource_deletion(volume['id'])
+ super(VolumesTestJSON, cls).tearDownClass()
diff --git a/tempest/tests/compute/test_volumes_negative.py b/tempest/tests/compute/test_volumes_negative.py
index ea2811c..5c93f07 100644
--- a/tempest/tests/compute/test_volumes_negative.py
+++ b/tempest/tests/compute/test_volumes_negative.py
@@ -20,15 +20,10 @@
from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
-from tempest.tests.compute.base import BaseComputeTest
+from tempest.tests.compute import base
-class VolumesNegativeTest(BaseComputeTest):
-
- @classmethod
- def setUpClass(cls):
- super(VolumesNegativeTest, cls).setUpClass()
- cls.client = cls.volumes_extensions_client
+class VolumesNegativeTestBase(object):
@attr(type='negative')
def test_volume_get_nonexistant_volume_id(self):
@@ -140,3 +135,21 @@
Negative: Should not be able to delete volume when empty ID is passed
"""
resp, volume = self.client.delete_volume('')
+
+
+class VolumesNegativeTestXML(base.BaseComputeTestXML,
+ VolumesNegativeTestBase):
+ @classmethod
+ def setUpClass(cls):
+ cls._interface = "xml"
+ super(VolumesNegativeTestXML, cls).setUpClass()
+ cls.client = cls.volumes_extensions_client
+
+
+class VolumesNegativeTestJSON(base.BaseComputeTestJSON,
+ VolumesNegativeTestBase):
+ @classmethod
+ def setUpClass(cls):
+ cls._interface = "json"
+ super(VolumesNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.volumes_extensions_client