BIND 10 trac648, updated. a73a3ef00b42b0fc5aa5ecf832cb713db74288a1 Working show_processes with test.
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Mar 4 18:38:10 UTC 2011
The branch, trac648 has been updated
via a73a3ef00b42b0fc5aa5ecf832cb713db74288a1 (commit)
via cf020fa451a20df9625253b3b2ccbc00e8144c1c (commit)
via be4c4ffc719d10735bfaea5a7cd5bdea7e5f06c7 (commit)
from 715fd606c4d77f1947c8c26142a5d516d54a00da (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 a73a3ef00b42b0fc5aa5ecf832cb713db74288a1
Author: Shane Kerr <shane at isc.org>
Date: Fri Mar 4 19:36:51 2011 +0100
Working show_processes with test.
commit cf020fa451a20df9625253b3b2ccbc00e8144c1c
Author: Shane Kerr <shane at isc.org>
Date: Fri Mar 4 16:26:57 2011 +0100
Have a working test for the new "ping" command.
commit be4c4ffc719d10735bfaea5a7cd5bdea7e5f06c7
Author: Shane Kerr <shane at isc.org>
Date: Fri Mar 4 14:15:05 2011 +0100
Got the paths and such set up to run tests properly now.
-----------------------------------------------------------------------
Summary of changes:
src/bin/bind10/bind10.py.in | 14 +++++
src/bin/bind10/bob.spec | 10 ++++
src/bin/bind10/tests/Makefile.am | 7 ++-
src/bin/bind10/tests/bind10_cmd_test.py | 91 +++++++++++++++++++++++++++++--
4 files changed, 114 insertions(+), 8 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/bind10/bind10.py.in b/src/bin/bind10/bind10.py.in
index 83acf1f..676ff2b 100755
--- a/src/bin/bind10/bind10.py.in
+++ b/src/bin/bind10/bind10.py.in
@@ -270,6 +270,14 @@ class BoB:
answer = isc.config.ccsession.create_answer(0)
return answer
+ def get_processes(self):
+ pids = list(self.processes.keys())
+ pids.sort()
+ process_list = [ ]
+ for pid in pids:
+ process_list.append([ pid, self.processes[pid].name ])
+ return process_list
+
def command_handler(self, command, args):
if self.verbose:
sys.stdout.write("[bind10] Boss got command: " + command + "\n")
@@ -280,7 +288,13 @@ class BoB:
if command == "shutdown":
self.runnable = False
answer = isc.config.ccsession.create_answer(0)
+ elif command == "ping":
+ answer = isc.config.ccsession.create_answer(0, "pong")
+ elif command == "show_processes":
+ answer = isc.config.ccsession.create_answer(0,
+ self.get_processes())
else:
+ print("should be doing the unknown command thingy")
answer = isc.config.ccsession.create_answer(1,
"Unknown command")
return answer
diff --git a/src/bin/bind10/bob.spec b/src/bin/bind10/bob.spec
index b45a12f..c206b34 100644
--- a/src/bin/bind10/bob.spec
+++ b/src/bin/bind10/bob.spec
@@ -21,6 +21,16 @@
"command_name": "shutdown",
"command_description": "Shut down BIND 10",
"command_args": []
+ },
+ {
+ "command_name": "ping",
+ "command_description": "Ping the boss process",
+ "command_args": []
+ },
+ {
+ "command_name": "show_processes",
+ "command_description": "List the running BIND 10 processes",
+ "command_args": []
}
]
}
diff --git a/src/bin/bind10/tests/Makefile.am b/src/bin/bind10/tests/Makefile.am
index d2a8c37..dbb59e0 100644
--- a/src/bin/bind10/tests/Makefile.am
+++ b/src/bin/bind10/tests/Makefile.am
@@ -1,6 +1,6 @@
PYCOVERAGE_RUN = @PYCOVERAGE_RUN@
-#PYTESTS = args_test.py bind10_test.py signal_test.py
-PYTESTS = bind10_test.py signal_test.py
+#PYTESTS = args_test.py bind10_test.py bind10_cmd_test.py
+PYTESTS = bind10_test.py bind10_cmd_test.py
EXTRA_DIST = $(PYTESTS)
# test using command-line arguments, so use check-local target instead of TESTS
@@ -13,5 +13,6 @@ endif
for pytest in $(PYTESTS) ; do \
echo Running test: $$pytest ; \
env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/bin/bind10 \
- $(PYCOVERAGE_RUN) $(abs_srcdir)/$$pytest || exit ; \
+ BIND10_MSGQ_SOCKET_FILE=$(abs_top_builddir)/msgq_socket \
+ $(PYCOVERAGE_RUN) $(abs_srcdir)/$$pytest || exit ; \
done
diff --git a/src/bin/bind10/tests/bind10_cmd_test.py b/src/bin/bind10/tests/bind10_cmd_test.py
index 0861def..2926864 100644
--- a/src/bin/bind10/tests/bind10_cmd_test.py
+++ b/src/bin/bind10/tests/bind10_cmd_test.py
@@ -10,7 +10,9 @@ import isc.cc
BIND10_EXE="../run_bind10.sh"
TIMEOUT=3
-class TestBossBindctl(unittest.TestCase):
+# TODO: single setup
+
+class TestBossCmd(unittest.TestCase):
def _waitForString(self, bob, s):
"""Read the input from the Process object until we find the
string we're looking for or we timeout."""
@@ -27,20 +29,99 @@ class TestBossBindctl(unittest.TestCase):
break
return found_string
- def testBasicBindctl(self):
- """Run basic bindctl"""
+ def testPing(self):
+ """Simple aliveness check"""
+ ping_worked = False
+
+ # start bind10
+ bob = subprocess.Popen(args=(BIND10_EXE,),
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ started_ok = self._waitForString(bob, '[bind10] BIND 10 started')
+
+ if started_ok:
+ # wrap everything in a try block so we don't leave
+ # stray processes around on error
+ try:
+ # connect to the command channel
+ self.cc = isc.cc.Session()
+ self.cc.group_subscribe('Boss')
+
+ # send a ping
+ cmd = { "command": ['ping']}
+ seq = self.cc.group_sendmsg(cmd, 'Boss')
+
+ # wait for a pong
+ env, msg = self.cc.recvmsg(False, seq)
+ if 'result' in msg:
+ result = msg['result']
+ if (result[0] == 0) and (result[1] == 'pong'):
+ ping_worked = True
+ except:
+ pass
+
+ # shut down
+ bob.terminate()
+ bob.wait()
+
+ # check that we were able to ping
+ self.assertEqual(ping_worked, True)
+
+ def _check_processes(self, process_list):
+ # the msgq and cfgmgr are required, everything else is optional
+ msgq_pid = None
+ cfgmgr_pid = None
+ for process in process_list:
+ if len(process) != 2:
+ return False
+ if type(process[0]) != int:
+ return False
+ if type(process[1]) != str:
+ return False
+ if process[1] == 'b10-msgq':
+ msgq_pid = process[0]
+ elif process[1] == 'b10-cfgmgr':
+ cfgmgr_pid = process[0]
+ if msgq_pid and cfgmgr_pid:
+ return True
+ return False
+
+ def testShowServices(self):
+ """Get a list of children"""
+ command_worked = False
+
# start bind10
bob = subprocess.Popen(args=(BIND10_EXE,),
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
started_ok = self._waitForString(bob, '[bind10] BIND 10 started')
- # connect to the command channel
- self.cc = isc.cc.Session()
+ if started_ok:
+ # wrap everything in a try block so we don't leave
+ # stray processes around on error
+ try:
+ # connect to the command channel
+ self.cc = isc.cc.Session()
+ self.cc.group_subscribe('Boss')
+
+ # send a ping
+ cmd = { "command": ['show_processes']}
+ seq = self.cc.group_sendmsg(cmd, 'Boss')
+
+ # wait for a pong
+ env, msg = self.cc.recvmsg(False, seq)
+ if 'result' in msg:
+ result = msg['result']
+ if (result[0] == 0) and self._check_processes(result[1]):
+ command_worked = True
+ except:
+ pass
# shut down
bob.terminate()
bob.wait()
+ # check that we were able to ping
+ self.assertEqual(command_worked, True)
+
if __name__ == '__main__':
unittest.main()
More information about the bind10-changes
mailing list