Fix handling expected exceptions in rabbit driver
We shouldn't be logging expected exceptions. Add a failing rabbit driver test to check this and fix it. Change-Id: I78b758957117be7c11c5826a27dd6d1d4fffe9cb
This commit is contained in:
parent
6ec2c8bdbf
commit
5fa7f93d09
@ -40,7 +40,8 @@ class AMQPIncomingMessage(base.IncomingMessage):
|
||||
def _send_reply(self, conn, reply=None, failure=None,
|
||||
ending=False, log_failure=True):
|
||||
if failure:
|
||||
failure = rpc_common.serialize_remote_exception(failure)
|
||||
failure = rpc_common.serialize_remote_exception(failure,
|
||||
log_failure)
|
||||
|
||||
msg = {'result': reply, 'failure': failure}
|
||||
if ending:
|
||||
|
@ -24,6 +24,7 @@ import kombu
|
||||
import testscenarios
|
||||
|
||||
from oslo import messaging
|
||||
from oslo.messaging._drivers import common as driver_common
|
||||
from oslo.messaging._drivers import impl_rabbit as rabbit_driver
|
||||
from oslo.messaging.openstack.common import jsonutils
|
||||
from oslo.messaging import transport as msg_transport
|
||||
@ -96,6 +97,14 @@ class TestSendReceive(test_utils.BaseTestCase):
|
||||
senders = []
|
||||
replies = []
|
||||
msgs = []
|
||||
errors = []
|
||||
|
||||
def stub_error(msg, *a, **kw):
|
||||
if (a and len(a) == 1 and isinstance(a[0], dict) and a[0]):
|
||||
a = a[0]
|
||||
errors.append(str(msg) % a)
|
||||
|
||||
self.stubs.Set(driver_common.LOG, 'error', stub_error)
|
||||
|
||||
def send_and_wait_for_reply(i):
|
||||
try:
|
||||
@ -150,6 +159,11 @@ class TestSendReceive(test_utils.BaseTestCase):
|
||||
else:
|
||||
self.assertEqual(reply, {'bar': order[i]})
|
||||
|
||||
if not self.timeout and self.failure and not self.expected:
|
||||
self.assertTrue(len(errors) > 0, errors)
|
||||
else:
|
||||
self.assertEqual(len(errors), 0, errors)
|
||||
|
||||
|
||||
TestSendReceive.generate_scenarios()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user