BIND 10 trac2136, updated. 0472e39d599fb08acd60141a51a1839caaa2165d [2136] Revised the test scripts and the config db file
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Jul 31 11:29:18 UTC 2012
The branch, trac2136 has been updated
via 0472e39d599fb08acd60141a51a1839caaa2165d (commit)
from c46ccb258d6d2ba5d42f5e672450bfbe69a9fd27 (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 0472e39d599fb08acd60141a51a1839caaa2165d
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Jul 31 20:13:27 2012 +0900
[2136] Revised the test scripts and the config db file
- Fixed the incorrect previous fix.
There should not be the inconsistency on number of mock Auth instances on
both test scripts: b10-stats_test.py and b10-stats-httpd_test.py. In the
previous change, there was the inconsistency in MockBoss class. Actually in
b10-stats-httpd_test.py, the number of auth instances which Cfgmgr answers
was four, but the number of actually invoked auth instances was one.
- Reduce the number of invoked mock Auth instances
In theses test scripts, multiple Auth instances need to be invoked. But if
four instances are actually invoked in these scripts, open files(ulimit -n)
exceeds 256. In the environment where ulimit -n was set to 256, the
b10-stats-httpd_test.py test failed actually. In that case,
b10-stats-httpd_test.py needs open files more than 256. So the number of the
auth instances in mock modules was reduced into 2 in the scripts. This fix is
for the comment at #2136.
-----------------------------------------------------------------------
Summary of changes:
src/bin/stats/tests/b10-config_test.db | 2 +-
src/bin/stats/tests/b10-stats_test.py | 49 ++++++++++++++++++--------------
src/bin/stats/tests/test_utils.py | 10 ++++---
3 files changed, 34 insertions(+), 27 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/stats/tests/b10-config_test.db b/src/bin/stats/tests/b10-config_test.db
index 5ea65ff..b1d6689 100644
--- a/src/bin/stats/tests/b10-config_test.db
+++ b/src/bin/stats/tests/b10-config_test.db
@@ -1 +1 @@
-{"version": 2, "Boss": {"components": {"b10-auth": {"kind": "needed", "special": "auth"}, "b10-auth-2": {"kind": "needed", "special": "auth"}, "b10-auth-3": {"kind": "needed", "special": "auth"}, "b10-auth-4": {"kind": "needed", "special": "auth"}}}}
+{"version": 2, "Boss": {"components": {"b10-auth": {"kind": "needed", "special": "auth"}, "b10-auth-2": {"kind": "needed", "special": "auth"}}}}
diff --git a/src/bin/stats/tests/b10-stats_test.py b/src/bin/stats/tests/b10-stats_test.py
index bb82069..0cca50e 100644
--- a/src/bin/stats/tests/b10-stats_test.py
+++ b/src/bin/stats/tests/b10-stats_test.py
@@ -30,7 +30,7 @@ import imp
import stats
import isc.cc.session
-from test_utils import BaseModules, ThreadingServerManager, MyStats, SignalHandler, send_command, send_shutdown, MockAuth
+from test_utils import BaseModules, ThreadingServerManager, MyStats, SignalHandler, send_command, send_shutdown
from isc.testutils.ccsession_mock import MockModuleCCSession
class TestUtilties(unittest.TestCase):
@@ -150,19 +150,11 @@ class TestStats(unittest.TestCase):
# set the signal handler for deadlock
self.sig_handler = SignalHandler(self.fail)
self.base = BaseModules()
- # invoke more three MockAuth
- for i in ['2', '3', '4']:
- setattr(self.base, "auth"+i, \
- ThreadingServerManager(MockAuth))
- getattr(self.base, "auth"+i).run()
self.const_timestamp = 1308730448.965706
self.const_datetime = '2011-06-22T08:14:08Z'
self.const_default_datetime = '1970-01-01T00:00:00Z'
def tearDown(self):
- # shutdown more three MockAuth
- for i in ['2', '3', '4']:
- getattr(self.base, "auth"+i).shutdown()
self.base.shutdown()
# reset the signal handler
self.sig_handler.reset()
@@ -379,11 +371,9 @@ class TestStats(unittest.TestCase):
bar2_tcp = 2001
bar3_tcp = 1002
bar3_udp = 1003
- # four auth instances invoked
+ # two auth instances invoked
list_auth = [ self.base.auth.server,
- self.base.auth2.server,
- self.base.auth3.server,
- self.base.auth4.server ]
+ self.base.auth2.server ]
sum_qtcp = 0
for a in list_auth: sum_qtcp += a.queries_tcp
sum_qudp = 0
@@ -417,7 +407,7 @@ class TestStats(unittest.TestCase):
self.assertEqual(self.stats.statistics_data_bymid['Auth']['bar2 at foo'],
{'queries.tcp': bar2_tcp})
# kill running Auth but the statistics data doesn't change
- self.base.auth4.server.shutdown()
+ self.base.auth2.server.shutdown()
self.stats.update_statistics_data()
self.assertTrue('Auth' in self.stats.statistics_data)
self.assertTrue('queries.tcp' in self.stats.statistics_data['Auth'])
@@ -505,6 +495,13 @@ class TestStats(unittest.TestCase):
self.assertFalse(self.stats.running)
def test_command_show(self):
+ # two auth instances invoked
+ list_auth = [ self.base.auth.server,
+ self.base.auth2.server ]
+ sum_qtcp = 0
+ sum_qudp = 0
+ sum_qtcp_perzone = 0
+ sum_qudp_perzone = 0
self.stats = stats.Stats()
self.assertEqual(self.stats.command_show(owner='Foo', name=None),
isc.config.create_answer(
@@ -515,22 +512,30 @@ class TestStats(unittest.TestCase):
self.assertEqual(self.stats.command_show(owner='Foo', name='bar'),
isc.config.create_answer(
1, "specified arguments are incorrect: owner: Foo, name: bar"))
+
+ for a in list_auth:
+ sum_qtcp += a.queries_tcp
+ sum_qudp += a.queries_udp
+ zonename = a.queries_per_zone[0]['zonename']
+ sum_qtcp_perzone += a.queries_per_zone[0]['queries.tcp']
+ sum_qudp_perzone += a.queries_per_zone[0]['queries.udp']
+
self.assertEqual(self.stats.command_show(owner='Auth'),
isc.config.create_answer(
- 0, {'Auth':{ 'queries.udp': 8,
- 'queries.tcp': 12,
+ 0, {'Auth':{ 'queries.udp': sum_qudp,
+ 'queries.tcp': sum_qtcp,
'queries.perzone': [{ 'zonename': 'test1.example',
- 'queries.udp': 16,
- 'queries.tcp': 20 }
+ 'queries.udp': sum_qudp_perzone,
+ 'queries.tcp': sum_qtcp_perzone }
]}}))
self.assertEqual(self.stats.command_show(owner='Auth', name='queries.udp'),
isc.config.create_answer(
- 0, {'Auth': {'queries.udp':8}}))
+ 0, {'Auth': {'queries.udp':sum_qudp}}))
self.assertEqual(self.stats.command_show(owner='Auth', name='queries.perzone'),
isc.config.create_answer(
0, {'Auth': {'queries.perzone': [{ 'zonename': 'test1.example',
- 'queries.udp': 16,
- 'queries.tcp': 20 }]}}))
+ 'queries.udp': sum_qudp_perzone,
+ 'queries.tcp': sum_qtcp_perzone }]}}))
orig_get_datetime = stats.get_datetime
orig_get_timestamp = stats.get_timestamp
stats.get_datetime = lambda x=None: self.const_datetime
@@ -796,7 +801,7 @@ class TestStats(unittest.TestCase):
stat.statistics_data['Boss'],
{'boot_time': self.const_datetime})
# check statistics data of each 'Auth' instances
- list_auth = ['', '2', '3', '4']
+ list_auth = ['', '2']
for i in list_auth:
auth = getattr(self.base,"auth"+i).server
for s in stat.statistics_data_bymid['Auth'].values():
diff --git a/src/bin/stats/tests/test_utils.py b/src/bin/stats/tests/test_utils.py
index 7d3f539..d094047 100644
--- a/src/bin/stats/tests/test_utils.py
+++ b/src/bin/stats/tests/test_utils.py
@@ -246,9 +246,7 @@ class MockBoss:
self.cc_session = self.mccs._session
self.got_command_name = ''
self.pid_list = [[ 9999, "b10-auth" ],
- [ 9998, "b10-auth-2" ],
- [ 9997, "b10-auth-3" ],
- [ 9996, "b10-auth-4" ]]
+ [ 9998, "b10-auth-2" ]]
self.statistics_data = {
'boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', self._BASETIME)
}
@@ -274,7 +272,7 @@ class MockBoss:
self.got_command_name = command
sdata = self.statistics_data
if command == 'getstats':
- return isc.config.create_answer(0, self.statistics_data)
+ return isc.config.create_answer(0, sdata)
elif command == 'show_processes':
# Return dummy pids
return isc.config.create_answer(
@@ -477,9 +475,13 @@ class BaseModules:
# MockAuth
self.auth = ThreadingServerManager(MockAuth)
self.auth.run()
+ self.auth2 = ThreadingServerManager(MockAuth)
+ self.auth2.run()
+
def shutdown(self):
# MockAuth
+ self.auth2.shutdown()
self.auth.shutdown()
# MockBoss
self.boss.shutdown()
More information about the bind10-changes
mailing list