Merge "add ability to publish to multiple topics"
This commit is contained in:
commit
0c191b397c
@ -200,8 +200,10 @@ class RPCPublisher(MessagingPublisher):
|
||||
|
||||
|
||||
class NotifierPublisher(MessagingPublisher):
|
||||
def __init__(self, parsed_url, topic):
|
||||
def __init__(self, parsed_url, default_topic):
|
||||
super(NotifierPublisher, self).__init__(parsed_url)
|
||||
options = urlparse.parse_qs(parsed_url.query)
|
||||
topic = options.get('topic', [default_topic])[-1]
|
||||
self.notifier = oslo.messaging.Notifier(
|
||||
messaging.get_transport(),
|
||||
driver=cfg.CONF.publisher_notifier.telemetry_driver,
|
||||
|
@ -176,6 +176,23 @@ class RpcOnlyPublisherTest(BasePublisherTestCase):
|
||||
self.assertEqual(expected, prepare.mock_calls)
|
||||
|
||||
|
||||
class NotifierOnlyPublisherTest(BasePublisherTestCase):
|
||||
|
||||
@mock.patch('oslo.messaging.Notifier')
|
||||
def test_publish_topic_override(self, notifier):
|
||||
msg_publisher.SampleNotifierPublisher(
|
||||
netutils.urlsplit('notifier://?topic=custom_topic'))
|
||||
notifier.assert_called_with(mock.ANY, topic='custom_topic',
|
||||
driver=mock.ANY, retry=mock.ANY,
|
||||
publisher_id=mock.ANY)
|
||||
|
||||
msg_publisher.EventNotifierPublisher(
|
||||
netutils.urlsplit('notifier://?topic=custom_event_topic'))
|
||||
notifier.assert_called_with(mock.ANY, topic='custom_event_topic',
|
||||
driver=mock.ANY, retry=mock.ANY,
|
||||
publisher_id=mock.ANY)
|
||||
|
||||
|
||||
class TestPublisher(testscenarios.testcase.WithScenarios,
|
||||
BasePublisherTestCase):
|
||||
scenarios = [
|
||||
|
Loading…
Reference in New Issue
Block a user