Browse Source

Merge "FUP: add missing test for PUT volume attachments API"

tags/21.0.0.0rc1
Zuul 3 months ago
committed by Gerrit Code Review
parent
commit
aaa3803807
2 changed files with 35 additions and 2 deletions
  1. +3
    -2
      nova/api/openstack/compute/schemas/volumes.py
  2. +32
    -0
      nova/tests/unit/api/openstack/compute/test_volumes.py

+ 3
- 2
nova/api/openstack/compute/schemas/volumes.py View File

@@ -96,8 +96,9 @@ del update_volume_attachment['properties']['volumeAttachment'][
'properties']['device']

# NOTE(brinzhang): Allow attachment_id, serverId, device, tag, and
# delete_on_termination to be specified for RESTfulness, even though
# we will not allow updating all of them.
# delete_on_termination (i.e., follow the content of the GET response)
# to be specified for RESTfulness, even though we will not allow updating
# all of them.
update_volume_attachment_v285 = {
'type': 'object',
'properties': {


+ 32
- 0
nova/tests/unit/api/openstack/compute/test_volumes.py View File

@@ -1384,6 +1384,22 @@ class UpdateVolumeAttachTests(VolumeAttachTestsV279):
self.req, FAKE_UUID,
FAKE_UUID_A, body=body)

@mock.patch.object(objects.BlockDeviceMapping,
'get_by_volume_and_instance')
def test_update_volume_with_changed_attachment_id_old_microversion(
self, mock_get_vol_and_inst):
body = {'volumeAttachment': {
'volumeId': FAKE_UUID_A,
'id': uuids.attachment_id,
}}
req = self._get_req(body, microversion='2.84')
ex = self.assertRaises(exception.ValidationError,
self.attachments.update,
req, FAKE_UUID,
FAKE_UUID_A, body=body)
self.assertIn('Additional properties are not allowed',
six.text_type(ex))

@mock.patch.object(objects.BlockDeviceMapping,
'get_by_volume_and_instance')
def test_update_volume_with_changed_serverId(self,
@@ -1411,6 +1427,22 @@ class UpdateVolumeAttachTests(VolumeAttachTestsV279):
self.req, FAKE_UUID,
FAKE_UUID_A, body=body)

@mock.patch.object(objects.BlockDeviceMapping,
'get_by_volume_and_instance')
def test_update_volume_with_changed_serverId_old_microversion(
self, mock_get_vol_and_inst):
body = {'volumeAttachment': {
'volumeId': FAKE_UUID_A,
'serverId': uuids.server_id,
}}
req = self._get_req(body, microversion='2.84')
ex = self.assertRaises(exception.ValidationError,
self.attachments.update,
req, FAKE_UUID,
FAKE_UUID_A, body=body)
self.assertIn('Additional properties are not allowed',
six.text_type(ex))

@mock.patch.object(objects.BlockDeviceMapping,
'get_by_volume_and_instance')
def test_update_volume_with_changed_device(self, mock_get_vol_and_inst):


Loading…
Cancel
Save