Commit 01254813 authored by Jan Kadlec's avatar Jan Kadlec

tests-extra: Basic test for changeset application

parent a89efd15
#!/usr/bin/env python3
'''Test for changeset application after restart. '''
from dnstest.test import Test
import dnstest.utils
t = Test()
master = t.server("knot")
slave = t.server("knot")
# Zone setup
zone = t.zone_rnd(1)
t.link(zone, master, slave, ixfr = True)
t.start()
# Load zones - master should sign
serial = master.zone_wait(zone)
slave.zone_wait(zone)
# Get AXFR from master
axfr_pre = master.dig(zone[0].name, "AXFR", log_no_sep=True)
# Restart and compare AXFRs
master.stop()
master.start()
master.zone_wait(zone)
axfr_post = master.dig(zone[0].name, "AXFR", log_no_sep=True)
t.axfr_diff_resp(axfr_pre, axfr_post, zone[0])
# Update zonefile on master
# Wait for changes on slave
# Restart and do an AXFR diff
# Update zone using DDNS
# Stop and start, do an AXFR diff
# Stop and start the slave server, make sure everything is applied
master.stop()
slave.stop()
t.end()
......@@ -253,12 +253,10 @@ class Test(object):
raise Exception("Server is out of testing scope")
slave.set_slave(zone, master, ddns, ixfr)
def _axfr_records(self, server, zone):
def _axfr_records(self, resp, zone):
unique = set()
records = list()
resp = server.dig(zone.name, "AXFR", log_no_sep=True)
for msg in resp.resp:
for rrset in msg.answer:
rrs = rrset.to_text(origin=dns.name.from_text(zone.name),
......@@ -278,10 +276,7 @@ class Test(object):
return unique, records
def _axfr_diff(self, server1, server2, zone):
unique1, rrsets1 = self._axfr_records(server1, zone)
unique2, rrsets2 = self._axfr_records(server2, zone)
def _axfr_diff_resp(self, unique1, rrset1s, unique2, rrsets2):
diff1 = sorted(list(unique1 - unique2))
if diff1:
set_err("AXFR DIFF")
......@@ -296,6 +291,13 @@ class Test(object):
for record in diff2:
detail_log(" %s" % record)
def _axfr_diff(self, server1, server2, zone):
unique1, rrsets1 = self._axfr_records(server1.dig(zone.name, "AXFR", log_no_sep=True), zone)
unique2, rrsets2 = self._axfr_records(server2.dig(zone.name, "AXFR", log_no_sep=True), zone)
self._axfr_diff_resp(unique1, rrsets1, unique2, rrsets2)
class IxfrChange():
def __init__(self):
self.soa_old = None
......@@ -452,3 +454,9 @@ class Test(object):
self._axfr_diff(server1, server2, zone)
detail_log(SEP)
def axfr_diff_resp(self, resp1, resp2, zone):
unique1, rrsets1 = self._axfr_records(resp1, zone)
unique2, rrsets2 = self._axfr_records(resp2, zone)
self._axfr_diff_resp(unique1, rrsets1, unique2, rrsets2)
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