Enable v2 api for volume and snapshot tests
For volume action tests, name field of the volume is updated with
the cinder v2 api.
For snapshot action tests,admin_snapshots_client is moved to base class
and name field of the snapshot is updated.
Partially implements: blueprint cinder-v2-api-tests
Change-Id: Iba7fd236c752ea15b73fd308ec6e3475cf42af9c
diff --git a/tempest/api/volume/admin/test_snapshots_actions.py b/tempest/api/volume/admin/test_snapshots_actions.py
index 720734b..02a2526 100644
--- a/tempest/api/volume/admin/test_snapshots_actions.py
+++ b/tempest/api/volume/admin/test_snapshots_actions.py
@@ -18,29 +18,28 @@
from tempest import test
-class SnapshotsActionsTest(base.BaseVolumeV1AdminTest):
+class SnapshotsActionsV2Test(base.BaseVolumeAdminTest):
_interface = "json"
@classmethod
def resource_setup(cls):
- super(SnapshotsActionsTest, cls).resource_setup()
+ super(SnapshotsActionsV2Test, cls).resource_setup()
cls.client = cls.snapshots_client
- # Create admin volume client
- cls.admin_snapshots_client = cls.os_adm.snapshots_client
-
# Create a test shared volume for tests
vol_name = data_utils.rand_name(cls.__name__ + '-Volume-')
+ cls.name_field = cls.special_fields['name_field']
+ params = {cls.name_field: vol_name}
_, cls.volume = \
- cls.volumes_client.create_volume(size=1, display_name=vol_name)
+ cls.volumes_client.create_volume(size=1, **params)
cls.volumes_client.wait_for_volume_status(cls.volume['id'],
'available')
# Create a test shared snapshot for tests
snap_name = data_utils.rand_name(cls.__name__ + '-Snapshot-')
+ params = {cls.name_field: snap_name}
_, cls.snapshot = \
- cls.client.create_snapshot(cls.volume['id'],
- display_name=snap_name)
+ cls.client.create_snapshot(cls.volume['id'], **params)
cls.client.wait_for_snapshot_status(cls.snapshot['id'],
'available')
@@ -54,7 +53,7 @@
cls.volumes_client.delete_volume(cls.volume['id'])
cls.volumes_client.wait_for_resource_deletion(cls.volume['id'])
- super(SnapshotsActionsTest, cls).resource_cleanup()
+ super(SnapshotsActionsV2Test, cls).resource_cleanup()
def tearDown(self):
# Set snapshot's status to available after test
@@ -62,7 +61,7 @@
snapshot_id = self.snapshot['id']
self.admin_snapshots_client.reset_snapshot_status(snapshot_id,
status)
- super(SnapshotsActionsTest, self).tearDown()
+ super(SnapshotsActionsV2Test, self).tearDown()
def _create_reset_and_force_delete_temp_snapshot(self, status=None):
# Create snapshot, reset snapshot status,
@@ -127,7 +126,11 @@
self._create_reset_and_force_delete_temp_snapshot('error_deleting')
-class SnapshotsActionsTestXML(SnapshotsActionsTest):
+class SnapshotsActionsV1Test(SnapshotsActionsV2Test):
+ _api_version = 1
+
+
+class SnapshotsActionsV1TestXML(SnapshotsActionsV1Test):
_interface = "xml"
def _get_progress_alias(self):
diff --git a/tempest/api/volume/admin/test_volumes_actions.py b/tempest/api/volume/admin/test_volumes_actions.py
index 3857fdb..1c3e04a 100644
--- a/tempest/api/volume/admin/test_volumes_actions.py
+++ b/tempest/api/volume/admin/test_volumes_actions.py
@@ -18,19 +18,21 @@
from tempest import test
-class VolumesActionsTest(base.BaseVolumeV1AdminTest):
+class VolumesActionsV2Test(base.BaseVolumeAdminTest):
_interface = "json"
@classmethod
def resource_setup(cls):
- super(VolumesActionsTest, cls).resource_setup()
+ super(VolumesActionsV2Test, cls).resource_setup()
cls.client = cls.volumes_client
# Create a test shared volume for tests
vol_name = utils.rand_name(cls.__name__ + '-Volume-')
+ cls.name_field = cls.special_fields['name_field']
+ params = {cls.name_field: vol_name}
_, cls.volume = cls.client.create_volume(size=1,
- display_name=vol_name)
+ **params)
cls.client.wait_for_volume_status(cls.volume['id'], 'available')
@classmethod
@@ -39,7 +41,7 @@
cls.client.delete_volume(cls.volume['id'])
cls.client.wait_for_resource_deletion(cls.volume['id'])
- super(VolumesActionsTest, cls).resource_cleanup()
+ super(VolumesActionsV2Test, cls).resource_cleanup()
def _reset_volume_status(self, volume_id, status):
# Reset the volume status
@@ -50,13 +52,14 @@
def tearDown(self):
# Set volume's status to available after test
self._reset_volume_status(self.volume['id'], 'available')
- super(VolumesActionsTest, self).tearDown()
+ super(VolumesActionsV2Test, self).tearDown()
def _create_temp_volume(self):
# Create a temp volume for force delete tests
vol_name = utils.rand_name('Volume')
+ params = {self.name_field: vol_name}
_, temp_volume = self.client.create_volume(size=1,
- display_name=vol_name)
+ **params)
self.client.wait_for_volume_status(temp_volume['id'], 'available')
return temp_volume
@@ -92,5 +95,9 @@
self._create_reset_and_force_delete_temp_volume('error')
-class VolumesActionsTestXML(VolumesActionsTest):
+class VolumesActionsV1Test(VolumesActionsV2Test):
+ _api_version = 1
+
+
+class VolumesActionsV1TestXML(VolumesActionsV1Test):
_interface = "xml"
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 638f76c..f9f03ac 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -175,6 +175,7 @@
cls.volume_types_client = cls.os_adm.volume_types_client
cls.admin_volume_client = cls.os_adm.volumes_client
cls.hosts_client = cls.os_adm.volume_hosts_client
+ cls.admin_snapshots_client = cls.os_adm.snapshots_client
elif cls._api_version == 2:
if not CONF.volume_feature_enabled.api_v2:
msg = "Volume API v2 is disabled"
@@ -183,6 +184,7 @@
cls.volume_types_client = cls.os_adm.volume_types_v2_client
cls.admin_volume_client = cls.os_adm.volumes_v2_client
cls.hosts_client = cls.os_adm.volume_hosts_v2_client
+ cls.admin_snapshots_client = cls.os_adm.snapshots_v2_client
@classmethod
def resource_cleanup(cls):