From 486f723f43ace9342532397c75b75efe0e913a2c Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 13 Aug 2013 11:15:03 +0200 Subject: [PATCH] Fix nova test_notifier wrt new notifier API The Oslo notifier api lost add_driver(), and nova copy of that code has been updated recently, so that broke Ceilometer testing of that piece. Fix it by using another mechanism to test. Change-Id: I0169fcc9955501d490dfcdd7742205ea5c9ba15b Closes-Bug: #1211532 --- nova_tests/test_notifier.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/nova_tests/test_notifier.py b/nova_tests/test_notifier.py index 5d59e930f..87ab33578 100644 --- a/nova_tests/test_notifier.py +++ b/nova_tests/test_notifier.py @@ -43,7 +43,6 @@ from nova import context from nova import db from nova.openstack.common import importutils from nova.openstack.common import log as logging -from nova.openstack.common.notifier import api as notifier_api # This option is used in the nova_notifier module, so make # sure it is defined. @@ -89,7 +88,10 @@ class TestNovaNotifier(base.TestCase): def setUp(self): super(TestNovaNotifier, self).setUp() nova_CONF.compute_driver = 'nova.virt.fake.FakeDriver' - nova_CONF.notification_driver = [nova_notifier.__name__] + nova_CONF.notification_driver = [ + nova_notifier.__name__, + 'nova.openstack.common.notifier.rpc_notifier', + ] nova_CONF.rpc_backend = 'nova.openstack.common.rpc.impl_fake' nova_CONF.vnc_enabled = False nova_CONF.spice.enabled = False @@ -149,9 +151,6 @@ class TestNovaNotifier(base.TestCase): # Set up to capture the notification messages generated by the # plugin and to invoke our notifier plugin. self.notifications = [] - notifier_api._reset_drivers() - notifier_api.add_driver(self) - notifier_api.add_driver(nova_notifier) ext_mgr = test_manager.TestExtensionManager([ extension.Extension('test', @@ -179,12 +178,13 @@ class TestNovaNotifier(base.TestCase): mock.patch.object(nova_notifier.instance_info_source, 'instance_get_by_uuid', self.fake_instance_ref_get), + mock.patch('nova.openstack.common.notifier.rpc_notifier.notify', + self.notify) ): self.compute.terminate_instance(self.context, instance=self.instance) def tearDown(self): - notifier_api._reset_drivers() self.Pollster.instances = [] super(TestNovaNotifier, self).tearDown() nova_notifier._gatherer = None @@ -206,9 +206,7 @@ class TestNovaNotifier(base.TestCase): self.notifications.append(message) def test_pollster_called(self): - # The notifier plugin sends another notification for the same - # instance, so we expect to have 2 entries in the list. - self.assertEqual(len(self.Pollster.instances), 2) + self.assertEqual(len(self.Pollster.instances), 1) def test_correct_instance(self): for i, (gatherer, inst) in enumerate(self.Pollster.instances):