BIND 10 trac2222, updated. 48df8a1486f00e27636febfa3487ddab9a051ca6 [2222] changed the misleading method name

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Sep 24 05:45:01 UTC 2012


The branch, trac2222 has been updated
       via  48df8a1486f00e27636febfa3487ddab9a051ca6 (commit)
       via  668cdb357976bea8bc0b775459324b68dd2906b9 (commit)
       via  179247735be1594337d07f0761b5fa8af2f44dc2 (commit)
       via  af6832161c3fc10de0239da3ddb47e7261413615 (commit)
       via  704457924e2a892e012b7c750bfe08fe56da7128 (commit)
       via  2fee008d989b5c60c13dbe86729e8a1ee8ac6456 (commit)
       via  396bb7832e661dc597853e9f062e7094a209baf0 (commit)
      from  9a655fdd02d00a22003c6f7c9902ef80072a2332 (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 48df8a1486f00e27636febfa3487ddab9a051ca6
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Mon Sep 24 13:41:50 2012 +0900

    [2222] changed the misleading method name

commit 668cdb357976bea8bc0b775459324b68dd2906b9
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Mon Sep 24 13:32:15 2012 +0900

    [2222] updated the comment to be detailed

commit 179247735be1594337d07f0761b5fa8af2f44dc2
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Mon Sep 24 13:24:18 2012 +0900

    [2222] changed to check the counter exactly incremented to one

commit af6832161c3fc10de0239da3ddb47e7261413615
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Mon Sep 24 13:22:07 2012 +0900

    [2222] removed checking self._counter_xfrrej isn't `None`
    
    Because self._counter_xfrrej is no longer assigned to `None` as a
    default in the constructor.

commit 704457924e2a892e012b7c750bfe08fe56da7128
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Mon Sep 24 14:03:44 2012 +0900

    [2222] corrected the comment according to what the code does

commit 2fee008d989b5c60c13dbe86729e8a1ee8ac6456
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Mon Sep 24 11:46:27 2012 +0900

    [2222] expanded the lambda statement to the normal method definition

commit 396bb7832e661dc597853e9f062e7094a209baf0
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Mon Sep 24 11:43:12 2012 +0900

    [2222] simplified complicated assignment of `incrementer`

-----------------------------------------------------------------------

Summary of changes:
 src/bin/xfrout/tests/xfrout_test.py.in             |   47 +++++++++++++-------
 src/bin/xfrout/xfrout.py.in                        |   15 +++----
 .../lettuce/features/xfrin_notify_handling.feature |    7 ++-
 3 files changed, 45 insertions(+), 24 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/xfrout/tests/xfrout_test.py.in b/src/bin/xfrout/tests/xfrout_test.py.in
index c519b90..6e3f4a8 100644
--- a/src/bin/xfrout/tests/xfrout_test.py.in
+++ b/src/bin/xfrout/tests/xfrout_test.py.in
@@ -320,10 +320,13 @@ class TestXfroutSessionBase(unittest.TestCase):
             'inc_axfr_running': _inc_axfr_running,
             'dec_axfr_running': _dec_axfr_running
             }
-        self.get_counter = lambda n: \
-            self._statistics_data[n] \
-            if n.find('ixfr_') == 0 or n.find('axfr_') == 0 \
-            else self._statistics_data['zones'][TEST_ZONE_NAME_STR][n]
+
+    def get_counter(self, name):
+        if name.find('ixfr_') == 0 or name.find('axfr_') == 0:
+            return self._statistics_data[name]
+        else:
+            return \
+                self._statistics_data['zones'][TEST_ZONE_NAME_STR][name]
 
     def tearDown(self):
         xfrout.get_rrset_len = self.orig_get_rrset_len
@@ -416,6 +419,8 @@ class TestXfroutSession(TestXfroutSessionBase):
                 "action": "DROP"
             }
         ]))
+        # check the 'xfrrej' counter initially
+        self.assertEqual(self.get_counter('xfrrej'), 0)
         # Localhost (the default in this test) is accepted
         rcode, msg = self.xfrsess._parse_query_message(self.mdata)
         self.assertEqual(rcode.to_text(), "NOERROR")
@@ -429,6 +434,8 @@ class TestXfroutSession(TestXfroutSessionBase):
                                 ('192.0.2.2', 12345))
         rcode, msg = self.xfrsess._parse_query_message(self.mdata)
         self.assertEqual(rcode.to_text(), "REFUSED")
+        # check the 'xfrrej' counter after incrementing
+        self.assertEqual(self.get_counter('xfrrej'), 1)
 
         # TSIG signed request
         request_data = self.create_request_data(with_tsig=True)
