From 10f43aa0bfc6d41282fc19fb4bacddb8bc85ddc5 Mon Sep 17 00:00:00 2001 From: Hans Lindgren Date: Tue, 26 Feb 2013 10:53:21 +0100 Subject: Fix target host variable from being overwritten The target host parameter of the compute api evacuate method is mistakenly overwritten before being used. The result is that the instance rebuild operation is tried against the original failed host and will always fail. Rename locally used variable to a different name and modify relevant test to prohibit this from happening again. Resolves bug 1133204. Change-Id: I517b2dc19d9561723391150105b4943b56dba637 --- nova/tests/compute/test_compute.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 5ad333c9e..5648d4df4 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -6348,8 +6348,14 @@ class ComputeAPITestCase(BaseTestCase): def fake_service_is_up(*args, **kwargs): return False + def fake_rebuild_instance(*args, **kwargs): + db.instance_update(self.context, instance_uuid, + {'host': kwargs['host']}) + self.stubs.Set(self.compute_api.servicegroup_api, 'service_is_up', fake_service_is_up) + self.stubs.Set(self.compute_api.compute_rpcapi, 'rebuild_instance', + fake_rebuild_instance) self.compute_api.evacuate(self.context.elevated(), instance, host='fake_dest_host', @@ -6358,6 +6364,7 @@ class ComputeAPITestCase(BaseTestCase): instance = db.instance_get_by_uuid(self.context, instance_uuid) self.assertEqual(instance['task_state'], task_states.REBUILDING) + self.assertEqual(instance['host'], 'fake_dest_host') db.instance_destroy(self.context, instance['uuid']) -- cgit