diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-08-09 17:04:29 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-08-09 17:04:29 +0000 |
| commit | fd00534df464095c780dd2e5a292b4d3696ad375 (patch) | |
| tree | e1bc386f9d024e82c48350b9247fc110e6653a50 /nova | |
| parent | 13ac52d2c21d6e0df7c896b25c91bd7a53b1871c (diff) | |
| parent | fcdfa93b210a092894284f60309e660a3a058fde (diff) | |
Merge "Send updated instance model to schedule_prep_resize"
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/compute/api.py | 7 | ||||
| -rw-r--r-- | nova/tests/compute/test_compute.py | 29 |
2 files changed, 31 insertions, 5 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 0122e175a..7164930f0 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1427,11 +1427,8 @@ class API(base.Base): if (current_memory_mb == new_memory_mb) and flavor_id: raise exception.CannotResizeToSameSize() - self.update(context, - instance, - task_state=task_states.RESIZE_PREP, - progress=0, - **kwargs) + instance = self.update(context, instance, + task_state=task_states.RESIZE_PREP, progress=0, **kwargs) request_spec = { 'instance_type': new_instance_type, diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 9a647953a..c88152b3e 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -3075,6 +3075,11 @@ class ComputeAPITestCase(BaseTestCase): filter_properties = msg['args']['filter_properties'] instance_properties = request_spec['instance_properties'] self.assertEqual(instance_properties['host'], 'host2') + # Ensure the instance passed to us has been updated with + # progress set to 0 and task_state set to RESIZE_PREP. + self.assertEqual(instance_properties['task_state'], + task_states.RESIZE_PREP) + self.assertEqual(instance_properties['progress'], 0) self.assertIn('host2', filter_properties['ignore_hosts']) self.stubs.Set(rpc, 'cast', _fake_cast) @@ -3084,6 +3089,16 @@ class ComputeAPITestCase(BaseTestCase): instance = db.instance_get_by_uuid(context, instance['uuid']) instance = jsonutils.to_primitive(instance) self.compute.run_instance(self.context, instance=instance) + # We need to set the host to something 'known'. Unfortunately, + # the compute manager is using a cached copy of FLAGS.host, + # so we can't just self.flags(host='host2') before calling + # run_instance above. Also, set progress to 10 so we ensure + # it is reset to 0 in compute_api.resize(). (verified in + # _fake_cast above). + instance = db.instance_update(self.context, instance['uuid'], + dict(host='host2', progress=10)) + # different host + self.flags(host='host3') try: self.compute_api.resize(context, instance, None) finally: @@ -3095,6 +3110,11 @@ class ComputeAPITestCase(BaseTestCase): filter_properties = msg['args']['filter_properties'] instance_properties = request_spec['instance_properties'] self.assertEqual(instance_properties['host'], 'host2') + # Ensure the instance passed to us has been updated with + # progress set to 0 and task_state set to RESIZE_PREP. + self.assertEqual(instance_properties['task_state'], + task_states.RESIZE_PREP) + self.assertEqual(instance_properties['progress'], 0) self.assertNotIn('host2', filter_properties['ignore_hosts']) self.stubs.Set(rpc, 'cast', _fake_cast) @@ -3105,6 +3125,15 @@ class ComputeAPITestCase(BaseTestCase): instance = db.instance_get_by_uuid(context, instance['uuid']) instance = jsonutils.to_primitive(instance) self.compute.run_instance(self.context, instance=instance) + # We need to set the host to something 'known'. Unfortunately, + # the compute manager is using a cached copy of FLAGS.host, + # so we can't just self.flags(host='host2') before calling + # run_instance above. Also, set progress to 10 so we ensure + # it is reset to 0 in compute_api.resize(). (verified in + # _fake_cast above). + instance = db.instance_update(self.context, instance['uuid'], + dict(host='host2', progress=10)) + # different host try: self.compute_api.resize(context, instance, None) finally: |
