Add test case: retype volume when driver not initialized
This patch does two things: 1.In volume-manager, after retyping volume failure, add the volume status check like in volume-scheduler. 2.Add test case: when retyping available volume, volume driver is not ready, the volume status will be still 'available'. Change-Id: I18fa10c978128e744c584e4af28b3f35f655eea6
This commit is contained in:
parent
da34b35579
commit
c3882d9055
|
@ -146,3 +146,22 @@ class VolumeRetypeTestCase(base.BaseVolumeTestCase):
|
|||
mock_authorize.assert_has_calls(
|
||||
[mock.call(vol_action_policies.RETYPE_POLICY, target_obj=mock.ANY)
|
||||
])
|
||||
|
||||
def test_retype_driver_not_initialized(self):
|
||||
volume = tests_utils.create_volume(
|
||||
self.context,
|
||||
host=CONF.host,
|
||||
status='available',
|
||||
volume_type_id=self.default_vol_type.id)
|
||||
|
||||
host_obj = {'host': CONF.host, 'capabilities': {}}
|
||||
|
||||
self.volume.driver._initialized = False
|
||||
self.assertRaises(exception.DriverNotInitialized,
|
||||
self.volume.retype,
|
||||
self.context, volume,
|
||||
self.multiattach_type.id, host_obj,
|
||||
migration_policy='on-demand')
|
||||
|
||||
volume.refresh()
|
||||
self.assertEqual('available', volume.status)
|
||||
|
|
|
@ -2701,7 +2701,9 @@ class VolumeManager(manager.CleanableManager,
|
|||
if new_reservations:
|
||||
QUOTAS.rollback(context, new_reservations)
|
||||
|
||||
status_update = {'status': volume.previous_status}
|
||||
previous_status = (
|
||||
volume.previous_status or volume.status)
|
||||
status_update = {'status': previous_status}
|
||||
if context.project_id != volume.project_id:
|
||||
project_id = volume.project_id
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue