NOTIFICATION_TRANSPORT should be global

This is a followup to "Use messaging notifications transport
instead of default" (Ic72fd658fe9b35d39cc3d7da2e4b9fe3454edfba).

The use of NOTIFICATION_TRANSPORT should be global. A unit
test is added; it fails if the variable isn't global.

A typo was addressed in the release notes.

Change-Id: Ie303d79aba893b36a7aecb29c0ff2703f742146e
This commit is contained in:
Ruby Loo 2016-05-31 14:26:22 -04:00
parent fb4e545e21
commit 4405e6d412
3 changed files with 25 additions and 2 deletions

View File

@ -43,7 +43,7 @@ TRANSPORT_ALIASES = {
def init(conf):
global TRANSPORT, NOTIFIER
global TRANSPORT, NOTIFICATION_TRANSPORT, NOTIFIER
exmods = get_allowed_exmods()
TRANSPORT = messaging.get_transport(conf,
allowed_remote_exmods=exmods,

View File

@ -11,11 +11,34 @@
# under the License.
import mock
from oslo_config import cfg
import oslo_messaging as messaging
from ironic.common import context as ironic_context
from ironic.common import rpc
from ironic.tests import base
CONF = cfg.CONF
class TestUtils(base.TestCase):
@mock.patch.object(messaging, 'Notifier', autospec=True)
@mock.patch.object(messaging, 'JsonPayloadSerializer', autospec=True)
@mock.patch.object(messaging, 'get_notification_transport', autospec=True)
@mock.patch.object(messaging, 'get_transport', autospec=True)
def test_init_globals(self, mock_get_transport, mock_get_notification,
mock_serializer, mock_notifier):
rpc.TRANSPORT = None
rpc.NOTIFICATION_TRANSPORT = None
rpc.NOTIFIER = None
rpc.init(CONF)
self.assertEqual(mock_get_transport.return_value, rpc.TRANSPORT)
self.assertEqual(mock_get_notification.return_value,
rpc.NOTIFICATION_TRANSPORT)
self.assertTrue(mock_serializer.called)
self.assertEqual(mock_notifier.return_value, rpc.NOTIFIER)
class TestRequestContextSerializer(base.TestCase):

View File

@ -1,6 +1,6 @@
---
features:
- It is now possible to configure the notifications tu use a different
- It is now possible to configure the notifications to use a different
transport URL than the RPCs. These could potentially be completely
different message broker hosts (though they don't need to be). If the
notification-specific configuration is not provided, the notifier will use