Browse Source

[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
Naoki Kambe 12 years ago
parent
commit
c2999ba2c1

+ 1 - 3
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],

+ 18 - 0
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