Commit 65b3d037 authored by Jan Včelák's avatar Jan Včelák 🚀

tests-extra: zone expiration by broken AXFR

parent a78c33a8
$ORIGIN example.
$TTL 1200
@ SOA ns admin 42 1 1 8 600
ns AAAA ::0
$ORIGIN example.
$TTL 1200
@ SOA ns admin 4242 1 1 8 600
ns AAAA ::0
#!/usr/bin/env python3
'''Test zone expiration by master shutdown or broken AXFR.'''
from dnstest.test import Test
def test_expire(zone, server):
resp = server.dig(zone[0].name, "SOA")
resp.check(rcode="SERVFAIL")
def break_xfrout(server):
with open(server.confile, "r+") as f:
config = f.read()
f.seek(0)
f.truncate()
config = config.replace("xfr-out ", "#xfr-out ")
f.write(config)
t = Test(tsig=False)
# this zone has refresh = 1s, retry = 1s and expire = 10s + 2s for connection timeouts
zone = t.zone("example.", storage=".")
EXPIRE_SLEEP = 15
master = t.server("knot")
slave = t.server("knot")
slave.max_conn_idle = "1s"
t.link(zone, master, slave)
t.start()
master.zone_wait(zone)
slave.zone_wait(zone)
# expire by shutting down the master
master.stop()
t.sleep(EXPIRE_SLEEP);
test_expire(zone, slave)
# bring back master (notifies slave)
master.start()
master.zone_wait(zone)
slave.zone_wait(zone)
# expire by breaking AXFR
break_xfrout(master)
master.update_zonefile(zone, version=1)
master.reload()
t.sleep(EXPIRE_SLEEP);
test_expire(zone, slave)
t.stop()
......@@ -391,7 +391,7 @@ class Server(object):
def gen_confile(self):
f = open(self.confile, mode="w")
f.write(self.get_config())
f.close
f.close()
  • 👍 I guess this is why we had to have a sleep after generating configs.

Please register or sign in to reply
def dig(self, rname, rtype, rclass="IN", udp=None, serial=None,
timeout=None, tries=3, flags="", bufsize=None, edns=None,
......
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