Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fail fast when messaging detects failure

  • Loading branch information...
commit 879e31c6a9d06712c14dce9df9414bbdd1a7c2ab 1 parent 62dbc6a
@daf daf authored
Showing with 19 additions and 1 deletion.
  1. +4 −1 pyon/net/messaging.py
  2. +15 −0 pyon/net/test/test_messaging.py
View
5 pyon/net/messaging.py
@@ -20,6 +20,7 @@
from pyon.net.transport import LocalTransport, LocalRouter, AMQPTransport, ComposableTransport
from collections import defaultdict
+import traceback
class BaseNode(object):
"""
@@ -174,8 +175,10 @@ def _new_transport(self, ch_number=None):
amq_chan = blocking_cb(self.client.channel, 'on_open_callback', channel_number=ch_number)
if amq_chan is None:
log.error("AMQCHAN IS NONE THIS SHOULD NEVER HAPPEN, chan number requested: %s", ch_number)
- import traceback
traceback.print_stack()
+ from pyon.container.cc import Container
+ if Container.instance is not None:
+ Container.instance.fail_fast("AMQCHAN IS NONE, messaging has failed", True)
raise StandardError("AMQCHAN IS NONE THIS SHOULD NEVER HAPPEN, chan number requested: %s" % ch_number)
transport = AMQPTransport(amq_chan)
View
15 pyon/net/test/test_messaging.py
@@ -222,6 +222,21 @@ def test_destroy_pool(self):
self.assertEqual(chmock._destroy_queue.call_count, 20)
+ @patch('pyon.net.messaging.blocking_cb')
+ def test__new_transport(self, bcbmock):
+ self._node.client = Mock()
+ transport = self._node._new_transport()
+
+ bcbmock.assert_called_once_with(self._node.client.channel, 'on_open_callback', channel_number=None)
+
+ @patch('pyon.net.messaging.traceback', Mock())
+ @patch('pyon.net.messaging.blocking_cb', return_value=None)
+ @patch('pyon.container.cc.Container.instance')
+ def test__new_transport_fails(self, containermock, bcbmock):
+ self._node.client = Mock()
+ self.assertRaises(StandardError, self._node._new_transport)
+ containermock.fail_fast.assert_called_once_with("AMQCHAN IS NONE, messaging has failed", True)
+
@attr('UNIT')
class TestMessaging(PyonTestCase):
def test_ioloop(self):
Please sign in to comment.
Something went wrong with that request. Please try again.