From 66418ecdc7cbaa3fa6405d1f9eb409f8acdfe3e7 Mon Sep 17 00:00:00 2001 From: Juan Antonio Osorio Robles Date: Wed, 11 May 2016 09:29:41 +0300 Subject: [PATCH] Fix creation of notification server The parameters that the NotificationDispatcher receives changed recently, and the targets (with its priorities) and requeuing now depend on the server/listener. So this patch makes the change to remove those parameters from the creation of that object, and replace the MessageHandlingServer for a NotificationServer that can actually handle these things. Change-Id: Ifc9cfcbd7e80cdd451a79c579294873cbd220c39 Closes-Bug: #1580461 --- barbican/queue/__init__.py | 12 ++++++------ barbican/tests/queue/test_keystone_listener.py | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/barbican/queue/__init__.py b/barbican/queue/__init__.py index 51f81caf2..e23388409 100644 --- a/barbican/queue/__init__.py +++ b/barbican/queue/__init__.py @@ -18,7 +18,7 @@ Queue objects for Barbican """ import oslo_messaging as messaging from oslo_messaging.notify import dispatcher as notify_dispatcher -from oslo_messaging import server as msg_server +from oslo_messaging.notify import listener from barbican.common import config from barbican.common import exception @@ -107,9 +107,9 @@ def get_notification_server(targets, endpoints, serializer=None): allow_requeue = getattr(getattr(CONF, KS_NOTIFICATIONS_GRP_NAME), 'allow_requeue') TRANSPORT._require_driver_features(requeue=allow_requeue) - dispatcher = notify_dispatcher.NotificationDispatcher(targets, endpoints, - serializer, - allow_requeue) + dispatcher = notify_dispatcher.NotificationDispatcher(endpoints, + serializer) # we don't want blocking executor so use eventlet as executor choice - return msg_server.MessageHandlingServer(TRANSPORT, dispatcher, - executor='eventlet') + return listener.NotificationServer(TRANSPORT, targets, dispatcher, + executor='eventlet', + allow_requeue=allow_requeue) diff --git a/barbican/tests/queue/test_keystone_listener.py b/barbican/tests/queue/test_keystone_listener.py index 1e594a100..0e8b89146 100644 --- a/barbican/tests/queue/test_keystone_listener.py +++ b/barbican/tests/queue/test_keystone_listener.py @@ -266,7 +266,8 @@ class WhenUsingMessageServer(UtilMixin, utils.BaseTestCase): super(WhenUsingMessageServer, self).setUp() queue.init(self.conf) - patcher = mock.patch('oslo_messaging.server.MessageHandlingServer') + patcher = mock.patch('oslo_messaging.notify.listener.' + 'NotificationServer') mock_server_class = patcher.start() self.addCleanup(patcher.stop) @@ -316,7 +317,7 @@ class WhenUsingMessageServer(UtilMixin, utils.BaseTestCase): msg_server.start() self.msg_server_mock.start.assert_called_with() - @mock.patch.object(service.Service, 'stop') + @mock.patch.object(service.Service, 'stop', autospec=True) def test_should_stop(self, mock_service_stop): msg_server = keystone_listener.MessageServer(self.conf) msg_server.stop()