summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-04-13 17:17:09 +0000
committerGerrit Code Review <review@openstack.org>2015-04-13 17:17:09 +0000
commitb3e8c1bd05bf2d8738294b7bc6016d9905e8d5ca (patch)
tree7e951b400b4ec7d4c2db50c7460dc40d964c6444
parent46fa5be2e4b6453dddfb90ba19ce68b39e525534 (diff)
parent513b1c9f3b4727f99f5d637aadb37f3710a8e7d6 (diff)
downloadoslo-messaging-b3e8c1bd05bf2d8738294b7bc6016d9905e8d5ca.tar.gz
Merge "Don't raise Timeout on no-matchmaker results" into stable/kilo
-rw-r--r--oslo_messaging/_drivers/impl_zmq.py9
-rw-r--r--oslo_messaging/tests/drivers/test_impl_zmq.py33
2 files changed, 40 insertions, 2 deletions
diff --git a/oslo_messaging/_drivers/impl_zmq.py b/oslo_messaging/_drivers/impl_zmq.py
index 7fcfd62..0e06843 100644
--- a/oslo_messaging/_drivers/impl_zmq.py
+++ b/oslo_messaging/_drivers/impl_zmq.py
@@ -770,10 +770,15 @@ def _multi_send(method, context, topic, msg, timeout=None,
# Don't stack if we have no matchmaker results
if not queues:
- LOG.warn(_("No matchmaker results. Not casting."))
+ warn_log = _LW("No matchmaker results. Not sending.")
+
+ if method.__name__ == '_cast':
+ LOG.warn(warn_log)
+ return
+
# While not strictly a timeout, callers know how to handle
# this exception and a timeout isn't too big a lie.
- raise rpc_common.Timeout(_("No match from matchmaker."))
+ raise rpc_common.Timeout(warn_log)
# This supports brokerless fanout (addresses > 1)
return_val = None
diff --git a/oslo_messaging/tests/drivers/test_impl_zmq.py b/oslo_messaging/tests/drivers/test_impl_zmq.py
index 5f3527d..ee0f034 100644
--- a/oslo_messaging/tests/drivers/test_impl_zmq.py
+++ b/oslo_messaging/tests/drivers/test_impl_zmq.py
@@ -27,6 +27,7 @@ except ImportError:
zmq = None
import oslo_messaging
+from oslo_messaging._drivers import common as rpc_common
from oslo_messaging.tests import utils as test_utils
# eventlet is not yet py3 compatible, so skip if not installed
@@ -385,6 +386,38 @@ class TestZmqListener(ZmqBaseTestCase):
class TestZmqDriver(ZmqBaseTestCase):
@mock.patch('oslo_messaging._drivers.impl_zmq._cast', autospec=True)
+ @mock.patch('oslo_messaging._drivers.matchmaker.MatchMakerBase.queues',
+ autospec=True)
+ def test_zmqdriver_multi_send_cast_with_no_queues(self,
+ mock_queues,
+ mock_cast):
+ context = mock.Mock(autospec=impl_zmq.RpcContext)
+ topic = 'testtopic'
+ msg = 'jeronimo'
+
+ with mock.patch.object(impl_zmq.LOG, 'warn') as flog:
+ mock_queues.return_value = None
+ impl_zmq._multi_send(mock_cast, context, topic, msg)
+ self.assertEqual(1, flog.call_count)
+ args, kwargs = flog.call_args
+ self.assertIn('No matchmaker results', args[0])
+
+ @mock.patch('oslo_messaging._drivers.impl_zmq._call', autospec=True)
+ @mock.patch('oslo_messaging._drivers.matchmaker.MatchMakerBase.queues',
+ autospec=True)
+ def test_zmqdriver_multi_send_call_with_no_queues(self,
+ mock_queues,
+ mock_call):
+ context = mock.Mock(autospec=impl_zmq.RpcContext)
+ topic = 'testtopic'
+ msg = 'jeronimo'
+
+ mock_queues.return_value = None
+ self.assertRaises(rpc_common.Timeout,
+ impl_zmq._multi_send,
+ mock_call, context, topic, msg)
+
+ @mock.patch('oslo_messaging._drivers.impl_zmq._cast', autospec=True)
@mock.patch('oslo_messaging._drivers.impl_zmq._multi_send', autospec=True)
def test_zmqdriver_send(self, mock_multi_send, mock_cast):
context = mock.Mock(autospec=impl_zmq.RpcContext)