Merge "Add a skip for bug #1334368"
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 2a9b407..c5be1f3 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -142,10 +142,6 @@
_api_version = 1
-class BaseVolumeV2Test(BaseVolumeTest):
- _api_version = 2
-
-
class BaseVolumeV1AdminTest(BaseVolumeV1Test):
"""Base test case class for all Volume Admin API tests."""
@classmethod
diff --git a/tempest/api/volume/test_volumes_list.py b/tempest/api/volume/test_volumes_list.py
index e2f7a38..b8a2faa 100644
--- a/tempest/api/volume/test_volumes_list.py
+++ b/tempest/api/volume/test_volumes_list.py
@@ -23,10 +23,8 @@
LOG = logging.getLogger(__name__)
-VOLUME_FIELDS = ('id', 'display_name')
-
-class VolumesListTest(base.BaseVolumeV1Test):
+class VolumesV2ListTestJSON(base.BaseVolumeTest):
"""
This test creates a number of 1G volumes. To run successfully,
@@ -36,7 +34,7 @@
VOLUME_BACKING_FILE_SIZE is at least 4G in your localrc
"""
- _interface = 'json'
+ VOLUME_FIELDS = ('id', 'name')
def assertVolumesIn(self, fetched_list, expected_list, fields=None):
if fields:
@@ -48,7 +46,7 @@
return
def str_vol(vol):
- return "%s:%s" % (vol['id'], vol['display_name'])
+ return "%s:%s" % (vol['id'], vol[self.name])
raw_msg = "Could not find volumes %s in expected list %s; fetched %s"
self.fail(raw_msg % ([str_vol(v) for v in missing_vols],
@@ -58,8 +56,9 @@
@classmethod
@test.safe_setup
def setUpClass(cls):
- super(VolumesListTest, cls).setUpClass()
+ super(VolumesV2ListTestJSON, cls).setUpClass()
cls.client = cls.volumes_client
+ cls.name = cls.VOLUME_FIELDS[1]
# Create 3 test volumes
cls.volume_list = []
@@ -77,7 +76,7 @@
for volid in cls.volume_id_list:
resp, _ = cls.client.delete_volume(volid)
cls.client.wait_for_resource_deletion(volid)
- super(VolumesListTest, cls).tearDownClass()
+ super(VolumesV2ListTestJSON, cls).tearDownClass()
def _list_by_param_value_and_assert(self, params, with_detail=False):
"""
@@ -92,16 +91,22 @@
self.assertEqual(200, resp.status)
# Validating params of fetched volumes
- for volume in fetched_vol_list:
- for key in params:
- msg = "Failed to list volumes %s by %s" % \
- ('details' if with_detail else '', key)
- if key == 'metadata':
- self.assertThat(volume[key].items(),
- matchers.ContainsAll(params[key].items()),
- msg)
- else:
- self.assertEqual(params[key], volume[key], msg)
+ # In v2, only list detail view includes items in params.
+ # In v1, list view and list detail view are same. So the
+ # following check should be run when 'with_detail' is True
+ # or v1 tests.
+ if with_detail or self._api_version == 1:
+ for volume in fetched_vol_list:
+ for key in params:
+ msg = "Failed to list volumes %s by %s" % \
+ ('details' if with_detail else '', key)
+ if key == 'metadata':
+ self.assertThat(
+ volume[key].items(),
+ matchers.ContainsAll(params[key].items()),
+ msg)
+ else:
+ self.assertEqual(params[key], volume[key], msg)
@test.attr(type='smoke')
def test_volume_list(self):
@@ -110,7 +115,7 @@
resp, fetched_list = self.client.list_volumes()
self.assertEqual(200, resp.status)
self.assertVolumesIn(fetched_list, self.volume_list,
- fields=VOLUME_FIELDS)
+ fields=self.VOLUME_FIELDS)
@test.attr(type='gate')
def test_volume_list_with_details(self):
@@ -123,32 +128,31 @@
@test.attr(type='gate')
def test_volume_list_by_name(self):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
- params = {'display_name': volume['display_name']}
+ params = {self.name: volume[self.name]}
resp, fetched_vol = self.client.list_volumes(params)
self.assertEqual(200, resp.status)
self.assertEqual(1, len(fetched_vol), str(fetched_vol))
- self.assertEqual(fetched_vol[0]['display_name'],
- volume['display_name'])
+ self.assertEqual(fetched_vol[0][self.name],
+ volume[self.name])
@test.attr(type='gate')
def test_volume_list_details_by_name(self):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
- params = {'display_name': volume['display_name']}
+ params = {self.name: volume[self.name]}
resp, fetched_vol = self.client.list_volumes_with_detail(params)
self.assertEqual(200, resp.status)
self.assertEqual(1, len(fetched_vol), str(fetched_vol))
- self.assertEqual(fetched_vol[0]['display_name'],
- volume['display_name'])
+ self.assertEqual(fetched_vol[0][self.name],
+ volume[self.name])
@test.attr(type='gate')
def test_volumes_list_by_status(self):
params = {'status': 'available'}
resp, fetched_list = self.client.list_volumes(params)
self.assertEqual(200, resp.status)
- for volume in fetched_list:
- self.assertEqual('available', volume['status'])
+ self._list_by_param_value_and_assert(params)
self.assertVolumesIn(fetched_list, self.volume_list,
- fields=VOLUME_FIELDS)
+ fields=self.VOLUME_FIELDS)
@test.attr(type='gate')
def test_volumes_list_details_by_status(self):
@@ -166,10 +170,9 @@
params = {'availability_zone': zone}
resp, fetched_list = self.client.list_volumes(params)
self.assertEqual(200, resp.status)
- for volume in fetched_list:
- self.assertEqual(zone, volume['availability_zone'])
+ self._list_by_param_value_and_assert(params)
self.assertVolumesIn(fetched_list, self.volume_list,
- fields=VOLUME_FIELDS)
+ fields=self.VOLUME_FIELDS)
@test.attr(type='gate')
def test_volumes_list_details_by_availability_zone(self):
@@ -198,7 +201,7 @@
def test_volume_list_param_display_name_and_status(self):
# Test to list volume when display name and status param is given
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
- params = {'display_name': volume['display_name'],
+ params = {self.name: volume[self.name],
'status': 'available'}
self._list_by_param_value_and_assert(params)
@@ -206,10 +209,19 @@
def test_volume_list_with_detail_param_display_name_and_status(self):
# Test to list volume when name and status param is given
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
- params = {'display_name': volume['display_name'],
+ params = {self.name: volume[self.name],
'status': 'available'}
self._list_by_param_value_and_assert(params, with_detail=True)
-class VolumeListTestXML(VolumesListTest):
+class VolumesV2ListTestXML(VolumesV2ListTestJSON):
+ _interface = 'xml'
+
+
+class VolumesV1ListTestJSON(VolumesV2ListTestJSON):
+ _api_version = 1
+ VOLUME_FIELDS = ('id', 'display_name')
+
+
+class VolumesV1ListTestXML(VolumesV1ListTestJSON):
_interface = 'xml'
diff --git a/tempest/api/volume/v2/test_volumes_list.py b/tempest/api/volume/v2/test_volumes_list.py
index e90c957..7ca8599 100644
--- a/tempest/api/volume/v2/test_volumes_list.py
+++ b/tempest/api/volume/v2/test_volumes_list.py
@@ -13,22 +13,16 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-import operator
from tempest.api.volume import base
-from tempest.common.utils import data_utils
-from tempest.openstack.common import log as logging
from tempest import test
-from testtools import matchers
-
-LOG = logging.getLogger(__name__)
-
-VOLUME_FIELDS = ('id', 'name')
-class VolumesV2ListTestJSON(base.BaseVolumeV2Test):
+class VolumesV2ListTestJSON(base.BaseVolumeTest):
"""
+ volumes v2 specific tests.
+
This test creates a number of 1G volumes. To run successfully,
ensure that the backing file for the volume group that Nova uses
has space for at least 3 1G volumes!
@@ -36,25 +30,6 @@
VOLUME_BACKING_FILE_SIZE is at least 4G in your localrc
"""
- _interface = 'json'
-
- def assertVolumesIn(self, fetched_list, expected_list, fields=None):
- if fields:
- expected_list = map(operator.itemgetter(*fields), expected_list)
- fetched_list = map(operator.itemgetter(*fields), fetched_list)
-
- missing_vols = [v for v in expected_list if v not in fetched_list]
- if len(missing_vols) == 0:
- return
-
- def str_vol(vol):
- return "%s:%s" % (vol['id'], vol['name'])
-
- raw_msg = "Could not find volumes %s in expected list %s; fetched %s"
- self.fail(raw_msg % ([str_vol(v) for v in missing_vols],
- [str_vol(v) for v in expected_list],
- [str_vol(v) for v in fetched_list]))
-
@classmethod
@test.safe_setup
def setUpClass(cls):
@@ -79,124 +54,6 @@
cls.client.wait_for_resource_deletion(volid)
super(VolumesV2ListTestJSON, cls).tearDownClass()
- def _list_by_param_value_and_assert(self, params, expected_list=None,
- with_detail=False):
- """
- Perform list or list_details action with given params
- and validates result.
- """
- if with_detail:
- resp, fetched_vol_list = \
- self.client.list_volumes_with_detail(params=params)
- else:
- resp, fetched_vol_list = self.client.list_volumes(params=params)
-
- self.assertEqual(200, resp.status)
- if expected_list is None:
- expected_list = self.volume_list
- self.assertVolumesIn(fetched_vol_list, expected_list,
- fields=VOLUME_FIELDS)
- # Validating params of fetched volumes
- if with_detail:
- for volume in fetched_vol_list:
- for key in params:
- msg = "Failed to list volumes %s by %s" % \
- ('details' if with_detail else '', key)
- if key == 'metadata':
- self.assertThat(volume[key].items(),
- matchers.ContainsAll(
- params[key].items()), msg)
- else:
- self.assertEqual(params[key], volume[key], msg)
-
- @test.attr(type='smoke')
- def test_volume_list(self):
- # Get a list of Volumes
- # Fetch all volumes
- resp, fetched_list = self.client.list_volumes()
- self.assertEqual(200, resp.status)
- self.assertVolumesIn(fetched_list, self.volume_list,
- fields=VOLUME_FIELDS)
-
- @test.attr(type='gate')
- def test_volume_list_with_details(self):
- # Get a list of Volumes with details
- # Fetch all Volumes
- resp, fetched_list = self.client.list_volumes_with_detail()
- self.assertEqual(200, resp.status)
- self.assertVolumesIn(fetched_list, self.volume_list)
-
- @test.attr(type='gate')
- def test_volume_list_by_name(self):
- volume = self.volume_list[data_utils.rand_int_id(0, 2)]
- params = {'name': volume['name']}
- resp, fetched_vol = self.client.list_volumes(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(1, len(fetched_vol), str(fetched_vol))
- self.assertEqual(fetched_vol[0]['name'], volume['name'])
-
- @test.attr(type='gate')
- def test_volume_list_details_by_name(self):
- volume = self.volume_list[data_utils.rand_int_id(0, 2)]
- params = {'name': volume['name']}
- resp, fetched_vol = self.client.list_volumes_with_detail(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(1, len(fetched_vol), str(fetched_vol))
- self.assertEqual(fetched_vol[0]['name'], volume['name'])
-
- @test.attr(type='gate')
- def test_volumes_list_by_status(self):
- params = {'status': 'available'}
- self._list_by_param_value_and_assert(params)
-
- @test.attr(type='gate')
- def test_volumes_list_details_by_status(self):
- params = {'status': 'available'}
- self._list_by_param_value_and_assert(params, with_detail=True)
-
- @test.attr(type='gate')
- def test_volumes_list_by_availability_zone(self):
- volume = self.volume_list[data_utils.rand_int_id(0, 2)]
- zone = volume['availability_zone']
- params = {'availability_zone': zone}
- self._list_by_param_value_and_assert(params)
-
- @test.attr(type='gate')
- def test_volumes_list_details_by_availability_zone(self):
- volume = self.volume_list[data_utils.rand_int_id(0, 2)]
- zone = volume['availability_zone']
- params = {'availability_zone': zone}
- self._list_by_param_value_and_assert(params, with_detail=True)
-
- @test.attr(type='gate')
- def test_volume_list_with_param_metadata(self):
- # Test to list volumes when metadata param is given
- params = {'metadata': self.metadata}
- self._list_by_param_value_and_assert(params)
-
- @test.attr(type='gate')
- def test_volume_list_with_details_param_metadata(self):
- # Test to list volumes details when metadata param is given
- params = {'metadata': self.metadata}
- self._list_by_param_value_and_assert(params, with_detail=True)
-
- @test.attr(type='gate')
- def test_volume_list_param_display_name_and_status(self):
- # Test to list volume when display name and status param is given
- volume = self.volume_list[data_utils.rand_int_id(0, 2)]
- params = {'name': volume['name'],
- 'status': 'available'}
- self._list_by_param_value_and_assert(params, expected_list=[volume])
-
- @test.attr(type='gate')
- def test_volume_list_with_details_param_display_name_and_status(self):
- # Test to list volume when name and status param is given
- volume = self.volume_list[data_utils.rand_int_id(0, 2)]
- params = {'name': volume['name'],
- 'status': 'available'}
- self._list_by_param_value_and_assert(params, expected_list=[volume],
- with_detail=True)
-
@test.attr(type='gate')
def test_volume_list_details_with_multiple_params(self):
# List volumes detail using combined condition