Add tests for "new" Transfers API (mv 3.55)

Add a client and test class for Block Storage API v3.55

Change-Id: I4179799bc40a50bdbeecaee461d32e827269cc1f
This commit is contained in:
Brian Rosmaita 2021-05-06 18:01:05 -04:00
parent 34df1e10d3
commit cafd2d1656
7 changed files with 73 additions and 10 deletions

View File

@ -463,3 +463,7 @@ Microversion tests implemented in Tempest
* `3.20`_ * `3.20`_
.. _3.20: https://docs.openstack.org/cinder/latest/contributor/api_microversion_history.html#id19 .. _3.20: https://docs.openstack.org/cinder/latest/contributor/api_microversion_history.html#id19
* `3.55`_
.. _3.55: https://docs.openstack.org/cinder/latest/contributor/api_microversion_history.html#maximum-in-rocky

View File

@ -0,0 +1,8 @@
---
features:
- |
Add a ``TransfersV355Client`` to the volume v3 ``transfer_client`` library
supporting create, list, show, delete, and accept operations for the `new
Volume Transfers API
<https://docs.openstack.org/api-ref/block-storage/v3/#volume-transfers-volume-transfers-3-55-or-later>`_
of the Block Storage API v3. The min_microversion of this API is 3.55.

View File

@ -104,3 +104,30 @@ class VolumesTransfersTest(base.BaseVolumeTest):
self.client.delete_volume_transfer(transfer_id) self.client.delete_volume_transfer(transfer_id)
waiters.wait_for_volume_resource_status( waiters.wait_for_volume_resource_status(
self.volumes_client, volume['id'], 'available') self.volumes_client, volume['id'], 'available')
class VolumesTransfersV355Test(VolumesTransfersTest):
"""Test volume transfer for the "new" Transfers API mv 3.55"""
min_microversion = '3.55'
max_microversion = 'latest'
credentials = ['primary', 'alt', 'admin']
@classmethod
def setup_clients(cls):
super(VolumesTransfersV355Test, cls).setup_clients()
cls.client = cls.os_primary.volume_transfers_mv355_client_latest
cls.alt_client = cls.os_alt.volume_transfers_mv355_client_latest
@decorators.idempotent_id('9f36bb2b-619f-4507-b246-76aeb9a28851')
def test_create_get_list_accept_volume_transfer(self):
"""Test create, get, list, accept with volume-transfers API mv 3.55"""
super(VolumesTransfersV355Test, self). \
test_create_get_list_accept_volume_transfer()
@decorators.idempotent_id('af4a5b97-0859-4f31-aa3c-85b05bb63322')
def test_create_list_delete_volume_transfer(self):
"""Test create, list, delete with volume-transfers API mv 3.55"""
super(VolumesTransfersV355Test, self). \
test_create_list_delete_volume_transfer()

View File

@ -264,6 +264,8 @@ class Manager(clients.ServiceClients):
self.volume_v3.SchedulerStatsClient() self.volume_v3.SchedulerStatsClient()
self.volume_transfers_client_latest = \ self.volume_transfers_client_latest = \
self.volume_v3.TransfersClient() self.volume_v3.TransfersClient()
self.volume_transfers_mv355_client_latest = \
self.volume_v3.TransfersV355Client()
self.volume_availability_zone_client_latest = \ self.volume_availability_zone_client_latest = \
self.volume_v3.AvailabilityZoneClient() self.volume_v3.AvailabilityZoneClient()
self.volume_limits_client_latest = self.volume_v3.LimitsClient() self.volume_limits_client_latest = self.volume_v3.LimitsClient()

View File

