From 71904e1d3ddaa196ba1b2bf8c12eff2cfe98ec13 Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Thu, 11 Apr 2019 14:58:40 +0000 Subject: [PATCH] SW-610: fixed messagebus test which failed if ran in parallel in multiple builds-with-tests. The problem was a too largs messagebody filling the broker queue. Reduced the bodies size to a more real life value. --- LCS/Messaging/python/messaging/messagebus.py | 2 +- .../python/messaging/test/t_messagebus.py | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/LCS/Messaging/python/messaging/messagebus.py b/LCS/Messaging/python/messaging/messagebus.py index 1d98ad7ebe4..9e63a6bc7fa 100644 --- a/LCS/Messaging/python/messaging/messagebus.py +++ b/LCS/Messaging/python/messaging/messagebus.py @@ -82,8 +82,8 @@ class FromBus(object): try: logger.debug("[FromBus] Connecting to broker: %s", self.broker) if 'reconnect' in self.broker_options: + # Ignoring duplicate reconnect option in connection init. Is taken care of by proton. self.broker_options.pop('reconnect') - logger.info('[FromBus] Ignoring duplicate reconnect option in connection init') self.connection = proton.utils.BlockingConnection(self.broker, **self.broker_options) logger.debug("[FromBus] Connected to broker: %s", self.broker) except proton.ConnectionException as ex: diff --git a/LCS/Messaging/python/messaging/test/t_messagebus.py b/LCS/Messaging/python/messaging/test/t_messagebus.py index aaae9a5dfc1..9fd36ba7db3 100644 --- a/LCS/Messaging/python/messaging/test/t_messagebus.py +++ b/LCS/Messaging/python/messaging/test/t_messagebus.py @@ -394,13 +394,8 @@ class SendReceiveMessage(unittest.TestCase): self.test_queue.open() self.addCleanup(self.test_queue.close) - self.frombus = FromBus(self.test_queue.address) - self.tobus = ToBus(self.test_queue.address) - - # if there are any dangling messages in the self.test_queue.address, they hold state between the individual tests - # make sure the queue is empty by receiving any dangling messages - with self.frombus: - self.frombus.drain() + self.frombus = self.test_queue.create_frombus() + self.tobus = self.test_queue.create_tobus() def _test_sendrecv(self, send_msg): """ @@ -473,7 +468,7 @@ class SendReceiveMessage(unittest.TestCase): """ Test send/receive of an RequestMessage, containing a large string """ - content = 1000000*'abcdefghijklmnopqrstuvwxyz' # 1 million 24char string + content = 100000*'abcdefghijklmnopqrstuvwxyz' #large enough string, but not too big to overload the broker buffers self._test_sendrecv(RequestMessage(content, reply_to=self.test_queue.address)) def test_sendrecv_request_message_with_nested_dicts_and_lists_with_special_types(self): @@ -488,7 +483,7 @@ class SendReceiveMessage(unittest.TestCase): {'a': 'b', 'c': { 'timestamp': round_to_millisecond_precision(datetime.utcnow())}}], 'bar': [], - 'large_string': 1000000*'abcdefghijklmnopqrstuvwxyz' # 1 million 24char string + 'large_string': 100000*'abcdefghijklmnopqrstuvwxyz' #large enough string, but not too big to overload the broker buffers } self._test_sendrecv(RequestMessage(content, reply_to=self.test_queue.address)) @@ -502,5 +497,5 @@ class SendReceiveMessage(unittest.TestCase): self.assertEqual(content, convertStringDigitKeysToInt(recv_msg.body)) if __name__ == '__main__': - logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO) - unittest.main() + logging.basicConfig(format='%(asctime)s %(process)d %(levelname)s %(message)s', level=logging.INFO) + unittest.main(defaultTest='SendReceiveMessage') -- GitLab