diff --git a/tests-extra/tests/zone/expire/data/example.zone b/tests-extra/tests/zone/expire/data/example.zone new file mode 100644 index 0000000000000000000000000000000000000000..2fbcf4bc4b9daad20d6678d647de1aaa0bcf1b0e --- /dev/null +++ b/tests-extra/tests/zone/expire/data/example.zone @@ -0,0 +1,5 @@ +$ORIGIN example. +$TTL 1200 + +@ SOA ns admin 42 1 1 8 600 +ns AAAA ::0 diff --git a/tests-extra/tests/zone/expire/data/example.zone.1 b/tests-extra/tests/zone/expire/data/example.zone.1 new file mode 100644 index 0000000000000000000000000000000000000000..0c22c7a1742611eb76222bb438e3211b47248f71 --- /dev/null +++ b/tests-extra/tests/zone/expire/data/example.zone.1 @@ -0,0 +1,5 @@ +$ORIGIN example. +$TTL 1200 + +@ SOA ns admin 4242 1 1 8 600 +ns AAAA ::0 diff --git a/tests-extra/tests/zone/expire/test.py b/tests-extra/tests/zone/expire/test.py new file mode 100644 index 0000000000000000000000000000000000000000..4a1469bbe7708f576068286ad007637007486131 --- /dev/null +++ b/tests-extra/tests/zone/expire/test.py @@ -0,0 +1,53 @@ +#!/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() diff --git a/tests-extra/tools/dnstest/server.py b/tests-extra/tools/dnstest/server.py index 05d69e7f0007a104e9e9cc155ecc0a2d4aec5b30..4ec22f957a0356e87266b3f7fc2a9521ca280b3f 100644 --- a/tests-extra/tools/dnstest/server.py +++ b/tests-extra/tools/dnstest/server.py @@ -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() def dig(self, rname, rtype, rclass="IN", udp=None, serial=None, timeout=None, tries=3, flags="", bufsize=None, edns=None,