Browse Source

[master] Merge branch 'trac2225_statistics_4'

Naoki Kambe 12 years ago
parent
commit
a5db81cca2

+ 1 - 3
src/lib/python/isc/statistics/counters.py

@@ -393,9 +393,7 @@ class Counters():
             for name in zones:
             for name in zones:
                 if attr in zones[name]:
                 if attr in zones[name]:
                     sum_ += zones[name][attr]
                     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
         # insert entire-server counts
         statistics_data[self._perzone_prefix] = dict(
         statistics_data[self._perzone_prefix] = dict(
             statistics_data[self._perzone_prefix],
             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._statistics_data, '/'.join(args), 2)
         self.check_get_statistics()
         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):
     def test_undefined_item(self):
         # test DataNotFoundError raising when specifying item defined
         # test DataNotFoundError raising when specifying item defined
         # in the specfile
         # in the specfile