BIND 10 trac1175, updated. 31fff87f0e451bd542549fcbf8ef54111fb8db2d [1175] - add 3-time retry to creating the server object when it fails in the ThreadingServerManager class - suppress outputs by Msgq, and add dummy sys module and the output methods - pass Exceptions raised while it's running with a thread
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Sep 5 05:11:56 UTC 2011
The branch, trac1175 has been updated
via 31fff87f0e451bd542549fcbf8ef54111fb8db2d (commit)
via e6ba004df7a6c61a1eb01b8a2c42ffca31108544 (commit)
via 551b7acfbb53017b8d333e6e6aee7a0be5e3d41d (commit)
via 678ee5b01c108bbd43eb95937dfdda2e766e10f0 (commit)
from 8a8c3718955c21d01be54961e203dd5f1ad54703 (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 31fff87f0e451bd542549fcbf8ef54111fb8db2d
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Mon Sep 5 05:01:18 2011 +0000
[1175]
- add 3-time retry to creating the server object when it fails in the
ThreadingServerManager class
- suppress outputs by Msgq, and add dummy sys module and the output
methods
- pass Exceptions raised while it's running with a thread
commit e6ba004df7a6c61a1eb01b8a2c42ffca31108544
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Mon Sep 5 04:53:24 2011 +0000
[1175] remove a logging name from unittest
commit 551b7acfbb53017b8d333e6e6aee7a0be5e3d41d
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Mon Sep 5 04:53:11 2011 +0000
[1175]
- remove a logging name from unittest
- do stats_httpd.stop() in teadDown() instead of each test case
- send 'shutdown' command to kill stats_httpd when testing address already in use
commit 678ee5b01c108bbd43eb95937dfdda2e766e10f0
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Mon Sep 5 04:46:08 2011 +0000
[1175] remove -v option from pycoverage
-----------------------------------------------------------------------
Summary of changes:
src/bin/stats/tests/Makefile.am | 2 +-
src/bin/stats/tests/b10-stats-httpd_test.py | 27 ++----------
src/bin/stats/tests/b10-stats_test.py | 3 -
src/bin/stats/tests/test_utils.py | 56 ++++++++++++++++++++++----
4 files changed, 53 insertions(+), 35 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/stats/tests/Makefile.am b/src/bin/stats/tests/Makefile.am
index 2b57bcf..368e90c 100644
--- a/src/bin/stats/tests/Makefile.am
+++ b/src/bin/stats/tests/Makefile.am
@@ -23,7 +23,7 @@ endif
env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/bin/stats:$(abs_top_builddir)/src/bin/stats/tests:$(abs_top_builddir)/src/bin/msgq:$(abs_top_builddir)/src/lib/python/isc/config \
B10_FROM_SOURCE=$(abs_top_srcdir) \
CONFIG_TESTDATA_PATH=$(abs_top_srcdir)/src/lib/config/tests/testdata \
- $(PYCOVERAGE_RUN) $(abs_srcdir)/$$pytest -v || exit ; \
+ $(PYCOVERAGE_RUN) $(abs_srcdir)/$$pytest || exit ; \
done
CLEANDIRS = __pycache__
diff --git a/src/bin/stats/tests/b10-stats-httpd_test.py b/src/bin/stats/tests/b10-stats-httpd_test.py
index 06ede85..c76ab8a 100644
--- a/src/bin/stats/tests/b10-stats-httpd_test.py
+++ b/src/bin/stats/tests/b10-stats-httpd_test.py
@@ -39,9 +39,6 @@ import stats_httpd
import stats
from test_utils import BaseModules, ThreadingServerManager, MyStats, MyStatsHttpd, send_shutdown
-# set test name for logger
-isc.log.init("b10-stats-httpd_test")
-
DUMMY_DATA = {
'Boss' : {
"boot_time": "2011-03-04T11:59:06Z"
@@ -283,6 +280,8 @@ class TestHttpServer(unittest.TestCase):
self.base = BaseModules()
def tearDown(self):
+ if hasattr(self, "stats_httpd"):
+ self.stats_httpd.stop()
self.base.shutdown()
def my_signal_handler(self, signal, frame):
@@ -294,7 +293,6 @@ class TestHttpServer(unittest.TestCase):
self.assertEqual(len(self.stats_httpd.httpd), 1)
for httpd in self.stats_httpd.httpd:
self.assertTrue(isinstance(httpd, stats_httpd.HttpServer))
- self.stats_httpd.stop()
class TestStatsHttpdError(unittest.TestCase):
"""Tests for StatsHttpdError exception"""
@@ -319,6 +317,8 @@ class TestStatsHttpd(unittest.TestCase):
self.ipv6_enabled = is_ipv6_enabled()
def tearDown(self):
+ if hasattr(self, "stats_httpd"):
+ self.stats_httpd.stop()
self.stats_server.shutdown()
self.base.shutdown()
@@ -339,7 +339,6 @@ class TestStatsHttpd(unittest.TestCase):
self.assertTrue('address' in self.stats_httpd.config['listen_on'][0])
self.assertTrue('port' in self.stats_httpd.config['listen_on'][0])
self.assertTrue(server_address in set(self.stats_httpd.http_addrs))
- self.stats_httpd.stop()
def test_openclose_mccs(self):
self.stats_httpd = MyStatsHttpd(get_availaddr())
@@ -350,7 +349,6 @@ class TestStatsHttpd(unittest.TestCase):
self.stats_httpd.mccs = None
self.assertEqual(self.stats_httpd.mccs, None)
self.assertEqual(self.stats_httpd.close_mccs(), None)
- self.stats_httpd.stop()
def test_mccs(self):
self.stats_httpd = MyStatsHttpd(get_availaddr())
@@ -368,7 +366,6 @@ class TestStatsHttpd(unittest.TestCase):
self.assertTrue(len(statistics_spec[mod]), len(DUMMY_DATA[mod]))
self.stats_httpd.close_mccs()
self.assertIsNone(self.stats_httpd.mccs)
- self.stats_httpd.stop()
def test_httpd(self):
# dual stack (addresses is ipv4 and ipv6)
@@ -379,7 +376,6 @@ class TestStatsHttpd(unittest.TestCase):
self.assertTrue(isinstance(ht, stats_httpd.HttpServer))
self.assertTrue(ht.address_family in set([socket.AF_INET, socket.AF_INET6]))
self.assertTrue(isinstance(ht.socket, socket.socket))
- self.stats_httpd.stop()
# dual stack (address is ipv6)
if self.ipv6_enabled:
@@ -389,7 +385,6 @@ class TestStatsHttpd(unittest.TestCase):
self.assertTrue(isinstance(ht, stats_httpd.HttpServer))
self.assertEqual(ht.address_family, socket.AF_INET6)
self.assertTrue(isinstance(ht.socket, socket.socket))
- self.stats_httpd.stop()
# dual stack (address is ipv4)
if self.ipv6_enabled:
@@ -399,7 +394,6 @@ class TestStatsHttpd(unittest.TestCase):
self.assertTrue(isinstance(ht, stats_httpd.HttpServer))
self.assertEqual(ht.address_family, socket.AF_INET)
self.assertTrue(isinstance(ht.socket, socket.socket))
- self.stats_httpd.stop()
# only-ipv4 single stack
if not self.ipv6_enabled:
@@ -409,7 +403,6 @@ class TestStatsHttpd(unittest.TestCase):
self.assertTrue(isinstance(ht, stats_httpd.HttpServer))
self.assertEqual(ht.address_family, socket.AF_INET)
self.assertTrue(isinstance(ht.socket, socket.socket))
- self.stats_httpd.stop()
# any address (IPv4)
server_addresses = get_availaddr(address='0.0.0.0')
@@ -418,7 +411,6 @@ class TestStatsHttpd(unittest.TestCase):
self.assertTrue(isinstance(ht, stats_httpd.HttpServer))
self.assertEqual(ht.address_family,socket.AF_INET)
self.assertTrue(isinstance(ht.socket, socket.socket))
- self.stats_httpd.stop()
# any address (IPv6)
if self.ipv6_enabled:
@@ -428,7 +420,6 @@ class TestStatsHttpd(unittest.TestCase):
self.assertTrue(isinstance(ht, stats_httpd.HttpServer))
self.assertEqual(ht.address_family,socket.AF_INET6)
self.assertTrue(isinstance(ht.socket, socket.socket))
- self.stats_httpd.stop()
# existent hostname
self.assertRaises(stats_httpd.HttpServerError, MyStatsHttpd,
@@ -451,7 +442,7 @@ class TestStatsHttpd(unittest.TestCase):
self.stats_httpd_server = ThreadingServerManager(MyStatsHttpd, server_addresses)
self.stats_httpd_server.run()
self.assertRaises(stats_httpd.HttpServerError, MyStatsHttpd, server_addresses)
- self.stats_httpd_server.shutdown()
+ send_shutdown("StatsHttpd")
def test_running(self):
self.stats_httpd_server = ThreadingServerManager(MyStatsHttpd, get_availaddr())
@@ -467,7 +458,6 @@ class TestStatsHttpd(unittest.TestCase):
self.stats_httpd = MyStatsHttpd(get_availaddr())
self.stats_httpd.cc_session.close()
self.assertRaises(ValueError, self.stats_httpd.start)
- self.stats_httpd.stop()
def test_select_failure1(self):
def raise_select_except(*args):
@@ -476,7 +466,6 @@ class TestStatsHttpd(unittest.TestCase):
stats_httpd.select.select = raise_select_except
self.stats_httpd = MyStatsHttpd(get_availaddr())
self.assertRaises(select.error, self.stats_httpd.start)
- self.stats_httpd.stop()
stats_httpd.select.select = orig_select
def test_select_failure2(self):
@@ -522,7 +511,6 @@ class TestStatsHttpd(unittest.TestCase):
self.assertRaises(
IOError,
self.stats_httpd.open_template, '/path/to/foo/bar')
- self.stats_httpd.stop()
def test_commands(self):
self.stats_httpd = MyStatsHttpd(get_availaddr())
@@ -538,7 +526,6 @@ class TestStatsHttpd(unittest.TestCase):
self.stats_httpd.command_handler("__UNKNOWN_COMMAND__", None),
isc.config.ccsession.create_answer(
1, "Unknown command: __UNKNOWN_COMMAND__"))
- self.stats_httpd.stop()
def test_config(self):
self.stats_httpd = MyStatsHttpd(get_availaddr())
@@ -588,7 +575,6 @@ class TestStatsHttpd(unittest.TestCase):
dict(listen_on=[dict(address="1.2.3.4",port=543210)]))
)
self.assertEqual(ret, 1)
- self.stats_httpd.stop()
def test_xml_handler(self):
self.stats_httpd = MyStatsHttpd(get_availaddr())
@@ -608,7 +594,6 @@ class TestStatsHttpd(unittest.TestCase):
{ 'Dummy' : {'bar':'foo'} }
xml_body2 = self.stats_httpd.xml_handler()
self.assertNotEqual(xml_body1, xml_body2)
- self.stats_httpd.stop()
def test_xsd_handler(self):
self.stats_httpd = MyStatsHttpd(get_availaddr())
@@ -650,7 +635,6 @@ class TestStatsHttpd(unittest.TestCase):
}
xsd_body2 = self.stats_httpd.xsd_handler()
self.assertNotEqual(xsd_body1, xsd_body2)
- self.stats_httpd.stop()
def test_xsl_handler(self):
self.stats_httpd = MyStatsHttpd(get_availaddr())
@@ -690,7 +674,6 @@ class TestStatsHttpd(unittest.TestCase):
}
xsl_body2 = self.stats_httpd.xsl_handler()
self.assertNotEqual(xsl_body1, xsl_body2)
- self.stats_httpd.stop()
def test_for_without_B10_FROM_SOURCE(self):
# just lets it go through the code without B10_FROM_SOURCE env
diff --git a/src/bin/stats/tests/b10-stats_test.py b/src/bin/stats/tests/b10-stats_test.py
index 892032d..a52ce63 100644
--- a/src/bin/stats/tests/b10-stats_test.py
+++ b/src/bin/stats/tests/b10-stats_test.py
@@ -33,9 +33,6 @@ import stats
import isc.cc.session
from test_utils import BaseModules, ThreadingServerManager, MyStats, send_command, send_shutdown
-# set test name for logger
-isc.log.init("b10-stats_test")
-
class TestUtilties(unittest.TestCase):
items = [
{ 'item_name': 'test_int1', 'item_type': 'integer', 'item_default': 12345 },
diff --git a/src/bin/stats/tests/test_utils.py b/src/bin/stats/tests/test_utils.py
index ff45440..cb63abb 100644
--- a/src/bin/stats/tests/test_utils.py
+++ b/src/bin/stats/tests/test_utils.py
@@ -42,7 +42,19 @@ def send_shutdown(module_name, **kwargs):
class ThreadingServerManager:
def __init__(self, server, *args, **kwargs):
- self.server = server(*args, **kwargs)
+ self.server = None
+ n = 0
+ while True:
+ try:
+ self.server = server(*args, **kwargs)
+ except isc.cc.session.SessionTimeout:
+ if self.server is not None:
+ self.server.shutdown()
+ # retrying until 3 times
+ if n >2: raise
+ n = n + 1
+ continue
+ else: break
self.server_name = server.__name__
self.server._thread = threading.Thread(
name=self.server_name, target=self.server.run)
@@ -57,10 +69,21 @@ class ThreadingServerManager:
self.server.shutdown()
self.server._thread.join(0) # timeout is 0
+def do_nothing(*args, **kwargs): pass
+
+class dummy_sys:
+ """Dummy for sys"""
+ class dummy_io:
+ write = do_nothing
+ stdout = stderr = dummy_io()
+
class MockMsgq:
def __init__(self):
self._started = threading.Event()
- self.msgq = msgq.MsgQ(verbose=True)
+ # suppress output to stdout and stderr
+ msgq.sys = dummy_sys()
+ msgq.print = do_nothing
+ self.msgq = msgq.MsgQ(verbose=False)
result = self.msgq.setup()
if result:
sys.exit("Error on Msgq startup: %s" % result)
@@ -86,7 +109,10 @@ class MockCfgmgr:
def run(self):
self._started.set()
- self.cfgmgr.run()
+ try:
+ self.cfgmgr.run()
+ except Exception:
+ pass
def shutdown(self):
self.cfgmgr.running = False
@@ -138,8 +164,11 @@ class MockBoss:
self.mccs.start()
self.running = True
self._started.set()
- while self.running:
- self.mccs.check_command(False)
+ try:
+ while self.running:
+ self.mccs.check_command(False)
+ except Exception:
+ pass
def shutdown(self):
self.running = False
@@ -216,8 +245,11 @@ class MockAuth:
self.mccs.start()
self.running = True
self._started.set()
- while self.running:
- self.mccs.check_command(False)
+ try:
+ while self.running:
+ self.mccs.check_command(False)
+ except Exception:
+ pass
def shutdown(self):
self.running = False
@@ -241,7 +273,10 @@ class MyStats(stats.Stats):
def run(self):
self._started.set()
- self.start()
+ try:
+ self.start()
+ except Exception:
+ pass
def shutdown(self):
self.command_shutdown()
@@ -278,7 +313,10 @@ class MyStatsHttpd(stats_httpd.StatsHttpd):
def run(self):
self._started.set()
- self.start()
+ try:
+ self.start()
+ except Exception:
+ pass
def shutdown(self):
self.stop()
More information about the bind10-changes
mailing list