Commit 14966915 authored by Daniel Salzman's avatar Daniel Salzman

tests-extra: add basic IXFR tests

parent f0ca635a
#!/usr/bin/env python3
'''Test for IXFR from Knot to Bind'''
from dnstest.test import Test
t = Test()
master = t.server("bind")
slave = t.server("knot")
zones = t.zone_rnd(5, records=50) + t.zone("wild.") + \
t.zone("cname-loop.") + t.zone("records.")
t.link(zones, master, slave, ixfr=True)
t.start()
# Wait for AXFR to slave server.
serials_init = master.zones_wait(zones)
slave.zones_wait(zones)
serials_prev = serials_init
for i in range(4):
# Update zone files on master.
for zone in zones:
master.update_zonefile(zone, random=True)
master.reload()
# Wait for IXFR to slave.
serials = master.zones_wait(zones, serials_prev)
slave.zones_wait(zones, serials_prev)
serials_prev = serials
# Compare IXFR between servers.
t.xfr_diff(master, slave, zones, serials_init)
t.end()
......@@ -64,10 +64,11 @@ class IxfrTopology():
if not self.init_soa:
self.init_soa = soa
self.test.xfr_diff(self.ref_master, self.master, self.zone, serial=self.init_soa)
self.test.xfr_diff(self.ref_master, self.ref_slave, self.zone, serial=self.init_soa)
self.test.xfr_diff(self.ref_master, self.slave1, self.zone, serial=self.init_soa)
self.test.xfr_diff(self.ref_master, self.slave2, self.zone, serial=self.init_soa)
serial = {self.zone[0].name: self.init_soa}
self.test.xfr_diff(self.ref_master, self.master, self.zone, serial)
self.test.xfr_diff(self.ref_master, self.ref_slave, self.zone, serial)
self.test.xfr_diff(self.ref_master, self.slave1, self.zone, serial)
self.test.xfr_diff(self.ref_master, self.slave2, self.zone, serial)
check_log("====================================")
......
#!/usr/bin/env python3
'''Test for IXFR from Knot to Bind'''
from dnstest.test import Test
t = Test()
master = t.server("knot")
slave = t.server("bind")
zones = t.zone_rnd(5, records=50) + t.zone("wild.") + \
t.zone("cname-loop.") + t.zone("records.")
t.link(zones, master, slave, ixfr=True)
t.start()
# Wait for AXFR to slave server.
serials_init = master.zones_wait(zones)
slave.zones_wait(zones)
serials_prev = serials_init
for i in range(4):
# Update zone files on master.
for zone in zones:
master.update_zonefile(zone, random=True)
master.reload()
# Wait for IXFR to slave.
serials = master.zones_wait(zones, serials_prev)
slave.zones_wait(zones, serials_prev)
serials_prev = serials
# Compare IXFR between servers.
t.xfr_diff(master, slave, zones, serials_init)
t.end()
#!/usr/bin/env python3
'''Test for IXFR from Knot to Bind'''
from dnstest.test import Test
t = Test()
master = t.server("knot")
slave = t.server("knot")
zones = t.zone_rnd(5, records=50) + t.zone("wild.") + \
t.zone("cname-loop.") + t.zone("records.")
t.link(zones, master, slave, ixfr=True)
t.start()
# Wait for AXFR to slave server.
serials_init = master.zones_wait(zones)
slave.zones_wait(zones)
serials_prev = serials_init
for i in range(4):
# Update zone files on master.
for zone in zones:
master.update_zonefile(zone, random=True)
master.reload()
# Wait for IXFR to slave.
serials = master.zones_wait(zones, serials_prev)
slave.zones_wait(zones, serials_prev)
serials_prev = serials
# Compare IXFR between servers.
t.xfr_diff(master, slave, zones, serials_init)
t.end()
......@@ -16,10 +16,10 @@ t.link(zone, bind)
t.start()
# Wait for zone and get serial.
serial = bind.zone_wait(zone)
serial = bind.zones_wait(zone)
knot.zone_wait(zone)
# Query IXFR over UDP and compare responses.
t.xfr_diff(knot, bind, zone, serial=serial, udp=True)
t.xfr_diff(knot, bind, zone, serial, udp=True)
t.end()
......@@ -538,9 +538,15 @@ class Server(object):
return _serial
def zones_wait(self, zone_list):
def zones_wait(self, zone_list, serials=None):
new_serials = dict()
for zone in zone_list:
self.zone_wait(zone)
old_serial = serials[zone.name] if serials else None
new_serial = self.zone_wait(zone, serial=old_serial)
new_serials[zone.name] = new_serial
return new_serials
def zone_verify(self, zone):
zone = zone_arg_check(zone)
......@@ -598,10 +604,13 @@ class Server(object):
self.zones[zone.name].zfile.backup()
def update_zonefile(self, zone, version):
def update_zonefile(self, zone, version=None, random=False):
zone = zone_arg_check(zone)
self.zones[zone.name].zfile.upd_file(version=version)
if random:
self.zones[zone.name].zfile.update_rnd()
else:
self.zones[zone.name].zfile.upd_file(version=version)
def add_query_module(self, zone, module, param):
# Convert one item list to single object.
......
......@@ -257,7 +257,7 @@ class Test(object):
item_lower = item[0].lower() + " " + item[1]
if item_lower in unique and rrset.rdtype != dns.rdatatype.SOA:
detail_log("!Duplicate record %s:" % server.name)
detail_log("!Duplicate record server='%s':" % server.name)
detail_log(" %s" % item_lower)
continue
......@@ -273,14 +273,14 @@ class Test(object):
diff1 = sorted(list(unique1 - unique2))
if diff1:
set_err("AXFR DIFF")
detail_log("!Extra records %s:" % server1.name)
detail_log("!Extra records server='%s':" % server1.name)
for record in diff1:
detail_log(" %s" % record)
diff2 = sorted(list(unique2 - unique1))
if diff2:
set_err("AXFR DIFF")
detail_log("!Extra records %s:" % server2.name)
detail_log("!Extra records server='%s':" % server2.name)
for record in diff2:
detail_log(" %s" % record)
......@@ -311,7 +311,7 @@ class Test(object):
if len(self.removed) != len(other.removed):
set_err("IXFR CHANGE DIFF")
detail_log("!Number of remove records:")
detail_log(" (%s) != (%s)" %
detail_log(" (%i) != (%i)" %
(len(self.removed), len(other.removed)))
for rem1, rem2 in zip(self.removed, other.removed):
......@@ -330,7 +330,7 @@ class Test(object):
if len(self.added) != len(other.added):
set_err("IXFR CHANGE DIFF")
detail_log("!Number of add records:")
detail_log(" (%s) != (%s)" %
detail_log(" (%i) != (%i)" %
(len(self.added), len(other.added)))
for add1, add2 in zip(self.added, other.added):
......@@ -361,28 +361,32 @@ class Test(object):
soa = item_lower
continue
if not change.soa_old: # First change.
if not change.soa_old: # Remove change section.
change.soa_old = item_lower
continue
if not change.soa_new: # Removed rdata SOA.
if not change.soa_new: # Add change section.
change.soa_new = item_lower
else: # Added rdata SOA.
change.sort()
changes.append(change)
change = Test.IxfrChange()
change.soa_old = item_lower
continue
# Next change -> store the actual one.
change.sort()
changes.append(change)
change = Test.IxfrChange()
change.soa_old = item_lower
else:
if not soa:
set_err("IXFR FORMAT")
detail_log("!Missing leading SOA %s:%s before:" %
(server.name, zone.name))
detail_log("!Missing leading SOA zone='%s', " \
"server='%s' before:" %
(zone.name, server.name))
detail_log(" %s" % item_lower)
if not change.soa_old:
set_err("IXFR FORMAT")
detail_log("!Expected SOA %s:%s before:" %
(server.name, zone.name))
detail_log("!Expected SOA zone='%s', server='%s' " \
"before:" %
(zone.name, server.name))
detail_log(" %s" % item_lower)
if not change.soa_new:
......@@ -392,16 +396,17 @@ class Test(object):
if not soa:
set_err("IXFR FORMAT")
detail_log("!Missing leading SOA %s:%s" %
(server.name, zone.name))
detail_log("!Missing leading SOA zone='%s', server='%s'" %
(zone.name, server.name))
elif change.removed or change.added:
set_err("IXFR FORMAT")
detail_log("!Missing trailing SOA %s:%s" %
(server.name, zone.name))
detail_log("!Missing trailing SOA zone='%s', server='%s'" %
(zone.name, server.name))
elif change.soa_old and change.soa_old != soa:
set_err("IXFR FORMAT")
detail_log("!Trailing SOA differs from the leading one %s:%s" %
(server.name, zone.name))
detail_log("!Trailing SOA differs from the leading one " \
"zone='%s', server='%s'" %
(zone.name, server.name))
return soa, changes
......@@ -418,19 +423,19 @@ class Test(object):
if len(changes1) != len(changes2):
set_err("IXFR DIFF")
detail_log("!Number of changes:")
detail_log(" (%s:%s) != (%s:%s)" %
detail_log(" (server='%s', num='%i') != (server='%s', num='%i')" %
(server1.name, len(changes1),
server2.name, len(changes2)))
for change1, change2 in zip(changes1, changes2):
change1.cmp(change2)
def xfr_diff(self, server1, server2, zones, serial=None, udp=False):
def xfr_diff(self, server1, server2, zones, serials=None, udp=False):
for zone in zones:
check_log("CHECK %sXFR DIFF %s %s<->%s" % ("I" if serial else "A",
check_log("CHECK %sXFR DIFF %s %s<->%s" % ("I" if serials else "A",
zone.name, server1.name, server2.name))
if serial:
self._ixfr_diff(server1, server2, zone, serial, udp)
if serials:
self._ixfr_diff(server1, server2, zone, serials[zone.name], udp)
else:
self._axfr_diff(server1, server2, zone)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment