BIND 10 trac2353, updated. 58f0aac3a8f36f335c0546f44122ff43f42f5761 [2353] Test unknown pids in BoB.reap_children()

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Nov 16 05:33:58 UTC 2012


The branch, trac2353 has been updated
       via  58f0aac3a8f36f335c0546f44122ff43f42f5761 (commit)
       via  84fbdaeddb176af0a5cd73caf76698208b4e94a7 (commit)
       via  09f21f49fa1e214af117262c305efb3968becd8f (commit)
      from  36d2b848c6badf00bae61bd958b891b7e2acc8cd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 58f0aac3a8f36f335c0546f44122ff43f42f5761
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri Nov 16 11:03:43 2012 +0530

    [2353] Test unknown pids in BoB.reap_children()

commit 84fbdaeddb176af0a5cd73caf76698208b4e94a7
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri Nov 16 11:02:46 2012 +0530

    [2353] Simply assertFalse() for the list

commit 09f21f49fa1e214af117262c305efb3968becd8f
Author: Mukund Sivaraman <muks at isc.org>
Date:   Fri Nov 16 10:57:35 2012 +0530

    [2353] Test exception handling in BoB.reap_children()

-----------------------------------------------------------------------

Summary of changes:
 src/bin/bind10/tests/bind10_test.py.in |   43 ++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

-----------------------------------------------------------------------
diff --git a/src/bin/bind10/tests/bind10_test.py.in b/src/bin/bind10/tests/bind10_test.py.in
index debf0cf..491b315 100644
--- a/src/bin/bind10/tests/bind10_test.py.in
+++ b/src/bin/bind10/tests/bind10_test.py.in
@@ -717,6 +717,21 @@ class MockBob(BoB):
         self.get_process_exit_status_called = True
         return (53, 0)
 
+    def _get_process_exit_status_unknown_pid(self):
+        if self.get_process_exit_status_called:
+            return (0, 0)
+        self.get_process_exit_status_called = True
+        return (42, 0)
+
+    def _get_process_exit_status_raises_oserror_echild(self):
+        raise OSError(errno.ECHILD, 'Mock error')
+
+    def _get_process_exit_status_raises_oserror_other(self):
+        raise OSError(0, 'Mock error')
+
+    def _get_process_exit_status_raises_other(self):
+        raise Exception('Mock error')
+
 class MockBobSimple(BoB):
     def __init__(self):
         BoB.__init__(self)
@@ -1448,6 +1463,34 @@ class TestBossComponents(unittest.TestCase):
         # now, we should as the mock component.failed() returns False
         self.assertTrue(component in bob.components_to_restart)
 
+        # case where the returned pid is unknown to us. nothing should
+        # happpen then.
+        bob.get_process_exit_status_called = False
+        bob._get_process_exit_status = bob._get_process_exit_status_unknown_pid
+        bob.components_to_restart = []
+        # this should do nothing as the pid is unknown
+        bob.reap_children()
+        self.assertFalse(bob.components_to_restart)
+
+        # case where bob._get_process_exit_status() raises OSError with errno.ECHILD
+        bob._get_process_exit_status = bob._get_process_exit_status_raises_oserror_echild
+        bob.components_to_restart = []
+        # this should catch and handle the OSError
+        bob.reap_children()
+        self.assertFalse(bob.components_to_restart)
+
+        # case where bob._get_process_exit_status() raises OSError with
+        # errno other than ECHILD
+        bob._get_process_exit_status = bob._get_process_exit_status_raises_oserror_other
+        with self.assertRaises(OSError):
+            bob.reap_children()
+
+        # case where bob._get_process_exit_status() raises something
+        # other than OSError
+        bob._get_process_exit_status = bob._get_process_exit_status_raises_other
+        with self.assertRaises(Exception):
+            bob.reap_children()
+
     def test_kill_started_components(self):
         '''Test that started components are killed.'''
         bob = MockBob()



More information about the bind10-changes mailing list