Browse Source

[1217] and adjust wrappers

Jelte Jansen 13 years ago
parent
commit
c5f6948823

+ 6 - 3
src/lib/python/isc/datasrc/client_inc.cc

@@ -89,7 +89,7 @@ None\n\
 ";
 
 const char* const DataSourceClient_getIterator_doc = "\
-get_iterator(name, individual_rrs=False) -> ZoneIterator\n\
+get_iterator(name, adjust_ttl=True) -> ZoneIterator\n\
 \n\
 Returns an iterator to the given zone.\n\
 \n\
@@ -111,8 +111,11 @@ anything else.\n\
 Parameters:\n\
   isc.dns.Name The name of zone apex to be traversed. It doesn't do\n\
                nearest match as find_zone.\n\
-  individual_rrs If this is True (default is False), each RR will be\n\
-                 as a separate RRset\n\
+  adjust_ttl   If True, the iterator will treat RRs with the same\n\
+               name and type but different TTL values to be of the\n\
+               same RRset, and will adjust the TTL to the lowest\n\
+               value found. If false, it will consider the RR to\n\
+               belong to a different RRset.\n\
 \n\
 Return Value(s): Pointer to the iterator.\n\
 ";

+ 12 - 26
src/lib/python/isc/datasrc/tests/datasrc_test.py

@@ -87,7 +87,7 @@ class DataSrcClient(unittest.TestCase):
 
         # for RRSIGS, the TTL's are currently modified. This test should
         # start failing when we fix that.
-        rrs = dsc.get_iterator(isc.dns.Name("sql1.example.com."), True)
+        rrs = dsc.get_iterator(isc.dns.Name("sql1.example.com."), False)
 
         # we do not know the order in which they are returned by the iterator
         # but we do want to check them, so we put all records into one list
@@ -114,10 +114,7 @@ class DataSrcClient(unittest.TestCase):
                      "256 3 5 AwEAAdYdRhBAEY67R/8G1N5AjGF6asIiNh/pNGeQ8xDQP13J"+
                      "N2lo+sNqWcmpYNhuVqRbLB+mamsU1XcCICSBvAlSmfz/ZUdafX23knAr"+
                      "TlALxMmspcfdpqun3Yr3YYnztuj06rV7RqmveYckWvAUXVYMSMQZfJ30"+
-                     "5fs0dE/xLztL/CzZ"
-                  ])
-        add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.DNSKEY(), isc.dns.RRTTL(3600), [
+                     "5fs0dE/xLztL/CzZ",
                      "257 3 5 AwEAAbaKDSa9XEFTsjSYpUTHRotTS9Tz3krfDucugW5UokGQ"+
                      "KC26QlyHXlPTZkC+aRFUs/dicJX2kopndLcnlNAPWiKnKtrsFSCnIJDB"+
                      "ZIyvcKq+9RXmV3HK3bUdHnQZ88IZWBRmWKfZ6wnzHo53kdYKAemTErkz"+
@@ -130,15 +127,7 @@ class DataSrcClient(unittest.TestCase):
                   isc.dns.RRType.NS(), isc.dns.RRTTL(3600),
                   [
                     "dns01.example.com.",
-                  ])
-        add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.NS(), isc.dns.RRTTL(3600),
-                  [
                     "dns02.example.com.",
-                  ])
-        add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.NS(), isc.dns.RRTTL(3600),
-                  [
                     "dns03.example.com."
                   ])
         add_rrset(expected_rrset_list, name, rrclass,
@@ -148,19 +137,16 @@ class DataSrcClient(unittest.TestCase):
                   ])
         # For RRSIGS, we can't add the fake data through the API, so we
         # simply pass no rdata at all (which is skipped by the check later)
-        # Since we passed individual_rrs = True to get_iterator, each RRSIG
-        # will be returned as a separate RRset, so add them all one at a time
+        
+        # Since we passed adjust_ttl = False to get_iterator, we get several
+        # sets of RRSIGs, one for each TTL
         add_rrset(expected_rrset_list, name, rrclass,
                   isc.dns.RRType.RRSIG(), isc.dns.RRTTL(3600), None)
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.RRSIG(), isc.dns.RRTTL(3600), None)
-        add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.RRSIG(), isc.dns.RRTTL(3600), None)
+                  isc.dns.RRType.RRSIG(), isc.dns.RRTTL(7200), None)
         add_rrset(expected_rrset_list, name, rrclass,
                   isc.dns.RRType.RRSIG(), isc.dns.RRTTL(3600), None)
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.RRSIG(), isc.dns.RRTTL(7200), None)
-        add_rrset(expected_rrset_list, name, rrclass,
                   isc.dns.RRType.SOA(), isc.dns.RRTTL(3600),
                   [
                      "master.example.com. admin.example.com. 678 3600 1800 2419200 7200"
@@ -202,26 +188,26 @@ class DataSrcClient(unittest.TestCase):
         # instead of failing?
         self.assertRaises(isc.datasrc.Error, rrs.get_next_rrset)
 
-        # Without an individual_rrs argument, it should return 55 RRsets
+        # Without the adjust_ttl argument, it should return 55 RRsets
         dsc = isc.datasrc.DataSourceClient("sqlite3", READ_ZONE_DB_CONFIG)
         rrets = dsc.get_iterator(isc.dns.Name("example.com"))
         # there are more than 80 RRs in this zone... let's just count them
         # (already did a full check of the smaller zone above)
         self.assertEqual(55, len(list(rrets)))
 
-        # same test, but now with explicit False argument for individual_rrs
+        # same test, but now with explicit True argument for adjust_ttl
         dsc = isc.datasrc.DataSourceClient("sqlite3", READ_ZONE_DB_CONFIG)
-        rrets = dsc.get_iterator(isc.dns.Name("example.com"), False)
+        rrets = dsc.get_iterator(isc.dns.Name("example.com"), True)
         # there are more than 80 RRs in this zone... let's just count them
         # (already did a full check of the smaller zone above)
         self.assertEqual(55, len(list(rrets)))
 
-        # Count should be 84 if we request individual records
+        # Count should be 71 if we request individual rrsets for differing ttls
         dsc = isc.datasrc.DataSourceClient("sqlite3", READ_ZONE_DB_CONFIG)
-        rrets = dsc.get_iterator(isc.dns.Name("example.com"), True)
+        rrets = dsc.get_iterator(isc.dns.Name("example.com"), False)
         # there are more than 80 RRs in this zone... let's just count them
         # (already did a full check of the smaller zone above)
-        self.assertEqual(84, len(list(rrets)))
+        self.assertEqual(71, len(list(rrets)))
         # TODO should we catch this (iterating past end) and just return None
         # instead of failing?
         self.assertRaises(isc.datasrc.Error, rrs.get_next_rrset)