diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-04-01 20:24:45 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-04-01 20:24:45 +0000 |
| commit | cbcd3fb2bf4f698efcd4899a1c3935a6fd91d85b (patch) | |
| tree | 5dc35bb2d4fd493dc98a865255bed62c41291252 /nova/tests | |
| parent | 37dad352a17203102b4b9b828f84db9b75c57071 (diff) | |
| parent | b893608b77dac11fceb0b0392f8f908de586970b (diff) | |
Merge "Make kombu failures retry on IOError"
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/rpc/test_kombu.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/nova/tests/rpc/test_kombu.py b/nova/tests/rpc/test_kombu.py index 47d15f844..aa49b5d51 100644 --- a/nova/tests/rpc/test_kombu.py +++ b/nova/tests/rpc/test_kombu.py @@ -35,14 +35,15 @@ class MyException(Exception): pass -def _raise_exc_stub(stubs, times, obj, method, exc_msg): +def _raise_exc_stub(stubs, times, obj, method, exc_msg, + exc_class=MyException): info = {'called': 0} orig_method = getattr(obj, method) def _raise_stub(*args, **kwargs): info['called'] += 1 if info['called'] <= times: - raise MyException(exc_msg) + raise exc_class(exc_msg) orig_method(*args, **kwargs) stubs.Set(obj, method, _raise_stub) return info @@ -213,6 +214,18 @@ class RpcKombuTestCase(common.BaseRpcAMQPTestCase): self.assertEqual(info['called'], 2) self.assertTrue(isinstance(result, self.rpc.DirectConsumer)) + def test_declare_consumer_ioerrors_will_reconnect(self): + """Test that an IOError exception causes a reconnection""" + info = _raise_exc_stub(self.stubs, 2, self.rpc.DirectConsumer, + '__init__', 'Socket closed', exc_class=IOError) + + conn = self.rpc.Connection() + result = conn.declare_consumer(self.rpc.DirectConsumer, + 'test_topic', None) + + self.assertEqual(info['called'], 3) + self.assertTrue(isinstance(result, self.rpc.DirectConsumer)) + def test_publishing_errors_will_reconnect(self): # Test that any exception with 'timeout' in it causes a # reconnection when declaring the publisher class and when |
