BIND 10 trac1462, updated. 0fa94211a98fbfbd15bde8929c9317eeba2888d7 [1462] added (improved) a test case where serial number arithmetic is crucial.

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Dec 30 07:13:30 UTC 2011


The branch, trac1462 has been updated
       via  0fa94211a98fbfbd15bde8929c9317eeba2888d7 (commit)
       via  6c0170de9a6b46c077c9babc2858263a7dc51d83 (commit)
       via  8c0f14ccee6098c9b95c6b3962e5c47d229533fa (commit)
       via  0f43276e0bbd287aaff58fd4d025d67105d26f12 (commit)
       via  5656072ed849c848ec4014d5e6deb357b9cf5dc2 (commit)
      from  e38899e87a623f8f55768222f76a26a5a6b71671 (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 0fa94211a98fbfbd15bde8929c9317eeba2888d7
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Thu Dec 29 23:12:41 2011 -0800

    [1462] added (improved) a test case where serial number arithmetic is crucial.

commit 6c0170de9a6b46c077c9babc2858263a7dc51d83
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Thu Dec 29 23:01:56 2011 -0800

    [1462] added one more request_serial > current_serial case.  some comment
    cleanup, eliminating redundancy.

commit 8c0f14ccee6098c9b95c6b3962e5c47d229533fa
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Thu Dec 29 22:57:33 2011 -0800

    [1462] recovered another ixfr-to-axfr test case.

commit 0f43276e0bbd287aaff58fd4d025d67105d26f12
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Thu Dec 29 22:52:57 2011 -0800

    [1462] recovered an AXFR-style IXFR test case.

commit 5656072ed849c848ec4014d5e6deb357b9cf5dc2
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Thu Dec 29 22:38:21 2011 -0800

    [1462] some style fixes, mainly removing white spaces from blank lines.

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

Summary of changes:
 src/bin/xfrout/tests/xfrout_test.py.in |   60 ++++++++++++++++++++-----------
 src/bin/xfrout/xfrout.py.in            |    4 +-
 2 files changed, 41 insertions(+), 23 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/xfrout/tests/xfrout_test.py.in b/src/bin/xfrout/tests/xfrout_test.py.in
index 1e07c74..209bf22 100644
--- a/src/bin/xfrout/tests/xfrout_test.py.in
+++ b/src/bin/xfrout/tests/xfrout_test.py.in
@@ -38,7 +38,7 @@ TEST_ZONE_NAME_STR = "example.com."
 TEST_ZONE_NAME = Name(TEST_ZONE_NAME_STR)
 TEST_RRCLASS = RRClass.IN()
 IXFR_OK_VERSION = 2011111802
-IXFR_NG_VERSION = 2011112800
+IXFR_NG_VERSION = 2011111803
 SOA_CURRENT_VERSION = 2011112001
 
 # our fake socket, where we can read and insert messages
@@ -110,6 +110,9 @@ class MockDataSrcClient:
             soa_rrset = create_soa(SOA_CURRENT_VERSION)
             soa_rrset.add_rdata(soa_rrset.get_rdata()[0])
             return (ZoneFinder.SUCCESS, soa_rrset)
+        elif name == Name('maxserial.example.com'):
+            soa_rrset = create_soa(0xffffffff)
+            return (ZoneFinder.SUCCESS, soa_rrset)
         elif rrtype == RRType.SOA():
             return (ZoneFinder.SUCCESS, create_soa(SOA_CURRENT_VERSION))
         raise ValueError('Unexpected input to mock finder: bug in test case?')
@@ -123,9 +126,6 @@ class MockDataSrcClient:
     def get_soa(self):  # emulate ZoneIterator.get_soa()
         if self._zone_name == Name('nosoa.example.com'):
             return None
-        if self._zone_name == Name('serial.example.com'):
-            soa_rrset = create_soa(0xffffffff)
-            return soa_rrset
         soa_rrset = create_soa(SOA_CURRENT_VERSION)
         if self._zone_name == Name('multisoa.example.com'):
             soa_rrset.add_rdata(soa_rrset.get_rdata()[0])
@@ -713,24 +713,40 @@ class TestXfroutSession(TestXfroutSessionBase):
                 self.getmsg(), TEST_ZONE_NAME, TEST_RRCLASS), Rcode.NOERROR())
         self.assertNotEqual(None, self.xfrsess._jnl_reader)
 
+        # Successful case, but as a result of falling back to AXFR-style
+        # IXFR.  A zone iterator should be set up instead of a journal reader.
+        self.mdata = self.create_request_data(ixfr=IXFR_NG_VERSION)
+        self.assertEqual(self.xfrsess._xfrout_setup(
+                self.getmsg(), TEST_ZONE_NAME, TEST_RRCLASS), Rcode.NOERROR())
+        self.assertNotEqual(None, self.xfrsess._iterator)
+        self.assertEqual(None, self.xfrsess._jnl_reader)
+
         # Successful case, but the requested SOA serial is greater than that of
         # the local SOA.  Both iterator and jnl_reader should be None,
         # indicating that the response will contain just one SOA.
-        self.mdata = self.create_request_data(ixfr=IXFR_NG_VERSION)
+        self.mdata = self.create_request_data(ixfr=SOA_CURRENT_VERSION+1)
         self.assertEqual(self.xfrsess._xfrout_setup(
                 self.getmsg(), TEST_ZONE_NAME, TEST_RRCLASS), Rcode.NOERROR())
         self.assertEqual(None, self.xfrsess._iterator)
         self.assertEqual(None, self.xfrsess._jnl_reader)
 