@@ -457,6 +464,8 @@ class TestXfroutSession(TestXfroutSessionBase):
         ]))
         [rcode, msg] = self.xfrsess._parse_query_message(request_data)
         self.assertEqual(rcode.to_text(), "REFUSED")
+        # check the 'xfrrej' counter after incrementing
+        self.assertEqual(self.get_counter('xfrrej'), 2)
 
         # ACL using TSIG: no TSIG; should be rejected
         acl_setter(isc.acl.dns.REQUEST_LOADER.load([
@@ -464,6 +473,8 @@ class TestXfroutSession(TestXfroutSessionBase):
         ]))
         [rcode, msg] = self.xfrsess._parse_query_message(self.mdata)
         self.assertEqual(rcode.to_text(), "REFUSED")
+        # check the 'xfrrej' counter after incrementing
+        self.assertEqual(self.get_counter('xfrrej'), 3)
 
         #
         # ACL using IP + TSIG: both should match
@@ -483,24 +494,28 @@ class TestXfroutSession(TestXfroutSessionBase):
                                 ('192.0.2.2', 12345))
         [rcode, msg] = self.xfrsess._parse_query_message(request_data)
         self.assertEqual(rcode.to_text(), "REFUSED")
+        # check the 'xfrrej' counter after incrementing
+        self.assertEqual(self.get_counter('xfrrej'), 4)
         # Address matches, but TSIG doesn't (not included)
         self.xfrsess._remote = (socket.AF_INET, socket.SOCK_STREAM,
                                 ('192.0.2.1', 12345))
         [rcode, msg] = self.xfrsess._parse_query_message(self.mdata)
         self.assertEqual(rcode.to_text(), "REFUSED")
+        # check the 'xfrrej' counter after incrementing
+        self.assertEqual(self.get_counter('xfrrej'), 5)
         # Neither address nor TSIG matches
         self.xfrsess._remote = (socket.AF_INET, socket.SOCK_STREAM,
                                 ('192.0.2.2', 12345))
         [rcode, msg] = self.xfrsess._parse_query_message(self.mdata)
         self.assertEqual(rcode.to_text(), "REFUSED")
+        # check the 'xfrrej' counter after incrementing
+        self.assertEqual(self.get_counter('xfrrej'), 6)
 
     def test_transfer_acl(self):
         # ACL checks only with the default ACL
         def acl_setter(acl):
             self.xfrsess._acl = acl
-        self.assertEqual(self.get_counter('xfrrej'), 0)
         self.check_transfer_acl(acl_setter)
-        self.assertGreater(self.get_counter('xfrrej'), 0)
 
     def test_transfer_acl_with_notcallable_xfrrej(self):
         # ACL checks only with the default ACL and not callable xfrrej
@@ -520,9 +535,7 @@ class TestXfroutSession(TestXfroutSessionBase):
             self.xfrsess._zone_config[zone_key]['transfer_acl'] = acl
             self.xfrsess._acl = isc.acl.dns.REQUEST_LOADER.load([
                     {"from": "127.0.0.1", "action": "DROP"}])
-        self.assertEqual(self.get_counter('xfrrej'), 0)
         self.check_transfer_acl(acl_setter)
-        self.assertGreater(self.get_counter('xfrrej'), 0)
 
     def test_transfer_zoneacl_nomatch(self):
         # similar to the previous one, but the per zone doesn't match the
@@ -534,9 +547,7 @@ class TestXfroutSession(TestXfroutSessionBase):
                 isc.acl.dns.REQUEST_LOADER.load([
                     {"from": "127.0.0.1", "action": "DROP"}])
             self.xfrsess._acl = acl
-        self.assertEqual(self.get_counter('xfrrej'), 0)
         self.check_transfer_acl(acl_setter)
-        self.assertGreater(self.get_counter('xfrrej'), 0)
 
     def test_get_transfer_acl(self):
         # set the default ACL.  If there's no specific zone ACL, this one
@@ -1645,15 +1656,21 @@ class TestXfroutCounter(unittest.TestCase):
                 '%s/%s/%s' % (XfroutCounter.perzone_prefix,\
                                   zone_name, counter_name))
 
-    def test_xxcrementers(self):
+    def test_incdecrementers(self):
         # for per-zone counters
         result = { XfroutCounter.entire_server: {},
                    TEST_ZONE_NAME_STR: {} }
         for counter_name in self._counters:
-            incrementer = \
-                dict(self.xfrout_counter.get_counters_for_xfroutsession(), \
-                         **self.xfrout_counter.get_counters_for_notifyout())\
-                         ['counter_%s' % counter_name]
+            cntrs_xfrss = \
+                self.xfrout_counter.get_counters_for_xfroutsession()
+            cntrs_notfy = \
+                self.xfrout_counter.get_counters_for_notifyout()
+            cnt_name = 'counter_%s' % counter_name
+            incrementer = None
+            if cnt_name in cntrs_xfrss:
+                incrementer = cntrs_xfrss[cnt_name]
+            else:
+                incrementer = cntrs_notfy[cnt_name]
             self.start_incrementer(incrementer, TEST_ZONE_NAME_STR)
             self.assertEqual(self.get_count(\
                         TEST_ZONE_NAME_STR, counter_name), \
diff --git a/src/bin/xfrout/xfrout.py.in b/src/bin/xfrout/xfrout.py.in
index bf1b502..835696e 100755
--- a/src/bin/xfrout/xfrout.py.in
+++ b/src/bin/xfrout/xfrout.py.in
@@ -169,9 +169,9 @@ class XfroutSession():
         self.ClientClass = client_class # parameterize this for testing
         self._soa = None # will be set in _xfrout_setup or in tests
         self._jnl_reader = None # will be set to a reader for IXFR
-        # Set counter handlers for counting Xfr requests or
-        # incrementing or decrementing Xfr running. An argument
-        # is required for zone name in counting Xfr requests.
+        # Extract counter handler from the `counters` argument and add
+        # it to the class attribute of the name whose prefix is
+        # '_counter_' '_inc_' or '_dec_'
         for (k, v) in counters.items():
             if k.find('counter_') == 0 or k.find('inc_') == 0 \
                     or k.find('dec_') == 0:
@@ -278,9 +278,8 @@ class XfroutSession():
                          format_zone_str(zone_name, zone_class))
             return None, None
         elif acl_result == REJECT:
-            if self._counter_xfrrej is not None:
-                # count rejected Xfr request by each zone name
-                self._counter_xfrrej(zone_name.to_text())
+            # count rejected Xfr request by each zone name
+            self._counter_xfrrej(zone_name.to_text())
             logger.debug(DBG_XFROUT_TRACE, XFROUT_QUERY_REJECTED,
                          self._request_type, format_addrinfo(self._remote),
                          format_zone_str(zone_name, zone_class))
@@ -982,7 +981,7 @@ class XfroutCounter:
                 if n.find('xfr_running') == 1 ]
         self._lock = threading.RLock()
         self._create_perzone_incrementers()
-        self._create_xfrrunning_xxcrementers()
+        self._create_xfrrunning_incdecrementers()
 
     def get_statistics(self):
         """Calculates an entire server counts, and returns statistics
@@ -1055,7 +1054,7 @@ class XfroutCounter:
                 self._counters_for_xfroutsession['counter_%s' % item] \
                     = __perzone_incrementer
 
-    def _create_xfrrunning_xxcrementers(self):
+    def _create_xfrrunning_incdecrementers(self):
         """Creates increment/decrement method of (a|i)xfr_running
         based on the spec file. Incrementer can be accessed by name
         "inc_${item_name}". Decrementer can be accessed by name
diff --git a/tests/lettuce/features/xfrin_notify_handling.feature b/tests/lettuce/features/xfrin_notify_handling.feature
index ff3946d..ffde7b9 100644
--- a/tests/lettuce/features/xfrin_notify_handling.feature
+++ b/tests/lettuce/features/xfrin_notify_handling.feature
@@ -46,8 +46,13 @@ Feature: Xfrin incoming notify handling
     Then wait for new bind10 stderr message ZONEMGR_RECEIVE_NOTIFY
     Then wait for new bind10 stderr message XFRIN_XFR_TRANSFER_STARTED
     And when I query statistics axfr_running of bind10 module Xfrout with cmdctl port 47804
-    # xfering might not be started yet.
+
+    # The counter may or may not have been incremented. Whatever the
+    # server likes. This test should have been actually effective but
+    # the axfr transfering is mostly done in real short time. it is
+    # hardly to observe 'axfr_running' incremented to one.
     Then the statistics counter axfr_running should be between 0 and 1
+
     Then wait for new bind10 stderr message XFRIN_TRANSFER_SUCCESS not XFRIN_XFR_PROCESS_FAILURE
     Then wait for new bind10 stderr message ZONEMGR_RECEIVE_XFRIN_SUCCESS
     Then wait 5 times for new master stderr message NOTIFY_OUT_SENDING_NOTIFY



More information about the bind10-changes mailing list