Set content_type for messages in Qpid notifier.
Fix bug 963050. This patch is the Qpid equivalent for a patch that just went in for the rabbit/kombu notifier. Glance encodes the message in json format before passing it in to the notifier. Explicitly set the content type for the messages to 'application/json'. Change-Id: I2f83f51487541b951f3eca0ae4d160a64f5a3db1
This commit is contained in:
parent
c1b7b9c5ae
commit
2d36facf14
@ -135,10 +135,16 @@ class QpidStrategy(strategy.Strategy):
|
||||
return self.session.sender(address)
|
||||
|
||||
def warn(self, msg):
|
||||
self.sender_warn.send(msg)
|
||||
qpid_msg = qpid.messaging.Message(content=msg,
|
||||
content_type='application/json')
|
||||
self.sender_warn.send(qpid_msg)
|
||||
|
||||
def info(self, msg):
|
||||
self.sender_info.send(msg)
|
||||
qpid_msg = qpid.messaging.Message(content=msg,
|
||||
content_type='application/json')
|
||||
self.sender_info.send(qpid_msg)
|
||||
|
||||
def error(self, msg):
|
||||
self.sender_error.send(msg)
|
||||
qpid_msg = qpid.messaging.Message(content=msg,
|
||||
content_type='application/json')
|
||||
self.sender_error.send(qpid_msg)
|
||||
|
@ -15,6 +15,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import logging
|
||||
import unittest
|
||||
|
||||
@ -315,6 +316,8 @@ class TestQpidNotifier(unittest.TestCase):
|
||||
super(TestQpidNotifier, self).tearDown()
|
||||
|
||||
def _test_notify(self, priority):
|
||||
test_msg = json.dumps({'a': 'b'})
|
||||
|
||||
self.mock_connection = self.mocker.CreateMock(self.orig_connection)
|
||||
self.mock_session = self.mocker.CreateMock(self.orig_session)
|
||||
self.mock_sender = self.mocker.CreateMock(self.orig_sender)
|
||||
@ -328,18 +331,18 @@ class TestQpidNotifier(unittest.TestCase):
|
||||
'"type": "topic"}, "create": "always"}' % p)
|
||||
self.mock_session.sender(expected_address).AndReturn(
|
||||
self.mock_sender)
|
||||
self.mock_sender.send('stuff')
|
||||
self.mock_sender.send(mox.IgnoreArg())
|
||||
|
||||
self.mocker.ReplayAll()
|
||||
|
||||
conf = utils.TestConfigOpts({"notifier_strategy": "qpid"})
|
||||
notifier = self.notify_qpid.QpidStrategy(conf)
|
||||
if priority == "info":
|
||||
notifier.info("stuff")
|
||||
elif priority == "warn":
|
||||
notifier.warn("stuff")
|
||||
elif priority == "error":
|
||||
notifier.error("stuff")
|
||||
if priority == 'info':
|
||||
notifier.info(test_msg)
|
||||
elif priority == 'warn':
|
||||
notifier.warn(test_msg)
|
||||
elif priority == 'error':
|
||||
notifier.error(test_msg)
|
||||
|
||||
self.mocker.VerifyAll()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user