Skip to content

Commit 215475e

Browse files
stephenfinmriedem
authored andcommitted
Follow-up for I6a777b4b7a5729488f939df8c40e49bd40aec3dd
Remove some tests that, due to changes in the aforementioned patch, are essentially duplicates now. Change-Id: Ib4bcc6dc36723b9ddc9d8f8c2656d6e6b18bdeff Signed-off-by: Stephen Finucane <[email protected]>
1 parent f260f12 commit 215475e

File tree

2 files changed

+6
-86
lines changed

2 files changed

+6
-86
lines changed

nova/tests/functional/api_sample_tests/test_volumes.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -258,40 +258,9 @@ def _get_vol_attachment_subs(self, subs):
258258
return subs
259259

260260
def test_attach_volume_to_server(self):
261-
self.stub_out('nova.volume.cinder.API.get', fakes.stub_volume_get)
262-
self.stub_out('nova.volume.cinder.API.attachment_create',
263-
lambda *a, **k: {'id': uuids.attachment_id})
264-
device_name = '/dev/vdd'
265-
bdm = objects.BlockDeviceMapping()
266-
bdm['device_name'] = device_name
267-
self.stub_out(
268-
'nova.compute.manager.ComputeManager.reserve_block_device_name',
269-
lambda *a, **k: bdm)
270-
self.stub_out(
271-
'nova.compute.manager.ComputeManager.attach_volume',
272-
lambda *a, **k: None)
273-
274-
volume = fakes.stub_volume_get(None, context.get_admin_context(),
275-
self.OLD_VOLUME_ID)
276-
subs = {
277-
'volume_id': volume['id'],
278-
'device': device_name
279-
}
280-
server_id = self._post_server()
281-
subs = self._get_vol_attachment_subs(subs)
282-
response = self._do_post('servers/%s/os-volume_attachments'
283-
% server_id,
284-
'attach-volume-to-server-req', subs)
285-
286-
self._verify_response('attach-volume-to-server-resp', subs,
287-
response, 200)
288-
289-
def test_attach_volume_to_server_new_flow(self):
290261
self.stub_out('nova.volume.cinder.API.get', fakes.stub_volume_get)
291262
self.stub_out('nova.volume.cinder.API.attachment_create',
292263
lambda *a, **k: {'id': uuids.volume})
293-
self.stub_out('nova.objects.BlockDeviceMapping.save',
294-
lambda *a, **k: None)
295264
device_name = '/dev/vdd'
296265
bdm = objects.BlockDeviceMapping()
297266
bdm['device_name'] = device_name

nova/tests/unit/compute/test_compute_api.py

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4132,42 +4132,6 @@ def test_get_bdm_image_metadata_with_cinder_down(self, mock_get):
41324132
self.context,
41334133
bdms, legacy_bdm=True)
41344134

4135-
@mock.patch.object(cinder.API, 'get')
4136-
@mock.patch.object(cinder.API, 'attachment_create',
4137-
side_effect=exception.InvalidInput(reason='error'))
4138-
def test_validate_bdm_with_error_volume(self, mock_attach_create,
4139-
mock_get):
4140-
# Tests that an InvalidInput exception raised from
4141-
# volume_api.reserve_volume due to the volume status not being
4142-
# 'available' results in _validate_bdm re-raising InvalidVolume.
4143-
instance = self._create_instance_obj()
4144-
del instance.id
4145-
instance_type = self._create_flavor()
4146-
volume_id = 'e856840e-9f5b-4894-8bde-58c6e29ac1e8'
4147-
volume_info = {'status': 'error',
4148-
'attach_status': 'detached',
4149-
'id': volume_id,
4150-
'multiattach': False}
4151-
mock_get.return_value = volume_info
4152-
bdms = [objects.BlockDeviceMapping(
4153-
**fake_block_device.FakeDbBlockDeviceDict(
4154-
{
4155-
'boot_index': 0,
4156-
'volume_id': volume_id,
4157-
'source_type': 'volume',
4158-
'destination_type': 'volume',
4159-
'device_name': 'vda',
4160-
}))]
4161-
4162-
self.assertRaises(exception.InvalidVolume,
4163-
self.compute_api._validate_bdm,
4164-
self.context,
4165-
instance, instance_type, bdms)
4166-
4167-
mock_get.assert_called_once_with(self.context, volume_id)
4168-
mock_attach_create.assert_called_once_with(
4169-
self.context, volume_id, instance.uuid)
4170-
41714135
@mock.patch.object(cinder.API, 'get_snapshot',
41724136
side_effect=exception.CinderConnectionFailed(reason='error'))
41734137
@mock.patch.object(cinder.API, 'get',
@@ -4444,25 +4408,12 @@ def test_provision_instances_with_cinder_down(self, mock_get):
44444408
self._test_provision_instances_with_cinder_error(
44454409
expected_exception=exception.CinderConnectionFailed)
44464410

4447-
@mock.patch.object(cinder.API, 'get',
4448-
return_value={'id': '1', 'multiattach': False})
4449-
@mock.patch.object(cinder.API, 'check_availability_zone')
4450-
@mock.patch.object(cinder.API, 'attachment_create',
4451-
side_effect=exception.InvalidInput(reason='error'))
4452-
def test_provision_instances_with_error_volume(self,
4453-
mock_cinder_check_av_zone,
4454-
mock_reserve_volume,
4455-
mock_get):
4456-
self._test_provision_instances_with_cinder_error(
4457-
expected_exception=exception.InvalidVolume)
4458-
4459-
@mock.patch.object(cinder.API, 'get',
4460-
return_value={'id': '1', 'multiattach': False})
4461-
@mock.patch.object(cinder.API, 'check_availability_zone')
4462-
@mock.patch.object(cinder.API, 'attachment_create',
4463-
side_effect=exception.InvalidInput(reason='error'))
4464-
def test_provision_instances_with_error_volume_new_flow(self,
4465-
mock_cinder_check_av_zone, mock_attach_create, mock_get):
4411+
@mock.patch.object(cinder.API, 'get', new=mock.Mock(
4412+
return_value={'id': '1', 'multiattach': False}))
4413+
@mock.patch.object(cinder.API, 'check_availability_zone', new=mock.Mock())
4414+
@mock.patch.object(cinder.API, 'attachment_create', new=mock.Mock(
4415+
side_effect=exception.InvalidInput(reason='error')))
4416+
def test_provision_instances_with_error_volume(self):
44664417
self._test_provision_instances_with_cinder_error(
44674418
expected_exception=exception.InvalidVolume)
44684419

0 commit comments

Comments
 (0)