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 <doug.hellmann@dreamhost.com>
This commit is contained in:
Doug Hellmann 2012-11-28 14:38:24 -05:00
parent 0ca8c83df9
commit 4f7bb48bc5

View File

@ -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],