Commit de66fdd7 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2353] Test BoB.startup() when socket already exists

parent cdbe6ded
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment