From 6c871589b55600719a28bc59a6290b4cbc33dda1 Mon Sep 17 00:00:00 2001 From: Libor Peltan <libor.peltan@nic.cz> Date: Tue, 24 Jan 2017 14:40:32 +0100 Subject: [PATCH] test: huge rrset testcase: udp, tcp, axfr --- .../records/huge_rrset/data/example.com.zone | 17 ++++++ tests-extra/tests/records/huge_rrset/test.py | 57 +++++++++++++++++++ tests-extra/tools/dnstest/zonefile.py | 7 +++ 3 files changed, 81 insertions(+) create mode 100644 tests-extra/tests/records/huge_rrset/data/example.com.zone create mode 100644 tests-extra/tests/records/huge_rrset/test.py diff --git a/tests-extra/tests/records/huge_rrset/data/example.com.zone b/tests-extra/tests/records/huge_rrset/data/example.com.zone new file mode 100644 index 0000000000..171e65273e --- /dev/null +++ b/tests-extra/tests/records/huge_rrset/data/example.com.zone @@ -0,0 +1,17 @@ +$ORIGIN example.com. +$TTL 3600 + +@ SOA dns1.example.com. hostmaster.example.com. ( + 2010111213 ; serial + 6h ; refresh + 1h ; retry + 1w ; expire + 1d ) ; minimum + + NS dns1 + + +dns1 A 192.0.2.1 + +labs.example.com. IN A 0.0.0.0 +labs.example.com. IN DNAME rd.example.com. diff --git a/tests-extra/tests/records/huge_rrset/test.py b/tests-extra/tests/records/huge_rrset/test.py new file mode 100644 index 0000000000..e16e87a8c7 --- /dev/null +++ b/tests-extra/tests/records/huge_rrset/test.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 + +''' Test querying rset with too many rdata ''' + +import random +import dns.exception +import dns.rcode +import dns.tsig +from dnstest.utils import * +from dnstest.test import Test + +t = Test(tsig=False) + +master = t.server("knot") + +ZONE = "example.com." +HUGE = "huge.%s" % ZONE + +zone = t.zone(ZONE, storage=".") + +rndfix = random.randint(1, 65000) +for i in range(1, 3000): + zone[0].append_rndAAAA(HUGE, rndfix, i) + +t.link(zone, master) + +t.start() + +master.zone_wait(zone) + +resp = master.dig(HUGE, "AAAA", udp=True) +resp.check(rcode="NOERROR", flags="TC") +resp.check_count(0, section="answer") + +resp = master.dig(HUGE, "AAAA", udp=False) +resp.check(rcode="SERVFAIL", noflags="TC") +resp.check_count(0, section="answer") + +resp = master.dig(ZONE, "AXFR", tries=1, timeout=2) + +got_messages = 0 + +for msg in resp.resp: + got_messages += 1 + if got_messages is 1: + isset(msg.rcode() == dns.rcode.NOERROR, "NOERROR") + elif got_messages is 2: + isset(msg.rcode() == dns.rcode.SERVFAIL, "SERVFAIL") + break + else: + break + +if got_messages != 2: + set_err("AXFR MSGCOUNT") + detail_log("!AXFR message count: %i != 1" % got_messages) + +t.end() diff --git a/tests-extra/tools/dnstest/zonefile.py b/tests-extra/tools/dnstest/zonefile.py index 34946b0cd4..48760dc06d 100644 --- a/tests-extra/tools/dnstest/zonefile.py +++ b/tests-extra/tools/dnstest/zonefile.py @@ -252,6 +252,13 @@ class ZoneFile(object): os.remove(old_name) + def append_rndAAAA(self, owner, rnd1=random.randint(1, 65000), rnd2=random.randint(1, 65000)): + '''Append AAAA record with owner owner and random IPv6''' + + with open(self.path, "a") as file: + file.write("%s IN AAAA dead:beef:dead:beef:dead:beef:%04x:%04x\n" % + (owner, rnd1, rnd2)) + def remove(self): '''Remove zone file.''' -- GitLab