]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2353] Test BoB.startup()
authorMukund Sivaraman <muks@isc.org>
Mon, 19 Nov 2012 22:22:55 +0000 (03:52 +0530)
committerMukund Sivaraman <muks@isc.org>
Mon, 19 Nov 2012 22:22:55 +0000 (03:52 +0530)
src/bin/bind10/tests/bind10_test.py.in

index 8672e528a8e0c4b1fb6e11097e4ed78992e23440..833ea155fa9cabe72bfb18682cca432b1d997064 100644 (file)
@@ -1904,6 +1904,42 @@ class TestBossComponents(unittest.TestCase):
         self.assertEqual(len(bob._unix_sockets), 1)
         self.assertEqual(bob._unix_sockets[42][1], b'You')
 
+    def test_startup(self):
+        '''Test that BoB.startup() handles failures properly.'''
+        class MockBobStartup(BoB):
+            def __init__(self, throw):
+                self.throw = throw
+                self.started = False
+                self.killed = False
+                self.msgq_socket_file = None
+                self.curproc = 'myproc'
+                self.runnable = False
+
+            def start_all_components(self):
+                self.started = True
+                if self.throw:
+                    raise Exception('Assume starting components has failed.')
+
+            def kill_started_components(self):
+                self.killed = True
+
+        # All is well case
+        bob = MockBobStartup(False)
+        r = bob.startup()
+        self.assertIsNone(r)
+        self.assertTrue(bob.started)
+        self.assertFalse(bob.killed)
+        self.assertTrue(bob.runnable)
+
+        # Case where starting all components fails
+        bob = MockBobStartup(True)
+        r = bob.startup()
+        # r contains an error message
+        self.assertEqual(r, 'Unable to start myproc: Assume starting components has failed.')
+        self.assertTrue(bob.started)
+        self.assertTrue(bob.killed)
+        self.assertFalse(bob.runnable)
+
 class SocketSrvTest(unittest.TestCase):
     """
     This tests some methods of boss related to the unix domain sockets used