BIND 10 trac2136, updated. 07a1ba094496174c6d62458999c36bde17498c3c [2136] moved invoking update_modules() to outside of the method
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Aug 9 04:53:20 UTC 2012
The branch, trac2136 has been updated
discards 5f228ec5c5ece6555fe75815df78d78dd69d43a8 (commit)
discards f5a1df44489a75c4d708a5ec6217e512b2f803ce (commit)
discards 6ebdb1ea7d09467ccece71d9486c70490ce46fc7 (commit)
discards 1f2f3ffa10fe5065f64137c21f54f5e747d041f1 (commit)
discards 7ee55b5bff4f09e43c50e72eaace12adf49326ae (commit)
discards 2a0dd303927d9405b35b7e440f39335fb08b9093 (commit)
discards a768351ad6526b5c8563ab3145b0e24fdd542dc0 (commit)
discards 795f84a22aaf809c44c4739afd60eda3a0e9d0f8 (commit)
discards 347c79485e7e38fbcfa2ed77cb689063b5b016f8 (commit)
discards 3f922de50497aaac2c1454e8614db268fd45cdd1 (commit)
discards 58b6810a302a68dffdfc64ed991011d339246feb (commit)
discards 99b60989f294af3d7711176f31a487760318065d (commit)
discards 082d6a9435c0bf4eb31e334b0c527a277c6e7b30 (commit)
discards f8f9de23f77e701057ca03eed7388b6d1e050794 (commit)
discards 0472e39d599fb08acd60141a51a1839caaa2165d (commit)
discards c46ccb258d6d2ba5d42f5e672450bfbe69a9fd27 (commit)
discards 7e6d71c5e0a5be43e3d236ffda036d26708ed50a (commit)
discards 6d204445a85e55502898864e9cd865ff9463b466 (commit)
discards be0d496fc4885e3c340415eeb7e38e04ec2c74b5 (commit)
discards 2b1cbf918989de09682327530dc941448c5879d1 (commit)
discards 8f7ae09ae64882c5685d6bfc9605b4a7129abe75 (commit)
discards 4b300f5bdf874a8a1af25d081325471e3dc060f8 (commit)
discards 6c0bc0b402bbc16d4659a91a381c0b5c81594378 (commit)
discards 6d44728f8e1508dedf9ceaf1833e918c300c7530 (commit)
discards e206cb2d5d22d27aae219445133c449e58dfa3c0 (commit)
discards e7739c11cb126eb1ccde59ab7cbad61eff80fe1d (commit)
discards 4a50ef0287747928c8dbd4d045df9780df3c3840 (commit)
discards 4df681f83940c701a8b6e88e59cce9fe2a03981b (commit)
discards 5980e50577cca094153209d1565d641f63d9ebee (commit)
discards 1c195bb85881b91fae165ef5b8334da8b6611a00 (commit)
via 07a1ba094496174c6d62458999c36bde17498c3c (commit)
via 4b19f8ee1250afec018f1b33981d62861b4499ff (commit)
via 37ce3a04782c3d2dd0b87c07662e7de8b6b69bf9 (commit)
via 2fc9bd636bac797227795e5697dedfd1632fdbc2 (commit)
via ec6716e2a75b4c18592a7b1157b37da2123de745 (commit)
via 003d0276c8140694e36ff7468fd1992e17afd6d0 (commit)
via e0a964e89cd91e560b6d2cff08f67296826fb2cf (commit)
via 1bbbf9d3e6083abef236fdb2eb782b299ef3121c (commit)
via 4eb908f8e222d1b3404e7d32d98a82201402789b (commit)
via 7e4d13a765da43d7241441db2236e1e6a73b5335 (commit)
via 3364acc50b843a875988b17c3cb4fac57508cb5c (commit)
via dde8b6049fe7c15cbc7e926177639cb87a706e8d (commit)
via cd4f19acfa69fefed0dd37d7d5275904f026e5a7 (commit)
via 785ab6a3e720a1e683afcca2da4a6691fc453e75 (commit)
via edb6cc58638ff43fb338b463660103e544ddcacd (commit)
via 30bbd3eb05036df144b1b9a364d22f1941222526 (commit)
via 6efc1e2e635a46a12a1cf8c601fdc1c7ae28b32b (commit)
via b9a77c84d6de3f0378709603ad57e1533f376871 (commit)
via 5fa38c20028899696a48c1a3b8edf54918cd252b (commit)
via 1045e7f9b31bd683fb3a100bbd24fd21d4ab2c7e (commit)
via c832cd2d0699320b1e6258a61aa34c797f796268 (commit)
via e60a5349460b72ca051e8fc2a07972200c837d83 (commit)
via 156fa6fbf1ebaf007de56dc2b1c9082b6f4ed041 (commit)
via 9d7105c0c05e2ab709b1ac3554461a30e48ded71 (commit)
via 715ea50c714014ee7f8aee95d7762434482d2f09 (commit)
via be7020b5461d37bbb95abfe84c78c797b80766e8 (commit)
via a519acdad6e7b15cf52d23c6ae0bfad3c843855a (commit)
via 0abcaf5cdd42eecfeb82aec54a68d74805a89e03 (commit)
via 86b531b99411ad1bc047e35cd3e0ddfd1cf501d7 (commit)
via 47dd0cc48213f82dbea6a6365be79fe85c260011 (commit)
via 4c67dd80aaab44f9cd153646f76c9c208b7abc35 (commit)
via da81d3d6b99ac696728924dac36a9adf7bb79169 (commit)
via c71cb1be7bea3537f6de97fef3ad25c4651a850f (commit)
via 9d21102f8822ad32f9879a2fe20a74f29ce72c2d (commit)
via 2e760ad9496385fe00fed546686b33417b7c9615 (commit)
via 9fd7da352dbaf73073aed881e82418c1eba93c4f (commit)
via 94d932029fddd38e608aa478eea96cdf59035487 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (5f228ec5c5ece6555fe75815df78d78dd69d43a8)
\
N -- N -- N (07a1ba094496174c6d62458999c36bde17498c3c)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
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 07a1ba094496174c6d62458999c36bde17498c3c
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Wed Aug 8 21:39:21 2012 +0900
[2136] moved invoking update_modules() to outside of the method
When the set command was used for collecting statistics data, the action was
randomly. But in the case that periodical polling is used for collecting
statistics data, update_modules doesn't need to be invoked so many times every
time update_statistics_data is invoked. Invoking update_module() causes an IO
wait for receiving statistics spec from Cfgmgr.
commit 4b19f8ee1250afec018f1b33981d62861b4499ff
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Wed Aug 8 21:29:24 2012 +0900
[2136] corrected the improper test
Not self.stats.mccs.specification but self.stats.modules['Stats'] should be set
the invalid spec_module into. And it should check whether StatsError is raised
by setting the owner to the self module name in the argument of command_show.
commit 37ce3a04782c3d2dd0b87c07662e7de8b6b69bf9
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Wed Aug 8 21:22:45 2012 +0900
[2136] removed the do_polling method from the __init__ method of stats.Stats()
Because do_polling() is done when the show command is invoked, the do_polling
method didn't need to be done when the stats is starting. Related to this
change, the b10-stats_test.py was changed. do_polling() is inserted before the
assertion of statistics_data.
commit 2fc9bd636bac797227795e5697dedfd1632fdbc2
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Thu Aug 9 13:26:36 2012 +0900
[2136] added a note about a value from the Boss command show_processes
commit ec6716e2a75b4c18592a7b1157b37da2123de745
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Wed Aug 8 20:05:53 2012 +0900
[2136] removed an unnecessary loop
commit 003d0276c8140694e36ff7468fd1992e17afd6d0
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Thu Aug 9 13:41:04 2012 +0900
[2136] revised the internal method _accum()
- Other conditions are considered. One case is that two args are string type,
another case is that either of them is None type.
- _accum() was moved to outside of the Stats class for testing it individually.
- revised the FIXME description in update_statistics_data() according to the
above changes
commit e0a964e89cd91e560b6d2cff08f67296826fb2cf
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Wed Aug 8 21:51:22 2012 +0900
[2136] Changes regarding the test config file
- moved b10-config_test.db from src/bin/stats/tests to
src/bin/stats/tests/testdata
- renamed its name to b10-config.db
- changed its format to multiline
These changes are due to the reviewer's comment.
commit 1bbbf9d3e6083abef236fdb2eb782b299ef3121c
Author: Mukund Sivaraman <muks at isc.org>
Date: Wed Aug 8 11:02:03 2012 +0530
[2136] Update comment text
commit 4eb908f8e222d1b3404e7d32d98a82201402789b
Author: Mukund Sivaraman <muks at isc.org>
Date: Wed Aug 8 11:01:53 2012 +0530
[2136] Minor whitespace update
commit 7e4d13a765da43d7241441db2236e1e6a73b5335
Author: Mukund Sivaraman <muks at isc.org>
Date: Wed Aug 8 10:36:30 2012 +0530
[2136] Remove redundant tests
commit 3364acc50b843a875988b17c3cb4fac57508cb5c
Author: Mukund Sivaraman <muks at isc.org>
Date: Wed Aug 8 10:32:06 2012 +0530
[2136] Indent code
commit dde8b6049fe7c15cbc7e926177639cb87a706e8d
Author: Mukund Sivaraman <muks at isc.org>
Date: Wed Aug 8 10:28:45 2012 +0530
[2136] Assign and use intval earlier
commit cd4f19acfa69fefed0dd37d7d5275904f026e5a7
Author: Mukund Sivaraman <muks at isc.org>
Date: Sun Aug 5 20:30:14 2012 +0530
[2136] Add back part of a deleted comment
commit 785ab6a3e720a1e683afcca2da4a6691fc453e75
Author: Mukund Sivaraman <muks at isc.org>
Date: Sun Aug 5 20:29:59 2012 +0530
[2136] Make minor text updates
commit edb6cc58638ff43fb338b463660103e544ddcacd
Author: Mukund Sivaraman <muks at isc.org>
Date: Sun Aug 5 19:47:55 2012 +0530
[2136] Re-indent code
commit 30bbd3eb05036df144b1b9a364d22f1941222526
Author: Mukund Sivaraman <muks at isc.org>
Date: Sun Aug 5 18:31:38 2012 +0530
[2136] Make some minor changes to poll-interval's description
commit 6efc1e2e635a46a12a1cf8c601fdc1c7ae28b32b
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Wed Aug 1 16:54:54 2012 +0900
[2136] Updated the do_polling method
A list of instances for stats to request is obtained from the show_processes
command of Boss instead of asking the components config of Boss.
commit b9a77c84d6de3f0378709603ad57e1533f376871
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Wed Aug 1 16:19:38 2012 +0900
[2136] Updated the "show_processes" to provide address of each module
This information is used for other module e.g. stats to count running instances
of same module. The address information is seen in the third index of the
array.
commit 5fa38c20028899696a48c1a3b8edf54918cd252b
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Wed Aug 1 19:13:08 2012 +0900
[2136] Introduced an address() method for the Component classes
It returns the "_address" attribute of the classes. This is used for the
"show_processes" command of Boss to provide address information.
commit 1045e7f9b31bd683fb3a100bbd24fd21d4ab2c7e
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Wed Aug 1 15:47:21 2012 +0900
[2136] Updated the 'show' command handler
The stats module decides if polling should be done by the the last time of
polling. If more than one seconds past since the last request to each module,
the stats module requests each module statistics data and then shows the latest
result. Otherwise, the stats module just shows statistics data which it has.
commit c832cd2d0699320b1e6258a61aa34c797f796268
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Wed Aug 1 15:37:23 2012 +0900
[2136] Separated the updating process from the receiving process
In the updating process, it communicates with the cfgmgr module for updating
statistics specification of each module. This fix is for separating such mixed
communication process.
commit e60a5349460b72ca051e8fc2a07972200c837d83
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Jul 31 20:13:27 2012 +0900
[2136] Revised the test scripts and the config db file
- Fixed the incorrect previous fix.
There should not be the inconsistency on number of mock Auth instances on
both test scripts: b10-stats_test.py and b10-stats-httpd_test.py. In the
previous change, there was the inconsistency in MockBoss class. Actually in
b10-stats-httpd_test.py, the number of auth instances which Cfgmgr answers
was four, but the number of actually invoked auth instances was one.
- Reduce the number of invoked mock Auth instances
In theses test scripts, multiple Auth instances need to be invoked. But if
four instances are actually invoked in these scripts, open files(ulimit -n)
exceeds 256. In the environment where ulimit -n was set to 256, the
b10-stats-httpd_test.py test failed actually. In that case,
b10-stats-httpd_test.py needs open files more than 256. So the number of the
auth instances in mock modules was reduced into 2 in the scripts. This fix is
for the comment at #2136.
commit 156fa6fbf1ebaf007de56dc2b1c9082b6f4ed041
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Fri Jul 27 10:16:51 2012 +0900
[2136] Fixed unfinished MockAuth objects
The extra MockAuth objects didn't shut down in
BaseModules.shutdown(). But these weren't needed for unittest of stats
httpd. So setting up and shutting up of them were moved to
b10-stats_test.py from test_utils.py.
commit 9d7105c0c05e2ab709b1ac3554461a30e48ded71
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Thu Jul 26 17:59:20 2012 -0700
[2136] some small suggested wording fixes to doc.
commit 715ea50c714014ee7f8aee95d7762434482d2f09
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Jul 24 19:18:13 2012 +0900
[2136] Fixed wrong checking: The variable key was assumed to be constant.
commit be7020b5461d37bbb95abfe84c78c797b80766e8
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Jul 24 16:23:31 2012 +0900
[2136] Removed 'trees' argument from 'getstats' command
commit a519acdad6e7b15cf52d23c6ae0bfad3c843855a
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Jul 24 09:44:20 2012 +0900
[2136] Refactoring unittest and update to evaluate the next_polltime value as a
integer
commit 0abcaf5cdd42eecfeb82aec54a68d74805a89e03
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Mon Jul 23 19:47:25 2012 +0900
[2136] Updated not to calculate next timing based on current timestamp in every
polling
commit 86b531b99411ad1bc047e35cd3e0ddfd1cf501d7
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Mon Jul 23 14:33:34 2012 +0900
[2136] moved creation of a stats.Stats object in each test case
commit 47dd0cc48213f82dbea6a6365be79fe85c260011
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Sun Jul 22 13:10:32 2012 +0900
[2136] kept consistency in unittest due to the previous changes
commit 4c67dd80aaab44f9cd153646f76c9c208b7abc35
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Sun Jul 22 02:06:45 2012 +0900
[2136] do group_sendmsg too all modules then do group_recvmsg in
do_polling for efficiency
Also added setting timeout value to one second for precise and
refactoring timeout handling
commit da81d3d6b99ac696728924dac36a9adf7bb79169
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Sun Jul 22 02:05:44 2012 +0900
[2136] added a new message id for getting invalid statistics data from the
module
commit c71cb1be7bea3537f6de97fef3ad25c4651a850f
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Sat Jul 21 23:37:59 2012 +0900
[2136] updated bind10-guide.* due to removing set command from stats module
commit 9d21102f8822ad32f9879a2fe20a74f29ce72c2d
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Sat Jul 21 23:23:02 2012 +0900
[2136] added some misc changes
Changes in b10-stats_test.py:
- added deeply checking statistics values of each of module and
instance
- added stats_server.shutdown() at the end of the test_config method.
Because the running stats_server was never shut down even after
stats_server.run() was invoked.
Changes in test_utils.py:
- Changed the way of invoking multiple auth instances just for efficiency
commit 2e760ad9496385fe00fed546686b33417b7c9615
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Wed Jul 25 11:46:42 2012 +0900
[2136] renamed 'pid' to 'mid' and change the default value -1 to None on
the second argument of the the 'update_statistics_data' method
Instead of PID(Process Id) used in previous version of stats codes,
'mid' (module id) is used for identifying multiple instances of same
module. 'lname' of CC-session in stats codes is assigned to it.
commit 9fd7da352dbaf73073aed881e82418c1eba93c4f
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Sun Jul 22 02:24:16 2012 +0900
[2136] removed the obsoleted command 'sendstats' from the mock modules
commit 94d932029fddd38e608aa478eea96cdf59035487
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Sat Jul 21 21:51:31 2012 +0900
[2136] removed 'set' command and introduced a 'poll-interval' config item
The description about 'set' command was removed from the manpages, and
A 'poll-interval' config item was introduced into the manpages. Also
the implement, the testcases and specification related to the set
command were removed from source codes and the specfile.
-----------------------------------------------------------------------
Summary of changes:
configure.ac | 1 +
src/bin/stats/stats.py.in | 117 +++++++++++++++++++---------
src/bin/stats/tests/Makefile.am | 6 +-
src/bin/stats/tests/b10-config_test.db | 1 -
src/bin/stats/tests/b10-stats_test.py | 56 ++++++++++---
src/bin/stats/tests/test_utils.py | 2 +-
src/bin/stats/tests/testdata/Makefile.am | 1 +
src/bin/stats/tests/testdata/b10-config.db | 14 ++++
8 files changed, 147 insertions(+), 51 deletions(-)
delete mode 100644 src/bin/stats/tests/b10-config_test.db
create mode 100644 src/bin/stats/tests/testdata/Makefile.am
create mode 100644 src/bin/stats/tests/testdata/b10-config.db
-----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index af350a8..8f324ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1039,6 +1039,7 @@ AC_CONFIG_FILES([Makefile
src/bin/zonemgr/tests/Makefile
src/bin/stats/Makefile
src/bin/stats/tests/Makefile
+ src/bin/stats/tests/testdata/Makefile
src/bin/usermgr/Makefile
src/bin/tests/Makefile
src/lib/Makefile
diff --git a/src/bin/stats/stats.py.in b/src/bin/stats/stats.py.in
index 43f9cb7..66436e1 100755
--- a/src/bin/stats/stats.py.in
+++ b/src/bin/stats/stats.py.in
@@ -98,6 +98,45 @@ def get_spec_defaults(spec):
return spec.get("item_default", None)
return dict([ (s['item_name'], _get_spec_defaults(s)) for s in spec ])
+def _accum(a, b):
+ """If the first arg is dict or list type, two values
+ would be merged and accumlated. This is for internal use."""
+
+ # If both of args are dict or list type, two
+ # values are merged.
+ if type(a) is dict and type(b) is dict:
+ return dict([ (k, _accum(v, b[k])) \
+ if k in b else (k, v) \
+ for (k, v) in a.items() ] \
+ + [ (k, v) \
+ for (k, v) in b.items() \
+ if k not in a ])
+ elif type(a) is list and type(b) is list:
+ return [ _accum(a[i], b[i]) \
+ if len(b) > i else a[i] \
+ for i in range(len(a)) ] \
+ + [ b[i] \
+ for i in range(len(b)) \
+ if len(a) <= i ]
+ # If both of args are integer or float type, two
+ # values are added.
+ elif (type(a) is int and type(b) is int) \
+ or (type(a) is float or type(b) is float):
+ return a + b
+
+ # If both of args are string type,
+ # values are compared and bigger one is returned.
+ elif type(a) is str and type(b) is str:
+ if a < b: return b
+ return a
+
+ # If the first arg is None type, the second value is returned.
+ elif a is None:
+ return b
+
+ # Nothing matches above, the first arg is returned
+ return a
+
class Callback():
"""
A Callback handler class
@@ -156,6 +195,7 @@ class Stats:
# set a absolute timestamp polling at next time
self.next_polltime = get_timestamp() + self.get_interval()
# initialized Statistics data
+ self.update_modules()
if self.update_statistics_data(
self.module_name,
self.cc_session.lname,
@@ -166,8 +206,6 @@ class Stats:
self.module_name)
# define the variable of the last time of polling
self._lasttime_poll = 0.0
- # try to do polling firstly
- self.do_polling()
def get_interval(self):
"""return the current value of 'poll-interval'"""
@@ -190,6 +228,31 @@ class Stats:
if answer:
(rcode, value) = isc.config.ccsession.parse_answer(answer)
if rcode == 0 and type(value) is list:
+ # NOTE: For example, the "show_processes" command
+ # of Boss is assumed to return the response in this
+ # format:
+ # [
+ # ...
+ # [
+ # 20061,
+ # "b10-auth",
+ # "Auth"
+ # ],
+ # [
+ # 20103,
+ # "b10-auth-2",
+ # "Auth"
+ # ]
+ # ...
+ # ]
+ # If multiple instances of the same module are
+ # running, the address names of them, which are at the
+ # third element, must be also same. Thus, the value of
+ # the third element of each outer element is read here
+ # for counting multiple instances. This is a
+ # workaround for counting the instances. This should
+ # be fixed in another proper way in the future
+ # release.
modules = [ v[2] if type(v) is list and len(v) > 2 \
else None for v in value ]
# start requesting each module to collect statistics data
@@ -226,6 +289,7 @@ class Stats:
pass
# update statistics data
+ self.update_modules()
while len(_statistics_data) > 0:
(_module_name, _lname, _args) = _statistics_data.pop(0)
if self.update_statistics_data(_module_name, _lname, _args):
@@ -350,7 +414,7 @@ class Stats:
module. If it can't find specified statistics data, it raises
StatsError.
"""
- self.update_statistics_data()
+ self.update_modules()
if owner and name:
try:
return {owner:{name:self.statistics_data[owner][name]}}
@@ -392,47 +456,24 @@ class Stats:
# interfaces aren't changed in this fix.
def _accum_bymodule(statistics_data_bymid):
- # This is an internal function for the superordinate
- # function. It accumulates statistics data of each module id by
- # module. It returns the accumulation result.
- def _accum(a, b):
- # If the first arg is dict or list type, two values
- # would be merged and accumlated.
- if type(a) is dict:
- return dict([ (k, _accum(v, b[k])) \
- if k in b else (k, v) \
- for (k, v) in a.items() ] \
- + [ (k, v) \
- for (k, v) in b.items() \
- if k not in a ])
- elif type(a) is list:
- return [ _accum(a[i], b[i]) \
- if len(b) > i else a[i] \
- for i in range(len(a)) ] \
- + [ b[i] \
- for i in range(len(b)) \
- if len(a) <= i ]
- # If the first arg is integer or float type, two
- # values are just added.
- # FIXME: A issue might happen when consolidating
- # statistics of the multiple instances. If they have
- # different statistics data which are not for adding
- # each other, this might happen: If these are integer
- # or float, these are added each other, otherwise
- # these are overwritten into one of them.
- elif type(a) is int or type(a) is float:
- return a + b
- # If the first arg is str or other types than above,
- # then it just returns the first arg which is assumed
- # to be the newer value.
- return a
+ """This is an internal method for the superordinate
+ method. It accumulates statistics data of each module id
+ by module. It returns a accumulated result."""
+ # FIXME: A issue might happen when consolidating
+ # statistics of the multiple instances. If they have
+ # different statistics data which are not for adding each
+ # other, this might happen: If these are integer or float,
+ # these are added each other. If these are string , these
+ # are compared and consolidated into bigger one. If one
+ # of them is None type , these might be consolidated
+ # into not None-type one. Otherwise these are overwritten
+ # into one of them.
ret = {}
for data in statistics_data_bymid.values():
ret.update(_accum(data, ret))
return ret
# Firstly, it gets default statistics data in each spec file.
- self.update_modules()
statistics_data = {}
for (name, module) in self.modules.items():
value = get_spec_defaults(module.get_statistics_spec())
diff --git a/src/bin/stats/tests/Makefile.am b/src/bin/stats/tests/Makefile.am
index de184b3..7484e5d 100644
--- a/src/bin/stats/tests/Makefile.am
+++ b/src/bin/stats/tests/Makefile.am
@@ -1,6 +1,8 @@
+SUBDIRS = testdata .
+
PYCOVERAGE_RUN = @PYCOVERAGE_RUN@
PYTESTS = b10-stats_test.py b10-stats-httpd_test.py
-EXTRA_DIST = $(PYTESTS) test_utils.py b10-config_test.db
+EXTRA_DIST = $(PYTESTS) test_utils.py
CLEANFILES = test_utils.pyc
# If necessary (rare cases), explicitly specify paths to dynamic libraries
@@ -23,7 +25,7 @@ endif
PYTHONPATH=$(COMMON_PYTHON_PATH):$(abs_top_builddir)/src/bin/stats:$(abs_top_builddir)/src/bin/stats/tests:$(abs_top_builddir)/src/bin/msgq:$(abs_top_builddir)/src/lib/python/isc/config \
B10_FROM_SOURCE=$(abs_top_srcdir) \
BIND10_MSGQ_SOCKET_FILE=$(abs_top_builddir)/msgq_socket \
- CONFIG_TESTDATA_PATH=$(abs_top_srcdir)/src/bin/stats/tests \
+ CONFIG_TESTDATA_PATH=$(abs_top_srcdir)/src/bin/stats/tests/testdata \
B10_LOCKFILE_DIR_FROM_BUILD=$(abs_top_builddir) \
$(PYCOVERAGE_RUN) $(abs_srcdir)/$$pytest || exit ; \
done
diff --git a/src/bin/stats/tests/b10-config_test.db b/src/bin/stats/tests/b10-config_test.db
deleted file mode 100644
index b1d6689..0000000
--- a/src/bin/stats/tests/b10-config_test.db
+++ /dev/null
@@ -1 +0,0 @@
-{"version": 2, "Boss": {"components": {"b10-auth": {"kind": "needed", "special": "auth"}, "b10-auth-2": {"kind": "needed", "special": "auth"}}}}
diff --git a/src/bin/stats/tests/b10-stats_test.py b/src/bin/stats/tests/b10-stats_test.py
index 45ef3d1..5a7b6b1 100644
--- a/src/bin/stats/tests/b10-stats_test.py
+++ b/src/bin/stats/tests/b10-stats_test.py
@@ -100,6 +100,44 @@ class TestUtilties(unittest.TestCase):
self.assertNotEqual(stats.get_datetime(
(2011, 6, 22, 8, 23, 40, 2, 173, 0)), self.const_datetime)
+ def test__accum(self):
+ self.assertEqual(stats._accum(None, None), None)
+ self.assertEqual(stats._accum(None, "b"), "b")
+ self.assertEqual(stats._accum("a", None), "a")
+ self.assertEqual(stats._accum(1, 2), 3)
+ self.assertEqual(stats._accum(0.5, 0.3), 0.8)
+ self.assertEqual(stats._accum('aa','bb'), 'bb')
+ self.assertEqual(stats._accum('1970-01-01T09:00:00Z','2012-08-09T09:33:31Z'),
+ '2012-08-09T09:33:31Z')
+ self.assertEqual(stats._accum(
+ [1, 2, 3], [4, 5]), [5, 7, 3])
+ self.assertEqual(stats._accum(
+ [4, 5], [1, 2, 3]), [5, 7, 3])
+ self.assertEqual(stats._accum(
+ [1, 2, 3], [None, 5, 6]), [1, 7, 9])
+ self.assertEqual(stats._accum(
+ [None, 5, 6], [1, 2, 3]), [1, 7, 9])
+ self.assertEqual(stats._accum(
+ [1, 2, 3], [None, None, None, None]), [1,2,3,None])
+ self.assertEqual(stats._accum(
+ [[1,2],3],[[],5,6]), [[1,2],8,6])
+ self.assertEqual(stats._accum(
+ {'one': 1, 'two': 2, 'three': 3},
+ {'one': 4, 'two': 5}),
+ {'one': 5, 'two': 7, 'three': 3})
+ self.assertEqual(stats._accum(
+ {'one': 1, 'two': 2, 'three': 3},
+ {'four': 4, 'five': 5}),
+ {'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5})
+ self.assertEqual(stats._accum(
+ {'one': [1, 2], 'two': [3, None, 5], 'three': [None, 3, None]},
+ {'one': [2], 'two': [4, 5], 'three': [None, None, None], 'four': 'FOUR'}),
+ {'one':[3,2], 'two':[7,5,5], 'three':[None,3,None], 'four': 'FOUR'})
+ self.assertEqual(stats._accum(
+ [ {'one': 1, 'two': 2, 'three': 3}, {'four': 4, 'five': 5, 'six': 6} ],
+ [ {}, {'four': 1, 'five': 2, 'six': 3} ]),
+ [ {'one': 1, 'two': 2, 'three': 3}, {'four': 5, 'five': 7, 'six': 9} ])
+
class TestCallback(unittest.TestCase):
def setUp(self):
self.dummy_func = lambda *x, **y : (x, y)
@@ -366,6 +404,7 @@ class TestStats(unittest.TestCase):
def test_update_statistics_data_withmid(self):
self.stats = stats.Stats()
+ self.stats.do_polling()
# samples of query number
bar1_tcp = 1001
bar2_tcp = 2001
@@ -548,11 +587,11 @@ class TestStats(unittest.TestCase):
0, {'Stats': {'timestamp':self.const_timestamp}}))
stats.get_datetime = orig_get_datetime
stats.get_timestamp = orig_get_timestamp
- self.stats.mccs.specification = isc.config.module_spec.ModuleSpec(
+ self.stats.modules[self.stats.module_name] = isc.config.module_spec.ModuleSpec(
{ "module_name": self.stats.module_name,
"statistics": [] } )
self.assertRaises(
- stats.StatsError, self.stats.command_show, owner='Foo', name='bar')
+ stats.StatsError, self.stats.command_show, owner=self.stats.module_name, name='bar')
def test_command_showchema(self):
self.stats = stats.Stats()
@@ -788,8 +827,8 @@ class TestStats(unittest.TestCase):
stat = stats_server.server
stats_server.run()
self.assertEqual(
- send_command('status', 'Stats'),
- (0, "Stats is up. (PID " + str(os.getpid()) + ")"))
+ send_command('show', 'Stats'),
+ (0, stat.statistics_data))
# check statistics data of 'Boss'
boss = self.base.boss.server
self.assertEqual(
@@ -805,11 +844,10 @@ class TestStats(unittest.TestCase):
for i in list_auth:
auth = getattr(self.base,"auth"+i).server
for s in stat.statistics_data_bymid['Auth'].values():
- for t in s.values():
- self.assertEqual(
- s, {'queries.perzone': auth.queries_per_zone,
- 'queries.tcp': auth.queries_tcp,
- 'queries.udp': auth.queries_udp})
+ self.assertEqual(
+ s, {'queries.perzone': auth.queries_per_zone,
+ 'queries.tcp': auth.queries_tcp,
+ 'queries.udp': auth.queries_udp})
n = len(stat.statistics_data_bymid['Auth'])
self.assertEqual(n, len(list_auth))
# check consolidation of statistics data of the auth
diff --git a/src/bin/stats/tests/test_utils.py b/src/bin/stats/tests/test_utils.py
index f213852..895f64e 100644
--- a/src/bin/stats/tests/test_utils.py
+++ b/src/bin/stats/tests/test_utils.py
@@ -125,7 +125,7 @@ class MockCfgmgr:
def __init__(self):
self._started = threading.Event()
self.cfgmgr = isc.config.cfgmgr.ConfigManager(
- os.environ['CONFIG_TESTDATA_PATH'], "b10-config_test.db")
+ os.environ['CONFIG_TESTDATA_PATH'], "b10-config.db")
self.cfgmgr.read_config()
def run(self):
diff --git a/src/bin/stats/tests/testdata/Makefile.am b/src/bin/stats/tests/testdata/Makefile.am
new file mode 100644
index 0000000..8f9da09
--- /dev/null
+++ b/src/bin/stats/tests/testdata/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = b10-config.db
diff --git a/src/bin/stats/tests/testdata/b10-config.db b/src/bin/stats/tests/testdata/b10-config.db
new file mode 100644
index 0000000..2f89b98
--- /dev/null
+++ b/src/bin/stats/tests/testdata/b10-config.db
@@ -0,0 +1,14 @@
+{ "version": 2,
+ "Boss": {
+ "components": {
+ "b10-auth": {
+ "kind": "needed",
+ "special": "auth"
+ },
+ "b10-auth-2": {
+ "kind": "needed",
+ "special": "auth"
+ }
+ }
+ }
+}
More information about the bind10-changes
mailing list