Commit 8e28187a authored by zhanglikun's avatar zhanglikun
Browse files

Merge branch 'master' into trac598_new

parents d1fdfd86 4b3e621a
234. [func] jerry
237. [bug] naokikambe
Resolved that the stats module wasn't configurable in bindctl in
spite of its having configuration items. The configuration part
was removed from the original spec file "stats.spec" and was
placed in a new spec file "stats-schema.spec". Because it means
definitions of statistics items. The command part is still
there. Thus stats module currently has no its own configuration,
and the items in "stats-schema.spec" are neither visible nor
configurable through bindctl. "stats-schema.spec" is shared with
stats module and stats-httpd module, and maybe with other
statistical modules in future. "stats.spec" has own configuration
and commands of stats module, if it requires.
(Trac#719, git a234b20dc6617392deb8a1e00eb0eed0ff353c0a)
236. [func] jelte
C++ client side of configuration now uses BIND10 logging system.
It also has improved error handling when communicating with the
rest of the system.
(Trac #743, git 86632c12308c3ed099d75eb828f740c526dd7ec0)
235. [func] jinmei
libdns++: added support for TSIG signing and verification. It can
be done using a newly introduced TSIGContext class.
Note: we temporarily disabled support for truncated signature
and modified some part of the code introduced in #226 accordingly.
We plan to fix this pretty soon.
(Trac #812, git ebe0c4b1e66d359227bdd1bd47395fee7b957f14)
(Trac #871, git 7c54055c0e47c7a0e36fcfab4b47ff180c0ca8c8)
(Trac #813, git ffa2f0672084c1f16e5784cdcdd55822f119feaa)
(Trac #893, git 5aaa6c0f628ed7c2093ecdbac93a2c8cf6c94349)
234. [func] jerry
src/bin/xfrin: update xfrin to use TSIG. Currently it only supports
sending a signed TSIG request or SOA request.
(Trac #815, git a892818fb13a1839c82104523cb6cb359c970e88)
233. [func] stephen
233. [func] stephen
Added new-style logging statements to the NSAS code.
(Trac #745, git ceef68cd1223ae14d8412adbe18af2812ade8c2d)
232. [func] stephen
To facilitate the writing of extended descriptions in message files,
altered the message file format. The message is now flagged with a "%"
as the first non-blank character in the line and the lines in the
extended description are no longer preceded by a "+".
232. [func] stephen
To facilitate the writing of extended descriptions in
message files, altered the message file format. The message
is now flagged with a "%" as the first non-blank character
in the line and the lines in the extended description are
no longer preceded by a "+".
(Trac #900, git b395258c708b49a5da8d0cffcb48d83294354ba3)
231. [func]*
231. [func]* vorner
The logging interface changed slightly. We use
logger.foo(MESSAGE_ID).arg(bar); instead of logger.foo(MESSAGE_ID, bar);
internally. The message definitions use '%1,%2,...' instead of '%s,%d',
which allows us to cope better with mismatched placeholders and allows
reordering of them in case of translation.
logger.foo(MESSAGE_ID).arg(bar); instead of logger.foo(MESSAGE_ID,
bar); internally. The message definitions use '%1,%2,...'
instead of '%s,%d', which allows us to cope better with
mismatched placeholders and allows reordering of them in
case of translation.
(Trac901, git 4903410e45670b30d7283f5d69dc28c2069237d6)
230. [bug] naokikambe
......
......@@ -807,6 +807,7 @@ AC_OUTPUT([doc/version.ent
src/bin/stats/stats.py
src/bin/stats/stats_httpd.py
src/bin/stats/stats.spec
src/bin/stats/stats-schema.spec
src/bin/stats/stats-httpd.spec
src/bin/stats/stats-httpd-xml.tpl
src/bin/stats/stats-httpd-xsd.tpl
......
......@@ -5,7 +5,7 @@ pkglibexecdir = $(libexecdir)/@PACKAGE@
pkglibexec_SCRIPTS = b10-stats b10-stats-httpd
b10_statsdir = $(pkgdatadir)
b10_stats_DATA = stats.spec stats-httpd.spec
b10_stats_DATA = stats.spec stats-httpd.spec stats-schema.spec
b10_stats_DATA += stats-httpd-xml.tpl stats-httpd-xsd.tpl stats-httpd-xsl.tpl
CLEANFILES = b10-stats stats.pyc
......@@ -13,7 +13,7 @@ CLEANFILES += b10-stats-httpd stats_httpd.pyc
man_MANS = b10-stats.8 b10-stats-httpd.8
EXTRA_DIST = $(man_MANS) b10-stats.xml b10-stats-httpd.xml
EXTRA_DIST += stats.spec stats-httpd.spec
EXTRA_DIST += stats.spec stats-httpd.spec stats-schema.spec
EXTRA_DIST += stats-httpd-xml.tpl stats-httpd-xsd.tpl stats-httpd-xsl.tpl
if ENABLE_MAN
......@@ -28,8 +28,7 @@ endif
# this is done here since configure.ac AC_OUTPUT doesn't expand exec_prefix
b10-stats: stats.py
$(SED) -e "s|@@PYTHONPATH@@|@pyexecdir@|" \
-e "s|.*#@@REMOVED@@$$||" stats.py >$@
$(SED) -e "s|@@PYTHONPATH@@|@pyexecdir@|" stats.py >$@
chmod a+x $@
b10-stats-httpd: stats_httpd.py
......
......@@ -66,6 +66,10 @@ bindctl(1)\&. Please see the manual of
bindctl(1)
about how to configure the settings\&.
.PP
/usr/local/share/bind10\-devel/stats\-schema\&.spec
\(em This is a spec file for data schema of of BIND 10 statistics\&. This schema cannot be configured via
bindctl(1)\&.
.PP
/usr/local/share/bind10\-devel/stats\-httpd\-xml\&.tpl
\(em the template file of XML document\&.
......
......@@ -112,6 +112,12 @@
of <refentrytitle>bindctl</refentrytitle><manvolnum>1</manvolnum> about
how to configure the settings.
</para>
<para><filename>/usr/local/share/bind10-devel/stats-schema.spec</filename>
<!--TODO: The filename should be computed from prefix-->
&mdash; This is a spec file for data schema of
of BIND 10 statistics. This schema cannot be configured
via <refentrytitle>bindctl</refentrytitle><manvolnum>1</manvolnum>.
</para>
<para>
<filename>/usr/local/share/bind10-devel/stats-httpd-xml.tpl</filename>
<!--TODO: The filename should be computed from prefix-->
......
......@@ -63,11 +63,17 @@ switches to verbose mode\&. It sends verbose messages to STDOUT\&.
.PP
/usr/local/share/bind10\-devel/stats\&.spec
\(em This is a spec file for
\fBb10\-stats\fR\&. It contains definitions of statistics items of BIND 10 and commands received via
\fBb10\-stats\fR\&. It contains commands for
\fBb10\-stats\fR\&. They can be invoked via
bindctl(1)\&.
.PP
/usr/local/share/bind10\-devel/stats\-schema\&.spec
\(em This is a spec file for data schema of of BIND 10 statistics\&. This schema cannot be configured via
bindctl(1)\&.
.SH "SEE ALSO"
.PP
\fBb10-stats-httpd\fR(8),
\fBbind10\fR(8),
\fBbindctl\fR(1),
\fBb10-auth\fR(8),
......
......@@ -89,16 +89,26 @@
<refsect1>
<title>FILES</title>
<para><filename>/usr/local/share/bind10-devel/stats.spec</filename>
<!--TODO: The filename should be computed from prefix-->
&mdash; This is a spec file for <command>b10-stats</command>. It
contains definitions of statistics items of BIND 10 and commands
received via
<refentrytitle>bindctl</refentrytitle><manvolnum>1</manvolnum>.
contains commands for <command>b10-stats</command>. They can be
invoked
via <refentrytitle>bindctl</refentrytitle><manvolnum>1</manvolnum>.
</para>
<para><filename>/usr/local/share/bind10-devel/stats-schema.spec</filename>
<!--TODO: The filename should be computed from prefix-->
&mdash; This is a spec file for data schema of
of BIND 10 statistics. This schema cannot be configured
via <refentrytitle>bindctl</refentrytitle><manvolnum>1</manvolnum>.
</para>
</refsect1>
<refsect1>
<title>SEE ALSO</title>
<para>
<citerefentry>
<refentrytitle>b10-stats-httpd</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>bind10</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
......
{
"module_spec": {
"module_name": "Stats",
"module_description": "Statistics data schema",
"config_data": [
{
"item_name": "report_time",
"item_type": "string",
"item_optional": false,
"item_default": "1970-01-01T00:00:00Z",
"item_title": "Report time",
"item_description": "A date time when stats module reports",
"item_format": "date-time"
},
{
"item_name": "bind10.boot_time",
"item_type": "string",
"item_optional": false,
"item_default": "1970-01-01T00:00:00Z",
"item_title": "bind10.BootTime",
"item_description": "A date time when bind10 process starts initially",
"item_format": "date-time"
},
{
"item_name": "stats.boot_time",
"item_type": "string",
"item_optional": false,
"item_default": "1970-01-01T00:00:00Z",
"item_title": "stats.BootTime",
"item_description": "A date time when the stats module starts initially or when the stats module restarts",
"item_format": "date-time"
},
{
"item_name": "stats.start_time",
"item_type": "string",
"item_optional": false,
"item_default": "1970-01-01T00:00:00Z",
"item_title": "stats.StartTime",
"item_description": "A date time when the stats module starts collecting data or resetting values last time",
"item_format": "date-time"
},
{
"item_name": "stats.last_update_time",
"item_type": "string",
"item_optional": false,
"item_default": "1970-01-01T00:00:00Z",
"item_title": "stats.LastUpdateTime",
"item_description": "The latest date time when the stats module receives from other modules like auth server or boss process and so on",
"item_format": "date-time"
},
{
"item_name": "stats.timestamp",
"item_type": "real",
"item_optional": false,
"item_default": 0.0,
"item_title": "stats.Timestamp",
"item_description": "A current time stamp since epoch time (1970-01-01T00:00:00Z)",
"item_format": "second"
},
{
"item_name": "stats.lname",
"item_type": "string",
"item_optional": false,
"item_default": "",
"item_title": "stats.LocalName",
"item_description": "A localname of stats module given via CC protocol"
},
{
"item_name": "auth.queries.tcp",
"item_type": "integer",
"item_optional": false,
"item_default": 0,
"item_title": "auth.queries.tcp",
"item_description": "A number of total query counts which all auth servers receive over TCP since they started initially"
},
{
"item_name": "auth.queries.udp",
"item_type": "integer",
"item_optional": false,
"item_default": 0,
"item_title": "auth.queries.udp",
"item_description": "A number of total query counts which all auth servers receive over UDP since they started initially"
}
],
"commands": []
}
}
......@@ -24,12 +24,6 @@ from optparse import OptionParser, OptionValueError
from collections import defaultdict
from isc.config.ccsession import ModuleCCSession, create_answer
from isc.cc import Session, SessionError
# Note: Following lines are removed in b10-stats #@@REMOVED@@
if __name__ == 'stats': #@@REMOVED@@
try: #@@REMOVED@@
from fake_time import time, strftime, gmtime #@@REMOVED@@
except ImportError: #@@REMOVED@@
pass #@@REMOVED@@
# for setproctitle
import isc.util.process
......@@ -39,13 +33,15 @@ isc.util.process.rename()
# from a directory relative to that, otherwise we use the ones
# installed on the system
if "B10_FROM_SOURCE" in os.environ:
SPECFILE_LOCATION = os.environ["B10_FROM_SOURCE"] + os.sep + \
"src" + os.sep + "bin" + os.sep + "stats" + os.sep + "stats.spec"
BASE_LOCATION = os.environ["B10_FROM_SOURCE"] + os.sep + \
"src" + os.sep + "bin" + os.sep + "stats"
else:
PREFIX = "@prefix@"
DATAROOTDIR = "@datarootdir@"
SPECFILE_LOCATION = "@datadir@" + os.sep + "@PACKAGE@" + os.sep + "stats.spec"
SPECFILE_LOCATION = SPECFILE_LOCATION.replace("${datarootdir}", DATAROOTDIR).replace("${prefix}", PREFIX)
BASE_LOCATION = "@datadir@" + os.sep + "@PACKAGE@"
BASE_LOCATION = BASE_LOCATION.replace("${datarootdir}", DATAROOTDIR).replace("${prefix}", PREFIX)
SPECFILE_LOCATION = BASE_LOCATION + os.sep + "stats.spec"
SCHEMA_SPECFILE_LOCATION = BASE_LOCATION + os.sep + "stats-schema.spec"
class Singleton(type):
"""
......@@ -184,8 +180,7 @@ class CCSessionListener(Listener):
self.session = self.subject.session = self.cc_session._session
# initialize internal data
self.config_spec = self.cc_session.get_module_spec().get_config_spec()
self.stats_spec = self.config_spec
self.stats_spec = isc.config.module_spec_from_file(SCHEMA_SPECFILE_LOCATION).get_config_spec()
self.stats_data = self.initialize_data(self.stats_spec)
# add event handler invoked via SessionSubject object
......
......@@ -2,86 +2,7 @@
"module_spec": {
"module_name": "Stats",
"module_description": "Stats daemon",
"config_data": [
{
"item_name": "report_time",
"item_type": "string",
"item_optional": false,
"item_default": "1970-01-01T00:00:00Z",
"item_title": "Report time",
"item_description": "A date time when stats module reports",
"item_format": "date-time"
},
{
"item_name": "bind10.boot_time",
"item_type": "string",
"item_optional": false,
"item_default": "1970-01-01T00:00:00Z",
"item_title": "bind10.BootTime",
"item_description": "A date time when bind10 process starts initially",
"item_format": "date-time"
},
{
"item_name": "stats.boot_time",
"item_type": "string",
"item_optional": false,
"item_default": "1970-01-01T00:00:00Z",
"item_title": "stats.BootTime",
"item_description": "A date time when the stats module starts initially or when the stats module restarts",
"item_format": "date-time"
},
{
"item_name": "stats.start_time",
"item_type": "string",
"item_optional": false,
"item_default": "1970-01-01T00:00:00Z",
"item_title": "stats.StartTime",
"item_description": "A date time when the stats module starts collecting data or resetting values last time",
"item_format": "date-time"
},
{
"item_name": "stats.last_update_time",
"item_type": "string",
"item_optional": false,
"item_default": "1970-01-01T00:00:00Z",
"item_title": "stats.LastUpdateTime",
"item_description": "The latest date time when the stats module receives from other modules like auth server or boss process and so on",
"item_format": "date-time"
},
{
"item_name": "stats.timestamp",
"item_type": "real",
"item_optional": false,
"item_default": 0.0,
"item_title": "stats.Timestamp",
"item_description": "A current time stamp since epoch time (1970-01-01T00:00:00Z)",
"item_format": "second"
},
{
"item_name": "stats.lname",
"item_type": "string",
"item_optional": false,
"item_default": "",
"item_title": "stats.LocalName",
"item_description": "A localname of stats module given via CC protocol"
},
{
"item_name": "auth.queries.tcp",
"item_type": "integer",
"item_optional": false,
"item_default": 0,
"item_title": "auth.queries.tcp",
"item_description": "A number of total query counts which all auth servers receive over TCP since they started initially"
},
{
"item_name": "auth.queries.udp",
"item_type": "integer",
"item_optional": false,
"item_default": 0,
"item_title": "auth.queries.udp",
"item_description": "A number of total query counts which all auth servers receive over UDP since they started initially"
}
],
"config_data": [],
"commands": [
{
"command_name": "status",
......
......@@ -46,7 +46,7 @@ else:
BASE_LOCATION = "@datadir@" + os.sep + "@PACKAGE@"
BASE_LOCATION = BASE_LOCATION.replace("${datarootdir}", DATAROOTDIR).replace("${prefix}", PREFIX)
SPECFILE_LOCATION = BASE_LOCATION + os.sep + "stats-httpd.spec"
STATS_SPECFILE_LOCATION = BASE_LOCATION + os.sep + "stats.spec"
SCHEMA_SPECFILE_LOCATION = BASE_LOCATION + os.sep + "stats-schema.spec"
XML_TEMPLATE_LOCATION = BASE_LOCATION + os.sep + "stats-httpd-xml.tpl"
XSD_TEMPLATE_LOCATION = BASE_LOCATION + os.sep + "stats-httpd-xsd.tpl"
XSL_TEMPLATE_LOCATION = BASE_LOCATION + os.sep + "stats-httpd-xsl.tpl"
......@@ -175,7 +175,7 @@ class StatsHttpd:
SPECFILE_LOCATION, self.config_handler, self.command_handler)
self.cc_session = self.mccs._session
# read spec file of stats module and subscribe 'Stats'
self.stats_module_spec = isc.config.module_spec_from_file(STATS_SPECFILE_LOCATION)
self.stats_module_spec = isc.config.module_spec_from_file(SCHEMA_SPECFILE_LOCATION)
self.stats_config_spec = self.stats_module_spec.get_config_spec()
self.stats_module_name = self.stats_module_spec.get_module_name()
......
......@@ -23,7 +23,11 @@ import unittest
import imp
from isc.cc.session import Session, SessionError
from isc.config.ccsession import ModuleCCSession, ModuleCCSessionError
from fake_time import time, strftime, gmtime
import stats
stats.time = time
stats.strftime = strftime
stats.gmtime = gmtime
from stats import SessionSubject, CCSessionListener, get_timestamp, get_datetime
from fake_time import _TEST_TIME_SECS, _TEST_TIME_STRF
......@@ -540,9 +544,14 @@ class TestStats2(unittest.TestCase):
os.environ["B10_FROM_SOURCE"] + os.sep + \
"src" + os.sep + "bin" + os.sep + "stats" + \
os.sep + "stats.spec")
self.assertEqual(stats.SCHEMA_SPECFILE_LOCATION,
os.environ["B10_FROM_SOURCE"] + os.sep + \
"src" + os.sep + "bin" + os.sep + "stats" + \
os.sep + "stats-schema.spec")
imp.reload(stats)
# change path of SPECFILE_LOCATION
stats.SPECFILE_LOCATION = TEST_SPECFILE_LOCATION
stats.SCHEMA_SPECFILE_LOCATION = TEST_SPECFILE_LOCATION
self.assertEqual(stats.SPECFILE_LOCATION, TEST_SPECFILE_LOCATION)
self.subject = stats.SessionSubject(session=self.session, verbose=True)
self.session = self.subject.session
......
......@@ -21,11 +21,12 @@ import os
import tempfile
from zonemgr import *
ZONE_NAME_CLASS1_IN = ("sd.cn.", "IN")
ZONE_NAME_CLASS2_CH = ("tw.cn.", "CH")
ZONE_NAME_CLASS3_IN = ("example.com", "IN")
ZONE_NAME_CLASS1_CH = ("sd.cn.", "CH")
ZONE_NAME_CLASS2_IN = ("tw.cn.", "IN")
ZONE_NAME_CLASS1_IN = ("example.net.", "IN")
ZONE_NAME_CLASS1_CH = ("example.net.", "CH")
ZONE_NAME_CLASS2_IN = ("example.org.", "IN")
ZONE_NAME_CLASS2_CH = ("example.org.", "CH")
ZONE_NAME_CLASS3_IN = ("example.com.", "IN")
ZONE_NAME_CLASS3_CH = ("example.com.", "CH")
MAX_TRANSFER_TIMEOUT = 14400
LOWERBOUND_REFRESH = 10
......@@ -80,12 +81,12 @@ class MyZonemgrRefresh(ZonemgrRefresh):
self._refresh_jitter = 0.25
def get_zone_soa(zone_name, db_file):
if zone_name == 'sd.cn.':
return (1, 2, 'sd.cn.', 'cn.sd.', 21600, 'SOA', None,
'a.dns.cn. root.cnnic.cn. 2009073106 7200 3600 2419200 21600')
elif zone_name == 'tw.cn.':
return (1, 2, 'tw.cn.', 'cn.sd.', 21600, 'SOA', None,
'a.dns.cn. root.cnnic.cn. 2009073112 7200 3600 2419200 21600')
if zone_name == 'example.net.':
return (1, 2, 'example.net.', 'example.net.sd.', 21600, 'SOA', None,
'a.example.net. root.example.net. 2009073106 7200 3600 2419200 21600')
elif zone_name == 'example.org.':
return (1, 2, 'example.org.', 'example.org.sd.', 21600, 'SOA', None,
'a.example.org. root.example.org. 2009073112 7200 3600 2419200 21600')
else:
return None
sqlite3_ds.get_zone_soa = get_zone_soa
......@@ -94,15 +95,15 @@ class MyZonemgrRefresh(ZonemgrRefresh):
self._slave_socket, FakeConfig())
current_time = time.time()
self._zonemgr_refresh_info = {
('sd.cn.', 'IN'): {
('example.net.', 'IN'): {
'last_refresh_time': current_time,
'next_refresh_time': current_time + 6500,
'zone_soa_rdata': 'a.dns.cn. root.cnnic.cn. 2009073105 7200 3600 2419200 21600',
'zone_soa_rdata': 'a.example.net. root.example.net. 2009073105 7200 3600 2419200 21600',
'zone_state': 0},
('tw.cn.', 'CH'): {
('example.org.', 'CH'): {
'last_refresh_time': current_time,
'next_refresh_time': current_time + 6900,
'zone_soa_rdata': 'a.dns.cn. root.cnnic.cn. 2009073112 7200 3600 2419200 21600',
'zone_soa_rdata': 'a.example.org. root.example.org. 2009073112 7200 3600 2419200 21600',
'zone_state': 0}
}
......@@ -157,6 +158,7 @@ class TestZonemgrRefresh(unittest.TestCase):
self.assertFalse(self.zone_refresh._zone_not_exist(ZONE_NAME_CLASS2_CH))
self.assertTrue(self.zone_refresh._zone_not_exist(ZONE_NAME_CLASS2_IN))
self.assertTrue(self.zone_refresh._zone_not_exist(ZONE_NAME_CLASS3_IN))
self.assertTrue(self.zone_refresh._zone_not_exist(ZONE_NAME_CLASS3_CH))
def test_set_zone_notify_timer(self):
time1 = time.time()
......@@ -179,20 +181,20 @@ class TestZonemgrRefresh(unittest.TestCase):
self.assertTrue(self.zone_refresh._zone_is_expired(ZONE_NAME_CLASS1_IN))
def test_get_zone_soa_rdata(self):
soa_rdata1 = 'a.dns.cn. root.cnnic.cn. 2009073105 7200 3600 2419200 21600'
soa_rdata2 = 'a.dns.cn. root.cnnic.cn. 2009073112 7200 3600 2419200 21600'
soa_rdata1 = 'a.example.net. root.example.net. 2009073105 7200 3600 2419200 21600'
soa_rdata2 = 'a.example.org. root.example.org. 2009073112 7200 3600 2419200 21600'
self.assertEqual(soa_rdata1, self.zone_refresh._get_zone_soa_rdata(ZONE_NAME_CLASS1_IN))
self.assertRaises(KeyError, self.zone_refresh._get_zone_soa_rdata, ZONE_NAME_CLASS1_CH)
self.assertEqual(soa_rdata2, self.zone_refresh._get_zone_soa_rdata(ZONE_NAME_CLASS2_CH))
self.assertRaises(KeyError, self.zone_refresh._get_zone_soa_rdata, ZONE_NAME_CLASS2_IN)
def test_zonemgr_reload_zone(self):
soa_rdata = 'a.dns.cn. root.cnnic.cn. 2009073106 1800 900 2419200 21600'
soa_rdata = 'a.example.net. root.example.net. 2009073106 1800 900 2419200 21600'
# We need to restore this not to harm other tests
old_get_zone_soa = sqlite3_ds.get_zone_soa
def get_zone_soa(zone_name, db_file):
return (1, 2, 'sd.cn.', 'cn.sd.', 21600, 'SOA', None,
'a.dns.cn. root.cnnic.cn. 2009073106 1800 900 2419200 21600')
return (1, 2, 'example.net.', 'example.net.sd.', 21600, 'SOA', None,
'a.example.net. root.example.net. 2009073106 1800 900 2419200 21600')
sqlite3_ds.get_zone_soa = get_zone_soa
self.zone_refresh.zonemgr_reload_zone(ZONE_NAME_CLASS1_IN)
......@@ -274,15 +276,15 @@ class TestZonemgrRefresh(unittest.TestCase):
self.assertTrue(self.zone_refresh._zone_mgr_is_empty())
def test_zonemgr_add_zone(self):
soa_rdata = 'a.dns.cn. root.cnnic.cn. 2009073106 1800 900 2419200 21600'
soa_rdata = 'a.example.net. root.example.net. 2009073106 1800 900 2419200 21600'
# This needs to be restored. The following test actually failed if we left
# this unclean
old_get_zone_soa = sqlite3_ds.get_zone_soa
time1 = time.time()
def get_zone_soa(zone_name, db_file):
return (1, 2, 'sd.cn.', 'cn.sd.', 21600, 'SOA', None,
'a.dns.cn. root.cnnic.cn. 2009073106 1800 900 2419200 21600')
return (1, 2, 'example.net.', 'example.net.sd.', 21600, 'SOA', None,
'a.example.net. root.example.net. 2009073106 1800 900 2419200 21600')
sqlite3_ds.get_zone_soa = get_zone_soa
......@@ -314,15 +316,15 @@ class TestZonemgrRefresh(unittest.TestCase):
current_time = time.time()
self.assertTrue(zone_timeout <= current_time)
self.assertRaises(ZonemgrException, self.zone_refresh.zone_handle_notify,\
("org.cn.", "IN"), "127.0.0.1")
ZONE_NAME_CLASS3_CH, "127.0.0.1")
self.assertRaises(ZonemgrException, self.zone_refresh.zone_handle_notify,\
ZONE_NAME_CLASS3_IN, "127.0.0.1")
def test_zone_refresh_success(self):
soa_rdata = 'a.dns.cn. root.cnnic.cn. 2009073106 1800 900 2419200 21600'
soa_rdata = 'a.example.net. root.example.net. 2009073106 1800 900 2419200 21600'
def get_zone_soa(zone_name, db_file):
return (1, 2, 'sd.cn.', 'cn.sd.', 21600, 'SOA', None,
'a.dns.cn. root.cnnic.cn. 2009073106 1800 900 2419200 21600')
return (1, 2, 'example.net.', 'example.net.sd.', 21600, 'SOA', None,
'a.example.net. root.example.net. 2009073106 1800 900 2419200 21600')
sqlite3_ds.get_zone_soa = get_zone_soa
time1 = time.time()
self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["zone_state"] = ZONE_REFRESHING
......@@ -337,11 +339,11 @@ class TestZonemgrRefresh(unittest.TestCase):
last_refresh_time = self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["last_refresh_time"]
self.assertTrue(time1 <= last_refresh_time)
self.assertTrue(last_refresh_time <= time2)
self.assertRaises(ZonemgrException, self.zone_refresh.zone_refresh_success, ("org.cn.", "CH"))
self.assertRaises(ZonemgrException, self.zone_refresh.zone_refresh_success, ("example.test.", "CH"))
self.assertRaises(ZonemgrException, self.zone_refresh.zone_refresh_success, ZONE_NAME_CLASS3_IN)
def test_zone_refresh_fail(self):
soa_rdata = 'a.dns.cn. root.cnnic.cn. 2009073105 7200 3600 2419200 21600'
soa_rdata = 'a.example.net. root.example.net. 2009073105 7200 3600 2419200 21600'
time1 = time.time()
self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["zone_state"] = ZONE_REFRESHING
self.zone_refresh.zone_refresh_fail(ZONE_NAME_CLASS1_IN)
......@@ -357,22 +359,22 @@ class TestZonemgrRefresh(unittest.TestCase):
self.zone_refresh.zone_refresh_fail(ZONE_NAME_CLASS1_IN)
self.assertEqual(ZONE_EXPIRED, self.zone_refresh._zonemgr_refresh_info[ZONE_NAME_CLASS1_IN]["zone_state"])
self.assertRaises(ZonemgrException, self.zone_refresh.zone_refresh_fail, ("org.cn.", "CH"))
self.assertRaises(ZonemgrException, self.zone_refresh.zone_refresh_fail, ZONE_NAME_CLASS3_CH)
self.assertRaises(ZonemgrException, self.zone_refresh.zone_refresh_fail, ZONE_NAME_CLASS3_IN)
def test_find_need_do_refresh_zone(self):
time1 = time.time()
self.zone_refresh._zonemgr_refresh_info = {
("sd.cn.","IN"):{
("example.net.","IN"):{
'last_refresh_time': time1,
'next_refresh_time': time1 + 7200,
'zone_soa_rdata': 'a.dns.cn. root.cnnic.cn. 2009073105 7200 3600 2419200 21600',
'zone_soa_rdata': 'a.example.net. root.example.net. 2009073105 7200 3600 2419200 21600',
'zone_state': ZONE_OK},
("tw.cn.","CH"):{
("example.org.","CH"):{
'last_refresh_time': time1 - 7200,
'next_refresh_time': time1,
'refresh_timeout': time1 + MAX_TRANSFER_TIMEOUT,
'zone_soa_rdata': 'a.dns.cn. root.cnnic.cn. 2009073112 7200 3600 2419200 21600',
'zone_soa_rdata': 'a.example.org. root.example.org. 2009073112 7200 3600 2419200 21600',
'zone_state': ZONE_REFRESHING}
}
zone_need_refresh = self.zone_refresh._find_need_do_refresh_zone()
......@@ -385,10 +387,10 @@ class TestZonemgrRefresh(unittest.TestCase):
def test_do_refresh(self):
time1 = time.time()
self.zone_refresh._zonemgr_refresh_info = {
("sd.cn.", "IN"):{
("example.net.", "IN"):{
'last_refresh_time': time1 - 7200,