Commit 08915b38 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[1371] updated test data with diffs

parent 1d4541df
#!/usr/bin/env python3.1
import isc.datasrc
import isc.log
from isc.dns import *
isc.log.init("dummy") # XXX
ZONE_NAME = Name('example.com')
NS_NAME = Name('a.dns.example.com')
def create_a(address, ttl=3600):
rrset = RRset(NS_NAME, RRClass.IN(), RRType.A(), RRTTL(ttl))
rrset.add_rdata(Rdata(RRType.A(), RRClass.IN(), address))
return rrset
def create_aaaa(address):
rrset = RRset(NS_NAME, RRClass.IN(), RRType.AAAA(), RRTTL(3600))
rrset.add_rdata(Rdata(RRType.AAAA(), RRClass.IN(), address))
return rrset
def create_ns(name):
rrset = RRset(ZONE_NAME, RRClass.IN(), RRType.NS(), RRTTL(3600))
rrset.add_rdata(Rdata(RRType.NS(), RRClass.IN(), name))
return rrset
def create_soa(serial):
rrset = RRset(ZONE_NAME, RRClass.IN(), RRType.SOA(), RRTTL(3600))
rdata_str = 'master.example.com. admin.example.com. ' + \
str(serial) + ' 3600 1800 2419200 7200'
rrset.add_rdata(Rdata(RRType.SOA(), RRClass.IN(), rdata_str))
return rrset
client = isc.datasrc.DataSourceClient('sqlite3',
'{ "database_file": "test.sqlite3" }')
# Install the initial data
updater = client.get_updater(ZONE_NAME, True)
updater.add_rrset(create_soa(2011111802))
updater.add_rrset(create_ns('a.dns.example.com.'))
updater.add_rrset(create_a('192.0.2.53'))
updater.add_rrset(create_aaaa('2001:db8::1'))
updater.commit()
# Incremental update to generate diffs
updater = client.get_updater(ZONE_NAME, False, True)
updater.delete_rrset(create_soa(2011111802))
updater.add_rrset(create_soa(2011111900))
updater.add_rrset(create_a('192.0.2.2', 7200))
updater.delete_rrset(create_soa(2011111900))
updater.delete_rrset(create_a('192.0.2.53'))
updater.delete_rrset(create_aaaa('2001:db8::1'))
updater.add_rrset(create_soa(2011112001))
updater.add_rrset(create_a('192.0.2.1'))
updater.commit()
;; This is the source of a zone stored in test.sqlite3. It's provided
;; for reference purposes only.
example.com. 3600 IN SOA a.dns.example.com. mail.example.com. 1 1 1 1 1
example.com. 3600 IN SOA master.example.com. admin.example.com. 2011112001 3600 1800 2419200 7200
example.com. 3600 IN NS a.dns.example.com.
a.dns.example.com. 3600 IN A 192.0.2.1
a.dns.example.com. 7200 IN A 192.0.2.2
......@@ -42,7 +42,7 @@ IXFR_NG_VERSION = 2011112800
# SOA intended to be used for the new SOA as a result of transfer.
soa_rdata = Rdata(RRType.SOA(), TEST_RRCLASS,
'master.example.com. admin.example.com ' +
'1234 3600 1800 2419200 7200')
'2011112001 3600 1800 2419200 7200')
soa_rrset = RRset(TEST_ZONE_NAME, TEST_RRCLASS, RRType.SOA(), RRTTL(3600))
soa_rrset.add_rdata(soa_rdata)
......@@ -88,10 +88,7 @@ class MockDataSrcClient:
def __create_soa(self):
soa_rrset = RRset(self._zone_name, RRClass.IN(), RRType.SOA(),
RRTTL(3600))
soa_rrset.add_rdata(Rdata(RRType.SOA(), RRClass.IN(),
'master.example.com. ' +
'admin.example.com. 1234 ' +
'3600 1800 2419200 7200'))
soa_rrset.add_rdata(soa_rdata)
return soa_rrset
def find_zone(self, zone_name):
......@@ -284,12 +281,9 @@ class TestXfroutSessionBase(unittest.TestCase):
{})
self.set_request_type(RRType.AXFR()) # test AXFR by default
self.mdata = self.create_request_data()
self.soa_rrset = RRset(Name('example.com'), RRClass.IN(), RRType.SOA(),
self.soa_rrset = RRset(TEST_ZONE_NAME, RRClass.IN(), RRType.SOA(),
RRTTL(3600))
self.soa_rrset.add_rdata(Rdata(RRType.SOA(), RRClass.IN(),
'master.Example.com. ' +
'admin.exAmple.com. ' +
'1234 3600 1800 2419200 7200'))
self.soa_rrset.add_rdata(soa_rdata)
# some test replaces a module-wide function. We should ensure the
# original is used elsewhere.
self.orig_get_rrset_len = xfrout.get_rrset_len
......@@ -542,7 +536,7 @@ class TestXfroutSession(TestXfroutSessionBase):
RRTTL(3600))
soa_rrset.add_rdata(Rdata(RRType.SOA(), RRClass.IN(),
'master.Example.com. admin.exAmple.com. ' +
'1234 3600 1800 2419200 7200'))
'2011112001 3600 1800 2419200 7200'))
msg.add_rrset(Message.SECTION_ANSWER, soa_rrset)
self.xfrsess._send_message(self.sock, msg)
send_out_data = self.sock.readsent()[2:]
......
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