Commit 1257b930 authored by Shane Kerr's avatar Shane Kerr
Browse files

Moved tests to their own subdirectory.

Adding wait for retry on process failure.



git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1220 e5f2f494-b856-4b98-b285-d166d9295462
parent 08379e2d
......@@ -171,7 +171,7 @@ AC_OUTPUT([src/bin/cfgmgr/b10-cfgmgr.py
src/bin/cmdctl/run_b10-cmdctl.sh
src/bin/cmdctl/unittest/cmdctl_test
src/bin/bind10/bind10.py
src/bin/bind10/bind10_test
src/bin/bind10/tests/bind10_test
src/bin/bind10/run_bind10.sh
src/bin/bindctl/bindctl
src/bin/bindctl/unittest/bindctl_test
......
......@@ -12,3 +12,8 @@ bind10: bind10.py
$(SED) -e "s|@@PYTHONPATH@@|@pyexecdir@|" \
-e "s|@@LIBEXECDIR@@|$(pkglibexecdir)|" bind10.py >$@
chmod a+x $@
check: test
test:
$(SHELL) tests/bind10_test
......@@ -2,6 +2,7 @@
import sys; sys.path.append ('@@PYTHONPATH@@')
import os
import time
"""\
This file implements the Boss of Bind (BoB, or bob) program.
......@@ -50,11 +51,49 @@ import isc.cc
import isc
# This is the version that gets displayed to the user.
__version__ = "v20100225"
__version__ = "v20100308"
# Nothing at all to do with the 1990-12-10 article here:
# http://www.subgenius.com/subg-digest/v2/0056.html
class RestartSchedule:
"""
Keeps state when restarting something (in this case, a process).
When a process dies unexpectedly, we need to restart it. However, if
it fails to restart for some reason, then we should not simply keep
restarting it at high speed.
A more sophisticated algorithm can be developed, but for now we choose
a simple set of rules:
* If a process was been running for >=10 seconds, we restart it
right away.
* If a process was running for <10 seconds, we wait until 10 seconds
after it was started."""
def __init__(self, restart_frequency=10.0):
self.restart_frequency = restart_frequency
self.run_start_time = None
self.run_stop_time = None
self.restart_time = None
def set_run_start_time(self, when=None):
if when is None:
when = time.time()
self.run_start_time = when
self.restart_time = when + self.restart_frequency
def set_run_stop_time(self, when=None):
if when is None:
when = time.time()
self.run_stop_time = when
def get_restart_time(self, when=None):
if when is None:
when = time.time()
return max(when, self.restart_time)
class ProcessInfo:
"""Information about a process"""
......@@ -89,6 +128,8 @@ class ProcessInfo:
self.env = env
self.dev_null_stdout = dev_null_stdout
self._spawn()
self.last_spawn_time = time.time()
# self.respawn
def respawn(self):
self._spawn()
......
......@@ -8,9 +8,9 @@ BIND10_PATH=@abs_top_srcdir@/src/bin/bind10
PATH=@abs_top_srcdir@/src/bin/msgq:@abs_top_srcdir@/src/bin/auth:@abs_top_srcdir@/src/bin/bind-cfgd:$PATH
export PATH
PYTHONPATH=@abs_top_srcdir@/src/lib/python
PYTHONPATH=@abs_top_srcdir@/src/lib/python:@abs_top_srcdir@/src/bin/bind10
export PYTHONPATH
cd ${BIND10_PATH}
cd ${BIND10_PATH}/tests
exec ${PYTHON_EXEC} -O bind10_test.py $*
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