Make VolumeAttachmentsSampleV249 test other methods
The 2.49 microversion for the os-volume_attachments API only changes the POST action to attach a volume with a tag. But we should make sure 2.49 is backward compatible on the GET, PUT and DELETE methods for the same API. This makes VolumeAttachmentsSampleV249 extend VolumeAttachmentsSample and also removes duplicate code by adding the _get_vol_attachment_subs method. In addition, VolumeAttachmentsSampleV249OldCinderFlow is removed since it didn't really work properly (it was missing a few stubs) and was redundant with the test_tagged_attach_volume unit test found in nova.tests.unit.test_compute_api. Change-Id: I757576d3474997c49c67745fb245122fc2c6decc
This commit is contained in:
parent
6ae35e11b8
commit
e3c089bf1d
@ -1,8 +1,8 @@
|
||||
{
|
||||
"volumeAttachment": {
|
||||
"device": "/dev/sdb",
|
||||
"device": "/dev/vdd",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "84ffbfa0-daf4-4e23-bf4b-dc532c459d4e",
|
||||
"serverId": "189dc814-35bc-428b-bba4-8d5ac0d1e087",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"volumeAttachments": [
|
||||
{
|
||||
"device": "/dev/sdd",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "4bcb3ae6-68aa-4e89-aac3-97b3dac2f714",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
},
|
||||
{
|
||||
"device": "/dev/sdc",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f804",
|
||||
"serverId": "4bcb3ae6-68aa-4e89-aac3-97b3dac2f714",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804"
|
||||
}
|
||||
]
|
||||
}
|
5
doc/api_samples/os-volumes/v2.49/update-volume-req.json
Normal file
5
doc/api_samples/os-volumes/v2.49/update-volume-req.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"volumeAttachment": {
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f805"
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"volumeAttachment": {
|
||||
"device": "/dev/sdd",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "3dc0a2a6-e1bb-4643-8b6f-c146684d676d",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"volumeAttachments": [
|
||||
{
|
||||
"device": "/dev/sdd",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "%(uuid)s",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
},
|
||||
{
|
||||
"device": "/dev/sdc",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f804",
|
||||
"serverId": "%(uuid)s",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f804"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"volumeAttachment": {
|
||||
"volumeId": "%(volume_id)s"
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"volumeAttachment": {
|
||||
"device": "/dev/sdd",
|
||||
"id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
|
||||
"serverId": "%(uuid)s",
|
||||
"volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
|
||||
}
|
||||
}
|
@ -245,6 +245,10 @@ class VolumeAttachmentsSample(test_servers.ServersSampleBase):
|
||||
|
||||
self.stub_out('nova.compute.api.API.get', fake_compute_api_get)
|
||||
|
||||
def _get_vol_attachment_subs(self, subs):
|
||||
"""Allows subclasses to override/supplement request/response subs"""
|
||||
return subs
|
||||
|
||||
def test_attach_volume_to_server(self):
|
||||
self.stub_out('nova.objects.Service.get_minimum_version',
|
||||
lambda *a, **k: COMPUTE_VERSION_OLD_ATTACH_FLOW)
|
||||
@ -268,6 +272,7 @@ class VolumeAttachmentsSample(test_servers.ServersSampleBase):
|
||||
'device': device_name
|
||||
}
|
||||
server_id = self._post_server()
|
||||
subs = self._get_vol_attachment_subs(subs)
|
||||
response = self._do_post('servers/%s/os-volume_attachments'
|
||||
% server_id,
|
||||
'attach-volume-to-server-req', subs)
|
||||
@ -300,6 +305,7 @@ class VolumeAttachmentsSample(test_servers.ServersSampleBase):
|
||||
'device': device_name
|
||||
}
|
||||
server_id = self._post_server()
|
||||
subs = self._get_vol_attachment_subs(subs)
|
||||
response = self._do_post('servers/%s/os-volume_attachments'
|
||||
% server_id,
|
||||
'attach-volume-to-server-req', subs)
|
||||
@ -362,7 +368,7 @@ class VolumeAttachmentsSample(test_servers.ServersSampleBase):
|
||||
self.assertEqual('', response.text)
|
||||
|
||||
|
||||
class VolumeAttachmentsSampleV249(test_servers.ServersSampleBase):
|
||||
class VolumeAttachmentsSampleV249(VolumeAttachmentsSample):
|
||||
sample_dir = "os-volumes"
|
||||
microversion = '2.49'
|
||||
scenarios = [('v2_49', {'api_major_version': 'v2.1'})]
|
||||
@ -371,53 +377,5 @@ class VolumeAttachmentsSampleV249(test_servers.ServersSampleBase):
|
||||
super(VolumeAttachmentsSampleV249, self).setUp()
|
||||
self.useFixture(fixtures.CinderFixtureNewAttachFlow(self))
|
||||
|
||||
def test_attach_volume_to_server(self):
|
||||
device_name = '/dev/sdb'
|
||||
bdm = objects.BlockDeviceMapping()
|
||||
bdm['device_name'] = device_name
|
||||
volume = fakes.stub_volume_get(None, context.get_admin_context(),
|
||||
'a26887c6-c47b-4654-abb5-dfadf7d3f803')
|
||||
subs = {
|
||||
'volume_id': volume['id'],
|
||||
'device': device_name,
|
||||
'tag': 'foo',
|
||||
}
|
||||
server_id = self._post_server()
|
||||
response = self._do_post('servers/%s/os-volume_attachments'
|
||||
% server_id,
|
||||
'attach-volume-to-server-req', subs)
|
||||
|
||||
self._verify_response('attach-volume-to-server-resp', subs,
|
||||
response, 200)
|
||||
|
||||
|
||||
class VolumeAttachmentsSampleV249OldCinderFlow(test_servers.ServersSampleBase):
|
||||
|
||||
sample_dir = "os-volumes"
|
||||
microversion = '2.49'
|
||||
scenarios = [('v2_49', {'api_major_version': 'v2.1'})]
|
||||
|
||||
def setUp(self):
|
||||
super(VolumeAttachmentsSampleV249OldCinderFlow, self).setUp()
|
||||
self.useFixture(fixtures.CinderFixture(self))
|
||||
|
||||
def test_attach_volume_to_server(self):
|
||||
device_name = '/dev/sdb'
|
||||
bdm = objects.BlockDeviceMapping()
|
||||
bdm['device_name'] = device_name
|
||||
volume = fakes.stub_volume_get(None, context.get_admin_context(),
|
||||
'a26887c6-c47b-4654-abb5-dfadf7d3f803')
|
||||
self.stub_out('nova.objects.Service.get_minimum_version',
|
||||
lambda *a, **k: COMPUTE_VERSION_OLD_ATTACH_FLOW)
|
||||
subs = {
|
||||
'volume_id': volume['id'],
|
||||
'device': device_name,
|
||||
'tag': 'foo',
|
||||
}
|
||||
server_id = self._post_server()
|
||||
response = self._do_post('servers/%s/os-volume_attachments'
|
||||
% server_id,
|
||||
'attach-volume-to-server-req', subs)
|
||||
|
||||
self._verify_response('attach-volume-to-server-resp', subs,
|
||||
response, 200)
|
||||
def _get_vol_attachment_subs(self, subs):
|
||||
return dict(subs, tag='foo')
|
||||
|
Loading…
Reference in New Issue
Block a user