summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2013-03-21 18:43:36 -0400
committerRussell Bryant <rbryant@redhat.com>2013-03-21 18:43:36 -0400
commitec8465a7b1077a71082324220e7c44cf700a4d4b (patch)
tree32e31f1e4fbdb0a280ef16c0077cba40a2d1919b
parentbf70726d4228ebf3e65aa75b8f0ca6cab5e1e159 (diff)
Enable message envelope.
Grizzly had the ability to receive messages with an envelope, but did not send them. Now update the code to send them. Change-Id: I73aad7697cf83ad4aabb3c2058b7cc4f53f783c2
-rw-r--r--openstack/common/rpc/amqp.py2
-rw-r--r--openstack/common/rpc/common.py9
-rw-r--r--openstack/common/rpc/impl_zmq.py2
-rw-r--r--tests/unit/rpc/amqp.py23
-rw-r--r--tests/unit/rpc/test_common.py6
-rw-r--r--tests/unit/rpc/test_zmq.py9
6 files changed, 5 insertions, 46 deletions
diff --git a/openstack/common/rpc/amqp.py b/openstack/common/rpc/amqp.py
index 2dcb12b..81fb41e 100644
--- a/openstack/common/rpc/amqp.py
+++ b/openstack/common/rpc/amqp.py
@@ -662,7 +662,7 @@ def notify(conf, context, topic, msg, connection_pool, envelope):
pack_context(msg, context)
with ConnectionContext(conf, connection_pool) as conn:
if envelope:
- msg = rpc_common.serialize_msg(msg, force_envelope=True)
+ msg = rpc_common.serialize_msg(msg)
conn.notify_send(topic, msg)
diff --git a/openstack/common/rpc/common.py b/openstack/common/rpc/common.py
index 5661bef..8bffc2b 100644
--- a/openstack/common/rpc/common.py
+++ b/openstack/common/rpc/common.py
@@ -70,10 +70,6 @@ _VERSION_KEY = 'oslo.version'
_MESSAGE_KEY = 'oslo.message'
-# TODO(russellb) Turn this on after Grizzly.
-_SEND_RPC_ENVELOPE = False
-
-
class RPCException(Exception):
message = _("An unknown RPC related exception occurred.")
@@ -441,10 +437,7 @@ def version_is_compatible(imp_version, version):
return True
-def serialize_msg(raw_msg, force_envelope=False):
- if not _SEND_RPC_ENVELOPE and not force_envelope:
- return raw_msg
-
+def serialize_msg(raw_msg):
# NOTE(russellb) See the docstring for _RPC_ENVELOPE_VERSION for more
# information about this format.
msg = {_VERSION_KEY: _RPC_ENVELOPE_VERSION,
diff --git a/openstack/common/rpc/impl_zmq.py b/openstack/common/rpc/impl_zmq.py
index 87f8d21..f7a59a2 100644
--- a/openstack/common/rpc/impl_zmq.py
+++ b/openstack/common/rpc/impl_zmq.py
@@ -221,7 +221,7 @@ class ZmqClient(object):
def cast(self, msg_id, topic, data, envelope=False):
msg_id = msg_id or 0
- if not (envelope or rpc_common._SEND_RPC_ENVELOPE):
+ if not envelope:
self.outq.send(map(bytes,
(msg_id, topic, 'cast', _serialize(data))))
return
diff --git a/tests/unit/rpc/amqp.py b/tests/unit/rpc/amqp.py
index 739297c..d8a3570 100644
--- a/tests/unit/rpc/amqp.py
+++ b/tests/unit/rpc/amqp.py
@@ -91,30 +91,11 @@ class BaseRpcAMQPTestCase(common.BaseRpcTestCase):
envelope=False)
self.assertEqual(self.test_msg, raw_msg)
- # Envelopes enabled, but not enabled for notifications
- self.stubs.Set(rpc_common, '_SEND_RPC_ENVELOPE', True)
- self.rpc.notify(FLAGS, self.context, 'notifications.info', raw_msg,
- envelope=False)
- self.assertEqual(self.test_msg, raw_msg)
-
# Now turn it on for notifications
- msg = {
- 'oslo.version': rpc_common._RPC_ENVELOPE_VERSION,
- 'oslo.message': jsonutils.dumps(raw_msg),
- }
- self.rpc.notify(FLAGS, self.context, 'notifications.info', raw_msg,
- envelope=True)
- remove_unique_id(self.test_msg)
- remove_unique_id(msg)
- self.assertEqual(self.test_msg, msg)
-
- # Make sure envelopes are still on notifications, even if turned off
- # for general messages.
- self.stubs.Set(rpc_common, '_SEND_RPC_ENVELOPE', False)
self.rpc.notify(FLAGS, self.context, 'notifications.info', raw_msg,
envelope=True)
- remove_unique_id(self.test_msg)
- self.assertEqual(self.test_msg, msg)
+ # Make sure the msg envelope was applied
+ self.assertTrue('oslo.version' in self.test_msg)
def test_single_reply_queue_on_has_ids(
self, single_reply_queue_for_callee_off=False):
diff --git a/tests/unit/rpc/test_common.py b/tests/unit/rpc/test_common.py
index b378b18..ee7bc96 100644
--- a/tests/unit/rpc/test_common.py
+++ b/tests/unit/rpc/test_common.py
@@ -238,13 +238,7 @@ class RpcCommonTestCase(test_utils.BaseTestCase):
self.assertRaises(rpc_common.ClientException, naughty)
self.assertRaises(ValueError, really_naughty)
- def test_serialize_msg_v1(self):
- self.stubs.Set(rpc_common, '_SEND_RPC_ENVELOPE', False)
- msg = {'foo': 'bar'}
- self.assertEqual(msg, rpc_common.serialize_msg(msg))
-
def test_serialize_msg_v2(self):
- self.stubs.Set(rpc_common, '_SEND_RPC_ENVELOPE', True)
msg = {'foo': 'bar'}
s_msg = {'oslo.version': rpc_common._RPC_ENVELOPE_VERSION,
'oslo.message': jsonutils.dumps(msg)}
diff --git a/tests/unit/rpc/test_zmq.py b/tests/unit/rpc/test_zmq.py
index 5339e3c..5380a98 100644
--- a/tests/unit/rpc/test_zmq.py
+++ b/tests/unit/rpc/test_zmq.py
@@ -125,15 +125,6 @@ class RpcZmqBaseTopicTestCase(_RpcZmqBaseTestCase):
pass
-class RpcZmqEnvelopeEnabledTestCase(_RpcZmqBaseTestCase):
- """
- This sends messages with envelopes enabled.
- """
- def setUp(self):
- super(RpcZmqEnvelopeEnabledTestCase, self).setUp()
- self.stubs.Set(rpc_common, '_SEND_RPC_ENVELOPE', True)
-
-
class RpcZmqDirectTopicTestCase(_RpcZmqBaseTestCase):
"""
Test communication directly to a host,