BIND 10 trac2225_statistics, updated. 46618002ad19df9514ff135ae42cf64caa2b8662 [trac2225_statistics] rename dump_statistics() to get_statistics()
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Dec 14 10:13:45 UTC 2012
The branch, trac2225_statistics has been updated
via 46618002ad19df9514ff135ae42cf64caa2b8662 (commit)
via 4688552db82b8117a0bcf11c40e506784832ccb1 (commit)
via 2aa30dca729ac289c2a8bc2353e48183567be497 (commit)
via bfb02252f885e30c5d24968f59f21308add72599 (commit)
via db1ad53bb81b1f61d52d28758f08f80ba2b84221 (commit)
via 289118e3413d0790600aedb1de464ca8765c500c (commit)
via 1f05684cc6681ccfb9197ccdd2ed10fbfc4dc447 (commit)
via 868558c3f7286500ff7a9d1569101c5b3f5feca7 (commit)
via 0d0de6a5c721791fa761d21be5385a69d02a792b (commit)
via 7ec3307e272fd9a4ebf5f3f3123bda2d8c2cc5ff (commit)
via 4ae14bdf3b1b19c3023d9025a82c75b09e004819 (commit)
via 301ccaf97379ccf29d02ca4332ba8d456c0a5391 (commit)
via 2f7080c8e71f58b5c086e0514caecca46f16bc9f (commit)
via dbf92ead97b1b74ef9ac12c75a91f38c6258605c (commit)
via 4b368b5e65ad55d8e22236b354253a1ac317ba19 (commit)
via 6a4b9582cebc33c3ad6e82343e6d2cd9af7b71fd (commit)
via d4e066a2e7be1e075c41622cb658cbbec968f450 (commit)
from 0c8094b0e3e9ecae8fe44cb889b959ed467bac8b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 46618002ad19df9514ff135ae42cf64caa2b8662
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 18:44:08 2012 +0900
[trac2225_statistics] rename dump_statistics() to get_statistics()
It's due to the review comment.
commit 4688552db82b8117a0bcf11c40e506784832ccb1
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 18:40:27 2012 +0900
[trac2225_statistics] update document as it is
It's due to the review comment.
commit 2aa30dca729ac289c2a8bc2353e48183567be497
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 18:29:02 2012 +0900
[trac2225_statistics] add helpful comments to the complicated expression
Also rsplit() is used instead of split() to be simplified.
It's due to the review comment.
commit bfb02252f885e30c5d24968f59f21308add72599
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 17:54:51 2012 +0900
[trac2225_statistics] rename to clear_all()
It's due to the review comment.
commit db1ad53bb81b1f61d52d28758f08f80ba2b84221
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 17:49:00 2012 +0900
[trac2225_statistics] rename start()/stop() to start_timer()/stop_timer()
Due to the review comment.
commit 289118e3413d0790600aedb1de464ca8765c500c
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 17:45:47 2012 +0900
[trac2225_statistics] remove 'else' statement
In stead of being removed, it just returns if DataNotFoundError is raised.
Due to the review comment.
commit 1f05684cc6681ccfb9197ccdd2ed10fbfc4dc447
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 17:42:29 2012 +0900
[trac2225_statistics] update document of Counters.stop()
explicitly distinguishing duration time from date time.
Due to the review comment.
commit 868558c3f7286500ff7a9d1569101c5b3f5feca7
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 17:25:40 2012 +0900
[trac2225_statistics] use timedelta.total_seconds() instead of redundant computation
Due to the review comment.
commit 0d0de6a5c721791fa761d21be5385a69d02a792b
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 17:15:40 2012 +0900
[trac2225_statistics] remove an unnecessary formating
Due to the review comment.
commit 7ec3307e272fd9a4ebf5f3f3123bda2d8c2cc5ff
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 17:12:20 2012 +0900
[trac2225_statistics] remove an unnecessary try/expect statement
Due to the review comment.
commit 4ae14bdf3b1b19c3023d9025a82c75b09e004819
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 17:31:31 2012 +0900
[trac2225_statistics] add step as kwarg into inc() and use it in dec() with step=-1
Due to the review comment.
commit 301ccaf97379ccf29d02ca4332ba8d456c0a5391
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 17:34:04 2012 +0900
[trac2225_statistics] add a helper method _concat and its test
And replace it with '/'.join(args)
Due to the review comment.
commit 2f7080c8e71f58b5c086e0514caecca46f16bc9f
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 16:32:58 2012 +0900
[trac2225_statistics] synchronize when accessing self._disabled
And timer cannot be updated if self._disabled is true.
Due to the review comment.
commit dbf92ead97b1b74ef9ac12c75a91f38c6258605c
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 16:09:56 2012 +0900
[trac2225_statistics] document about cases when a spec file is specified and omitted
Due to the review comment.
commit 4b368b5e65ad55d8e22236b354253a1ac317ba19
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 16:01:25 2012 +0900
[trac2225_statistics] correct and add documentation of the Counters class
Due to the review comment.
commit 6a4b9582cebc33c3ad6e82343e6d2cd9af7b71fd
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 15:39:13 2012 +0900
[trac2225_statistics] correct documentation about an undefined method
Due to the review comment.
commit d4e066a2e7be1e075c41622cb658cbbec968f450
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Dec 14 13:41:57 2012 +0900
[trac2225_statistics] rename the class to the plural form (`Counters`) as it manages multiple counters
Due to the review comment.
-----------------------------------------------------------------------
Summary of changes:
src/lib/python/isc/statistics/counter.py | 166 +++++++++--------
.../python/isc/statistics/tests/counter_test.py | 192 +++++++++++---------
2 files changed, 199 insertions(+), 159 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/statistics/counter.py b/src/lib/python/isc/statistics/counter.py
index 5946790..1a67181 100644
--- a/src/lib/python/isc/statistics/counter.py
+++ b/src/lib/python/isc/statistics/counter.py
@@ -13,17 +13,17 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-"""BIND 10 Statistics counter module
+"""BIND 10 Statistics counters module
This module handles the statistics counters for BIND 10 modules. For
-using the module `counter.py`, firstly the init() method should be
-invoked in each module like b10-xfrin or b10-xfrout after importing
-this module.
+using the module `counter.py`, firstly a counters object should be
+created in each module like b10-xfrin or b10-xfrout after importing
+this module. A spec file can be specified in argument when creating.
- from isc.statistics import Counter
- self.counter = Counter(/path/to/foo.spec)
+ from isc.statistics import Counters
+ self.counters = Counters(/path/to/foo.spec)
-The first argument of Counter() can be specified, which is the
+The first argument of Counters() can be specified, which is the
location of the specification file like src/bin/xfrout/xfrout.spec. If
this initial preparation is done, statistics counters can be accessed
from each module. For example, in case that the item `xfrreqdone` is
@@ -31,13 +31,13 @@ defined in statistics_spec in xfrout.spec, the following methods is
callable. Since these methods requires the string of the zone name in
the first argument, in the b10-xfrout,
- self.counter.inc('zones', zone_name, 'xfrreqdone')
+ self.counters.inc('zones', zone_name, 'xfrreqdone')
then the counter for xfrreqdone corresponding to zone_name was
incremented. For getting the current number of this counter, we can do
this,
- number = self.counter.get('zones', zone_name, 'xfrreqdone')
+ number = self.counters.get('zones', zone_name, 'xfrreqdone')
then the current number was obtained and set in the above variable
`number`. Such a getter method would be mainly used for unittesting.
@@ -46,7 +46,7 @@ method is also callable. This method is used for decrementing the
counter number. Regarding the item `axfr_running`, an argument like
zone name is not required.
- self.counter.dec('axfr_running')
+ self.counters.dec('axfr_running')
These methods are effective in other module. For example, in case
that this module `counter.py` is once imported in such a main module
@@ -54,7 +54,7 @@ as b10-xfrout, Regarding the item `notifyoutv4`, the incrementer
as the following can be invoked via other module like notify_out.py,
which is firstly imported in the main module.
- self.counter.inc('zones', zone_name, 'notifyoutv4')
+ self.counters.inc('zones', zone_name, 'notifyoutv4')
In this example this is for incrementing the counter of the item
notifyoutv4. Thus, such statement can be also written in the other
@@ -81,14 +81,10 @@ def _add_counter(element, spec, identifier):
return isc.cc.data.find(element, identifier)
except isc.cc.data.DataNotFoundError:
pass
- try:
- isc.config.find_spec_part(spec, identifier)
- except isc.cc.data.DataNotFoundError:
- # spec or identifier is wrong
- raise
+ # check whether spec and identifier are correct
+ isc.config.find_spec_part(spec, identifier)
# examine spec of the top-level item first
- spec_ = isc.config.find_spec_part(
- spec, '%s' % identifier.split('/')[0])
+ spec_ = isc.config.find_spec_part(spec, identifier.split('/')[0])
if spec_['item_type'] == 'named_set' and \
spec_['named_set_item_spec']['item_type'] == 'map':
map_spec = spec_['named_set_item_spec']['map_item_spec']
@@ -130,16 +126,20 @@ def _stop_timer(start_time, element, spec, identifier):
the element, which is in seconds between start_time and the
current time and is float-type."""
delta = datetime.now() - start_time
- sec = round(delta.days * 86400 + delta.seconds + \
- delta.microseconds * 1E-6, 6)
+ sec = delta.total_seconds()
_set_counter(element, spec, identifier, sec)
+def _concat(*args, sep='/'):
+ """Concatenates words in args with a separator('/')
+ """
+ return sep.join(args)
+
class _Statistics():
"""Statistics data set"""
# default statistics data
_data = {}
# default statistics spec used in case of the specfile omitted in
- # Counter()
+ # Counters()
_spec = [
{
"item_name": "zones",
@@ -182,11 +182,21 @@ class _Statistics():
}
]
-class Counter():
- """A module for holding all statistics counters of modules. The
- counter numbers can be accessed by the accesseers defined
- according to a spec file. In this class, the structure of per-zone
- counters is assumed to be like this:
+class Counters():
+ """A class for holding and manipulating all statistics counters
+ for a module. A counters object is created by specifying a spec
+ file of the module in argument. According to statistics
+ specification in the spec file, a counter value can be incremented
+ or decremented or obtained. Method as inc() or dec() or get() is
+ useful for this. On the other hand, time data in a counters
+ object can be handled. The timer can be started and stopped. Then
+ duration time can be obtained. Method as start_timer() and
+ stop_timer() and get() is useful for this. Saved counters can be
+ cleared by the method clear_all(). Manipulating counters and
+ timers can be enabled or disabled. if disabled, the value is not
+ changed even if such methods is invoked. Including per-zone
+ counters, a list of counters which can be handled in the class are
+ like the following:
zones/example.com./notifyoutv4
zones/example.com./notifyoutv6
@@ -238,6 +248,12 @@ class Counter():
_statistics = _Statistics()
def __init__(self, spec_file_name=None):
+ """A constructor for the Counters class. A path of the spec
+ file can be specified in argument. Statistics data based on
+ statistics spec can be accumulated if specified. If omitted,
+ default statistics spec is used. Default statistics spec is
+ defined in other hidden class _Statistics().
+ """
self._zones_item_list = []
self._start_time = {}
self._disabled = False
@@ -254,97 +270,105 @@ class Counter():
self._statistics._spec, self._perzone_prefix)\
['named_set_item_spec']['map_item_spec'])
- def clear_counters(self):
+ def clear_all(self):
"""clears all statistics data"""
with self._rlock:
self._statistics._data = {}
def disable(self):
"""disables incrementing/decrementing counters"""
- self._disabled = True
+ with self._rlock:
+ self._disabled = True
def enable(self):
"""enables incrementing/decrementing counters"""
- self._disabled = False
+ with self._rlock:
+ self._disabled = False
- def inc(self, *args):
+ def inc(self, *args, step=1):
"""A incrementer for per-zone counter. Locks the thread
because it is considered to be invoked by a multi-threading
caller. isc.cc.data.DataNotFoundError is raised when
incrementing the counter of the item undefined in the spec
file."""
- identifier = '/'.join(args)
- step = 1
- if self._disabled: return
+ identifier = _concat(*args)
with self._rlock:
+ if self._disabled: return
_inc_counter(self._statistics._data,
self._statistics._spec,
identifier, step)
- def dec(self, *args):
+ def dec(self, *args, step=-1):
"""A decrementer for axfr or ixfr running. Locks the thread
because it is considered to be invoked by a multi-threading
caller. isc.cc.data.DataNotFoundError is raised when
decrementing the counter of the item undefined in the spec
file."""
- identifier = '/'.join(args)
- step = -1
- if self._disabled: return
- with self._rlock:
- _inc_counter(self._statistics._data,
- self._statistics._spec,
- identifier, step)
+ self.inc(*args, step=step)
def get(self, *args):
"""A getter method for counters. It returns the current number
of the specified counter. isc.cc.data.DataNotFoundError is
raised when the counter doesn't have a number yet."""
- identifier = '/'.join(args)
+ identifier = _concat(*args)
return _get_counter(self._statistics._data, identifier)
- def start(self, *args):
+ def start_timer(self, *args):
"""Sets the value returned from _start_timer() as a value of
the identifier in the self._start_time which is dict-type"""
- identifier = '/'.join(args)
- isc.cc.data.set(self._start_time, identifier, _start_timer())
-
- def stop(self, *args):
- """Sets duration time between corresponding time in
- self._start_time and current time into the value of the
- identifier. It deletes corresponding time in self._start_time
- after setting is successfully done. In case of stopping the
- timer which has never been started, it raises and does
- nothing. But in case of stopping the time which isn't defined
- in the spec file, it raises DataNotFoundError"""
- identifier = '/'.join(args)
- try:
- start_time = isc.cc.data.find(self._start_time,
- identifier)
- except isc.cc.data.DataNotFoundError:
- # do not set the end time if the timer isn't started
- pass
- else:
+ identifier = _concat(*args)
+ with self._rlock:
+ if self._disabled: return
+ isc.cc.data.set(self._start_time, identifier, _start_timer())
+
+ def stop_timer(self, *args):
+ """Sets duration time in seconds between corresponding date
+ time in self._start_time and current date time into the value
+ of the identifier. It deletes corresponding time in
+ self._start_time after setting is successfully done. In case
+ of stopping the timer which has never been started, it raises
+ and does nothing. But in case of stopping the time which isn't
+ defined in the spec file, it raises DataNotFoundError"""
+ identifier = _concat(*args)
+ with self._rlock:
+ if self._disabled: return
+ try:
+ start_time = isc.cc.data.find(self._start_time,
+ identifier)
+ except isc.cc.data.DataNotFoundError:
+ # do not set the end time if the timer isn't started
+ return
# set the end time
_stop_timer(
start_time,
self._statistics._data,
self._statistics._spec,
identifier)
- # delete the started timer
- del isc.cc.data.find(
- self._start_time,
- '/'.join(identifier.split('/')[0:-1]))\
- [identifier.split('/')[-1]]
-
- def dump_statistics(self):
+ # A datetime value of once used timer should be deleted
+ # for a future use.
+ # Here, names of branch and leaf are obtained from a
+ # string of identifier. The branch name is equivalent to
+ # the position of datetime to be deleted and the leaf name
+ # is equivalent to the value of datetime to be deleted.
+ (branch, leaf) = identifier.rsplit('/', 1)
+ # Then map of branch is obtained from self._start_time by
+ # using isc.cc.data.find().
+ branch_map = isc.cc.data.find(self._start_time, branch)
+ # Finally a value of the leaf name is deleted from the
+ # map.
+ del branch_map[leaf]
+
+ def get_statistics(self):
"""Calculates an entire server counts, and returns statistics
data format to send out the stats module including each
counter. If there is no counts, then it returns an empty
dictionary."""
# entire copy
statistics_data = self._statistics._data.copy()
- # If self.statistics_data contains nothing of zone name, it
- # returns an empty dict.
+ # If there is no 'zones' found in statistics_data,
+ # i.e. statistics_data contains no per-zone counter, it just
+ # returns statistics_data because calculating total counts
+ # across the zone names isn't necessary.
if self._perzone_prefix not in statistics_data:
return statistics_data
zones = statistics_data[self._perzone_prefix]
diff --git a/src/lib/python/isc/statistics/tests/counter_test.py b/src/lib/python/isc/statistics/tests/counter_test.py
index 090188a..63842e5 100644
--- a/src/lib/python/isc/statistics/tests/counter_test.py
+++ b/src/lib/python/isc/statistics/tests/counter_test.py
@@ -50,26 +50,26 @@ class TestBasicMethods(unittest.TestCase):
TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec1.spec'
def setUp(self):
- self.counter = counter.Counter(self.TEST_SPECFILE_LOCATION)
+ self.counters = counter.Counters(self.TEST_SPECFILE_LOCATION)
def tearDown(self):
- self.counter.clear_counters()
+ self.counters.clear_all()
def test_clear_counters(self):
self.assertRaises(isc.cc.data.DataNotFoundError,
- self.counter.get, 'counter')
- self.counter.inc('counter')
- self.assertEqual(self.counter.get('counter'), 1)
- self.counter.clear_counters()
+ self.counters.get, 'counter')
+ self.counters.inc('counter')
+ self.assertEqual(self.counters.get('counter'), 1)
+ self.counters.clear_all()
self.assertRaises(isc.cc.data.DataNotFoundError,
- self.counter.get, 'counter')
+ self.counters.get, 'counter')
def test_enablediable(self):
- self.assertFalse(self.counter._disabled)
- self.counter.disable()
- self.assertTrue(self.counter._disabled)
- self.counter.enable()
- self.assertFalse(self.counter._disabled)
+ self.assertFalse(self.counters._disabled)
+ self.counters.disable()
+ self.assertTrue(self.counters._disabled)
+ self.counters.enable()
+ self.assertFalse(self.counters._disabled)
def test_add_counter_normal(self):
element = {'counter' : 1}
@@ -128,41 +128,57 @@ class TestBasicMethods(unittest.TestCase):
counter_name = "counter"
timer_name = "seconds"
start_time = counter._start_timer()
- start_functor(concurrency, number, self.counter.inc,
+ start_functor(concurrency, number, self.counters.inc,
counter_name)
counter._stop_timer(start_time,
- self.counter._statistics._data,
- self.counter._statistics._spec,
+ self.counters._statistics._data,
+ self.counters._statistics._spec,
timer_name)
self.assertEqual(
- counter._get_counter(self.counter._statistics._data,
+ counter._get_counter(self.counters._statistics._data,
counter_name),
concurrency * number)
self.assertGreater(
- counter._get_counter(self.counter._statistics._data,
+ counter._get_counter(self.counters._statistics._data,
timer_name), 0)
-class BaseTestCounter():
+ def test_concat(self):
+ # only strings
+ a = ( 'a','b','c','d' )
+ self.assertEqual('a/b/c/d', counter._concat(*a))
+ self.assertEqual('aTbTcTd', counter._concat(*a, sep='T'))
+ self.assertEqual('a\\b\\c\\d', counter._concat(*a, sep='\\'))
+ # mixed with other types
+ b = a + (1,)
+ self.assertRaises(TypeError, counter._concat, *b)
+ b = a + (1.1,)
+ self.assertRaises(TypeError, counter._concat, *b)
+ b = a + ([],)
+ self.assertRaises(TypeError, counter._concat, *b)
+ b = a + ({},)
+ self.assertRaises(TypeError, counter._concat, *b)
+
+class BaseTestCounters():
def setUp(self):
self._statistics_data = {}
- self.counter = counter.Counter(self.TEST_SPECFILE_LOCATION)
- self._entire_server = self.counter._entire_server
- self._perzone_prefix = self.counter._perzone_prefix
+ self.counters = counter.Counters(self.TEST_SPECFILE_LOCATION)
+ self._entire_server = self.counters._entire_server
+ self._perzone_prefix = self.counters._perzone_prefix
def tearDown(self):
- self.counter.clear_counters()
+ self.counters.clear_all()
- def check_dump_statistics(self):
+ def check_get_statistics(self):
"""Checks no differences between the value returned from
- dump_statistics() and locally collected statistics data. Also
+ get_statistics() and locally collected statistics data. Also
checks the result isn't changed even after the method is
invoked twice. Finally checks it is valid for the the
statistics spec."""
- self.assertEqual(self.counter.dump_statistics(),
+ self.assertEqual(self.counters.get_statistics(),
self._statistics_data)
# Idempotency check
- self.assertEqual(self.counter.dump_statistics(),
+ self.assertEqual(self.counters.get_statistics(),
self._statistics_data)
if self.TEST_SPECFILE_LOCATION:
self.assertTrue(isc.config.module_spec_from_file(
@@ -171,131 +187,131 @@ class BaseTestCounter():
else:
self.assertTrue(isc.config.ModuleSpec(
{'module_name': 'Foo',
- 'statistics': self.counter._statistics._spec}
+ 'statistics': self.counters._statistics._spec}
).validate_statistics(
False, self._statistics_data))
def test_perzone_counters(self):
# for per-zone counters
- for name in self.counter._zones_item_list:
+ for name in self.counters._zones_item_list:
args = (self._perzone_prefix, TEST_ZONE_NAME_STR, name)
if name.find('time_to_') == 0:
- self.counter.start(*args)
- self.counter.stop(*args)
- self.assertGreater(self.counter.get(*args), 0)
- sec = self.counter.get(*args)
+ self.counters.start_timer(*args)
+ self.counters.stop_timer(*args)
+ self.assertGreater(self.counters.get(*args), 0)
+ sec = self.counters.get(*args)
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), sec)
# twice exec stopper, then second is not changed
- self.counter.stop(*args)
- self.assertEqual(self.counter.get(*args), sec)
+ self.counters.stop_timer(*args)
+ self.assertEqual(self.counters.get(*args), sec)
else:
- self.counter.inc(*args)
- self.assertEqual(self.counter.get(*args), 1)
+ self.counters.inc(*args)
+ self.assertEqual(self.counters.get(*args), 1)
# checks disable/enable
- self.counter.disable()
- self.counter.inc(*args)
- self.assertEqual(self.counter.get(*args), 1)
- self.counter.enable()
- self.counter.inc(*args)
- self.assertEqual(self.counter.get(*args), 2)
+ self.counters.disable()
+ self.counters.inc(*args)
+ self.assertEqual(self.counters.get(*args), 1)
+ self.counters.enable()
+ self.counters.inc(*args)
+ self.assertEqual(self.counters.get(*args), 2)
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), 2)
- self.check_dump_statistics()
+ self.check_get_statistics()
def test_xfrrunning_counters(self):
# for counters of xfer running
_suffix = 'xfr_running'
_xfrrunning_names = \
- isc.config.spec_name_list(self.counter._statistics._spec,
+ isc.config.spec_name_list(self.counters._statistics._spec,
"", True)
for name in _xfrrunning_names:
if name.find(_suffix) != 1: continue
args = name.split('/')
- self.counter.inc(*args)
- self.assertEqual(self.counter.get(*args), 1)
- self.counter.dec(*args)
- self.assertEqual(self.counter.get(*args), 0)
+ self.counters.inc(*args)
+ self.assertEqual(self.counters.get(*args), 1)
+ self.counters.dec(*args)
+ self.assertEqual(self.counters.get(*args), 0)
# checks disable/enable
- self.counter.disable()
- self.counter.inc(*args)
- self.assertEqual(self.counter.get(*args), 0)
- self.counter.enable()
- self.counter.inc(*args)
- self.assertEqual(self.counter.get(*args), 1)
- self.counter.disable()
- self.counter.dec(*args)
- self.assertEqual(self.counter.get(*args), 1)
- self.counter.enable()
- self.counter.dec(*args)
- self.assertEqual(self.counter.get(*args), 0)
+ self.counters.disable()
+ self.counters.inc(*args)
+ self.assertEqual(self.counters.get(*args), 0)
+ self.counters.enable()
+ self.counters.inc(*args)
+ self.assertEqual(self.counters.get(*args), 1)
+ self.counters.disable()
+ self.counters.dec(*args)
+ self.assertEqual(self.counters.get(*args), 1)
+ self.counters.enable()
+ self.counters.dec(*args)
+ self.assertEqual(self.counters.get(*args), 0)
self._statistics_data[name] = 0
- self.check_dump_statistics()
+ self.check_get_statistics()
def test_socket_counters(self):
# for ipsocket/unixsocket counters
_prefix = 'socket/'
_socket_names = \
- isc.config.spec_name_list(self.counter._statistics._spec,
+ isc.config.spec_name_list(self.counters._statistics._spec,
"", True)
for name in _socket_names:
if name.find(_prefix) != 0: continue
args = name.split('/')
- self.counter.inc(*args)
- self.assertEqual(self.counter.get(*args), 1)
+ self.counters.inc(*args)
+ self.assertEqual(self.counters.get(*args), 1)
# checks disable/enable
- self.counter.disable()
- self.counter.inc(*args)
- self.assertEqual(self.counter.get(*args), 1)
- self.counter.enable()
- self.counter.inc(*args)
- self.assertEqual(self.counter.get(*args), 2)
+ self.counters.disable()
+ self.counters.inc(*args)
+ self.assertEqual(self.counters.get(*args), 1)
+ self.counters.enable()
+ self.counters.inc(*args)
+ self.assertEqual(self.counters.get(*args), 2)
isc.cc.data.set(
self._statistics_data, '/'.join(args), 2)
- self.check_dump_statistics()
+ self.check_get_statistics()
def test_undefined_item(self):
# test DataNotFoundError raising when specifying item defined
# in the specfile
self.assertRaises(isc.cc.data.DataNotFoundError,
- self.counter.inc, '__undefined__')
+ self.counters.inc, '__undefined__')
self.assertRaises(isc.cc.data.DataNotFoundError,
- self.counter.dec, '__undefined__')
- self.counter.start('__undefined__')
+ self.counters.dec, '__undefined__')
+ self.counters.start_timer('__undefined__')
self.assertRaises(isc.cc.data.DataNotFoundError,
- self.counter.stop, '__undefined__')
+ self.counters.stop_timer, '__undefined__')
self.assertRaises(isc.cc.data.DataNotFoundError,
- self.counter.get, '__undefined__')
+ self.counters.get, '__undefined__')
-class TestCounter0(unittest.TestCase, BaseTestCounter):
+class TestCounters0(unittest.TestCase, BaseTestCounters):
TEST_SPECFILE_LOCATION = None
def setUp(self):
- BaseTestCounter.setUp(self)
+ BaseTestCounters.setUp(self)
def tearDown(self):
- BaseTestCounter.tearDown(self)
+ BaseTestCounters.tearDown(self)
-class TestCounter1(unittest.TestCase, BaseTestCounter):
+class TestCounters1(unittest.TestCase, BaseTestCounters):
TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec1.spec'
def setUp(self):
- BaseTestCounter.setUp(self)
+ BaseTestCounters.setUp(self)
def tearDown(self):
- BaseTestCounter.tearDown(self)
+ BaseTestCounters.tearDown(self)
-class TestCounter2(unittest.TestCase, BaseTestCounter):
+class TestCounters2(unittest.TestCase, BaseTestCounters):
TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec2.spec'
def setUp(self):
- BaseTestCounter.setUp(self)
+ BaseTestCounters.setUp(self)
def tearDown(self):
- BaseTestCounter.tearDown(self)
+ BaseTestCounters.tearDown(self)
-class TestCounter3(unittest.TestCase, BaseTestCounter):
+class TestCounters3(unittest.TestCase, BaseTestCounters):
TEST_SPECFILE_LOCATION = TESTDATA_SRCDIR + os.sep + 'test_spec3.spec'
def setUp(self):
- BaseTestCounter.setUp(self)
+ BaseTestCounters.setUp(self)
def tearDown(self):
- BaseTestCounter.tearDown(self)
+ BaseTestCounters.tearDown(self)
if __name__== "__main__":
unittest.main()
More information about the bind10-changes
mailing list