BIND 10 trac2884, updated. ca3f4ecf2c5dc37dab7d9e89f4bc41ee000f12c1 [2884] add a note for _add_counter()

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Jul 3 06:46:57 UTC 2013


The branch, trac2884 has been updated
       via  ca3f4ecf2c5dc37dab7d9e89f4bc41ee000f12c1 (commit)
       via  fcea4de8a92427f8b0910048ecb3c7c420d6daf9 (commit)
       via  8288bf44eb68ee5f7f098beeff11e9372065b757 (commit)
       via  6d1f4e151097981b21acb32175756afadf432fe6 (commit)
      from  ca59c5c8d5f309657b3f24f9edcc7100fd9d07a5 (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 ca3f4ecf2c5dc37dab7d9e89f4bc41ee000f12c1
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Wed Jul 3 15:15:22 2013 +0900

    [2884] add a note for _add_counter()

commit fcea4de8a92427f8b0910048ecb3c7c420d6daf9
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Wed Jul 3 13:32:02 2013 +0900

    [2884] s/TEST_RRCLASS.to_text()/TEST_RRCLASS_STR/g

commit 8288bf44eb68ee5f7f098beeff11e9372065b757
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Wed Jul 3 13:24:38 2013 +0900

    [2884] do not reuse the string of format
    
    for avoiding an unexpected behavior if '%s' or some special character for
    python formatting is included in the examined string.

commit 6d1f4e151097981b21acb32175756afadf432fe6
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Wed Jul 3 13:18:31 2013 +0900

    [2884] s/class name/RR class name/ig

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

Summary of changes:
 src/bin/xfrin/b10-xfrin.xml                        |    2 +-
 src/bin/xfrin/xfrin.spec                           |    4 ++--
 src/bin/xfrout/b10-xfrout.xml                      |    2 +-
 src/bin/xfrout/tests/xfrout_test.py.in             |   19 ++++++++-------
 src/bin/xfrout/xfrout.spec.pre.in                  |    4 ++--
 src/lib/python/isc/statistics/counters.py          |   25 ++++++++++++++++----
 .../isc/statistics/tests/testdata/test_spec2.spec  |    4 ++--
 .../isc/statistics/tests/testdata/test_spec3.spec  |    4 ++--
 8 files changed, 40 insertions(+), 24 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/xfrin/b10-xfrin.xml b/src/bin/xfrin/b10-xfrin.xml
index 0b30477..903a3a0 100644
--- a/src/bin/xfrin/b10-xfrin.xml
+++ b/src/bin/xfrin/b10-xfrin.xml
@@ -233,7 +233,7 @@ operation
             <varlistentry>
               <term><replaceable>classname</replaceable></term>
               <listitem><simpara>
-                An actual class name of the zone, e.g. IN, CH, and HS
+                An actual RR class name of the zone, e.g. IN, CH, and HS
                 </simpara>
                 <variablelist>
 
diff --git a/src/bin/xfrin/xfrin.spec b/src/bin/xfrin/xfrin.spec
index 8490681..d09685b 100644
--- a/src/bin/xfrin/xfrin.spec
+++ b/src/bin/xfrin/xfrin.spec
@@ -157,8 +157,8 @@
           "item_type": "named_set",
           "item_optional": false,
           "item_default": {},
-          "item_title": "Class name",
-          "item_description": "An actual class name of the zone, e.g. IN, CH, and HS",
+          "item_title": "RR class name",
+          "item_description": "An actual RR class name of the zone, e.g. IN, CH, and HS",
           "named_set_item_spec": {
             "item_name": "zonename",
             "item_type": "map",
diff --git a/src/bin/xfrout/b10-xfrout.xml b/src/bin/xfrout/b10-xfrout.xml
index ab2b644..468c6af 100644
--- a/src/bin/xfrout/b10-xfrout.xml
+++ b/src/bin/xfrout/b10-xfrout.xml
@@ -173,7 +173,7 @@
             <varlistentry>
               <term><replaceable>classname</replaceable></term>
               <listitem><simpara>
-                An actual class name of the zone, e.g. IN, CH, and HS
+                An actual RR class name of the zone, e.g. IN, CH, and HS
                 </simpara>
                 <variablelist>
 
diff --git a/src/bin/xfrout/tests/xfrout_test.py.in b/src/bin/xfrout/tests/xfrout_test.py.in
index ccf0fe8..d20ebe8 100644
--- a/src/bin/xfrout/tests/xfrout_test.py.in
+++ b/src/bin/xfrout/tests/xfrout_test.py.in
@@ -41,6 +41,7 @@ TSIG_KEY = TSIGKey("example.com:SFuWd/q99SzF8Yzd1QbB9g==")
 TEST_ZONE_NAME_STR = "example.com."
 TEST_ZONE_NAME = Name(TEST_ZONE_NAME_STR)
 TEST_RRCLASS = RRClass.IN
+TEST_RRCLASS_STR = TEST_RRCLASS.to_text()
 IXFR_OK_VERSION = 2011111802
 IXFR_NG_VERSION = 2011111803
 SOA_CURRENT_VERSION = 2011112001
@@ -441,7 +442,7 @@ class TestXfroutSession(TestXfroutSessionBase):
         # check the 'xfrrej' counter initially
         self.assertRaises(isc.cc.data.DataNotFoundError,
                           self.xfrsess._counters.get, 'zones',
-                          TEST_RRCLASS.to_text(), TEST_ZONE_NAME_STR,
+                          TEST_RRCLASS_STR, TEST_ZONE_NAME_STR,
                           'xfrrej')
         # Localhost (the default in this test) is accepted
         rcode, msg = self.xfrsess._parse_query_message(self.mdata)
@@ -458,7 +459,7 @@ class TestXfroutSession(TestXfroutSessionBase):
         self.assertEqual(rcode.to_text(), "REFUSED")
         # check the 'xfrrej' counter after incrementing
         self.assertEqual(self.xfrsess._counters.get(
-                'zones', TEST_RRCLASS.to_text(), TEST_ZONE_NAME_STR,
+                'zones', TEST_RRCLASS_STR, TEST_ZONE_NAME_STR,
                 'xfrrej'), 1)
 
         # TSIG signed request
@@ -490,7 +491,7 @@ class TestXfroutSession(TestXfroutSessionBase):
         self.assertEqual(rcode.to_text(), "REFUSED")
         # check the 'xfrrej' counter after incrementing
         self.assertEqual(self.xfrsess._counters.get(
-                'zones', TEST_RRCLASS.to_text(), TEST_ZONE_NAME_STR,
+                'zones', TEST_RRCLASS_STR, TEST_ZONE_NAME_STR,
                 'xfrrej'), 2)
 
         # ACL using TSIG: no TSIG; should be rejected
@@ -501,7 +502,7 @@ class TestXfroutSession(TestXfroutSessionBase):
         self.assertEqual(rcode.to_text(), "REFUSED")
         # check the 'xfrrej' counter after incrementing
         self.assertEqual(self.xfrsess._counters.get(
-                'zones', TEST_RRCLASS.to_text(), TEST_ZONE_NAME_STR,
+                'zones', TEST_RRCLASS_STR, TEST_ZONE_NAME_STR,
                 'xfrrej'), 3)
 
         #
@@ -524,7 +525,7 @@ class TestXfroutSession(TestXfroutSessionBase):
         self.assertEqual(rcode.to_text(), "REFUSED")
         # check the 'xfrrej' counter after incrementing
         self.assertEqual(self.xfrsess._counters.get(
-                'zones', TEST_RRCLASS.to_text(), TEST_ZONE_NAME_STR,
+                'zones', TEST_RRCLASS_STR, TEST_ZONE_NAME_STR,
                 'xfrrej'), 4)
         # Address matches, but TSIG doesn't (not included)
         self.xfrsess._remote = (socket.AF_INET, socket.SOCK_STREAM,
@@ -533,7 +534,7 @@ class TestXfroutSession(TestXfroutSessionBase):
         self.assertEqual(rcode.to_text(), "REFUSED")
         # check the 'xfrrej' counter after incrementing
         self.assertEqual(self.xfrsess._counters.get(
-                'zones', TEST_RRCLASS.to_text(), TEST_ZONE_NAME_STR,
+                'zones', TEST_RRCLASS_STR, TEST_ZONE_NAME_STR,
                 'xfrrej'), 5)
         # Neither address nor TSIG matches
         self.xfrsess._remote = (socket.AF_INET, socket.SOCK_STREAM,
@@ -542,7 +543,7 @@ class TestXfroutSession(TestXfroutSessionBase):
         self.assertEqual(rcode.to_text(), "REFUSED")
         # check the 'xfrrej' counter after incrementing
         self.assertEqual(self.xfrsess._counters.get(
-                'zones', TEST_RRCLASS.to_text(), TEST_ZONE_NAME_STR,
+                'zones', TEST_RRCLASS_STR, TEST_ZONE_NAME_STR,
                 'xfrrej'), 6)
 
     def test_transfer_acl(self):
@@ -943,13 +944,13 @@ class TestXfroutSession(TestXfroutSessionBase):
 
         self.assertRaises(isc.cc.data.DataNotFoundError,
                           self.xfrsess._counters.get,
-                          'zones', TEST_RRCLASS.to_text(),
+                          'zones', TEST_RRCLASS_STR,
                           TEST_ZONE_NAME_STR, 'xfrreqdone')
         self.xfrsess._reply_xfrout_query = myreply
         self.xfrsess.dns_xfrout_start(self.sock, self.mdata)
         self.assertEqual(self.sock.readsent(), b"success")
         self.assertGreater(self.xfrsess._counters.get(
-            'zones', TEST_RRCLASS.to_text(), TEST_ZONE_NAME_STR,
+            'zones', TEST_RRCLASS_STR, TEST_ZONE_NAME_STR,
             'xfrreqdone'), 0)
 
     def test_reply_xfrout_query_axfr(self):
diff --git a/src/bin/xfrout/xfrout.spec.pre.in b/src/bin/xfrout/xfrout.spec.pre.in
index 0284a5b..570f73e 100644
--- a/src/bin/xfrout/xfrout.spec.pre.in
+++ b/src/bin/xfrout/xfrout.spec.pre.in
@@ -137,8 +137,8 @@
             "item_type": "named_set",
             "item_optional": false,
             "item_default": {},
-            "item_title": "Class name",
-            "item_description": "An actual class name of the zone, e.g. IN, CH, and HS",
+            "item_title": "RR class name",
+            "item_description": "An actual RR class name of the zone, e.g. IN, CH, and HS",
             "named_set_item_spec": {
               "item_name": "zonename",
               "item_type": "map",
diff --git a/src/lib/python/isc/statistics/counters.py b/src/lib/python/isc/statistics/counters.py
index f20a17b..0c2c827 100644
--- a/src/lib/python/isc/statistics/counters.py
+++ b/src/lib/python/isc/statistics/counters.py
@@ -81,6 +81,22 @@ def _add_counter(element, spec, identifier):
         return isc.cc.data.find(element, identifier)
     except isc.cc.data.DataNotFoundError:
         pass
+
+    # Note: If there is a named_set type item in the statistics spec
+    # and if there are map type items under it, all of items under the
+    # map type item need to be added. For example, we're assuming that
+    # this method is now adding a counter whose identifier is like
+    # dir1/dir2/dir3/counter1. If both of dir1 and dir2 are named_set
+    # types, and if dir3 is a map type, and if counter1, counter2, and
+    # counter3 are defined as items under dir3 by the statistics spec,
+    # this method would add other two counters:
+    #
+    #   dir1/dir2/dir3/counter2
+    #   dir1/dir2/dir3/counter3
+    #
+    # Otherwise this method just adds the only counter
+    # dir1/dir2/dir3/counter1.
+
     # examine spec from the top-level item and know whether
     # has_named_set, and check whether spec and identifier are correct
     pidr = ''
@@ -177,8 +193,8 @@ class _Statistics():
           "item_type": "named_set",
           "item_optional": False,
           "item_default": {},
-          "item_title": "Class name",
-          "item_description": "Class name",
+          "item_title": "RR class name",
+          "item_description": "RR class name",
           "named_set_item_spec": {
             "item_name": "zonename",
             "item_type": "map",
@@ -412,9 +428,8 @@ class Counters():
         for cls in zones.keys():
             for zone in zones[cls].keys():
                 for (attr, val) in zones[cls][zone].items():
-                    id_str = '%s/%%s/%s' % (cls, attr)
-                    id_str1 = id_str % zone
-                    id_str2 = id_str % self._entire_server
+                    id_str1 = '%s/%s/%s' % (cls, zone, attr)
+                    id_str2 = '%s/%s/%s' % (cls, self._entire_server, attr)
                     _set_counter(zones_data, zones_spec, id_str1, val)
                     _inc_counter(zones_data, zones_spec, id_str2, val)
         # insert entire-server counts
diff --git a/src/lib/python/isc/statistics/tests/testdata/test_spec2.spec b/src/lib/python/isc/statistics/tests/testdata/test_spec2.spec
index 162a0f5..422fc0a 100644
--- a/src/lib/python/isc/statistics/tests/testdata/test_spec2.spec
+++ b/src/lib/python/isc/statistics/tests/testdata/test_spec2.spec
@@ -25,8 +25,8 @@
           "item_type": "named_set",
           "item_optional": false,
           "item_default": {},
-          "item_title": "Class name",
-          "item_description": "Class name for Xfrout statistics",
+          "item_title": "RR class name",
+          "item_description": "RR class name for Xfrout statistics",
           "named_set_item_spec": {
             "item_name": "zonename",
             "item_type": "map",
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 aa6c040..f620cad 100644
--- a/src/lib/python/isc/statistics/tests/testdata/test_spec3.spec
+++ b/src/lib/python/isc/statistics/tests/testdata/test_spec3.spec
@@ -32,8 +32,8 @@
           "item_type": "named_set",
           "item_optional": false,
           "item_default": {},
-          "item_title": "Class name",
-          "item_description": "Class name for Xfrout statistics",
+          "item_title": "RR class name",
+          "item_description": "RR class name for Xfrout statistics",
           "named_set_item_spec": {
             "item_name": "zonename",
             "item_type": "map",



More information about the bind10-changes mailing list