self.obj = obj
+# TODO(vbala) Split test methods handling multiple cases into multiple methods,
+# each handling a specific case.
class VMwareEsxVmdkDriverTestCase(test.TestCase):
"""Test class for VMwareEsxVmdkDriver."""
vops.change_backing_profile.assert_called_once_with(backing,
profile_id)
+ # Modify the previous case with no profile change.
+ get_volume_type_extra_specs.side_effect = [vmdk.THICK_VMDK_TYPE,
+ vmdk.THIN_VMDK_TYPE,
+ 'gold-1',
+ 'gold-1']
+ ds_sel.select_datastore.reset_mock()
+ vops.relocate_backing.reset_mock()
+ vops.move_backing_to_folder.reset_mock()
+ vops.change_backing_profile.reset_mock()
+
+ self.assertTrue(self._driver.retype(context, vol, new_type, diff,
+ host))
+ exp_req = {hub.DatastoreSelector.HARD_ANTI_AFFINITY_DS: [ds_value],
+ hub.DatastoreSelector.PROFILE_NAME: 'gold-1',
+ hub.DatastoreSelector.SIZE_BYTES: units.Gi}
+ ds_sel.select_datastore.assert_called_once_with(exp_req)
+ vops.relocate_backing.assert_called_once_with(
+ backing, candidate_ds, rp, host, vmdk.THIN_VMDK_TYPE)
+ vops.move_backing_to_folder.assert_called_once_with(backing, folder)
+ self.assertFalse(vops.change_backing_profile.called)
+
# Test with disk type conversion, profile change, backing with
# no snapshots and candidate datastore which is same as the backing
# datastore.
req[hub.DatastoreSelector.HARD_ANTI_AFFINITY_DS] = (
[datastore.value])
- if need_profile_change:
- LOG.debug("Backing: %(backing)s needs a profile change to: "
- "%(profile)s.",
- {'backing': backing,
- 'profile': new_profile})
+ if new_profile:
req[hub.DatastoreSelector.PROFILE_NAME] = new_profile
# Select datastore satisfying the requirements.
# Update the backing's storage profile if needed.
if need_profile_change:
+ LOG.debug("Backing: %(backing)s needs a profile change to:"
+ " %(profile)s.",
+ {'backing': backing,
+ 'profile': new_profile})
profile_id = None
if new_profile is not None:
profile_id = self.ds_sel.get_profile_id(new_profile)