BIND 10 trac2252, updated. 14ee53dc65a150d46f51e4cf6d666c38187ce075 [2252] add notes about counters of Xfrin: soaoutv4, axfrreqv4, soaoutv6, axfrreqv6, and xfrfail
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Mar 21 11:13:55 UTC 2013
The branch, trac2252 has been updated
via 14ee53dc65a150d46f51e4cf6d666c38187ce075 (commit)
via 9344c41c186e020cddf191880ff5bef4e653b461 (commit)
via b448dabbe9de31366ae5a20c0aae423f6257d953 (commit)
via c11f99307c27f07ad5b8ab9abb80f6ee5be32efc (commit)
via 0eec3b5ce47348b8fdf8eae9ffc61dcb4db0ccb0 (commit)
via c37fd56ccccd540bde166eb7f29c2c691bbff154 (commit)
via be426ec46dfd7aa3573872059ac9420dd4fd7d75 (commit)
via 208c318edbba5b98ebbd865f15c31bd77626328c (commit)
via bae4e4960422f2f86af1fc48d1f1d1a8f23a1b95 (commit)
via b0f2acac75969ee9773b3ec3eb584e017cbfb117 (commit)
via 5ac7de770cd112d0bc3842dd79c612bae3acc611 (commit)
via dc2960e9845fe08a27d49dcf9d6474ad8b825fb1 (commit)
via d1d37e198212833b5ca1e5c943f3f8aeef805a17 (commit)
via ad8e7ea08e814913ff6fadbf593a3fba44d4bbbc (commit)
via 26a9ee9fd3b8d2cf0c9643ac5441bcedfa3c2ab3 (commit)
from d6d04321180adf453ecb64c28e03b2c43591e521 (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 14ee53dc65a150d46f51e4cf6d666c38187ce075
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Thu Mar 21 18:47:25 2013 +0900
[2252] add notes about counters of Xfrin: soaoutv4, axfrreqv4, soaoutv6, axfrreqv6, and xfrfail
commit 9344c41c186e020cddf191880ff5bef4e653b461
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Thu Mar 21 18:35:07 2013 +0900
[2252] set the expected max value of rejection counters to 3
commit b448dabbe9de31366ae5a20c0aae423f6257d953
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Thu Mar 21 18:09:32 2013 +0900
[2252] update description of xfrin_notify_handling.feature
according to the actual tests running in this feature tests
commit c11f99307c27f07ad5b8ab9abb80f6ee5be32efc
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Thu Mar 21 18:04:04 2013 +0900
[2252] remove several initial checks for unixdomain socket counters of Xfrout
Because they are included in the previous initial statistics checks.
commit 0eec3b5ce47348b8fdf8eae9ffc61dcb4db0ccb0
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Thu Mar 21 15:35:19 2013 +0900
[2252] add a port number of cmdctl as an option of check_init_statistics()
commit c37fd56ccccd540bde166eb7f29c2c691bbff154
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Thu Mar 21 15:38:08 2013 +0900
[2252] generalize the module name as an argument of check_init_statistics()
not need to specify the category name with the module name
respectively, check all statistics items of the module from the top
level of the tree.
commit be426ec46dfd7aa3573872059ac9420dd4fd7d75
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Thu Mar 21 14:48:26 2013 +0900
[2252] update description of check_statistics_items() about min_value and max_value
commit 208c318edbba5b98ebbd865f15c31bd77626328c
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Thu Mar 21 13:26:21 2013 +0900
[2252] add tests dedicated to statistics
commit bae4e4960422f2f86af1fc48d1f1d1a8f23a1b95
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Mar 19 18:54:17 2013 +0900
[2252] remove checks of statistics counters from the existing test classes unrelated to statistics tests
commit b0f2acac75969ee9773b3ec3eb584e017cbfb117
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Mon Mar 18 20:37:13 2013 +0900
[2252] replace the log message XFRIN_RECEIVED_COMMAND to the more general id XFRIN_RECEIVED_COMMAND with the command name
commit 5ac7de770cd112d0bc3842dd79c612bae3acc611
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Mon Mar 18 20:01:01 2013 +0900
[2252] remove the if condition because we don't need to consider any other status than XFRIN_OK and XFRIN_FAIL
commit dc2960e9845fe08a27d49dcf9d6474ad8b825fb1
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Mon Mar 18 19:54:54 2013 +0900
[2252] add notes about the case that the timer is already started but not yet stopped
commit d1d37e198212833b5ca1e5c943f3f8aeef805a17
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Mon Mar 18 18:39:25 2013 +0900
[2252] _get_ipver_str() raises a ValueError exception on address families other than AF_INET or AF_INET6
commit ad8e7ea08e814913ff6fadbf593a3fba44d4bbbc
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Mon Mar 18 16:01:37 2013 +0900
[2252] update docstring of _get_ipver_str() about accessing
commit 26a9ee9fd3b8d2cf0c9643ac5441bcedfa3c2ab3
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Mon Mar 18 19:25:11 2013 +0900
[2252] update descriptions of latest_ixfr_duration and latest_axfr_duration about their default values
-----------------------------------------------------------------------
Summary of changes:
src/bin/xfrin/b10-xfrin.xml | 4 +-
src/bin/xfrin/tests/xfrin_test.py | 260 +++++++++++---------
src/bin/xfrin/xfrin.py.in | 28 ++-
src/bin/xfrin/xfrin.spec | 4 +-
src/bin/xfrin/xfrin_messages.mes | 5 +-
src/lib/python/isc/statistics/counters.py | 4 +-
.../isc/statistics/tests/testdata/test_spec3.spec | 4 +-
tests/lettuce/features/terrain/bind10_control.py | 38 +--
.../lettuce/features/xfrin_notify_handling.feature | 76 +++---
9 files changed, 232 insertions(+), 191 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/xfrin/b10-xfrin.xml b/src/bin/xfrin/b10-xfrin.xml
index ccec3f6..907c719 100644
--- a/src/bin/xfrin/b10-xfrin.xml
+++ b/src/bin/xfrin/b10-xfrin.xml
@@ -297,14 +297,14 @@ operation
<varlistentry>
<term>latest_ixfr_duration</term>
<listitem><simpara>
- Duration of the latest IXFR
+ Duration of the latest IXFR. 0.0 means no successful IXFR done.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term>latest_axfr_duration</term>
<listitem><simpara>
- Duration of the latest AXFR
+ Duration of the latest AXFR. 0.0 means no successful AXFR done.
</simpara></listitem>
</varlistentry>
diff --git a/src/bin/xfrin/tests/xfrin_test.py b/src/bin/xfrin/tests/xfrin_test.py
index 8ae7554..fd41fed 100644
--- a/src/bin/xfrin/tests/xfrin_test.py
+++ b/src/bin/xfrin/tests/xfrin_test.py
@@ -19,6 +19,7 @@ import shutil
import socket
import sys
import io
+from datetime import datetime
from isc.testutils.tsigctx_mock import MockTSIGContext
from isc.testutils.ccsession_mock import MockModuleCCSession
from isc.testutils.rrset_utils import *
@@ -855,8 +856,6 @@ class TestAXFR(TestXfrinConnection):
def tearDown(self):
time.time = self.orig_time_time
- # clear all statistics counters after each test
- self.conn._counters.clear_all()
super().tearDown()
def __create_mock_tsig(self, key, error, has_last_signature=True):
@@ -1077,25 +1076,17 @@ class TestAXFR(TestXfrinConnection):
c = MockXfrinConnection({}, TEST_ZONE_NAME, RRClass.CH, None,
threading.Event(), info)
c.init_socket()
- self.assertEqual(ver, c._get_ipver_str())
+ if ver:
+ self.assertEqual(ver, c._get_ipver_str())
+ else:
+ self.assertRaises(ValueError, c._get_ipver_str)
c.close()
def test_soacheck(self):
# we need to defer the creation until we know the QID, which is
# determined in _check_soa_serial(), so we use response_generator.
self.conn.response_generator = self._create_soa_response_data
- # check the statistics counters
- name2count = (('soaoutv4', 1),
- ('soaoutv6', 0))
- for (n, c) in name2count:
- self.assertRaises(isc.cc.data.DataNotFoundError,
- self.conn._counters.get, 'zones',
- TEST_ZONE_NAME_STR, n)
self.assertEqual(self.conn._check_soa_serial(), XFRIN_OK)
- for (n, c) in name2count:
- self.assertEqual(c, self.conn._counters.get('zones',
- TEST_ZONE_NAME_STR,
- n))
def test_soacheck_with_bad_response(self):
self.conn.response_generator = self._create_broken_response_data
@@ -1461,17 +1452,6 @@ class TestAXFR(TestXfrinConnection):
def test_do_xfrin(self):
self.conn.response_generator = self._create_normal_response_data
- # check the statistics counters
- name2count = (('axfrreqv4', 1),
- ('axfrreqv6', 0),
- ('ixfrreqv4', 0),
- ('ixfrreqv6', 0),
- ('xfrsuccess', 1),
- ('latest_axfr_duration', 0.0))
- for (n, c) in name2count:
- self.assertRaises(isc.cc.data.DataNotFoundError,
- self.conn._counters.get, 'zones',
- TEST_ZONE_NAME_STR, n)
self.assertEqual(self.conn.do_xfrin(False), XFRIN_OK)
self.assertFalse(self.conn._datasrc_client._journaling_enabled)
@@ -1482,19 +1462,6 @@ class TestAXFR(TestXfrinConnection):
self.assertEqual(0, self.conn._transfer_stats.ixfr_addition_count)
self.assertEqual(177, self.conn._transfer_stats.byte_count)
self.assertGreater(self.conn._transfer_stats.get_running_time(), 0)
- for (n, c) in name2count:
- if n == 'latest_axfr_duration':
- self.assertGreaterEqual(
- self.conn._counters.get('zones',
- TEST_ZONE_NAME_STR,
- n),
- c)
- else:
- self.assertEqual(
- c,
- self.conn._counters.get('zones',
- TEST_ZONE_NAME_STR,
- n))
def test_do_xfrin_with_tsig(self):
# use TSIG with a mock context. we fake all verify results to
@@ -1516,15 +1483,8 @@ class TestAXFR(TestXfrinConnection):
self.conn._tsig_ctx_creator = \
lambda key: self.__create_mock_tsig(key, TSIGError.BAD_SIG)
self.conn.response_generator = self._create_normal_response_data
- # check the statistics counters
- self.assertRaises(isc.cc.data.DataNotFoundError,
- self.conn._counters.get, 'zones',
- TEST_ZONE_NAME_STR, 'xfrfail')
self.assertEqual(self.conn.do_xfrin(False), XFRIN_FAIL)
self.assertEqual(1, self.conn._tsig_ctx.verify_called)
- self.assertEqual(1, self.conn._counters.get('zones',
- TEST_ZONE_NAME_STR,
- 'xfrfail'))
def test_do_xfrin_without_last_tsig(self):
# TSIG verify will succeed, but it will pretend the last message is
@@ -1663,75 +1623,6 @@ class TestAXFR(TestXfrinConnection):
self.conn.response_generator = self._create_soa_response_data
self.assertEqual(self.conn.do_xfrin(True), XFRIN_FAIL)
-class TestXfrinConnectionV6(TestXfrinConnection):
- '''Test of TestXfrinConnection for IPv6'''
- master_addrinfo = TEST_MASTER_IPV6_ADDRINFO
-
-class TestAXFRV6(TestXfrinConnectionV6):
- def setUp(self):
- super().setUp()
- XfrinInitialSOA().set_xfrstate(self.conn, XfrinInitialSOA())
-
- def tearDown(self):
- # clear all statistics counters after each test
- self.conn._counters.clear_all()
- super().tearDown()
-
- def test_soacheck(self):
- # we need to defer the creation until we know the QID, which is
- # determined in _check_soa_serial(), so we use response_generator.
- self.conn.response_generator = self._create_soa_response_data
- # check the statistics counters
- name2count = (('soaoutv4', 0),
- ('soaoutv6', 1))
- for (n, c) in name2count:
- self.assertRaises(isc.cc.data.DataNotFoundError,
- self.conn._counters.get, 'zones',
- TEST_ZONE_NAME_STR, n)
- self.assertEqual(self.conn._check_soa_serial(), XFRIN_OK)
- for (n, c) in name2count:
- self.assertEqual(c, self.conn._counters.get('zones',
- TEST_ZONE_NAME_STR,
- n))
-
- def test_do_xfrin(self):
- self.conn.response_generator = self._create_normal_response_data
- # check the statistics counters
- name2count = (('axfrreqv4', 0),
- ('axfrreqv6', 1),
- ('ixfrreqv4', 0),
- ('ixfrreqv6', 0),
- ('xfrsuccess', 1),
- ('latest_axfr_duration', 0.0))
- for (n, c) in name2count:
- self.assertRaises(isc.cc.data.DataNotFoundError,
- self.conn._counters.get, 'zones',
- TEST_ZONE_NAME_STR, n)
- self.assertEqual(self.conn.do_xfrin(False), XFRIN_OK)
- self.assertFalse(self.conn._datasrc_client._journaling_enabled)
-
- self.assertEqual(2, self.conn._transfer_stats.message_count)
- self.assertEqual(2, self.conn._transfer_stats.axfr_rr_count)
- self.assertEqual(0, self.conn._transfer_stats.ixfr_changeset_count)
- self.assertEqual(0, self.conn._transfer_stats.ixfr_deletion_count)
- self.assertEqual(0, self.conn._transfer_stats.ixfr_addition_count)
- self.assertEqual(177, self.conn._transfer_stats.byte_count)
- self.assertGreater(self.conn._transfer_stats.get_running_time(), 0)
- for (n, c) in name2count:
- if n == 'latest_axfr_duration':
- self.assertAlmostEqual(
- c,
- self.conn._counters.get('zones',
- TEST_ZONE_NAME_STR,
- n),
- delta=1.0)
- else:
- self.assertEqual(
- c,
- self.conn._counters.get('zones',
- TEST_ZONE_NAME_STR,
- n))
-
class TestIXFRResponse(TestXfrinConnection):
def setUp(self):
# replace time.time with a steadily increasing fake one
@@ -2230,6 +2121,147 @@ class TestXFRSessionWithSQLite3(TestXfrinConnection):
self.assertFalse(self.record_exist(Name('dns01.example.com'),
RRType.A))
+class TestStatisticsXfrinConn(TestXfrinConnection):
+ '''Test class based on TestXfrinConnection and including paramters
+ and methods related to statistics tests'''
+ # List of statistics counter names and expected initial values
+ name_to_counter = (('axfrreqv4', 0),
+ ('axfrreqv6', 0),
+ ('ixfrreqv4', 0),
+ ('ixfrreqv6', 0),
+ ('latest_axfr_duration', 0.0),
+ ('latest_ixfr_duration', 0.0),
+ ('soaoutv4', 0),
+ ('soaoutv6', 0),
+ ('xfrfail', 0),
+ ('xfrsuccess', 0))
+ zones = 'zones'
+ def setUp(self):
+ super().setUp()
+ # clear all statistics counters before each test
+ self.conn._counters.clear_all()
+
+ def _set_start_time(self):
+ """sets _start_time to datetime of current time"""
+ self._start_time = datetime.now()
+
+ def _get_dur_time(self):
+ """Returns duration time between _start_time and current. A
+ returned value is float type as second. It is rounded at six
+ decimal places. After all it deletes _start_time."""
+ delta = datetime.now() - self._start_time
+ ret = round(delta.days * 86400 + delta.seconds + \
+ delta.microseconds * 1E-6, 6)
+ del self._start_time
+ return ret
+
+ def _check_init_statistics(self):
+ '''checks exception being raised if not incremented statistics
+ counter gotten'''
+ for (name, exp) in self.name_to_counter:
+ self.assertRaises(isc.cc.data.DataNotFoundError,
+ self.conn._counters.get, self.zones,
+ TEST_ZONE_NAME_STR, name)
+
+ def _check_updated_statistics(self, overwrite):
+ '''checks getting expect values after updating the pairs of
+ statistics counter name and value on to the "overwrite"
+ dictionary'''
+ name2count = dict(self.name_to_counter)
+ name2count.update(overwrite)
+ for (name, exp) in name2count.items():
+ act = self.conn._counters.get(self.zones,
+ TEST_ZONE_NAME_STR,
+ name)
+ msg = '%s is expected %s but actually %s' \
+ % (name, exp, act)
+ if name == 'latest_axfr_duration' \
+ or name == 'latest_ixfr_duration':
+ # compare at 3 decimal places
+ self.assertAlmostEqual(exp, act, places=3, msg=msg)
+ else:
+ self.assertEqual(exp, act, msg=msg)
+
+class TestStatisticsXfrinAXFRv4(TestStatisticsXfrinConn):
+ '''Xfrin AXFR tests for IPv4 to check statistics counters'''
+ ipver = 'v4'
+ def test_soacheck(self):
+ self.conn.response_generator = self._create_soa_response_data
+ self._check_init_statistics()
+ self.assertEqual(self.conn._check_soa_serial(), XFRIN_OK)
+ self._check_updated_statistics({'soaout' + self.ipver: 1})
+
+ def test_do_xfrin(self):
+ self.conn.response_generator = self._create_normal_response_data
+ self._check_init_statistics()
+ self._set_start_time()
+ self.assertEqual(self.conn.do_xfrin(False), XFRIN_OK)
+ self._check_updated_statistics({'axfrreq' + self.ipver: 1,
+ 'xfrsuccess': 1,
+ 'latest_axfr_duration': \
+ self._get_dur_time()})
+
+ def test_do_soacheck_uptodate(self):
+ self.soa_response_params['answers'] = [begin_soa_rrset]
+ self.conn.response_generator = self._create_soa_response_data
+ self._check_init_statistics()
+ self.assertEqual(self.conn.do_xfrin(True), XFRIN_OK)
+ self._check_updated_statistics({'soaout' + self.ipver: 1,
+ 'xfrsuccess': 1})
+
+class TestStatisticsXfrinIXFRv4(TestStatisticsXfrinConn):
+ '''Xfrin IXFR tests for IPv4 to check statistics counters'''
+ ipver = 'v4'
+ def test_do_xfrin(self):
+ def create_ixfr_response():
+ self.conn.reply_data = self.conn.create_response_data(
+ questions=[Question(TEST_ZONE_NAME, TEST_RRCLASS,
+ RRType.IXFR)],
+ answers=[soa_rrset, begin_soa_rrset, soa_rrset, soa_rrset])
+ self.conn.response_generator = create_ixfr_response
+ self._check_init_statistics()
+ self._set_start_time()
+ self.assertEqual(XFRIN_OK, self.conn.do_xfrin(False, RRType.IXFR))
+ self._check_updated_statistics({'ixfrreq' + self.ipver: 1,
+ 'xfrsuccess': 1,
+ 'latest_ixfr_duration': \
+ self._get_dur_time()})
+
+ def test_do_xfrin_fail(self):
+ def create_ixfr_response():
+ self.conn.reply_data = self.conn.create_response_data(
+ questions=[Question(TEST_ZONE_NAME, TEST_RRCLASS,
+ RRType.IXFR)],
+ answers=[soa_rrset, begin_soa_rrset, soa_rrset,
+ self._create_soa('1235')])
+ self.conn.response_generator = create_ixfr_response
+ self._check_init_statistics()
+ self.assertEqual(XFRIN_FAIL, self.conn.do_xfrin(False, RRType.IXFR))
+ self._check_updated_statistics({'ixfrreq' + self.ipver: 1,
+ 'xfrfail': 1})
+
+ def test_do_xfrin_uptodate(self):
+ def create_response():
+ self.conn.reply_data = self.conn.create_response_data(
+ questions=[Question(TEST_ZONE_NAME, TEST_RRCLASS,
+ RRType.IXFR)],
+ answers=[begin_soa_rrset])
+ self.conn.response_generator = create_response
+ self._check_init_statistics()
+ self.assertEqual(XFRIN_OK, self.conn.do_xfrin(False, RRType.IXFR))
+ self._check_updated_statistics({'ixfrreq' + self.ipver: 1,
+ 'xfrsuccess': 1})
+
+class TestStatisticsXfrinAXFRv6(TestStatisticsXfrinAXFRv4):
+ '''Same tests as TestStatisticsXfrinAXFRv4 for IPv6'''
+ master_addrinfo = TEST_MASTER_IPV6_ADDRINFO
+ ipver = 'v6'
+
+class TestStatisticsIXFRv6(TestStatisticsXfrinIXFRv4):
+ '''Same tests as TestStatisticsXfrinIXFRv4 for IPv6'''
+ master_addrinfo = TEST_MASTER_IPV6_ADDRINFO
+ ipver = 'v6'
+
class TestXfrinRecorder(unittest.TestCase):
def setUp(self):
self.recorder = XfrinRecorder()
diff --git a/src/bin/xfrin/xfrin.py.in b/src/bin/xfrin/xfrin.py.in
index 9dfcb5d..a4e84dd 100755
--- a/src/bin/xfrin/xfrin.py.in
+++ b/src/bin/xfrin/xfrin.py.in
@@ -895,11 +895,14 @@ class XfrinConnection(asyncore.dispatcher):
def _get_ipver_str(self):
"""Returns a 'v4' or 'v6' string representing a IP version
- depending on the socket family"""
+ depending on the socket family. This is for an internal use
+ only. This is supported only for IP sockets. It raises a
+ ValueError exception on other address families."""
if self.socket.family == socket.AF_INET:
return 'v4'
elif self.socket.family == socket.AF_INET6:
return 'v6'
+ raise ValueError("Invalid address family. This is supported only for IP sockets")
def _check_soa_serial(self):
'''Send SOA query and compare the local and remote serials.
@@ -912,9 +915,8 @@ class XfrinConnection(asyncore.dispatcher):
self._send_query(RRType.SOA)
# count soaoutv4 or soaoutv6 requests
- if self._get_ipver_str():
- self._counters.inc('zones', self._zone_name.to_text(),
- 'soaout' + self._get_ipver_str())
+ self._counters.inc('zones', self._zone_name.to_text(),
+ 'soaout' + self._get_ipver_str())
data_len = self._get_request_response(2)
msg_len = socket.htons(struct.unpack('H', data_len)[0])
soa_response = self._get_request_response(msg_len)
@@ -953,15 +955,17 @@ class XfrinConnection(asyncore.dispatcher):
raise XfrinException('Unable to reconnect to master')
# start statistics timer
+ # Note: If the timer for the zone is already started but
+ # not yet stopped due to some error, the last start time
+ # is overwritten at this point.
self._counters.start_timer('zones', self._zone_name.to_text(),
'latest_' + req_str.lower() + '_duration')
logger.info(XFRIN_XFR_TRANSFER_STARTED, req_str, self.zone_str())
self._send_query(self._request_type)
# count AXFR/IXFR requests for statistics
- if self._get_ipver_str():
- self._counters.inc('zones', self._zone_name.to_text(),
- req_str.lower() + 'req' +
- self._get_ipver_str())
+ self._counters.inc('zones', self._zone_name.to_text(),
+ req_str.lower() + 'req' +
+ self._get_ipver_str())
self.__state = XfrinInitialSOA()
self._handle_xfrin_responses()
# Depending what data was found, we log different status reports
@@ -1031,9 +1035,8 @@ class XfrinConnection(asyncore.dispatcher):
# as possible
self._diff = None
counter_dict = {XFRIN_OK: 'xfrsuccess', XFRIN_FAIL: 'xfrfail'}
- if ret in counter_dict:
- self._counters.inc('zones', self._zone_name.to_text(),
- counter_dict[ret])
+ self._counters.inc('zones', self._zone_name.to_text(),
+ counter_dict[ret])
return ret
@@ -1511,6 +1514,7 @@ class Xfrin:
th.join()
def command_handler(self, command, args):
+ logger.debug(DBG_XFRIN_TRACE, XFRIN_RECEIVED_COMMAND, command)
answer = create_answer(0)
try:
if command == 'shutdown':
@@ -1586,8 +1590,6 @@ class Xfrin:
# b10-stats daemon is periodically asking to the
# b10-xfrin daemon.
answer = create_answer(0, self._counters.get_statistics())
- logger.debug(DBG_XFRIN_TRACE, XFRIN_RECEIVED_GETSTATS_COMMAND,
- str(answer))
else:
answer = create_answer(1, 'unknown command: ' + command)
diff --git a/src/bin/xfrin/xfrin.spec b/src/bin/xfrin/xfrin.spec
index 00c519b..6071ada 100644
--- a/src/bin/xfrin/xfrin.spec
+++ b/src/bin/xfrin/xfrin.spec
@@ -194,7 +194,7 @@
"item_optional": false,
"item_default": 0.0,
"item_title": "Latest IXFR duration",
- "item_description": "Duration of the latest IXFR"
+ "item_description": "Duration of the latest IXFR. 0.0 means no successful IXFR done."
},
{
"item_name": "latest_axfr_duration",
@@ -202,7 +202,7 @@
"item_optional": false,
"item_default": 0.0,
"item_title": "Latest AXFR duration",
- "item_description": "Duration of the latest AXFR"
+ "item_description": "Duration of the latest AXFR. 0.0 means no successful AXFR done."
}
]
}
diff --git a/src/bin/xfrin/xfrin_messages.mes b/src/bin/xfrin/xfrin_messages.mes
index 6f9d970..7160d17 100644
--- a/src/bin/xfrin/xfrin_messages.mes
+++ b/src/bin/xfrin/xfrin_messages.mes
@@ -275,6 +275,5 @@ there's some issue with it. It might be correct, but it should be checked
and possibly fixed on the remote server. The problem is described in the
message. The problem does not stop the zone from being used.
-% XFRIN_RECEIVED_GETSTATS_COMMAND received command to send statistics data: %1
-The xfrin daemon received a command on the command channel that
-statistics data should be sent to the stats daemon.
+% XFRIN_RECEIVED_COMMAND received command: %1
+The xfrin daemon received a command on the command channel.
diff --git a/src/lib/python/isc/statistics/counters.py b/src/lib/python/isc/statistics/counters.py
index c8a1474..a459573 100644
--- a/src/lib/python/isc/statistics/counters.py
+++ b/src/lib/python/isc/statistics/counters.py
@@ -327,7 +327,9 @@ class Counters():
def start_timer(self, *args):
"""Starts a timer which is identified by args and keeps it
running until stop_timer() is called. It acquires a lock to
- support multi-threaded use."""
+ support multi-threaded use. If the specified timer is already
+ started but not yet started, the last start time is
+ overwritten."""
identifier = _concat(*args)
with self._rlock:
if self._disabled: return
diff --git a/src/lib/python/isc/statistics/tests/testdata/test_spec3.spec b/src/lib/python/isc/statistics/tests/testdata/test_spec3.spec
index da01c4f..30f6b2f 100644
--- a/src/lib/python/isc/statistics/tests/testdata/test_spec3.spec
+++ b/src/lib/python/isc/statistics/tests/testdata/test_spec3.spec
@@ -103,7 +103,7 @@
"item_optional": false,
"item_default": 0.0,
"item_title": "Latest IXFR duration",
- "item_description": "Duration of the latest IXFR"
+ "item_description": "Duration of the latest IXFR. 0.0 means no successful IXFR done."
},
{
"item_name": "latest_axfr_duration",
@@ -111,7 +111,7 @@
"item_optional": false,
"item_default": 0.0,
"item_title": "Latest AXFR duration",
- "item_description": "Duration of the latest AXFR"
+ "item_description": "Duration of the latest AXFR. 0.0 means no successful AXFR done."
}
]
}
diff --git a/tests/lettuce/features/terrain/bind10_control.py b/tests/lettuce/features/terrain/bind10_control.py
index 596a406..5c22384 100644
--- a/tests/lettuce/features/terrain/bind10_control.py
+++ b/tests/lettuce/features/terrain/bind10_control.py
@@ -390,9 +390,14 @@ def check_statistics_items(step, category, has_except_for):
with the multiline part.
Expected values of items are taken from the multiline part of the step in
- the scenario. The multiline part has two columns: item_name and item_value.
- item_name is a relative name to category. item_value is an expected value
- for item_name.
+ the scenario. The multiline part has at most 5 columns: item_name,
+ item_value, min_value, and max_value. item_name is a relative name
+ to category. item_value is an expected value for
+ item_name. min_value and max_value are expected to be used when
+ item_value cannot be specified to be item_value. min_value is the
+ minimum value in the expected range, and max_value is the maximum
+ value in the expected range. Values would be examined if they are
+ in columns corresponding to these.
"""
def flatten(dictionary, prefix=''):
@@ -433,24 +438,21 @@ def check_statistics_items(step, category, has_except_for):
'Statistics item %s has unexpected value %s (expect %s)' % \
(name, found, 0)
- at step('check initial statistics for (Xfrin|Xfrout)')
-def check_init_statistics(step, module):
+ at step('check initial statistics for (\S+)( with cmdctl port \d+)?')
+def check_init_statistics(step, name, cmdctl_port):
"""
- check the initial statistics for Xfrin or Xfrout.
+ check the initial statistics for the module
Parameters:
- module : Xfrin or Xfrout
+ name ('module <name>'): The name of the module (case sensitive!)
+ cmdctl_port ('with cmdctl port <portnr>', optional): cmdctl port to send
+ the command to.
"""
- query_str = 'When I query statistics %%s of bind10 module %s with cmdctl' % module
+ query_str = 'query statistics of bind10 module ' + name
+ if cmdctl_port:
+ query_str = query_str + cmdctl_port
notcontain_str = 'last bindctl output should not contain "%s"'
- check_str = 'The statistics counters are 0 in category .%s%%s' % module
- if module == 'Xfrout':
- query_str = query_str + ' port 47804'
- step.given(query_str % 'zones')
+ check_str = 'statistics counters are 0 in category .' + name
+ step.given(query_str)
step.given(notcontain_str % 'error')
step.given(notcontain_str % 'example.org.')
- step.given(check_str % '.zones._SERVER_')
- if module == 'Xfrout':
- step.given(query_str % 'ixfr_running')
- step.given(check_str)
- step.given(query_str % 'axfr_running')
- step.given(check_str)
+ step.given(check_str)
diff --git a/tests/lettuce/features/xfrin_notify_handling.feature b/tests/lettuce/features/xfrin_notify_handling.feature
index a411a6f..e41aa05 100644
--- a/tests/lettuce/features/xfrin_notify_handling.feature
+++ b/tests/lettuce/features/xfrin_notify_handling.feature
@@ -1,5 +1,10 @@
Feature: Xfrin incoming notify handling
- Tests for Xfrin incoming notify handling.
+ Tests for Xfrin incoming notify handling. They also test
+ statistics counters incremented, which are related to notifying
+ and transferring by Xfrout and receiveing by Xfrin. Some cases are
+ considered: Transferring is done via IPv4 or IPv6 transport. A
+ transfer request from Xfrin is rejected by Xfrout. The master
+ server or slave server is unreachable.
Scenario: Handle incoming notify
Given I have bind10 running with configuration xfrin/retransfer_master.conf with cmdctl port 47804 as master
@@ -22,16 +27,13 @@ Feature: Xfrin incoming notify handling
#
# Test1 for Xfrout statistics
#
- check initial statistics for Xfrout
- When I query statistics socket of bind10 module Xfrout with cmdctl port 47804
- The statistics counters are 0 in category .Xfrout.socket.unixdomain except for the following items
- | item_name | min_value | max_value |
- | open | 0 | 1 |
+ check initial statistics for Xfrout with cmdctl port 47804
#
# Test2 for Xfrin statistics
#
check initial statistics for Xfrin
+
When I send bind10 with cmdctl port 47804 the command Xfrout notify example.org IN
Then wait for new master stderr message XFROUT_NOTIFY_COMMAND
Then wait for new bind10 stderr message AUTH_RECEIVED_NOTIFY
@@ -79,7 +81,7 @@ Feature: Xfrin incoming notify handling
# wait until the last stats requesting is finished
When I query statistics zones of bind10 module Xfrin with cmdctl
wait for new bind10 stderr message STATS_SEND_STATISTICS_REQUEST
- wait for new bind10 stderr message XFRIN_RECEIVED_GETSTATS_COMMAND
+ wait for new bind10 stderr message XFRIN_RECEIVED_COMMAND
last bindctl output should not contain "error"
When I query statistics zones of bind10 module Xfrin with cmdctl
@@ -118,16 +120,12 @@ Feature: Xfrin incoming notify handling
#
# Test1 for Xfrout statistics
#
- check initial statistics for Xfrout
- When I query statistics socket of bind10 module Xfrout with cmdctl port 47804
- The statistics counters are 0 in category .Xfrout.socket.unixdomain except for the following items
- | item_name | min_value | max_value |
- | open | 0 | 1 |
-
+ check initial statistics for Xfrout with cmdctl port 47804
#
# Test2 for Xfrin statistics
#
check initial statistics for Xfrin
+
When I send bind10 with cmdctl port 47804 the command Xfrout notify example.org IN
Then wait for new master stderr message XFROUT_NOTIFY_COMMAND
Then wait for new bind10 stderr message AUTH_RECEIVED_NOTIFY
@@ -175,7 +173,7 @@ Feature: Xfrin incoming notify handling
# wait until the last stats requesting is finished
When I query statistics zones of bind10 module Xfrin with cmdctl
wait for new bind10 stderr message STATS_SEND_STATISTICS_REQUEST
- wait for new bind10 stderr message XFRIN_RECEIVED_GETSTATS_COMMAND
+ wait for new bind10 stderr message XFRIN_RECEIVED_COMMAND
last bindctl output should not contain "error"
When I query statistics zones of bind10 module Xfrin with cmdctl
@@ -214,16 +212,13 @@ Feature: Xfrin incoming notify handling
#
# Test1 for Xfrout statistics
#
- check initial statistics for Xfrout
- When I query statistics socket of bind10 module Xfrout with cmdctl port 47804
- The statistics counters are 0 in category .Xfrout.socket.unixdomain except for the following items
- | item_name | min_value | max_value |
- | open | 0 | 1 |
+ check initial statistics for Xfrout with cmdctl port 47804
#
# Test2 for Xfrin statistics
#
check initial statistics for Xfrin
+
#
# set transfer_acl rejection
# Local xfr requests from Xfrin module would be rejected here.
@@ -261,11 +256,14 @@ Feature: Xfrin incoming notify handling
When I query statistics zones of bind10 module Xfrout with cmdctl port 47804
The statistics counters are 0 in category .Xfrout.zones except for the following items
- | item_name | item_value | min_value |
- | _SERVER_.notifyoutv6 | 5 | |
- | _SERVER_.xfrrej | | 1 |
- | example.org..notifyoutv6 | 5 | |
- | example.org..xfrrej | | 1 |
+ | item_name | item_value | min_value | max_value |
+ | _SERVER_.notifyoutv6 | 5 | | |
+ | _SERVER_.xfrrej | | 1 | 3 |
+ | example.org..notifyoutv6 | 5 | | |
+ | example.org..xfrrej | | 1 | 3 |
+ # Note: The above rejection counters might sometimes be increased
+ # up to 3. See this for details
+ # http://git.bind10.isc.org/~tester/builder/BIND10-lettuce/20120918210000-MacOS/logs/lettuce.out
When I query statistics socket of bind10 module Xfrout with cmdctl port 47804
The statistics counters are 0 in category .Xfrout.socket.unixdomain except for the following items
@@ -282,7 +280,7 @@ Feature: Xfrin incoming notify handling
# wait until the last stats requesting is finished
When I query statistics zones of bind10 module Xfrin with cmdctl
wait for new bind10 stderr message STATS_SEND_STATISTICS_REQUEST
- wait for new bind10 stderr message XFRIN_RECEIVED_GETSTATS_COMMAND
+ wait for new bind10 stderr message XFRIN_RECEIVED_COMMAND
last bindctl output should not contain "error"
When I query statistics zones of bind10 module Xfrin with cmdctl
@@ -294,6 +292,9 @@ Feature: Xfrin incoming notify handling
| example.org..soaoutv6 | 1 | 3 |
| example.org..axfrreqv6 | 1 | 3 |
| example.org..xfrfail | 1 | 3 |
+ # Note: The above requests and failures would be done several
+ # times depending on timing or environment. We expect here that
+ # they would be 1 to 3.
#
# Test for Xfr request rejected in IPv4
@@ -319,16 +320,13 @@ Feature: Xfrin incoming notify handling
#
# Test1 for Xfrout statistics
#
- check initial statistics for Xfrout
- When I query statistics socket of bind10 module Xfrout with cmdctl port 47804
- The statistics counters are 0 in category .Xfrout.socket.unixdomain except for the following items
- | item_name | min_value | max_value |
- | open | 0 | 1 |
+ check initial statistics for Xfrout with cmdctl port 47804
#
# Test2 for Xfrin statistics
#
check initial statistics for Xfrin
+
#
# set transfer_acl rejection
# Local xfr requests from Xfrin module would be rejected here.
@@ -366,11 +364,14 @@ Feature: Xfrin incoming notify handling
When I query statistics zones of bind10 module Xfrout with cmdctl port 47804
The statistics counters are 0 in category .Xfrout.zones except for the following items
- | item_name | item_value | min_value |
- | _SERVER_.notifyoutv4 | 5 | |
- | _SERVER_.xfrrej | | 1 |
- | example.org..notifyoutv4 | 5 | |
- | example.org..xfrrej | | 1 |
+ | item_name | item_value | min_value | max_value |
+ | _SERVER_.notifyoutv4 | 5 | | |
+ | _SERVER_.xfrrej | | 1 | 3 |
+ | example.org..notifyoutv4 | 5 | | |
+ | example.org..xfrrej | | 1 | 3 |
+ # Note: The above rejection counters might sometimes be increased
+ # up to 3. See this for details
+ # http://git.bind10.isc.org/~tester/builder/BIND10-lettuce/20120918210000-MacOS/logs/lettuce.out
When I query statistics socket of bind10 module Xfrout with cmdctl port 47804
The statistics counters are 0 in category .Xfrout.socket.unixdomain except for the following items
@@ -387,7 +388,7 @@ Feature: Xfrin incoming notify handling
# wait until the last stats requesting is finished
When I query statistics zones of bind10 module Xfrin with cmdctl
wait for new bind10 stderr message STATS_SEND_STATISTICS_REQUEST
- wait for new bind10 stderr message XFRIN_RECEIVED_GETSTATS_COMMAND
+ wait for new bind10 stderr message XFRIN_RECEIVED_COMMAND
last bindctl output should not contain "error"
When I query statistics zones of bind10 module Xfrin with cmdctl
@@ -399,6 +400,9 @@ Feature: Xfrin incoming notify handling
| example.org..soaoutv4 | 1 | 3 |
| example.org..axfrreqv4 | 1 | 3 |
| example.org..xfrfail | 1 | 3 |
+ # Note: The above requests and failures would be done several
+ # times depending on timing or environment. We expect here that
+ # they would be 1 to 3.
#
# Test for unreachable slave
More information about the bind10-changes
mailing list