From: Mukund Sivaraman Date: Thu, 6 Dec 2012 03:20:03 +0000 (+0530) Subject: [2353] Test BoB.startup() when socket already exists X-Git-Tag: bind10-1.0.0-beta-release~19^2~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de66fdd73b8f545768166b7406be878c137cc019;p=thirdparty%2Fkea.git [2353] Test BoB.startup() when socket already exists --- diff --git a/src/bin/bind10/tests/bind10_test.py.in b/src/bin/bind10/tests/bind10_test.py.in index 1d68393e36..4201cdc3bb 100644 --- a/src/bin/bind10/tests/bind10_test.py.in +++ b/src/bin/bind10/tests/bind10_test.py.in @@ -1234,6 +1234,7 @@ class TestBossComponents(unittest.TestCase): self._tmp_time = None self._tmp_sleep = None self._tmp_module_cc_session = None + self._tmp_cc_session = None def tearDown(self): if self._tmp_time is not None: @@ -1242,6 +1243,8 @@ class TestBossComponents(unittest.TestCase): time.sleep = self._tmp_sleep if self._tmp_module_cc_session is not None: isc.config.ModuleCCSession = self._tmp_module_cc_session + if self._tmp_cc_session is not None: + isc.cc.Session = self._tmp_cc_session def __unary_hook(self, param): """ @@ -1997,6 +2000,17 @@ class TestBossComponents(unittest.TestCase): def kill_started_components(self): self.killed = True + class DummySession(): + def __init__(self, socket_file): + raise isc.cc.session.SessionError('This is the expected case.') + + class DummySessionSocketExists(): + def __init__(self, socket_file): + # simulate that connect passes + return + + isc.cc.Session = DummySession + # All is well case, where all components are started # successfully. We check that the actual call to # start_all_components() is made, and BoB.runnable is true. @@ -2026,6 +2040,14 @@ class TestBossComponents(unittest.TestCase): r = bob.startup() self.assertEqual({'BIND10_MSGQ_SOCKET_FILE': 'foo'}, bob.c_channel_env) + # Check the case when socket file already exists + isc.cc.Session = DummySessionSocketExists + bob = MockBobStartup(False) + r = bob.startup() + self.assertIn('already running', r) + + # isc.cc.Session is restored during tearDown(). + class SocketSrvTest(unittest.TestCase): """ This tests some methods of boss related to the unix domain sockets used