summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorChris Behrens <cbehrens@codestud.com>2012-08-08 20:49:27 +0000
committerChris Behrens <cbehrens@codestud.com>2012-08-09 16:45:12 +0000
commitfcdfa93b210a092894284f60309e660a3a058fde (patch)
tree726fa1a6f22e581af3c71f380c0896dc8bd05dcd /nova/tests
parentf1c0a84be4dc1be15cb2b2c2676b9243fd24bd3d (diff)
Send updated instance model to schedule_prep_resize
A stale instance model was being passed to schedule_prep_resize. Fixes bug 1034595 Change-Id: Ic92a22a2c315d25c70d32685fdf9f38451077b9a
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/compute/test_compute.py29
1 files changed, 29 insertions, 0 deletions
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: