Merge "Don't allow call with fanout target"
This commit is contained in:
commit
3129701354
|
@ -136,6 +136,10 @@ class _CallContext(object):
|
||||||
|
|
||||||
def call(self, ctxt, method, **kwargs):
|
def call(self, ctxt, method, **kwargs):
|
||||||
"""Invoke a method and wait for a reply. See RPCClient.call()."""
|
"""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 = self._make_message(ctxt, method, kwargs)
|
||||||
msg_ctxt = self.serializer.serialize_context(ctxt)
|
msg_ctxt = self.serializer.serialize_context(ctxt)
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import testscenarios
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
from oslo import messaging
|
from oslo import messaging
|
||||||
|
from oslo.messaging import exceptions
|
||||||
from oslo.messaging import serializer as msg_serializer
|
from oslo.messaging import serializer as msg_serializer
|
||||||
from tests import utils as test_utils
|
from tests import utils as test_utils
|
||||||
|
|
||||||
|
@ -283,6 +284,26 @@ class TestCallRetry(test_utils.BaseTestCase):
|
||||||
client.call({}, 'foo')
|
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):
|
class TestSerializer(test_utils.BaseTestCase):
|
||||||
|
|
||||||
scenarios = [
|
scenarios = [
|
||||||
|
|
Loading…
Reference in New Issue