Commit 02c7dc98 authored by Daniel Salzman's avatar Daniel Salzman

Merge branch 'restart-tests' into 'master'

Restart tests

Review changes to the testing framework, please.

See merge request !247
parents a89efd15 8de726aa
#!/usr/bin/env python3
'''Test for changeset application after restart. '''
from dnstest.test import Test
import dnstest.utils
def check_axfr(server, zone):
# Get AXFR
axfr_pre = server.dig(zone[0].name, "AXFR", log_no_sep=True)
# Restart
# Get AXFR after restart
axfr_post = server.dig(zone[0].name, "AXFR", log_no_sep=True)
# Compare AXFRs
t.axfr_diff_resp(axfr_pre, axfr_post, server, server, zone[0])
t = Test()
master = t.server("knot")
slave = t.server("knot")
# Zone setup
zone = t.zone_rnd(1), master, slave, ixfr = True, ddns=True)
# Turn automatic DNSSEC on
master.dnssec_enable = True
master.gen_key(zone, ksk=True, alg="RSASHA256")
master.gen_key(zone, alg="RSASHA256")
# Load zones - master should sign
# Check DNSSEC application
check_axfr(master, zone)
# Update zone using DDNS
up = master.update(zone)
up.add("test123."+zone[0].name, "3600", "TXT", "test")
# Check DDNS application
check_axfr(master, zone)
serial = master.zone_wait(zone)
serial = slave.zone_wait(zone, serial)
# Update zonefile on master
master.update_zonefile(zone, random=True)
# Wait for all changes on slave
slave.zone_wait(zone, serial)
# Make sure slave applied everything
check_axfr(slave, zone)
......@@ -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(, "AXFR", log_no_sep=True)
for msg in resp.resp:
for rrset in msg.answer:
rrs = rrset.to_text(,
......@@ -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, server1, server2):
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(, "AXFR", log_no_sep=True), zone)
unique2, rrsets2 = self._axfr_records(server2.dig(, "AXFR", log_no_sep=True), zone)
self._axfr_diff_resp(unique1, rrsets1, unique2, rrsets2, server1, server2)
class IxfrChange():
def __init__(self):
self.soa_old = None
......@@ -452,3 +454,9 @@ class Test(object):
self._axfr_diff(server1, server2, zone)
def axfr_diff_resp(self, resp1, resp2, server1, server2, zone):
unique1, rrsets1 = self._axfr_records(resp1, zone)
unique2, rrsets2 = self._axfr_records(resp2, zone)
self._axfr_diff_resp(unique1, rrsets1, unique2, rrsets2, server1, server2)
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