More robust mocking of nova conductor

Update the nova notifier test to use the fake RPC implementation
to avoid hangs more completely.

Also update the test to mock out the entire conductor API object
in the manager created by the test, instead of mocking individual
methods.

Change-Id: I741a609bd3ddfeb302d39b1c61a4b6896de2bf47
Signed-off-by: Doug Hellmann <doug.hellmann@dreamhost.com>
This commit is contained in:
Doug Hellmann 2013-02-05 08:43:55 -05:00
parent 858ff927d7
commit d6782ad3c1

View File

@ -91,6 +91,7 @@ class TestNovaNotifier(base.TestCase):
super(TestNovaNotifier, self).setUp()
nova_CONF.compute_driver = 'nova.virt.fake.FakeDriver'
nova_CONF.notification_driver = [nova_notifier.__name__]
nova_CONF.rpc_backend = 'ceilometer.openstack.common.rpc.impl_fake'
self.compute = importutils.import_object(nova_CONF.compute_manager)
self.context = context.get_admin_context()
fake_network.set_stub_network_methods(self.stubs)
@ -168,19 +169,13 @@ class TestNovaNotifier(base.TestCase):
# 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.
@mock.patch.object(nova.conductor.api.API,
'block_device_mapping_get_all_by_instance',
lambda obj, context, instance: {})
@mock.patch.object(self.compute, 'conductor_api')
# The code that looks up the instance uses a global
# reference to the API, so we also have to patch that to
# return our fake data.
@mock.patch.object(nova.conductor.api.API,
'instance_get_by_uuid',
self.fake_db_instance_get)
@mock.patch('nova.conductor.api.API.instance_info_cache_delete')
@mock.patch('nova.conductor.api.API.instance_destroy')
@mock.patch('nova.conductor.api.API.block_device_mapping_destroy')
@mock.patch('nova.conductor.api.API.instance_update')
@mock.patch('nova.conductor.api.API.action_event_start')
@mock.patch('nova.conductor.api.API.action_event_finish')
@mock.patch('nova.compute.utils.add_instance_fault_from_exc')
def run_test(*omit_args):
self.compute.terminate_instance(self.context,
instance=self.instance)