Commit ef5e59d9 authored by Grigorii Demidov's avatar Grigorii Demidov

pydnstest/scenario: support for mandatory entries; sets/resilver: test for...

pydnstest/scenario: support for mandatory entries; sets/resilver: test for iteration over whole ns list
parent edb2b285
......@@ -159,6 +159,8 @@ class Entry:
self.raw_data_pending = False
self.raw_data = None
self.lineno = lineno
self.mandatory = False
self.fired = 0;
def match_part(self, code, msg):
""" Compare scripted reply to given message using single criteria. """
......@@ -367,6 +369,9 @@ class Entry:
section.append(rr)
def set_mandatory(self):
self.mandatory = True
class Range:
"""
Range represents a set of scripted queries valid for given step range.
......@@ -385,6 +390,9 @@ class Range:
def __del__(self):
dtag = '[ RANGE %d-%d ] %s' % (self.a, self.b, self.address)
dprint(dtag, 'received: %d sent: %d' % (self.received, self.sent))
for e in self.stored:
if e.mandatory is True and e.fired == 0:
raise Exception('Mandatory section at line %d is not fired' % e.lineno)
def add(self, entry):
""" Append a scripted response to the range"""
......@@ -408,6 +416,7 @@ class Range:
if random.random() < float(self.args['LOSS']):
return None
self.sent += 1
candidate.fired += 1
return resp
except Exception as e:
pass
......@@ -747,6 +756,8 @@ def parse_entry(op, args, file_in, in_entry = False):
out.begin_raw()
elif op == 'TSIG':
out.use_tsig(args)
elif op == 'MANDATORY':
out.set_mandatory()
else:
out.add_record(op, args)
return out
......
; config options
server:
stub-addr: 193.0.14.129 # K.ROOT-SERVERS.NET.
CONFIG_END
SCENARIO_BEGIN Iteration over ns server list.
; K.ROOT-SERVERS.NET.
RANGE_BEGIN 0 100
ADDRESS 193.0.14.129
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR NOERROR
SECTION QUESTION
. IN NS
SECTION ANSWER
. IN NS K.ROOT-SERVERS.NET.
SECTION ADDITIONAL
K.ROOT-SERVERS.NET. IN A 193.0.14.129
ENTRY_END
ENTRY_BEGIN
MATCH opcode subdomain
ADJUST copy_id copy_query
REPLY QR NOERROR
SECTION QUESTION
com. IN A
SECTION AUTHORITY
com. IN NS a.gtld-servers.net.
SECTION ADDITIONAL
a.gtld-servers.net. IN A 192.5.6.30
ENTRY_END
RANGE_END
; a.gtld-servers.net.
RANGE_BEGIN 0 100
ADDRESS 192.5.6.30
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR NOERROR
SECTION QUESTION
com. IN NS
SECTION ANSWER
com. IN NS a.gtld-servers.net.
SECTION ADDITIONAL
a.gtld-servers.net. IN A 192.5.6.30
ENTRY_END
ENTRY_BEGIN
MATCH opcode subdomain
ADJUST copy_id copy_query
REPLY QR NOERROR
SECTION QUESTION
example.com. IN A
SECTION AUTHORITY
example.com. IN NS ns1.example.com.
example.com. IN NS ns2.example.com.
example.com. IN NS ns3.example.com.
SECTION ADDITIONAL
ns1.example.com. IN A 1.2.3.4
ns2.example.com. IN A 1.2.3.5
ns3.example.com. IN A 1.2.3.6
ENTRY_END
RANGE_END
; ns1.example.com.
RANGE_BEGIN 0 100
ADDRESS 1.2.3.4
ENTRY_BEGIN
MANDATORY
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR AA REFUSED
SECTION QUESTION
www.example.com. IN A
SECTION ANSWER
SECTION AUTHORITY
SECTION ADDITIONAL
ENTRY_END
RANGE_END
; ns2.example.com.
RANGE_BEGIN 0 100
ADDRESS 1.2.3.5
ENTRY_BEGIN
MANDATORY
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR AA REFUSED
SECTION QUESTION
www.example.com. IN A
SECTION ANSWER
SECTION AUTHORITY
SECTION ADDITIONAL
ENTRY_END
RANGE_END
; ns3.example.com.
RANGE_BEGIN 0 100
ADDRESS 1.2.3.6
ENTRY_BEGIN
MANDATORY
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR AA REFUSED
SECTION QUESTION
www.example.com. IN A
SECTION ANSWER
SECTION AUTHORITY
SECTION ADDITIONAL
ENTRY_END
RANGE_END
STEP 1 QUERY
ENTRY_BEGIN
REPLY RD DO
SECTION QUESTION
www.example.com. IN A
ENTRY_END
; recursion happens here.
STEP 10 CHECK_ANSWER
ENTRY_BEGIN
MATCH opcode qname flags rcode question
REPLY QR RD RA DO SERVFAIL
SECTION QUESTION
www.example.com. IN A
SECTION ANSWER
SECTION AUTHORITY
SECTION ADDITIONAL
ENTRY_END
SCENARIO_END
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