Commit 68a15b9b authored by Naoki Kambe's avatar Naoki Kambe
Browse files

[2179] fixed the lost of default statistics data

If some values of a module were not changed from default values, these default
values were removed from statistics data of the stats module even if other
changed values were preserved. That is, it didn't fully support the
differential updates. It is now fixed to preserve it.
parent 53724b30
......@@ -565,7 +565,19 @@ class Stats:
for m in mlist:
if self.statistics_data_bymid[m]:
if m in self.statistics_data:
self.statistics_data[m].update(
# propagate the default values by times of
# instances
_len = len(self.statistics_data_bymid[m])
for i in range(0, _len - 1):
self.statistics_data[m] = _accum(
self.statistics_data[m],
self.statistics_data[m])
# replace the default values with summaries of the
# collected values of each module. But the default
# values which are not included in collected
# values are not replaced.
self.statistics_data[m] = merge_oldnew(
self.statistics_data[m],
_accum_bymodule(
self.statistics_data_bymid[m]))
......
......@@ -741,10 +741,14 @@ class TestStats(unittest.TestCase):
self.base.auth2.server ]
sum_qtcp = 0
sum_qudp = 0
sum_qtcp_perzone = 0
sum_qudp_perzone = 0
sum_qtcp_nds_perzone = 0
sum_qudp_nds_perzone = 0
sum_qtcp_perzone1 = 0
sum_qudp_perzone1 = 0
sum_qtcp_perzone2 = 4 * len(list_auth)
sum_qudp_perzone2 = 3 * len(list_auth)
sum_qtcp_nds_perzone10 = 0
sum_qudp_nds_perzone10 = 0
sum_qtcp_nds_perzone20 = 4 * len(list_auth)
sum_qudp_nds_perzone20 = 3 * len(list_auth)
self.stats = stats.Stats()
self.assertEqual(self.stats.command_show(owner='Foo', name=None),
isc.config.create_answer(
......@@ -759,36 +763,50 @@ class TestStats(unittest.TestCase):
for a in list_auth:
sum_qtcp += a.queries_tcp
sum_qudp += a.queries_udp
sum_qtcp_perzone += a.queries_per_zone[0]['queries.tcp']
sum_qudp_perzone += a.queries_per_zone[0]['queries.udp']
sum_qtcp_nds_perzone += a.nds_queries_per_zone['test10.example']['queries.tcp']
sum_qudp_nds_perzone += a.nds_queries_per_zone['test10.example']['queries.udp']
sum_qtcp_perzone1 += a.queries_per_zone[0]['queries.tcp']
sum_qudp_perzone1 += a.queries_per_zone[0]['queries.udp']
sum_qtcp_nds_perzone10 += a.nds_queries_per_zone['test10.example']['queries.tcp']
sum_qudp_nds_perzone10 += a.nds_queries_per_zone['test10.example']['queries.udp']
self.assertEqual(self.stats.command_show(owner='Auth'),
isc.config.create_answer(
0, {'Auth':{ 'queries.udp': sum_qudp,
'queries.tcp': sum_qtcp,
'queries.perzone': [{ 'zonename': 'test1.example',
'queries.udp': sum_qudp_perzone,
'queries.tcp': sum_qtcp_perzone }
'queries.udp': sum_qudp_perzone1,
'queries.tcp': sum_qtcp_perzone1 },
{ 'zonename': 'test2.example',
'queries.udp': sum_qudp_perzone2,
'queries.tcp': sum_qtcp_perzone2 }
],
'nds_queries.perzone': { 'test10.example' : {
'queries.udp': sum_qudp_nds_perzone,
'queries.tcp': sum_qtcp_nds_perzone } }
}}))
'queries.udp': sum_qudp_nds_perzone10,
'queries.tcp': sum_qtcp_nds_perzone10 },
'test20.example' : {
'queries.udp': sum_qudp_nds_perzone20,
'queries.tcp': sum_qtcp_nds_perzone20 }
}}}))
self.assertEqual(self.stats.command_show(owner='Auth', name='queries.udp'),
isc.config.create_answer(
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': sum_qudp_perzone,
'queries.tcp': sum_qtcp_perzone }]}}))
0, {'Auth': {'queries.perzone': [
{ 'zonename': 'test1.example',
'queries.udp': sum_qudp_perzone1,
'queries.tcp': sum_qtcp_perzone1 },
{ 'zonename': 'test2.example',
'queries.udp': sum_qudp_perzone2,
'queries.tcp': sum_qtcp_perzone2 }]}}))
self.assertEqual(self.stats.command_show(owner='Auth', name='nds_queries.perzone'),
isc.config.create_answer(
0, {'Auth': {'nds_queries.perzone': { 'test10.example': {
'queries.udp': sum_qudp_nds_perzone,
'queries.tcp': sum_qtcp_nds_perzone }}}}))
0, {'Auth': {'nds_queries.perzone': {
'test10.example': {
'queries.udp': sum_qudp_nds_perzone10,
'queries.tcp': sum_qtcp_nds_perzone10 },
'test20.example': {
'queries.udp': sum_qudp_nds_perzone20,
'queries.tcp': sum_qtcp_nds_perzone20 }}}}))
orig_get_datetime = stats.get_datetime
orig_get_timestamp = stats.get_timestamp
stats.get_datetime = lambda x=None: self.const_datetime
......@@ -1163,13 +1181,23 @@ class TestStats(unittest.TestCase):
'queries.tcp':
auth.queries_per_zone[0]['queries.tcp']*n,
'queries.udp':
auth.queries_per_zone[0]['queries.udp']*n}],
auth.queries_per_zone[0]['queries.udp']*n},
{'zonename': "test2.example",
'queries.tcp': 4*n,
'queries.udp': 3*n },
],
'nds_queries.perzone': {
'test10.example': {
'queries.tcp':
auth.nds_queries_per_zone['test10.example']['queries.tcp']*n,
'queries.udp':
auth.nds_queries_per_zone['test10.example']['queries.udp']*n}},
auth.nds_queries_per_zone['test10.example']['queries.udp']*n},
'test20.example': {
'queries.tcp':
4*n,
'queries.udp':
3*n},
},
'queries.tcp': auth.queries_tcp*n,
'queries.udp': auth.queries_udp*n})
# check statistics data of 'Stats'
......
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