From: Mukund Sivaraman Date: Mon, 5 Nov 2012 07:13:00 +0000 (+0530) Subject: [2353] Test BoB.reap_children X-Git-Tag: bind10-1.0.0-beta-release~19^2~104 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=356a8b2e2cdbd2470eb134bfe08f80fb54028abb;p=thirdparty%2Fkea.git [2353] Test BoB.reap_children --- diff --git a/src/bin/bind10/tests/bind10_test.py.in b/src/bin/bind10/tests/bind10_test.py.in index ece6370c3a..3caa691506 100644 --- a/src/bin/bind10/tests/bind10_test.py.in +++ b/src/bin/bind10/tests/bind10_test.py.in @@ -490,6 +490,7 @@ class MockBob(BoB): self.c_channel_env = {} self.components = { } self.creator = False + self.get_process_exit_status_called = False class MockSockCreator(isc.bind10.component.Component): def __init__(self, process, boss, kind, address=None, params=None): @@ -661,6 +662,12 @@ class MockBob(BoB): del self.components[12] self.cmdctl = False + def _get_process_exit_status(self): + if self.get_process_exit_status_called: + return (0, 0) + self.get_process_exit_status_called = True + return (53, 0) + class TestStartStopProcessesBob(unittest.TestCase): """ Check that the start_all_components method starts the right combination @@ -938,6 +945,12 @@ class MockComponent: self.restarted = True return True + def is_running(self): + return True + + def failed(self, status): + return False + class TestBossCmd(unittest.TestCase): def test_ping(self): """ @@ -1333,6 +1346,20 @@ class TestBossComponents(unittest.TestCase): self.assertFalse(component.restarted) self.assertFalse(component in bob.components_to_restart) + def test_reap_children(self): + '''Test that children are queued to be restarted when they ask for it.''' + bob = MockBob() + bob.runnable = True + component = MockComponent('test', 53) + bob.components[53] = component + + # at first, we don't have the component with pid 53 that + # terminated in our restart queue. + self.assertFalse(component in bob.components_to_restart) + bob.reap_children() + # now, we should as the mock component.failed() returns False + self.assertTrue(component in bob.components_to_restart) + class SocketSrvTest(unittest.TestCase): """ This tests some methods of boss related to the unix domain sockets used