Skip to content
Snippets Groups Projects
Commit ff23ec47 authored by Jan Kadlec's avatar Jan Kadlec
Browse files

tests-extra: Test for SOA events.

parent c807266b
No related branches found
No related tags found
No related merge requests found
$ORIGIN example.
$TTL 3600
@ SOA dns1 hostmaster 1 1 1 3 600
NS dns1
dns1 A 192.0.2.1
$ORIGIN example.
$TTL 3600
@ SOA dns1 hostmaster 2 10 1 3 600
NS dns1
dns1 A 192.0.2.1
#!/usr/bin/env python3
'''Test to end all tests'''
from dnstest.utils import *
from dnstest.test import Test
EXPIRE_SLEEP = 5
def test_refresh(slave):
resp = slave.dig("example.", "SOA")
resp.check(rcode="NOERROR")
t.sleep(EXPIRE_SLEEP)
resp = slave.dig("example.", "SOA")
resp.check(rcode="NOERROR")
def test_expire(slave):
resp = slave.dig("example.", "SOA")
resp.check(rcode="NOERROR")
t.sleep(EXPIRE_SLEEP)
resp = slave.dig("example.", "SOA")
resp.check(rcode="SERVFAIL")
t = Test()
master = t.server("bind")
slave = t.server("knot")
slave.max_conn_idle = "1s"
# this zone has refresh = 1s, retry = 1s and expire = 1s + 2s for connection timeouts
zone = t.zone("example.", storage=".")
t.link(zone, master, slave)
t.start()
slave.zone_wait(zone)
#test that zone does not expire when master is alive
test_refresh(slave)
master.stop()
#test that zone does expire when master is down
test_expire(slave)
#update master zone file with 10s refresh in SOA
master.update_zonefile(zone, version=1)
master.start()
slave.zone_wait(zone) #this has to work - retry is 1s
slave.flush()
#zone should expire, because refresh < expire
test_expire(slave)
#switch server roles, slave becomes master - there should be no expire
master.stop()
slave.zones = {}
master.zones = {}
t.link(zone, slave)
t.generate_conf()
slave.reload()
slave.zone_wait(zone)
t.sleep(EXPIRE_SLEEP)
slave.zone_wait(zone)
#switch again - zone should expire now
slave.zones = {}
t.link(zone, master, slave)
t.generate_conf()
slave.reload()
test_expire(slave)
t.stop()
......@@ -139,6 +139,7 @@ class Server(object):
self.ratelimit = None
self.disable_any = None
self.max_conn_idle = None
self.ip = None
self.addr = None
......@@ -199,7 +200,7 @@ class Server(object):
'''Set the server as a slave for the zone'''
if zone.name in self.zones:
raise Exception("Can't set zone='%s' as a slave" % name)
raise Exception("Can't set zone='%s' as a slave" % zone.name)
slave_file = zone.clone(self.dir + "/slave", exists=False)
z = Zone(slave_file, ddns, ixfr)
......@@ -815,6 +816,8 @@ class Knot(Server):
self._on_str_hex(s, "nsid", self.nsid)
self._on_str_hex(s, "rate-limit", self.ratelimit)
s.item_str("rundir", self.dir)
if (self.max_conn_idle):
s.item("max-conn-idle", self.max_conn_idle)
s.end()
s.begin("control")
......
......@@ -106,7 +106,7 @@ class Test(object):
elif server == "dummy":
srv = dnstest.server.Dummy()
else:
raise Exception("Usupported server '%s'" % server)
raise Exception("Unsupported server '%s'" % server)
type(srv).count += 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment