Commit 9d21102f authored by Naoki Kambe's avatar Naoki Kambe
Browse files

[2136] added some misc changes

Changes in b10-stats_test.py:
 - added deeply checking statistics values of each of module and
   instance

 - added stats_server.shutdown() at the end of the test_config method.
   Because the running stats_server was never shut down even after
   stats_server.run() was invoked.

Changes in test_utils.py:
 - Changed the way of invoking multiple auth instances just for efficiency
parent 2e760ad9
......@@ -453,6 +453,7 @@ class TestStats(unittest.TestCase):
params={ 'owner' : 'Boss',
'name' : 'boot_time' }),
(0, {'Boss': {'boot_time': '1970-01-01T00:00:00Z'}}))
stats_server.shutdown()
def test_commands(self):
# status
......@@ -743,6 +744,50 @@ class TestStats(unittest.TestCase):
isc.config.create_answer(
1, "module name is not specified"))
def test_statistics_data(self):
stats_server = ThreadingServerManager(MyStats)
stats = stats_server.server
stats_server.run()
self.assertEqual(
send_command('status', 'Stats'),
(0, "Stats is up. (PID " + str(os.getpid()) + ")"))
# check statistics data of 'Boss'
self.assertEqual(
stats.statistics_data_bymid['Boss']\
[self.base.boss.server.cc_session.lname],
{'boot_time': self.const_datetime})
self.assertEqual(
len(stats.statistics_data_bymid['Boss']), 1)
self.assertEqual(
stats.statistics_data['Boss'],
{'boot_time': self.const_datetime})
# check statistics data of each 'Auth' instances
list_auth = ['', '2', '3', '4']
for i in list_auth:
auth = getattr(self.base,"auth"+i).server
self.assertEqual(
stats.statistics_data_bymid['Auth']\
[auth.cc_session.lname],
{'queries.perzone': auth.queries_per_zone,
'queries.tcp': auth.queries_tcp,
'queries.udp': auth.queries_udp})
n = len(stats.statistics_data_bymid['Auth'])
self.assertEqual(n, len(list_auth))
# check consolidation of statistics data of the auth
# instances
self.assertEqual(
stats.statistics_data['Auth'],
{'queries.perzone': [
{'zonename':
auth.queries_per_zone[0]['zonename'],
'queries.tcp':
auth.queries_per_zone[0]['queries.tcp']*n,
'queries.udp':
auth.queries_per_zone[0]['queries.udp']*n}],
'queries.tcp': auth.queries_tcp*n,
'queries.udp': auth.queries_udp*n})
stats_server.shutdown()
class TestOSEnv(unittest.TestCase):
def test_osenv(self):
"""
......
......@@ -485,14 +485,10 @@ class BaseModules:
self.boss = ThreadingServerManager(MockBoss)
self.boss.run()
# MockAuth * 4
self.auth = ThreadingServerManager(MockAuth)
self.auth2 = ThreadingServerManager(MockAuth)
self.auth3 = ThreadingServerManager(MockAuth)
self.auth4 = ThreadingServerManager(MockAuth)
self.auth.run()
self.auth2.run()
self.auth3.run()
self.auth4.run()
for i in ['', '2', '3', '4']:
setattr(self,"auth"+i, \
ThreadingServerManager(MockAuth))
getattr(self, "auth"+i).run()
def shutdown(self):
# MockAuth
......
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