test: Don't test message's reply timeout
Message's reply time is affected by many factors. Heavy load usually affects a lot, we use threading module in test, due to the GIL issue, we can't make sure threads finished quickly as we expected. So we shouldn't assume messag replies quickly within (timeout + 0.100). Closes-Bug: #1510481 Change-Id: Ib55d5557c927d9917e355c59da62f8f9cd8a7f9c
This commit is contained in:
parent
e15c11c499
commit
8dfc064c79
@ -351,11 +351,6 @@ class TestSendReceive(test_utils.BaseTestCase):
|
||||
('zero', dict(rx_id=False, reply=0)),
|
||||
]
|
||||
|
||||
_reply_fail = [
|
||||
('reply_success', dict(reply_failure_404=False)),
|
||||
('reply_failure', dict(reply_failure_404=True)),
|
||||
]
|
||||
|
||||
_failure = [
|
||||
('success', dict(failure=False)),
|
||||
('failure', dict(failure=True, expected=False)),
|
||||
@ -372,7 +367,6 @@ class TestSendReceive(test_utils.BaseTestCase):
|
||||
cls.scenarios = testscenarios.multiply_scenarios(cls._n_senders,
|
||||
cls._context,
|
||||
cls._reply,
|
||||
cls._reply_fail,
|
||||
cls._failure,
|
||||
cls._timeout)
|
||||
|
||||
@ -405,10 +399,8 @@ class TestSendReceive(test_utils.BaseTestCase):
|
||||
|
||||
def send_and_wait_for_reply(i):
|
||||
try:
|
||||
if self.reply_failure_404:
|
||||
timeout = 0.01
|
||||
else:
|
||||
timeout = self.timeout
|
||||
|
||||
timeout = self.timeout
|
||||
replies.append(driver.send(target,
|
||||
self.ctxt,
|
||||
{'tx_id': i},
|
||||
@ -418,8 +410,7 @@ class TestSendReceive(test_utils.BaseTestCase):
|
||||
self.assertIsNone(self.timeout)
|
||||
except (ZeroDivisionError, oslo_messaging.MessagingTimeout) as e:
|
||||
replies.append(e)
|
||||
self.assertTrue(self.failure or self.timeout is not None
|
||||
or self.reply_failure_404)
|
||||
self.assertTrue(self.failure or self.timeout is not None)
|
||||
|
||||
while len(senders) < self.n_senders:
|
||||
senders.append(threading.Thread(target=send_and_wait_for_reply,
|
||||
@ -439,18 +430,6 @@ class TestSendReceive(test_utils.BaseTestCase):
|
||||
if len(order) > 1:
|
||||
order[-1], order[-2] = order[-2], order[-1]
|
||||
|
||||
if self.reply_failure_404:
|
||||
start = time.time()
|
||||
# NOTE(sileht): Simulate a rpc client restart
|
||||
# By returning a ExchangeNotFound when we try to
|
||||
# send reply
|
||||
exc = (driver._reply_q_conn.connection.
|
||||
connection.channel_errors[0]())
|
||||
exc.code = 404
|
||||
self.useFixture(mockpatch.Patch(
|
||||
'kombu.messaging.Producer.publish',
|
||||
side_effect=exc))
|
||||
|
||||
for i in order:
|
||||
if self.timeout is None:
|
||||
if self.failure:
|
||||
@ -464,22 +443,11 @@ class TestSendReceive(test_utils.BaseTestCase):
|
||||
msgs[i].reply({'rx_id': i})
|
||||
else:
|
||||
msgs[i].reply(self.reply)
|
||||
elif self.reply_failure_404:
|
||||
msgs[i].reply({})
|
||||
senders[i].join()
|
||||
|
||||
if self.reply_failure_404:
|
||||
# NOTE(sileht) all reply fail, first take
|
||||
# kombu_missing_consumer_retry_timeout seconds to fail
|
||||
# next immediately fail
|
||||
dt = time.time() - start
|
||||
rabbit_conf = self.conf.oslo_messaging_rabbit
|
||||
timeout = rabbit_conf.kombu_missing_consumer_retry_timeout
|
||||
self.assertTrue(timeout <= dt < (timeout + 0.100), dt)
|
||||
|
||||
self.assertEqual(len(senders), len(replies))
|
||||
for i, reply in enumerate(replies):
|
||||
if self.timeout is not None or self.reply_failure_404:
|
||||
if self.timeout is not None:
|
||||
self.assertIsInstance(reply, oslo_messaging.MessagingTimeout)
|
||||
elif self.failure:
|
||||
self.assertIsInstance(reply, ZeroDivisionError)
|
||||
|
Loading…
Reference in New Issue
Block a user