BIND 10 trac521, updated. 6ff2a83cb7a6c04a258e84818257fe6eda9634a6 [trac521] added a test case "test_command_handler" for bob.command_handler, which tests for bad commamd, "shutdown", "sendstats" and an unknown command, and tests values of parameters transmitted through the cc session.
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Apr 4 06:52:21 UTC 2011
The branch, trac521 has been updated
via 6ff2a83cb7a6c04a258e84818257fe6eda9634a6 (commit)
via 682ea37cfb7e20366521fd48fc98826a21344942 (commit)
from de3c708f962db8fe15287c9a5704d3aa8b257b03 (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 6ff2a83cb7a6c04a258e84818257fe6eda9634a6
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Mon Apr 4 06:49:05 2011 +0000
[trac521] added a test case "test_command_handler" for bob.command_handler,
which tests for bad commamd, "shutdown", "sendstats" and an unknown command, and tests values of parameters transmitted through the cc session.
commit 682ea37cfb7e20366521fd48fc98826a21344942
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Mon Apr 4 06:35:56 2011 +0000
[trac521] add string-casting for the verbose message
-----------------------------------------------------------------------
Summary of changes:
src/bin/bind10/bind10.py.in | 2 +-
src/bin/bind10/tests/bind10_test.py.in | 27 ++++++++++++++++++++++++++-
2 files changed, 27 insertions(+), 2 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/bind10/bind10.py.in b/src/bin/bind10/bind10.py.in
index ec3c165..f078a52 100755
--- a/src/bin/bind10/bind10.py.in
+++ b/src/bin/bind10/bind10.py.in
@@ -272,7 +272,7 @@ class BoB:
def command_handler(self, command, args):
if self.verbose:
- sys.stdout.write("[bind10] Boss got command: " + command + "\n")
+ sys.stdout.write("[bind10] Boss got command: " + str(command) + "\n")
answer = isc.config.ccsession.create_answer(1, "command not implemented")
if type(command) != str:
answer = isc.config.ccsession.create_answer(1, "bad command")
diff --git a/src/bin/bind10/tests/bind10_test.py.in b/src/bin/bind10/tests/bind10_test.py.in
index 0603443..641f399 100644
--- a/src/bin/bind10/tests/bind10_test.py.in
+++ b/src/bin/bind10/tests/bind10_test.py.in
@@ -1,4 +1,4 @@
-from bind10 import ProcessInfo, BoB, dump_pid, unlink_pid_file
+from bind10 import ProcessInfo, BoB, dump_pid, unlink_pid_file, _BASETIME
# XXX: environment tests are currently disabled, due to the preprocessor
# setup that we have now complicating the environment
@@ -9,6 +9,8 @@ import os
import signal
import socket
from isc.net.addr import IPAddr
+import time
+import isc
class TestProcessInfo(unittest.TestCase):
def setUp(self):
@@ -104,6 +106,29 @@ class TestBoB(unittest.TestCase):
self.assertEqual(bob.cfg_start_auth, True)
self.assertEqual(bob.cfg_start_resolver, False)
+ def test_command_handler(self):
+ class DummySession():
+ def group_sendmsg(self, msg, group):
+ (self.msg, self.group) = (msg, group)
+ def group_recvmsg(self, nonblock, seq): pass
+ bob = BoB()
+ bob.cc_session = DummySession()
+ self.assertEqual(bob.command_handler(-1, None),
+ isc.config.ccsession.create_answer(1, "bad command"))
+ self.assertEqual(bob.command_handler("shutdown", None),
+ isc.config.ccsession.create_answer(0))
+ self.assertFalse(bob.runnable)
+ self.assertEqual(bob.command_handler("sendstats", None),
+ isc.config.ccsession.create_answer(0))
+ self.assertEqual(bob.cc_session.group, "Stats")
+ self.assertEqual(bob.cc_session.msg,
+ isc.config.ccsession.create_command(
+ 'set', { "stats_data": {
+ 'bind10.boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME)
+ }}))
+ self.assertEqual(bob.command_handler("__UNKNOWN__", None),
+ isc.config.ccsession.create_answer(1, "Unknown command"))
+
# Class for testing the BoB start/stop components routines.
#
# Although testing that external processes start is outside the scope
More information about the bind10-changes
mailing list