Permalink
Browse files

Fail fast when messaging detects failure

  • Loading branch information...
1 parent 62dbc6a commit 879e31c6a9d06712c14dce9df9414bbdd1a7c2ab @daf daf committed Jan 14, 2013
Showing with 19 additions and 1 deletion.
  1. +4 −1 pyon/net/messaging.py
  2. +15 −0 pyon/net/test/test_messaging.py
View
@@ -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)
@@ -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):

0 comments on commit 879e31c

Please sign in to comment.