From c2999ba2c107046eace915fab85202846b6095af Mon Sep 17 00:00:00 2001 From: Naoki Kambe Date: Fri, 15 Feb 2013 14:28:42 +0900 Subject: [PATCH] [2225_statistics_4] calculate an entire server's counts even though they are zero As well as ffd4a283b18f8eaa453712e1e615e2440b12aa0d, in the platform (FreeBSD8, amd64), the timer counters can be zero. However get_statistics() in counters.py didn't calculate an entire server's counts if they are zero. This change is added so that it calculates counters even though they are zero. An new unittest is added to check that. This change fixes the issue reported in #2741. For details about errors related to this change, see the following build farm reports. http://git.bind10.isc.org/~tester/builder/BIND10-cppcheck/20130214075001-FreeBSD8-amd64-GCC/logs/unittests.out http://git.bind10.isc.org/~tester/builder/BIND10-cppcheck/20130206173746-FreeBSD8-amd64-GCC/logs/unittests.out http://git.bind10.isc.org/~tester/builder/BIND10-cppcheck/20130211135501-FreeBSD8-amd64-GCC/logs/unittests.out --- src/lib/python/isc/statistics/counters.py | 4 +--- .../isc/statistics/tests/counters_test.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/lib/python/isc/statistics/counters.py b/src/lib/python/isc/statistics/counters.py index 99b989dfeb..8138ab6172 100644 --- a/src/lib/python/isc/statistics/counters.py +++ b/src/lib/python/isc/statistics/counters.py @@ -393,9 +393,7 @@ class Counters(): for name in zones: if attr in zones[name]: sum_ += zones[name][attr] - if sum_ > 0: - _set_counter(zones_data, zones_spec, - id_str, sum_) + _set_counter(zones_data, zones_spec, id_str, sum_) # insert entire-server counts statistics_data[self._perzone_prefix] = dict( statistics_data[self._perzone_prefix], diff --git a/src/lib/python/isc/statistics/tests/counters_test.py b/src/lib/python/isc/statistics/tests/counters_test.py index 2d791c4318..8d749aeec7 100644 --- a/src/lib/python/isc/statistics/tests/counters_test.py +++ b/src/lib/python/isc/statistics/tests/counters_test.py @@ -274,6 +274,24 @@ class BaseTestCounters(): self._statistics_data, '/'.join(args), 2) self.check_get_statistics() + def test_perzone_zero_counters(self): + # setting all counters to zero + for name in self.counters._zones_item_list: + args = (self._perzone_prefix, TEST_ZONE_NAME_STR, name) + if name.find('time_to_') == 0: + # set zero + self.counters._incdec(*args, step=0.0) + for zone_str in (self._entire_server, TEST_ZONE_NAME_STR): + isc.cc.data.set(self._statistics_data, + '%s/%s/%s' % (args[0], zone_str, name), 0.0) + else: + # set zero + self.counters._incdec(*args, step=0) + for zone_str in (self._entire_server, TEST_ZONE_NAME_STR): + isc.cc.data.set(self._statistics_data, + '%s/%s/%s' % (args[0], zone_str, name), 0) + self.check_get_statistics() + def test_undefined_item(self): # test DataNotFoundError raising when specifying item defined # in the specfile