Browse Source

Merge "Don't allow call with fanout target"

changes/09/141509/2
Jenkins 7 years ago
committed by Gerrit Code Review
parent
commit
3129701354
  1. 4
      oslo/messaging/rpc/client.py
  2. 21
      tests/rpc/test_client.py

4
oslo/messaging/rpc/client.py

@ -136,6 +136,10 @@ class _CallContext(object):
def call(self, ctxt, method, **kwargs):
"""Invoke a method and wait for a reply. See RPCClient.call()."""
if self.target.fanout:
raise exceptions.InvalidTarget('A call cannot be used with fanout',
self.target)
msg = self._make_message(ctxt, method, kwargs)
msg_ctxt = self.serializer.serialize_context(ctxt)

21
tests/rpc/test_client.py

@ -17,6 +17,7 @@ import testscenarios
from oslo.config import cfg
from oslo import messaging
from oslo.messaging import exceptions
from oslo.messaging import serializer as msg_serializer
from tests import utils as test_utils
@ -283,6 +284,26 @@ class TestCallRetry(test_utils.BaseTestCase):
client.call({}, 'foo')
class TestCallFanout(test_utils.BaseTestCase):
scenarios = [
('target', dict(prepare=_notset, target={'fanout': True})),
('prepare', dict(prepare={'fanout': True}, target={})),
('both', dict(prepare={'fanout': True}, target={'fanout': True})),
]
def test_call_fanout(self):
transport = _FakeTransport(self.conf)
client = messaging.RPCClient(transport,
messaging.Target(**self.target))
if self.prepare is not _notset:
client = client.prepare(**self.prepare)
self.assertRaises(exceptions.InvalidTarget,
client.call, {}, 'foo')
class TestSerializer(test_utils.BaseTestCase):
scenarios = [

Loading…
Cancel
Save