-        # Successful case, but the requested SOA serial is equal to that of
-        # the local SOA.  Both iterator and jnl_reader should be None,
-        # indicating that the response will contain just one SOA.
+        # Similar to the previous case, but the requested serial is equal to
+        # the local SOA.
         self.mdata = self.create_request_data(ixfr=SOA_CURRENT_VERSION)
         self.assertEqual(self.xfrsess._xfrout_setup(
                 self.getmsg(), TEST_ZONE_NAME, TEST_RRCLASS), Rcode.NOERROR())
         self.assertEqual(None, self.xfrsess._iterator)
         self.assertEqual(None, self.xfrsess._jnl_reader)
 
+        # Similar to the previous case, but the comparison should be done
+        # based on serial number arithmetic, not as integers.
+        zone_name = Name('maxserial.example.com') # whose SOA is 0xffffffff
+        self.mdata = self.create_request_data(ixfr=1, zone_name=zone_name)
+        self.assertEqual(self.xfrsess._xfrout_setup(
+                 self.getmsg(), zone_name, TEST_RRCLASS), Rcode.NOERROR())
+        self.assertEqual(None, self.xfrsess._iterator)
+        self.assertEqual(None, self.xfrsess._jnl_reader)
+
         # The data source doesn't support journaling.  Should fallback to AXFR.
         zone_name = Name('nojournal.example.com')
         self.mdata = self.create_request_data(ixfr=IXFR_OK_VERSION,
@@ -780,12 +796,6 @@ class TestXfroutSession(TestXfroutSessionBase):
                                               num_soa=2)
         self.assertEqual(self.xfrsess._xfrout_setup(
                 self.getmsg(), zone_name, TEST_RRCLASS), Rcode.FORMERR())
-    
-        # the request soa is newer than the server's current serial
-        zone_name = Name('serial.example.com')
-        self.mdata = self.create_request_data(ixfr=1,zone_name=zone_name)
-        self.assertEqual(self.xfrsess._xfrout_setup(
-                 self.getmsg(), zone_name, TEST_RRCLASS), Rcode.NOERROR())
 
     def test_dns_xfrout_start_formerror(self):
         # formerror
@@ -1081,12 +1091,12 @@ class TestXfroutSessionWithSQLite3(TestXfroutSessionBase):
 
     def test_ixfr_to_axfr(self):
         self.xfrsess._request_data = \
-             self.create_request_data(ixfr=2000000000)
+            self.create_request_data(ixfr=IXFR_NG_VERSION)
         XfroutSession._handle(self.xfrsess)
         response = self.sock.read_msg(Message.PRESERVE_ORDER);
         self.assertEqual(Rcode.NOERROR(), response.get_rcode())
-        # The SOA serial is greater than that of requested one.
-        # So only the SOA was send.
+        # This is an AXFR-style IXFR.  So the question section should indicate
+        # that it's an IXFR resposne.
         self.assertEqual(RRType.IXFR(), response.get_question()[0].get_type())
         self.check_axfr_stream(response)
 
@@ -1112,11 +1122,9 @@ class TestXfroutSessionWithSQLite3(TestXfroutSessionBase):
         for (expected_rr, actual_rr) in zip(expected_records, actual_records):
             self.assertTrue(rrsets_equal(expected_rr, actual_rr))
 
-    def test_ixfr_soa_only(self):
-        # The requested SOA serial is the latest one.  The response should
-        # contain exactly one SOA of that serial.
+    def ixfr_soa_only_common_checks(self, request_serial):
         self.xfrsess._request_data = \
-            self.create_request_data(ixfr=SOA_CURRENT_VERSION)
+            self.create_request_data(ixfr=request_serial)
         XfroutSession._handle(self.xfrsess)
         response = self.sock.read_msg(Message.PRESERVE_ORDER);
         answers = response.get_section(Message.SECTION_ANSWER)
@@ -1124,6 +1132,16 @@ class TestXfroutSessionWithSQLite3(TestXfroutSessionBase):
         self.assertTrue(rrsets_equal(create_soa(SOA_CURRENT_VERSION),
                                      answers[0]))
 
+    def test_ixfr_soa_only(self):
+        # The requested SOA serial is the latest one.  The response should
+        # contain exactly one SOA of that serial.
+        self.ixfr_soa_only_common_checks(SOA_CURRENT_VERSION)
+
+    def test_ixfr_soa_only2(self):
+        # Similar to the previous test, but the requested SOA is larger than
+        # the current.
+        self.ixfr_soa_only_common_checks(SOA_CURRENT_VERSION + 1)
+
 class MyUnixSockServer(UnixSockServer):
     def __init__(self):
         self._shutdown_event = threading.Event()
diff --git a/src/bin/xfrout/xfrout.py.in b/src/bin/xfrout/xfrout.py.in
index 127c613..b4e8eb2 100755
--- a/src/bin/xfrout/xfrout.py.in
+++ b/src/bin/xfrout/xfrout.py.in
@@ -422,7 +422,7 @@ class XfroutSession():
                         format_zone_str(zone_name, zone_class),
                         begin_serial, end_serial)
             return Rcode.NOERROR()
-        
+
         # Set up the journal reader or fall back to AXFR-style IXFR
         try:
             code, self._jnl_reader = self._datasrc_client.get_journal_reader(
@@ -450,7 +450,7 @@ class XfroutSession():
 
         # Use the reader as the iterator to generate the response.
         self._iterator = self._jnl_reader
-        
+
         return Rcode.NOERROR()
 
     def _xfrout_setup(self, request_msg, zone_name, zone_class):




More information about the bind10-changes mailing list