Commit 31ec8c6c authored by tingting shen's avatar tingting shen
Browse files

Added verbose options to exactly what is happening with loadzone. Added...

Added verbose options to exactly what is happening with loadzone. Added loadzone test suite of different file formats to load.

git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@2340 e5f2f494-b856-4b98-b285-d166d9295462
parent 0eb4e311
65. [func] shentingting
Added verbose options to exactly what is happening with loadzone.
Added loadzone test suite of different file formats to load.
(tingting-loadzone, svn r2339)
64. [func] jerry
Added python logging framework. It is for testing and experimenting
with logging ideas. Currently, it supports three channels(file,
......
......@@ -415,6 +415,8 @@ AC_CONFIG_FILES([Makefile
src/bin/cfgmgr/tests/Makefile
src/bin/host/Makefile
src/bin/loadzone/Makefile
src/bin/loadzone/tests/correct/Makefile
src/bin/loadzone/tests/error/Makefile
src/bin/msgq/Makefile
src/bin/msgq/tests/Makefile
src/bin/auth/Makefile
......@@ -464,6 +466,8 @@ AC_OUTPUT([src/bin/cfgmgr/b10-cfgmgr.py
src/bin/bindctl/bindctl-source.py
src/bin/bindctl/tests/bindctl_test
src/bin/loadzone/run_loadzone.sh
src/bin/loadzone/tests/correct/correct_test.sh
src/bin/loadzone/tests/error/error_test.sh
src/bin/loadzone/b10-loadzone.py
src/bin/usermgr/run_b10-cmdctl-usermgr.sh
src/bin/usermgr/b10-cmdctl-usermgr.py
......@@ -491,6 +495,8 @@ AC_OUTPUT([src/bin/cfgmgr/b10-cfgmgr.py
chmod +x src/bin/bindctl/tests/bindctl_test
chmod +x src/bin/bindctl/run_bindctl.sh
chmod +x src/bin/loadzone/run_loadzone.sh
chmod +x src/bin/loadzone/tests/correct/correct_test.sh
chmod +x src/bin/loadzone/tests/error/error_test.sh
chmod +x src/bin/usermgr/run_b10-cmdctl-usermgr.sh
chmod +x src/bin/msgq/run_msgq.sh
chmod +x src/bin/msgq/tests/msgq_test
......
SUBDIRS = tests/correct
SUBDIRS += tests/error
bin_SCRIPTS = b10-loadzone
CLEANFILES = b10-loadzone
......@@ -22,23 +24,27 @@ install-data-local:
$(mkinstalldirs) $(DESTDIR)/@localstatedir@/@PACKAGE@
# TODO: permissions handled later
EXTRA_DIST += testdata/README
EXTRA_DIST += testdata/dsset-subzone.example.com.
EXTRA_DIST += testdata/example.com
EXTRA_DIST += testdata/example.com.signed
EXTRA_DIST += testdata/Kexample.com.+005+04456.key
EXTRA_DIST += testdata/Kexample.com.+005+04456.private
EXTRA_DIST += testdata/Kexample.com.+005+33495.key
EXTRA_DIST += testdata/Kexample.com.+005+33495.private
EXTRA_DIST += testdata/Ksql1.example.com.+005+12447.key
EXTRA_DIST += testdata/Ksql1.example.com.+005+12447.private
EXTRA_DIST += testdata/Ksql1.example.com.+005+33313.key
EXTRA_DIST += testdata/Ksql1.example.com.+005+33313.private
EXTRA_DIST += testdata/Ksql2.example.com.+005+38482.key
EXTRA_DIST += testdata/Ksql2.example.com.+005+38482.private
EXTRA_DIST += testdata/Ksql2.example.com.+005+63192.key
EXTRA_DIST += testdata/Ksql2.example.com.+005+63192.private
EXTRA_DIST += testdata/sql1.example.com
EXTRA_DIST += testdata/sql1.example.com.signed
EXTRA_DIST += testdata/sql2.example.com
EXTRA_DIST += testdata/sql2.example.com.signed
EXTRA_DIST += tests/normal/README
EXTRA_DIST += tests/normal/dsset-subzone.example.com.
EXTRA_DIST += tests/normal/example.com
EXTRA_DIST += tests/normal/example.com.signed
EXTRA_DIST += tests/normal/Kexample.com.+005+04456.key
EXTRA_DIST += tests/normal/Kexample.com.+005+04456.private
EXTRA_DIST += tests/normal/Kexample.com.+005+33495.key
EXTRA_DIST += tests/normal/Kexample.com.+005+33495.private
EXTRA_DIST += tests/normal/Ksql1.example.com.+005+12447.key
EXTRA_DIST += tests/normal/Ksql1.example.com.+005+12447.private
EXTRA_DIST += tests/normal/Ksql1.example.com.+005+33313.key
EXTRA_DIST += tests/normal/Ksql1.example.com.+005+33313.private
EXTRA_DIST += tests/normal/Ksql2.example.com.+005+38482.key
EXTRA_DIST += tests/normal/Ksql2.example.com.+005+38482.private
EXTRA_DIST += tests/normal/Ksql2.example.com.+005+63192.key
EXTRA_DIST += tests/normal/Ksql2.example.com.+005+63192.private
EXTRA_DIST += tests/normal/sql1.example.com
EXTRA_DIST += tests/normal/sql1.example.com.signed
EXTRA_DIST += tests/normal/sql2.example.com
EXTRA_DIST += tests/normal/sql2.example.com.signed
pytest:
$(SHELL) tests/correct/correct_test.sh
$(SHELL) tests/error/error_test.sh
......@@ -19,7 +19,8 @@ import sys; sys.path.append ('@@PYTHONPATH@@')
import re, getopt
import isc.datasrc
from isc.datasrc.master import MasterFile
import time
import os
#########################################################################
# usage: print usage note and exit
#########################################################################
......@@ -57,23 +58,32 @@ def main():
if len(args) != 1:
usage()
zonefile = args[0]
verbose = os.isatty(sys.stdout.fileno())
try:
master = MasterFile(zonefile, initial_origin)
master = MasterFile(zonefile, initial_origin, verbose)
except Exception as e:
print("Error reading zone file: " + str(e))
sys.stderr.write("Error reading zone file: %s\n" % str(e))
exit(1)
try:
zone = master.zonename()
if verbose:
sys.stdout.write("Using SQLite3 database file %s\n" % dbfile)
sys.stdout.write("Zone name is %s\n" % zone)
sys.stdout.write("Loading file \"%s\"\n" % zonefile)
except Exception as e:
print("Error reading zone file: " + str(e))
sys.stdout.write("\n")
sys.stderr.write("Error reading zone file: %s\n" % str(e))
exit(1)
try:
isc.datasrc.sqlite3_ds.load(dbfile, zone, master.zonedata)
if verbose:
master.closeverbose()
sys.stdout.write("\nDone.\n")
except Exception as e:
print("Error loading database: " + str(e))
sys.stdout.write("\n")
sys.stderr.write("Error loading database: %s\n"% str(e))
exit(1)
if __name__ == "__main__":
......
PYTESTS = correct_test.sh
EXTRA_DIST = get_zonedatas.py
EXTRA_DIST += include.db
EXTRA_DIST += inclsub.db
EXTRA_DIST += known.test.out
EXTRA_DIST += mix1.db
EXTRA_DIST += mix1sub1.db
EXTRA_DIST += mix1sub2.db
EXTRA_DIST += mix2.db
EXTRA_DIST += mix2sub1.txt
EXTRA_DIST += mix2sub2.txt
EXTRA_DIST += ttl1.db
EXTRA_DIST += ttl2.db
EXTRA_DIST += ttlext.db
# later will have configure option to choose this, like: coverage run --branch
PYCOVERAGE = $(PYTHON)
# test using command-line arguments, so use check-local target instead of TESTS
check-local:
for pytest in $(PYTESTS) ; do \
echo Running test: $$pytest ; \
env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/bin/loadzone \
$(SHELL) $(abs_srcdir)/$$pytest ; \
done
#! /bin/sh
# Copyright (C) 2010 Internet Systems Consortium.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
PYTHON_EXEC=${PYTHON_EXEC:-@PYTHON@}
export PYTHON_EXEC
PYTHONPATH=@abs_top_builddir@/src/lib/python
export PYTHONPATH
LOADZONE_PATH=@abs_top_srcdir@/src/bin/loadzone
status=0
echo "Loadzone include. from include.db file"
cd ${LOADZONE_PATH}/tests/correct
${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3 include.db >> /dev/null
echo "loadzone ttl1. from ttl1.db file"
${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3 ttl1.db >> /dev/null
echo "loadzone ttl2. from ttl2.db file"
${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3 ttl2.db >> /dev/null
echo "loadzone mix1. from mix1.db"
${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3 mix1.db >> /dev/null
echo "loadzone mix2. from mix2.db"
${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3 mix2.db >> /dev/null
echo "loadzone ttlext. from ttlext.db"
${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3 ttlext.db >> /dev/null
echo "loadzone example.com. from example.db"
${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3 example.db >> /dev/null
echo "I:test master file \$INCLUDE semantics"
echo "I:test master file BIND 8 compatibility TTL and \$TTL semantics"
echo "I:test master file RFC1035 TTL and \$TTL semantics"
echo "I:test master file BIND8 compatibility and mixed \$INCLUDE with \$TTL semantics"
echo "I:test master file RFC1035 TTL and mixed \$INCLUDE with \$TTL semantics"
echo "I:test master file BIND9 extenstion of TTL"
echo "I:test master file RFC1035 missing CLASS, TTL, NAME semantics"
${PYTHON_EXEC} get_zonedatas.py > test.out
echo "Compare test results."
diff test.out known.test.out || status=1
echo "Clean tmp files."
rm -f zone.sqlite3
rm -f test.out
echo "I:exit status: $status"
echo "------------------------------------------------------------------------------"
echo "Ran 7 test files"
echo ""
if [ "$status" -eq 1 ] ;then
echo "ERROR"
else
echo "OK"
fi
exit $status
;This file includes all kinds of rr form. missing name, ttl and class or not.
$ORIGIN example.com.
$TTL 60
@ IN SOA ns1.example.com. hostmaster.example.com. (1 43200 900 1814400 7200)
IN 20 NS ns1
NS ns2
ns1 IN 30 A 192.168.1.102
70 NS ns3
IN NS ns4
10 IN MX 10 mail.example.com.
ns2 80 A 1.1.1.1
ns3 IN A 2.2.2.2
ns4 A 3.3.3.3
ns5 90 IN A 4.4.4.4
from isc.datasrc import sqlite3_ds
import sys
ZONE_FILE = "zone.sqlite3"
zonename_set = ["include.", "ttl1.", "ttl2.", "mix1.", "mix2.", "ttlext.", "example.com."]
for zone_name in zonename_set:
for rr_data in sqlite3_ds.get_zone_datas(zone_name, ZONE_FILE):
data_len = len(rr_data[2])
sys.stdout.write(rr_data[2] + '\t\t' + str(rr_data[4]) + '\tIN\t' + rr_data[5] + '\t' + rr_data[7] + '\n')
a 300 A 10.0.1.1
$ORIGIN foo
b 300 A 10.0.2.2
$ORIGIN include. ; initialize origin
$TTL 300
@ IN SOA ns hostmaster (
1 ; serial
3600
1800
1814400
3600
)
NS ns
ns A 127.0.0.1
a A 10.0.0.1
$INCLUDE inclsub.db sub ; a.include. is the relative domain name origin for the included file
; use the current domain name
A 99.99.99.99
b A 10.0.0.2
$ORIGIN b
$INCLUDE inclsub.db
; use the current domain name
A 10.0.0.99
c A 10.0.0.3
include. 300 IN SOA ns.include. hostmaster.include. 1 3600 1800 1814400 3600
include. 300 IN NS ns.include.
ns.include. 300 IN A 127.0.0.1
a.include. 300 IN A 10.0.0.1
a.sub.include. 300 IN A 10.0.1.1
b.foo.sub.include. 300 IN A 10.0.2.2
a.include. 300 IN A 99.99.99.99
b.include. 300 IN A 10.0.0.2
a.b.include. 300 IN A 10.0.1.1
b.foo.b.include. 300 IN A 10.0.2.2
b.include. 300 IN A 10.0.0.99
c.b.include. 300 IN A 10.0.0.3
ttl1. 3 IN SOA ns.ttl1. hostmaster.ttl1. 1 3600 1800 1814400 3
ttl1. 3 IN NS ns.ttl1.
ns.ttl1. 3 IN A 10.53.0.1
a.ttl1. 3 IN TXT "soa minttl 3"
b.ttl1. 2 IN TXT "explicit ttl 2"
c.ttl1. 3 IN TXT "soa minttl 3"
d.ttl1. 1 IN TXT "default ttl 1"
e.ttl1. 4 IN TXT "explicit ttl 4"
f.ttl1. 1 IN TXT "default ttl 1"
ttl2. 1 IN SOA ns.ttl2. hostmaster.ttl2. 1 3600 1800 1814400 3
ttl2. 1 IN NS ns.ttl2.
ns.ttl2. 1 IN A 10.53.0.1
a.ttl2. 1 IN TXT "inherited ttl 1"
b.ttl2. 2 IN TXT "explicit ttl 2"
c.ttl2. 2 IN TXT "inherited ttl 2"
d.ttl2. 3 IN TXT "default ttl 3"
e.ttl2. 2 IN TXT "explicit ttl 2"
f.ttl2. 3 IN TXT "default ttl 3"
mix1. 3 IN SOA ns.mix1. hostmaster.mix1. 1 3600 1800 1814400 3
mix1. 3 IN NS ns.mix1.
ns.mix1. 3 IN A 10.53.0.1
a.mix1. 3 IN TXT "soa minttl 3"
b.mix1. 2 IN TXT "explicit ttl 2"
a.mix1. 3 IN TXT "soa minttl 3"
b.foo.mix1. 3 IN TXT "soa minttl 3"
c.mix1. 3 IN TXT "soa minttl 3"
d.mix1. 1 IN TXT "default ttl 1"
e.mix1. 4 IN TXT "explicit ttl 4"
f.mix1. 1 IN TXT "default ttl 1"
i.mix1. 1 IN TXT "default ttl 1"
g.mix1. 5 IN TXT "default ttl 5"
h.mix1. 5 IN TXT "the include ttl 5"
mix2. 1 IN SOA ns.mix2. hostmaster.mix2. 1 3600 1800 1814400 3
mix2. 1 IN NS ns.mix2.
ns.mix2. 1 IN A 10.53.0.1
a.mix2. 1 IN TXT "inherited ttl 1"
h.mix2. 1 IN TXT "inherited ttl 1"
g.mix2. 6 IN TXT "inherited ttl 6"
b.mix2. 6 IN TXT "explicit ttl 6"
c.mix2. 2 IN TXT "inherited ttl 2"
m.mix2. 6 IN TXT "explicit ttl 6"
d.mix2. 3 IN TXT "default ttl 3"
e.mix2. 2 IN TXT "explicit ttl 2"
n.mix2. 3 IN TXT "default ttl 3"
f.mix2. 3 IN TXT "default ttl 3"
g.mix2. 5 IN TXT "default ttl 5"
f.mix2. 5 IN TXT "default ttl 5"
ttlext. 3 IN SOA ns.ttlext. hostmaster.ttlext. 1 3600 1800 1814400 3
ttlext. 3 IN NS ns.ttlext.
ns.ttlext. 3 IN A 10.53.0.1
a.ttlext. 3 IN TXT "soa minttl 3"
b.ttlext. 2 IN TXT "explicit ttl 2"
c.ttlext. 3 IN TXT "soa minttl 3"
d.ttlext. 600 IN TXT "default ttl 600"
e.ttlext. 4 IN TXT "explicit ttl 4"
f.ttlext. 600 IN TXT "default ttl 600"
example.com. 60 IN SOA ns1.example.com. hostmaster.example.com. 1 43200 900 1814400 7200
example.com. 20 IN NS ns1.example.com.
example.com. 60 IN NS ns2.example.com.
ns1.example.com. 30 IN A 192.168.1.102
ns1.example.com. 70 IN NS ns3.example.com.
ns1.example.com. 60 IN NS ns4.example.com.
ns1.example.com. 10 IN MX 10 mail.example.com.
ns2.example.com. 80 IN A 1.1.1.1
ns3.example.com. 60 IN A 2.2.2.2
ns4.example.com. 60 IN A 3.3.3.3
ns5.example.com. 90 IN A 4.4.4.4
; $Id: ttl1.db,v 1.6 2007/06/19 23:47:04 tbox Exp $
$ORIGIN mix1.
@ IN SOA ns hostmaster (
1 ; serial
3600
1800
1814400
3
)
NS ns
ns A 10.53.0.1
a TXT "soa minttl 3"
b 2 TXT "explicit ttl 2"
$INCLUDE mix1sub1.db
c TXT "soa minttl 3"
$TTL 1
d TXT "default ttl 1"
e 4 TXT "explicit ttl 4"
f TXT "default ttl 1"
$INCLUDE mix1sub2.db
h 5 TXT "the include ttl 5"
a TXT "soa minttl 3"
$ORIGIN foo
b TXT "soa minttl 3"
i TXT "default ttl 1"
$TTL 5
g TXT "default ttl 5"
$ORIGIN mix2.
@ 1 IN SOA ns hostmaster (
1 ; serial
3600
1800
1814400
3
)
NS ns
ns A 10.53.0.1
a TXT "inherited ttl 1"
$INCLUDE mix2sub1.txt
b TXT "explicit ttl 6"
c 2 TXT "inherited ttl 2"
m TXT "explicit ttl 6"
$TTL 3
d TXT "default ttl 3"
e 2 TXT "explicit ttl 2"
n TXT "default ttl 3"
$INCLUDE mix2sub2.txt
f TXT "default ttl 5"
h TXT "inherited ttl 1"
$TTL 6
g TXT "inherited ttl 6"
f TXT "default ttl 3"
$TTL 5
g TXT "default ttl 5"
$ORIGIN ttl1.
@ IN SOA ns hostmaster (
1 ; serial
3600
1800
1814400
3
)
NS ns
ns A 10.53.0.1
a TXT "soa minttl 3"
b 2 TXT "explicit ttl 2"
c TXT "soa minttl 3"
$TTL 1
d TXT "default ttl 1"
e 4 TXT "explicit ttl 4"
f TXT "default ttl 1"
$ORIGIN ttl2.
@ 1 IN SOA ns hostmaster (
1 ; serial
3600
1800
1814400
3
)
NS ns
ns A 10.53.0.1
a TXT "inherited ttl 1"
b 2 TXT "explicit ttl 2"
c TXT "inherited ttl 2"
$TTL 3 ; a new ttl
d TXT "default ttl 3"
e 2 TXT "explicit ttl 2"
f TXT "default ttl 3"
; $Id: ttl1.db,v 1.6 2007/06/19 23:47:04 tbox Exp $
$ORIGIN ttlext.
@ IN SOA ns hostmaster (
1 ; serial
3600
1800
1814400
3
)
NS ns
ns A 10.53.0.1
a TXT "soa minttl 3"
b 2S TXT "explicit ttl 2"
c TXT "soa minttl 3"
$TTL 10M ; bind9 extention ttl
d TXT "default ttl 600"
e 4 TXT "explicit ttl 4"
f TXT "default ttl 600"
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