Commit 568a8cc4 authored by zhanglikun's avatar zhanglikun
Browse files

[519] Add unit test for the change to boss process. Catch the timeout...

[519] Add unit test for the change to boss process. Catch the timeout exception when boss receiving the answer from stats.
parent a53c7d7c
......@@ -329,7 +329,10 @@ class BoB:
'set', self._get_stats_data())
seq = self.cc_session.group_sendmsg(cmd, 'Stats')
# Consume the answer, in case it becomes a orphan message.
self.cc_session.group_recvmsg(False, seq)
try:
self.cc_session.group_recvmsg(False, seq)
except isc.cc.session.SessionTimeout:
pass
answer = isc.config.ccsession.create_answer(0)
elif command == "ping":
answer = isc.config.ccsession.create_answer(0, "pong")
......
......@@ -147,6 +147,12 @@ class TestBoB(unittest.TestCase):
self.assertEqual(bob.command_handler("shutdown", None),
isc.config.ccsession.create_answer(0))
self.assertFalse(bob.runnable)
# "getstats" command
self.assertEqual(bob.command_handler("getstats", None),
isc.config.ccsession.create_answer(0,
{ "stats_data": {
'bind10.boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME)
}}))
# "sendstats" command
self.assertEqual(bob.command_handler("sendstats", None),
isc.config.ccsession.create_answer(0))
......
......@@ -215,7 +215,9 @@ class CCSessionListener(Listener):
def _update_stats_data(self, args):
# 'args' must be dictionary type
self.stats_data.update(args['stats_data'])
if isinstance(args, dict) and isinstance(args.get('stats_data'), dict):
self.stats_data.update(args['stats_data'])
# overwrite "stats.LastUpdateTime"
self.stats_data['stats.last_update_time'] = get_datetime()
......
Supports Markdown
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