Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
703d5f36
Commit
703d5f36
authored
Jul 20, 2011
by
Naoki Kambe
Browse files
[trac930] add statistics validation for bob
parent
84d9095c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/bin/bind10/bind10_src.py.in
View file @
703d5f36
...
...
@@ -325,18 +325,18 @@ class BoB:
answer = isc.config.ccsession.create_answer(0, self._get_stats_data())
elif command == "sendstats":
# send statistics data to the stats daemon immediately
cmd = isc.config.ccsession.create_command(
statistics_data = {
'boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME)
}
valid = self.ccs.get_module_spec().validate_statistics(
True, statistics_data)
if valid:
cmd = isc.config.ccsession.create_command(
'set', { "owner": "Boss",
"data": {
'boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME)
}})
seq = self.cc_session.group_sendmsg(cmd, 'Stats')
# Consume the answer, in case it becomes a orphan message.
try:
self.cc_session.group_recvmsg(False, seq)
except isc.cc.session.SessionTimeout:
pass
answer = isc.config.ccsession.create_answer(0)
"data": statistics_data })
seq = self.cc_session.group_sendmsg(cmd, 'Stats')
self.cc_session.group_recvmsg(True, seq)
answer = isc.config.ccsession.create_answer(0)
elif command == "ping":
answer = isc.config.ccsession.create_answer(0, "pong")
elif command == "show_processes":
...
...
src/bin/bind10/tests/bind10_test.py.in
View file @
703d5f36
...
...
@@ -137,9 +137,27 @@ class TestBoB(unittest.TestCase):
def group_sendmsg(self, msg, group):
(self.msg, self.group) = (msg, group)
def group_recvmsg(self, nonblock, seq): pass
class DummyModuleCCSession():
module_spec = isc.config.module_spec.ModuleSpec({
"module_name": "Boss",
"statistics": [
{
"item_name": "boot_time",
"item_type": "string",
"item_optional": False,
"item_default": "1970-01-01T00:00:00Z",
"item_title": "Boot time",
"item_description": "A date time when bind10 process starts initially",
"item_format": "date-time"
}
]
})
def get_module_spec(self):
return self.module_spec
bob = BoB()
bob.verbose = True
bob.cc_session = DummySession()
bob.ccs = DummyModuleCCSession()
# a bad command
self.assertEqual(bob.command_handler(-1, None),
isc.config.ccsession.create_answer(1, "bad command"))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment