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
This commit is contained in:
Juan Antonio Osorio Robles 2016-05-11 09:29:41 +03:00
parent 67ebe72d2d
commit 66418ecdc7
2 changed files with 9 additions and 8 deletions

View File

@ -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)

View File

@ -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()