Commit 7cc8a7d6 authored by Naoki Kambe's avatar Naoki Kambe
Browse files

[917] implement per-zone queried counts in the Mock of Auth in Stats

parent 0a7bd233
......@@ -45,7 +45,12 @@ DUMMY_DATA = {
},
'Auth' : {
"queries.tcp": 2,
"queries.udp": 3
"queries.udp": 3,
"queries.per-zone": [{
"zonename": "test.example",
"queries.tcp": 2,
"queries.udp": 3
}]
},
'Stats' : {
"report_time": "2011-03-04T11:59:19Z",
......
......@@ -385,10 +385,14 @@ class TestStats(unittest.TestCase):
1, "specified arguments are incorrect: owner: Foo, name: bar"))
self.assertEqual(self.stats.command_show(owner='Auth'),
isc.config.create_answer(
0, {'queries.tcp': 0, 'queries.udp': 0}))
0, {'queries.tcp': 0, 'queries.udp': 0,
"queries.per-zone": []}))
self.assertEqual(self.stats.command_show(owner='Auth', name='queries.udp'),
isc.config.create_answer(
0, 0))
self.assertEqual(self.stats.command_show(owner='Auth', name='queries.per-zone'),
isc.config.create_answer(
0, []))
orig_get_timestamp = stats.get_timestamp
orig_get_datetime = stats.get_datetime
stats.get_timestamp = lambda : self.const_timestamp
......@@ -442,9 +446,12 @@ class TestStats(unittest.TestCase):
self.assertTrue('item_format' in item)
schema = value['Auth']
self.assertEqual(len(schema), 2)
self.assertEqual(len(schema), 3)
for item in schema:
self.assertTrue(len(item) == 6)
if item['item_type'] == 'list':
self.assertTrue(len(item) == 7)
else:
self.assertTrue(len(item) == 6)
self.assertTrue('item_name' in item)
self.assertTrue('item_type' in item)
self.assertTrue('item_optional' in item)
......@@ -509,6 +516,44 @@ class TestStats(unittest.TestCase):
"item_optional": False,
"item_title": "Queries UDP",
"item_type": "integer"
},
{
"item_name": "queries.per-zone",
"item_type": "list",
"item_optional": False,
"item_default": [],
"item_title": "Queries per zone",
"item_description": "Queries per zone",
"list_item_spec": {
"item_name": "item",
"item_type": "map",
"item_optional": False,
"item_default": {},
"map_item_spec": [
{
"item_name": "zonename",
"item_type": "string",
"item_optional": False,
"item_default": ""
},
{
"item_name": "queries.udp",
"item_type": "integer",
"item_optional": False,
"item_default": 0,
"item_title": "Queries UDP per zone",
"item_description": "A number of UDP query counts per zone"
},
{
"item_name": "queries.tcp",
"item_type": "integer",
"item_optional": False,
"item_default": 0,
"item_title": "Queries TCP per zone",
"item_description": "A number of TCP query counts per zone"
}
]
}
}]))
self.assertEqual(self.stats.command_showschema(owner='Auth', name='queries.tcp'),
isc.config.create_answer(
......@@ -520,6 +565,46 @@ class TestStats(unittest.TestCase):
"item_title": "Queries TCP",
"item_type": "integer"
}))
self.assertEqual(self.stats.command_showschema(owner='Auth', name='queries.per-zone'),
isc.config.create_answer(
0, {
"item_name": "queries.per-zone",
"item_type": "list",
"item_optional": False,
"item_default": [],
"item_title": "Queries per zone",
"item_description": "Queries per zone",
"list_item_spec": {
"item_name": "item",
"item_type": "map",
"item_optional": False,
"item_default": {},
"map_item_spec": [
{
"item_name": "zonename",
"item_type": "string",
"item_optional": False,
"item_default": ""
},
{
"item_name": "queries.udp",
"item_type": "integer",
"item_optional": False,
"item_default": 0,
"item_title": "Queries UDP per zone",
"item_description": "A number of UDP query counts per zone"
},
{
"item_name": "queries.tcp",
"item_type": "integer",
"item_optional": False,
"item_default": 0,
"item_title": "Queries TCP per zone",
"item_description": "A number of TCP query counts per zone"
}
]
}
}))
self.assertEqual(self.stats.command_showschema(owner='Stats', name='bar'),
isc.config.create_answer(
......
......@@ -232,6 +232,44 @@ class MockAuth:
"item_default": 0,
"item_title": "Queries UDP",
"item_description": "A number of total query counts which all auth servers receive over UDP since they started initially"
},
{
"item_name": "queries.per-zone",
"item_type": "list",
"item_optional": false,
"item_default": [],
"item_title": "Queries per zone",
"item_description": "Queries per zone",
"list_item_spec": {
"item_name": "item",
"item_type": "map",
"item_optional": false,
"item_default": {},
"map_item_spec": [
{
"item_name": "zonename",
"item_type": "string",
"item_optional": false,
"item_default": ""
},
{
"item_name": "queries.udp",
"item_type": "integer",
"item_optional": false,
"item_default": 0,
"item_title": "Queries UDP per zone",
"item_description": "A number of UDP query counts per zone"
},
{
"item_name": "queries.tcp",
"item_type": "integer",
"item_optional": false,
"item_default": 0,
"item_title": "Queries TCP per zone",
"item_description": "A number of TCP query counts per zone"
}
]
}
}
]
}
......@@ -251,6 +289,11 @@ class MockAuth:
self.got_command_name = ''
self.queries_tcp = 3
self.queries_udp = 2
self.queries_per_zone = [{
'zonename': 'test.example',
'queries.tcp': 5,
'queries.udp': 4
}]
def run(self):
self.mccs.start()
......@@ -273,7 +316,8 @@ class MockAuth:
if command == 'sendstats':
params = { "owner": "Auth",
"data": { 'queries.tcp': self.queries_tcp,
'queries.udp': self.queries_udp } }
'queries.udp': self.queries_udp,
'queries.per-zone' : self.queries_per_zone } }
return send_command("set", "Stats", params=params, session=self.cc_session)
return isc.config.create_answer(1, "Unknown Command")
......
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