mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 14:35:29 +00:00
[1429] Catch an exception
This commit is contained in:
@@ -886,7 +886,14 @@ class BoB:
|
|||||||
so to the _socket_cache.
|
so to the _socket_cache.
|
||||||
"""
|
"""
|
||||||
logger.error(BIND10_LOST_SOCKET_CONSUMER, unix_socket.fileno())
|
logger.error(BIND10_LOST_SOCKET_CONSUMER, unix_socket.fileno())
|
||||||
self._socket_cache.drop_application(unix_socket.fileno())
|
try:
|
||||||
|
self._socket_cache.drop_application(unix_socket.fileno())
|
||||||
|
except ValueError:
|
||||||
|
# This means the application holds no sockets. It's harmless, as it
|
||||||
|
# can happen in real life - for example, it requests a socket, but
|
||||||
|
# get_socket doesn't find it, so the application dies. It should be
|
||||||
|
# rare, though.
|
||||||
|
pass
|
||||||
|
|
||||||
def insert_creator(self, creator):
|
def insert_creator(self, creator):
|
||||||
"""
|
"""
|
||||||
|
@@ -159,7 +159,12 @@ class TestCacheCommands(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
Part of pretending to be the cache. Logs the parameter to
|
Part of pretending to be the cache. Logs the parameter to
|
||||||
self.__drop_app_called.
|
self.__drop_app_called.
|
||||||
|
|
||||||
|
In the case self.__raise_exception is set, the exception there
|
||||||
|
is raised instead.
|
||||||
"""
|
"""
|
||||||
|
if self.__raise_exception is not None:
|
||||||
|
raise self.__raise_exception
|
||||||
self.__drop_app_called = application
|
self.__drop_app_called = application
|
||||||
|
|
||||||
def test_consumer_dead(self):
|
def test_consumer_dead(self):
|
||||||
@@ -169,6 +174,16 @@ class TestCacheCommands(unittest.TestCase):
|
|||||||
self.__boss.socket_consumer_dead(self.FalseSocket())
|
self.__boss.socket_consumer_dead(self.FalseSocket())
|
||||||
self.assertEqual(42, self.__drop_app_called)
|
self.assertEqual(42, self.__drop_app_called)
|
||||||
|
|
||||||
|
def test_consumer_dead_invalid(self):
|
||||||
|
"""
|
||||||
|
Test that it doesn't crash in case the application is not known to
|
||||||
|
the cache, the boss doesn't crash, as this actually can happen in
|
||||||
|
practice.
|
||||||
|
"""
|
||||||
|
self.__raise_exception = ValueError("This application is unknown")
|
||||||
|
# This doesn't crash
|
||||||
|
self.__boss.socket_consumer_dead(self.FalseSocket())
|
||||||
|
|
||||||
def get_socket(self, token, application):
|
def get_socket(self, token, application):
|
||||||
"""
|
"""
|
||||||
Part of pretending to be the cache. If there's anything in
|
Part of pretending to be the cache. If there's anything in
|
||||||
|
Reference in New Issue
Block a user