From 4f7bb48bc50bb932eccc8e9c6f357d67fae69ff1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 28 Nov 2012 14:38:24 -0500 Subject: [PATCH] Fix blocking test for nova notifier Mock out the method of the conductor API that causes nova to try to use the message bus to communicate with the remote daemon. There is nothing listening in the CI environment, so the instance_update call hangs the tests. Change-Id: Id95ee0d3f45ef38adadcf94981f97ab12f60f6ad Signed-off-by: Doug Hellmann --- tests/compute/test_nova_notifier.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/compute/test_nova_notifier.py b/tests/compute/test_nova_notifier.py index f8e5d72b8..dcfd03513 100644 --- a/tests/compute/test_nova_notifier.py +++ b/tests/compute/test_nova_notifier.py @@ -148,7 +148,26 @@ class TestNovaNotifier(base.TestCase): super(TestNovaNotifier, self).tearDown() def test_notifications(self): - self.compute.terminate_instance(self.context, instance=self.instance) + # Folsom compatibility check + try: + import nova.conductor.api + except ImportError: + # Folsom does not have nova.conductor, and it is safe to + # call this method directly, but not safe to mock it + # because mock.patch() fails to find the original. + self.compute.terminate_instance(self.context, + instance=self.instance) + else: + # Under Grizzly, Nova has moved to no-db access on the + # compute node. The compute manager uses RPC to talk to + # the conductor. We need to disable communication between + # the nova manager and the remote system since we can't + # expect the message bus to be available, or the remote + # controller to be there if the message bus is online. + with mock.patch('nova.conductor.api.API.instance_update'): + self.compute.terminate_instance(self.context, + instance=self.instance) + self.assertTrue(self.Pollster.counters) self.assertTrue(self.Pollster.counters[0]) self.assertEqual(self.Pollster.counters[0][0],