Parcourir la source

[2964] before intial 'retransfer', make sure create an empty zone w/ loadzone

this is a backward compatible change, and is currently no-op in effect, but
will be crucial with main changes of this branch that are coming.
JINMEI Tatuya il y a 12 ans
Parent
commit
7a0ffbd781

+ 22 - 2
tests/lettuce/features/terrain/loadzone.py

@@ -25,12 +25,16 @@ def run_loadzone(zone, zone_file, db_file):
 
     Parameters:
     zone (str): the zone name
-    zone_file (str): master zone file for the zone
+    zone_file (str): master zone file for the zone; can be None to make an
+                     empty zone.
     db_file (str): SQLite3 DB file to load the zone into
 
     """
     sqlite_datasrc_cfg = '{"database_file": "' + db_file + '"}'
-    args = ['b10-loadzone', '-c', sqlite_datasrc_cfg, zone, zone_file]
+    if zone_file is not None:
+        args = ['b10-loadzone', '-c', sqlite_datasrc_cfg, zone, zone_file]
+    else:
+        args = ['b10-loadzone', '-c', sqlite_datasrc_cfg, '-e', zone]
     loadzone = subprocess.Popen(args, 1, None, None,
                                 subprocess.PIPE, subprocess.PIPE)
     (stdout, stderr) = loadzone.communicate()
@@ -54,6 +58,22 @@ def load_zone_to_dbfile(step, zone, db_file, zone_file):
     """
     run_loadzone(zone, zone_file, db_file)
 
+@step('make empty zone (\S+) in DB file (\S+)')
+def make_empty_zone_to_dbfile(step, zone, db_file):
+    """Make an empty zone into a data source.
+
+    If a non-empty zone already exists in the data source, it will be emptied;
+    otherwise, a new empty zone will be created.
+
+    It currently only works for an SQLite3-based data source.  Its
+    DB file name should be specified.
+
+    Step definition:
+    make empty zone <zone_name> to DB file <db_file>
+
+    """
+    run_loadzone(zone, None, db_file)
+
 @step('load (\d+) records for zone (\S+) to DB file (\S+)')
 def load_zone_rr_to_dbfile(step, num_records, zone, db_file):
     """Load a zone with a specified number of RRs into a data source.

+ 12 - 4
tests/lettuce/features/xfrin_bind10.feature

@@ -20,10 +20,13 @@ Feature: Xfrin
     And wait for bind10 stderr message XFRIN_STARTED
     And wait for bind10 stderr message ZONEMGR_STARTED
 
-    # Now we use the first step again to see if the file has been created
+    # Now we use the first step again to see if the file has been created.
+    # The DB currently doesn't know anything about the zone, so we install
+    # an empty zone for xfrin.
     The file data/test_nonexistent_db.sqlite3 should exist
-
     A query for www.example.org to [::1]:47806 should have rcode REFUSED
+    Then make empty zone example.org in DB file data/test_nonexistent_db.sqlite3
+
     When I send bind10 the command Xfrin retransfer example.org IN ::1 47807
     # The data we receive contain a NS RRset that refers to three names in the
     # example.org. zone. All these three are nonexistent in the data, producing
@@ -80,6 +83,9 @@ Feature: Xfrin
     And wait for bind10 stderr message CMDCTL_STARTED
     And wait for bind10 stderr message XFRIN_STARTED
 
+    # For xfrin make the data source aware of the zone (with empty data)
+    Then make empty zone example.org in DB file data/test_nonexistent_db.sqlite3
+
     # Set slave config for 'automatic' xfrin
     When I set bind10 configuration Xfrin/zones to [{"master_port": 47806, "name": "example.org", "master_addr": "::1"}]
 
@@ -135,10 +141,12 @@ Feature: Xfrin
     And wait for bind10 stderr message XFRIN_STARTED
     And wait for bind10 stderr message ZONEMGR_STARTED
 
-    # Now we use the first step again to see if the file has been created
+    # Now we use the first step again to see if the file has been created,
+    # then install empty zone data
     The file data/test_nonexistent_db.sqlite3 should exist
-
     A query for www.example.org to [::1]:47806 should have rcode REFUSED
+    Then make empty zone example.org in DB file data/test_nonexistent_db.sqlite3
+
     When I send bind10 the command Xfrin retransfer example.org IN ::1 47807
     # It should complain once about invalid data, then again that the whole
     # zone is invalid and then reject it.