BIND 10 trac2353, updated. 15249e567c9cfae135c1a2bc1a110b4a635b11ab [2353] Test BoB.start_msgq()
BIND 10 source code commits
bind10-changes at lists.isc.org
Sun Nov 18 22:20:43 UTC 2012
The branch, trac2353 has been updated
via 15249e567c9cfae135c1a2bc1a110b4a635b11ab (commit)
via da089cd9b9dc3aa3cb13f1c02e362b870e524b20 (commit)
from 5450b258dbeaaf876fd35c52a1191e4f083a620e (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 15249e567c9cfae135c1a2bc1a110b4a635b11ab
Author: Mukund Sivaraman <muks at isc.org>
Date: Mon Nov 19 03:50:21 2012 +0530
[2353] Test BoB.start_msgq()
commit da089cd9b9dc3aa3cb13f1c02e362b870e524b20
Author: Mukund Sivaraman <muks at isc.org>
Date: Mon Nov 19 03:02:40 2012 +0530
[2353] Remove obsolete comments
-----------------------------------------------------------------------
Summary of changes:
src/bin/bind10/bind10_src.py.in | 22 ++++++++++-----
src/bin/bind10/tests/bind10_test.py.in | 48 ++++++++++++++++++++++++++++----
2 files changed, 57 insertions(+), 13 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/bind10/bind10_src.py.in b/src/bin/bind10/bind10_src.py.in
index debf51c..6784fa3 100755
--- a/src/bin/bind10/bind10_src.py.in
+++ b/src/bin/bind10/bind10_src.py.in
@@ -216,6 +216,7 @@ class BoB:
self.clear_config = clear_config
self.cmdctl_port = cmdctl_port
self.wait_time = wait_time
+ self.msgq_timeout = 5
self._component_configurator = isc.bind10.component.Configurator(self,
isc.bind10.special_component.get_specials())
# The priorities here make them start in the correct order. First
@@ -412,21 +413,30 @@ class BoB:
# raised which is caught by the caller of start_all_processes(); this kills
# processes started up to that point before terminating the program.
+ def _make_process_info(self, name, args, env,
+ dev_null_stdout=False, dev_null_stderr=False):
+ return ProcessInfo(name, args, env, dev_null_stdout, dev_null_stderr)
+
def start_msgq(self):
"""
Start the message queue and connect to the command channel.
"""
self.log_starting("b10-msgq")
- msgq_proc = ProcessInfo("b10-msgq", ["b10-msgq"], self.c_channel_env,
- True, not self.verbose)
+ msgq_proc = self._make_process_info("b10-msgq", ["b10-msgq"],
+ self.c_channel_env,
+ True, not self.verbose)
msgq_proc.spawn()
self.log_started(msgq_proc.pid)
# Now connect to the c-channel
cc_connect_start = time.time()
while self.cc_session is None:
+ # this is only used by unittests
+ if self.msgq_timeout == 0:
+ break
+
# if we have been trying for "a while" give up
- if (time.time() - cc_connect_start) > 5:
+ if (time.time() - cc_connect_start) > self.msgq_timeout:
raise CChannelConnectError("Unable to connect to c-channel after 5 seconds")
# try to connect, and if we can't wait a short while
@@ -437,7 +447,8 @@ class BoB:
# Subscribe to the message queue. The only messages we expect to receive
# on this channel are once relating to process startup.
- self.cc_session.group_subscribe("Boss")
+ if self.cc_session is not None:
+ self.cc_session.group_subscribe("Boss")
return msgq_proc
@@ -493,9 +504,6 @@ class BoB:
# A couple of utility methods for starting processes...
- def _make_process_info(self, name, args, c_channel_env):
- return ProcessInfo(name, args, c_channel_env)
-
def start_process(self, name, args, c_channel_env, port=None, address=None):
"""
Given a set of command arguments, start the process and output
diff --git a/src/bin/bind10/tests/bind10_test.py.in b/src/bin/bind10/tests/bind10_test.py.in
index 1f41a6d..b599b84 100644
--- a/src/bin/bind10/tests/bind10_test.py.in
+++ b/src/bin/bind10/tests/bind10_test.py.in
@@ -748,8 +748,10 @@ class MockBob(BoB):
def _get_process_exit_status_raises_other(self):
raise Exception('Mock error')
- def _make_mock_process_info(self, name, args, c_channel_env):
- return MockProcessInfo(name, args, c_channel_env)
+ def _make_mock_process_info(self, name, args, c_channel_env,
+ dev_null_stdout=False, dev_null_stderr=False):
+ return MockProcessInfo(name, args, c_channel_env,
+ dev_null_stdout, dev_null_stderr)
class MockBobSimple(BoB):
def __init__(self):
@@ -758,6 +760,11 @@ class MockBobSimple(BoB):
self.started_process_name = None
self.started_process_args = None
+ def _make_mock_process_info(self, name, args, c_channel_env,
+ dev_null_stdout=False, dev_null_stderr=False):
+ return MockProcessInfo(name, args, c_channel_env,
+ dev_null_stdout, dev_null_stderr)
+
def start_process(self, name, args, c_channel_env, port=None, address=None):
self.started_process_name = name
self.started_process_args = args
@@ -1550,6 +1557,39 @@ class TestBossComponents(unittest.TestCase):
self.assertFalse(bob.get_processes())
self.assertTrue(component.forceful)
+ def test_start_msgq(self):
+ '''Test that b10-msgq is started.'''
+ bob = MockBobSimple()
+ bob.c_channel_env = {}
+ bob.msgq_timeout = 0
+
+ # use the MockProcessInfo creator
+ bob._make_process_info = bob._make_mock_process_info
+
+ # non-verbose case
+ bob.verbose = False
+ pi = bob.start_msgq()
+ self.assertEqual('b10-msgq', pi.name)
+ self.assertEqual(['b10-msgq'], pi.args)
+ self.assertTrue(pi.dev_null_stdout)
+ self.assertTrue(pi.dev_null_stderr)
+ self.assertEqual({}, pi.env)
+
+ # this is set by ProcessInfo.spawn()
+ self.assertEqual(42147, pi.pid)
+
+ # verbose case
+ bob.verbose = True
+ pi = bob.start_msgq()
+ self.assertEqual('b10-msgq', pi.name)
+ self.assertEqual(['b10-msgq'], pi.args)
+ self.assertTrue(pi.dev_null_stdout)
+ self.assertFalse(pi.dev_null_stderr)
+ self.assertEqual({}, pi.env)
+
+ # this is set by ProcessInfo.spawn()
+ self.assertEqual(42147, pi.pid)
+
def test_start_process(self):
'''Test that processes can be started.'''
bob = MockBob()
@@ -1591,8 +1631,6 @@ class TestBossComponents(unittest.TestCase):
self.assertEqual('/bin/true', bob.started_process_name)
self.assertEqual(['/bin/true', '-v'], bob.started_process_args)
- # there is another test with this name (minus the digits), but both
- # do different things.
def test_start_auth(self):
'''Test that b10-auth is started.'''
bob = MockBobSimple()
@@ -1610,8 +1648,6 @@ class TestBossComponents(unittest.TestCase):
self.assertEqual('b10-auth', bob.started_process_name)
self.assertEqual(['b10-auth', '-v'], bob.started_process_args)
- # there is another test with this name (minus the digits), but both
- # do different things.
def test_start_resolver(self):
'''Test that b10-resolver is started.'''
bob = MockBobSimple()
More information about the bind10-changes
mailing list