@ -39,6 +39,7 @@ from tempest.lib.services.volume.v3.snapshot_manage_client import \
SnapshotManageClient SnapshotManageClient
from tempest.lib.services.volume.v3.snapshots_client import SnapshotsClient from tempest.lib.services.volume.v3.snapshots_client import SnapshotsClient
from tempest.lib.services.volume.v3.transfers_client import TransfersClient from tempest.lib.services.volume.v3.transfers_client import TransfersClient
from tempest.lib.services.volume.v3.transfers_client import TransfersV355Client
from tempest.lib.services.volume.v3.types_client import TypesClient from tempest.lib.services.volume.v3.types_client import TypesClient
from tempest.lib.services.volume.v3.versions_client import VersionsClient from tempest.lib.services.volume.v3.versions_client import VersionsClient
from tempest.lib.services.volume.v3.volume_manage_client import \ from tempest.lib.services.volume.v3.volume_manage_client import \
@ -50,5 +51,6 @@ __all__ = ['AttachmentsClient', 'AvailabilityZoneClient', 'BackupsClient',
'GroupsClient', 'HostsClient', 'LimitsClient', 'MessagesClient', 'GroupsClient', 'HostsClient', 'LimitsClient', 'MessagesClient',
'QosSpecsClient', 'QuotaClassesClient', 'QuotasClient', 'QosSpecsClient', 'QuotaClassesClient', 'QuotasClient',
'SchedulerStatsClient', 'ServicesClient', 'SnapshotManageClient', 'SchedulerStatsClient', 'ServicesClient', 'SnapshotManageClient',
'SnapshotsClient', 'TransfersClient', 'TypesClient', 'SnapshotsClient', 'TransfersClient', 'TransfersV355Client',
'VersionsClient', 'VolumeManageClient', 'VolumesClient'] 'TypesClient', 'VersionsClient', 'VolumeManageClient',
'VolumesClient']

View File

@ -24,6 +24,8 @@ from tempest.lib.common import rest_client
class TransfersClient(rest_client.RestClient): class TransfersClient(rest_client.RestClient):
"""Client class to send CRUD Volume Transfer API requests""" """Client class to send CRUD Volume Transfer API requests"""
resource_path = 'os-volume-transfer'
def create_volume_transfer(self, **kwargs): def create_volume_transfer(self, **kwargs):
"""Create a volume transfer. """Create a volume transfer.
@ -32,14 +34,14 @@ class TransfersClient(rest_client.RestClient):
https://docs.openstack.org/api-ref/block-storage/v3/index.html#create-a-volume-transfer https://docs.openstack.org/api-ref/block-storage/v3/index.html#create-a-volume-transfer
""" """
post_body = json.dumps({'transfer': kwargs}) post_body = json.dumps({'transfer': kwargs})
resp, body = self.post('os-volume-transfer', post_body) resp, body = self.post(self.resource_path, post_body)
body = json.loads(body) body = json.loads(body)
self.validate_response(schema.create_volume_transfer, resp, body) self.validate_response(schema.create_volume_transfer, resp, body)
return rest_client.ResponseBody(resp, body) return rest_client.ResponseBody(resp, body)
def show_volume_transfer(self, transfer_id): def show_volume_transfer(self, transfer_id):
"""Returns the details of a volume transfer.""" """Returns the details of a volume transfer."""
url = "os-volume-transfer/%s" % transfer_id url = "%s/%s" % (self.resource_path, transfer_id)
resp, body = self.get(url) resp, body = self.get(url)
body = json.loads(body) body = json.loads(body)
self.validate_response(schema.show_volume_transfer, resp, body) self.validate_response(schema.show_volume_transfer, resp, body)
@ -53,7 +55,7 @@ class TransfersClient(rest_client.RestClient):
https://docs.openstack.org/api-ref/block-storage/v3/index.html#list-volume-transfers-for-a-project https://docs.openstack.org/api-ref/block-storage/v3/index.html#list-volume-transfers-for-a-project
https://docs.openstack.org/api-ref/block-storage/v3/index.html#list-volume-transfers-and-details https://docs.openstack.org/api-ref/block-storage/v3/index.html#list-volume-transfers-and-details
""" """
url = 'os-volume-transfer' url = self.resource_path
schema_list_transfers = schema.list_volume_transfers_no_detail schema_list_transfers = schema.list_volume_transfers_no_detail
if detail: if detail:
url += '/detail' url += '/detail'
@ -67,7 +69,7 @@ class TransfersClient(rest_client.RestClient):
def delete_volume_transfer(self, transfer_id): def delete_volume_transfer(self, transfer_id):
"""Delete a volume transfer.""" """Delete a volume transfer."""
resp, body = self.delete("os-volume-transfer/%s" % transfer_id) resp, body = self.delete("%s/%s" % (self.resource_path, transfer_id))
self.validate_response(schema.delete_volume_transfer, resp, body) self.validate_response(schema.delete_volume_transfer, resp, body)
return rest_client.ResponseBody(resp, body) return rest_client.ResponseBody(resp, body)
@ -78,9 +80,14 @@ class TransfersClient(rest_client.RestClient):
API reference: API reference:
https://docs.openstack.org/api-ref/block-storage/v3/index.html#accept-a-volume-transfer https://docs.openstack.org/api-ref/block-storage/v3/index.html#accept-a-volume-transfer
""" """
url = 'os-volume-transfer/%s/accept' % transfer_id url = '%s/%s/accept' % (self.resource_path, transfer_id)
post_body = json.dumps({'accept': kwargs}) post_body = json.dumps({'accept': kwargs})
resp, body = self.post(url, post_body) resp, body = self.post(url, post_body)
body = json.loads(body) body = json.loads(body)
self.validate_response(schema.accept_volume_transfer, resp, body) self.validate_response(schema.accept_volume_transfer, resp, body)
return rest_client.ResponseBody(resp, body) return rest_client.ResponseBody(resp, body)
class TransfersV355Client(TransfersClient):
"""Client class to send CRUD for the "new" Transfers API (mv 3.55)"""
resource_path = 'volume-transfers'

View File

@ -52,6 +52,7 @@ class TestTransfersClient(base.BaseServiceTest):
self.client = transfers_client.TransfersClient(fake_auth, self.client = transfers_client.TransfersClient(fake_auth,
'volume', 'volume',
'regionOne') 'regionOne')
self.resource_path = 'os-volume-transfer'
def _test_create_volume_transfer(self, bytes_body=False): def _test_create_volume_transfer(self, bytes_body=False):
resp_body = copy.deepcopy(self.FAKE_VOLUME_TRANSFER_INFO) resp_body = copy.deepcopy(self.FAKE_VOLUME_TRANSFER_INFO)
@ -72,7 +73,7 @@ class TestTransfersClient(base.BaseServiceTest):
resp_body, resp_body,
to_utf=bytes_body, to_utf=bytes_body,
status=202, status=202,
mock_args=['os-volume-transfer', payload], mock_args=[self.resource_path, payload],
**kwargs) **kwargs)
def _test_accept_volume_transfer(self, bytes_body=False): def _test_accept_volume_transfer(self, bytes_body=False):
@ -93,8 +94,9 @@ class TestTransfersClient(base.BaseServiceTest):
resp_body, resp_body,
to_utf=bytes_body, to_utf=bytes_body,
status=202, status=202,
mock_args=['os-volume-transfer/%s/accept' % mock_args=['%s/%s/accept' % (self.resource_path,
self.FAKE_VOLUME_TRANSFER_ID, payload], self.FAKE_VOLUME_TRANSFER_ID),
payload],
transfer_id=self.FAKE_VOLUME_TRANSFER_ID, transfer_id=self.FAKE_VOLUME_TRANSFER_ID,
**kwargs) **kwargs)
@ -156,3 +158,14 @@ class TestTransfersClient(base.BaseServiceTest):
{}, {},
status=202, status=202,
transfer_id="0e89cdd1-6249-421b-96d8-25fac0623d42") transfer_id="0e89cdd1-6249-421b-96d8-25fac0623d42")
class TestTransfersV355Client(TestTransfersClient):
def setUp(self):
super(TestTransfersV355Client, self).setUp()
fake_auth = fake_auth_provider.FakeAuthProvider()
self.client = transfers_client.TransfersV355Client(fake_auth,
'volume',
'regionOne')
self.resource_path = 'volume-transfers'