Parcourir la source

[2380] replaced old loadzone with the new one.

test parameters were adjusted accordingly.
there are some non trivial adjustments needed for the 'correct' test
cases for the original loadzone:
- completing the origin for some RDATA paramaeters (NS, SOA) does not
  work yet until we complete the RDATA support.  At the moment
  I made them FQDNs with comments
- a few TXT data were actually incorrect in the original tests, which
  caused a seeming regression.  I fixed the test data.
- there was one real bug in the $INCLUDE + origin support.  I'll go
  fix it; right now it fails

The 'error' test cases for the original loadzone also fail, but overall
the intended behavior looked preserved.  Fixing the tests to make it pass
seems to be quite difficult (because log output are different, and
the new loadzone ng is more verbose), so I plan to simply remove these
tests.
JINMEI Tatuya il y a 12 ans
Parent
commit
2b23275bd5

+ 2 - 0
configure.ac

@@ -1177,6 +1177,8 @@ AC_CONFIG_FILES([Makefile
                  src/bin/dbutil/tests/testdata/Makefile
                  src/bin/loadzone/Makefile
                  src/bin/loadzone/tests/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

+ 1 - 13
src/bin/loadzone/Makefile.am

@@ -1,16 +1,11 @@
-#SUBDIRS = . tests/correct tests/error  <= TBD: clean this up later
 SUBDIRS = . tests
 bin_SCRIPTS = b10-loadzone
-# tentative setup: clean this up:
-bin_SCRIPTS += b10-loadzone-ng
 noinst_SCRIPTS = run_loadzone.sh
 
 nodist_pylogmessage_PYTHON = $(PYTHON_LOGMSGPKG_DIR)/work/loadzone_messages.py
 pylogmessagedir = $(pyexecdir)/isc/log_messages/
 
 CLEANFILES = b10-loadzone
-# tentative setup: clean this up:
-CLEANFILES += b10-loadzone-ng
 CLEANFILES += $(PYTHON_LOGMSGPKG_DIR)/work/loadzone_messages.py
 CLEANFILES += $(PYTHON_LOGMSGPKG_DIR)/work/loadzone_messages.pyc
 
@@ -36,14 +31,7 @@ $(PYTHON_LOGMSGPKG_DIR)/work/loadzone_messages.py : loadzone_messages.mes
 	$(top_builddir)/src/lib/log/compiler/message \
 	-d $(PYTHON_LOGMSGPKG_DIR)/work -p $(srcdir)/loadzone_messages.mes
 
-b10-loadzone: b10-loadzone.py
-	$(SED) -e "s|@@PYTHONPATH@@|@pyexecdir@|" \
-	       -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" \
-	       -e "s|@@LIBEXECDIR@@|$(pkglibexecdir)|" b10-loadzone.py >$@
-	chmod a+x $@
-
-# tentatively named "-ng".
-b10-loadzone-ng: loadzone.py $(PYTHON_LOGMSGPKG_DIR)/work/loadzone_messages.py
+b10-loadzone: loadzone.py $(PYTHON_LOGMSGPKG_DIR)/work/loadzone_messages.py
 	$(SED) -e "s|@@PYTHONPATH@@|@pyexecdir@|" loadzone.py >$@
 	chmod a+x $@
 

+ 2 - 0
src/bin/loadzone/tests/Makefile.am

@@ -1,3 +1,5 @@
+SUBDIRS = . correct error
+
 PYCOVERAGE_RUN=@PYCOVERAGE_RUN@
 PYTESTS = loadzone_test.py
 

+ 9 - 8
src/bin/loadzone/tests/correct/correct_test.sh.in

@@ -28,28 +28,29 @@ TEST_OUTPUT_PATH=@abs_top_builddir@/src/bin/loadzone//tests/correct
 status=0
 echo "Loadzone include. from include.db file"
 cd ${TEST_FILE_PATH}
-${LOADZONE_PATH}/b10-loadzone -d ${TEST_OUTPUT_PATH}/zone.sqlite3 include.db >> /dev/null
+-c '{"database_file": "'${TEST_OUTPUT_PATH}/zone.sqlite3'"}'
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'${TEST_OUTPUT_PATH}/zone.sqlite3'"}' include. include.db >> /dev/null
 
 echo "loadzone  ttl1. from ttl1.db file"
-${LOADZONE_PATH}/b10-loadzone -d ${TEST_OUTPUT_PATH}/zone.sqlite3 ttl1.db >> /dev/null
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'${TEST_OUTPUT_PATH}/zone.sqlite3'"}' ttl1. ttl1.db >> /dev/null
 
 echo "loadzone ttl2. from ttl2.db file"
-${LOADZONE_PATH}/b10-loadzone -d ${TEST_OUTPUT_PATH}/zone.sqlite3 ttl2.db >> /dev/null
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'${TEST_OUTPUT_PATH}/zone.sqlite3'"}' ttl2. ttl2.db >> /dev/null
 
 echo "loadzone mix1. from mix1.db"
-${LOADZONE_PATH}/b10-loadzone -d ${TEST_OUTPUT_PATH}/zone.sqlite3 mix1.db >> /dev/null
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'${TEST_OUTPUT_PATH}/zone.sqlite3'"}' mix1. mix1.db >> /dev/null
 
 echo "loadzone mix2. from mix2.db"
-${LOADZONE_PATH}/b10-loadzone -d ${TEST_OUTPUT_PATH}/zone.sqlite3 mix2.db >> /dev/null
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'${TEST_OUTPUT_PATH}/zone.sqlite3'"}' mix2. mix2.db >> /dev/null
 
 echo "loadzone ttlext. from ttlext.db"
-${LOADZONE_PATH}/b10-loadzone -d ${TEST_OUTPUT_PATH}/zone.sqlite3 ttlext.db >> /dev/null
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'${TEST_OUTPUT_PATH}/zone.sqlite3'"}' ttlext. ttlext.db >> /dev/null
 
 echo "loadzone example.com. from example.db"
-${LOADZONE_PATH}/b10-loadzone -d ${TEST_OUTPUT_PATH}/zone.sqlite3 example.db >> /dev/null
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'${TEST_OUTPUT_PATH}/zone.sqlite3'"}' example.com. example.db >> /dev/null
 
 echo "loadzone comment.example.com. from comment.db"
-${LOADZONE_PATH}/b10-loadzone -d ${TEST_OUTPUT_PATH}/zone.sqlite3 comment.db >> /dev/null
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'${TEST_OUTPUT_PATH}/zone.sqlite3'"}' comment.example.com. comment.db >> /dev/null
 
 echo "I:test master file \$INCLUDE semantics"
 echo "I:test master file BIND 8 compatibility TTL and \$TTL semantics"

+ 10 - 4
src/bin/loadzone/tests/correct/example.db

@@ -2,11 +2,17 @@
 $ORIGIN example.com.
 $TTL 60
 @    IN SOA   ns1.example.com. hostmaster.example.com. (1 43200 900 1814400 7200)
-     IN     20      NS  ns1
-                    NS  ns2
+; these need #2390
+;     IN     20      NS  ns1
+;                    NS  ns2
+     IN     20      NS  ns1.example.com.
+                    NS  ns2.example.com.
 ns1  IN     30      A   192.168.1.102
-            70      NS  ns3
-     IN             NS  ns4
+; these need #2390
+;            70      NS  ns3
+;     IN             NS  ns4
+            70      NS  ns3.example.com.
+     IN             NS  ns4.example.com.
      10     IN      MX  10  mail.example.com.
 ns2         80      A   1.1.1.1
 ns3  IN             A   2.2.2.2

+ 6 - 2
src/bin/loadzone/tests/correct/include.db

@@ -1,13 +1,17 @@
 $ORIGIN include.   ; initialize origin
 $TTL 300
-@			IN SOA	ns hostmaster (
+; this needs #2500
+;@			IN SOA	ns hostmaster (
+@			IN SOA	ns.include. hostmaster.include. (
 				1        ; serial
 				3600
 				1800
 				1814400
 				3600
 				)
-			NS	ns
+; this needs #2390
+;			NS	ns
+			NS	ns.include.
 
 ns			A	127.0.0.1
 

+ 6 - 2
src/bin/loadzone/tests/correct/mix1.db

@@ -1,12 +1,16 @@
 $ORIGIN mix1.
-@			IN SOA	ns hostmaster (
+; this needs #2500
+;@			IN SOA	ns hostmaster (
+@			IN SOA	ns.mix1. hostmaster.mix1. (
 				1        ; serial
 				3600
 				1800
 				1814400
 				3
 				)
-			NS	ns
+; this needs #2390
+;			NS	ns
+			NS	ns.mix1.
 ns			A	10.53.0.1
 a			TXT	"soa minttl 3"
 b		2	TXT	"explicit ttl 2"

+ 6 - 2
src/bin/loadzone/tests/correct/mix2.db

@@ -1,12 +1,16 @@
 $ORIGIN mix2.
-@		1	IN SOA	ns hostmaster (
+; this needs #2500
+;@		1	IN SOA	ns hostmaster (
+@		1	IN SOA	ns.mix2. hostmaster.mix2. (
 				1        ; serial
 				3600
 				1800
 				1814400
 				3
 				)
-			NS	ns
+; this needs #2390
+;			NS	ns
+			NS	ns.mix2.
 ns			A	10.53.0.1
 a			TXT	"inherited ttl 1"
 $INCLUDE mix2sub1.txt

+ 2 - 2
src/bin/loadzone/tests/correct/mix2sub2.txt

@@ -1,3 +1,3 @@
-f                       TXT     "default  ttl 3"
+f                       TXT     "default ttl 3"
 $TTL 5
-g                       TXT     "default  ttl 5"
+g                       TXT     "default ttl 5"

+ 6 - 2
src/bin/loadzone/tests/correct/ttl1.db

@@ -1,12 +1,16 @@
 $ORIGIN ttl1.
-@			IN SOA	ns hostmaster (
+; this needs #2500
+;@			IN SOA	ns hostmaster (
+@			IN SOA	ns.ttl1. hostmaster.ttl1. (
 				1        ; serial
 				3600
 				1800
 				1814400
 				3
 				)
-			NS	ns
+; this needs #2390
+;			NS	ns
+			NS	ns.ttl1.
 ns			A	10.53.0.1
 a			TXT	"soa minttl 3"
 b		2	TXT	"explicit ttl 2"

+ 6 - 2
src/bin/loadzone/tests/correct/ttl2.db

@@ -1,12 +1,16 @@
 $ORIGIN ttl2.
-@		1	IN SOA	ns hostmaster (
+; this needs #2500
+;@		1	IN SOA	ns hostmaster (
+@		1	IN SOA	ns.ttl2. hostmaster.ttl2 (
 				1        ; serial
 				3600
 				1800
 				1814400
 				3
 				)
-			NS	ns
+; this needs #2390
+;			NS	ns
+			NS	ns.ttl2.
 ns			A	10.53.0.1
 a			TXT	"inherited ttl 1"
 b		2	TXT	"explicit ttl 2"

+ 6 - 2
src/bin/loadzone/tests/correct/ttlext.db

@@ -1,12 +1,16 @@
 $ORIGIN ttlext.
-@			IN SOA	ns hostmaster (
+; this needs #2500
+;@			IN SOA	ns hostmaster (
+@			IN SOA	ns.ttlext. hostmaster.ttlext. (
 				1        ; serial
 				3600
 				1800
 				1814400
 				3
 				)
-			NS	ns
+; this needs #2390
+;			NS	ns
+			NS	ns.ttlext.
 ns			A	10.53.0.1
 a			TXT	"soa minttl 3"
 b		2S	TXT	"explicit ttl 2"

+ 23 - 13
src/bin/loadzone/tests/error/error_test.sh.in

@@ -32,42 +32,52 @@ status=0
 
 echo "PYTHON PATH: $PYTHONPATH"
 
-echo "Test no \$ORIGIN error in zone file"
-${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3  ${TEST_FILE_PATH}/originerr1.db 1> /dev/null 2> error.out
-${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3  ${TEST_FILE_PATH}/originerr2.db 1> /dev/null 2>> error.out
+# This error cannot happen for the new loadzone as it requires the origin
+# as a command line argument.
+#echo "Test no \$ORIGIN error in zone file"
+#${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'zone.sqlite3'"}' ${TEST_FILE_PATH}/originerr1.db 1> /dev/null 2> error.out
+#${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'zone.sqlite3'"}' ${TEST_FILE_PATH}/originerr2.db 1> /dev/null 2>> error.out
 
 echo "Test: key word TTL spell error"
-${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3  ${TEST_FILE_PATH}/keyerror1.db 1> /dev/null 2>> error.out
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'zone.sqlite3'"}' \
+	com. ${TEST_FILE_PATH}/keyerror1.db 1> /dev/null 2>> error.out
 
 echo "Test: key word ORIGIN spell error"
-${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3  ${TEST_FILE_PATH}/keyerror2.db 1> /dev/null 2>> error.out
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'zone.sqlite3'"}' com. \
+	${TEST_FILE_PATH}/keyerror2.db 1> /dev/null 2>> error.out
 
 echo "Test: key INCLUDE spell error"
-${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3  ${TEST_FILE_PATH}/keyerror3.db 1> /dev/null 2>> error.out
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'zone.sqlite3'"}' com. \
+	${TEST_FILE_PATH}/keyerror3.db 1> /dev/null 2>> error.out
 
 echo "Test: include formal error, miss filename"
-${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3  ${TEST_FILE_PATH}/formerr1.db 1> /dev/null 2>>error.out
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'zone.sqlite3'"}' com. \
+	${TEST_FILE_PATH}/formerr1.db 1> /dev/null 2>>error.out
 
 echo "Test: include form error, domain is not absolute"
-${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3  ${TEST_FILE_PATH}/formerr2.db 1> /dev/null 2>> error.out
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'zone.sqlite3'"}' com. \
+	${TEST_FILE_PATH}/formerr2.db 1> /dev/null 2>> error.out
 
 echo "Test: TTL form error, no ttl value"
-${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3  ${TEST_FILE_PATH}/formerr3.db 1> /dev/null 2>> error.out
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'zone.sqlite3'"}' com. \
+	${TEST_FILE_PATH}/formerr3.db 1> /dev/null 2>> error.out
 
 echo "Test: TTL form error, ttl value error"
-${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3  ${TEST_FILE_PATH}/formerr4.db 1> /dev/null 2>> error.out
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'zone.sqlite3'"}' com. ${TEST_FILE_PATH}/formerr4.db 1> /dev/null 2>> error.out
 
 echo "Test: rr form error, no type"
-${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3  ${TEST_FILE_PATH}/formerr5.db 1> /dev/null 2>> error.out
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'zone.sqlite3'"}' com. \
+	${TEST_FILE_PATH}/formerr5.db 1> /dev/null 2>> error.out
 
 echo "Test: zone file is bogus"
 # since bogusfile doesn't exist anyway, we *don't* specify the directory
-${LOADZONE_PATH}/b10-loadzone -d zone.sqlite3  bogusfile 1> /dev/null 2>> error.out
+${LOADZONE_PATH}/b10-loadzone -c '{"database_file": "'zone.sqlite3'"}' . \
+	bogusfile 1> /dev/null 2>> error.out
 
 diff error.out ${TEST_FILE_PATH}/error.known || status=1
 
 echo "Clean tmp file."
-rm -f error.out
+#rm -f error.out
 rm -f zone.sqlite3
 
 echo "I:exit status:$status"

+ 2 - 2
tests/system/bindctl/setup.sh

@@ -22,5 +22,5 @@ SUBTEST_TOP=${TEST_TOP}/bindctl
 cp ${SUBTEST_TOP}/nsx1/b10-config.db.template ${SUBTEST_TOP}/nsx1/b10-config.db
 
 rm -f ${SUBTEST_TOP}/*/zone.sqlite3
-${B10_LOADZONE} -o . -d ${SUBTEST_TOP}/nsx1/zone.sqlite3 \
-	${SUBTEST_TOP}//nsx1/root.db
+${B10_LOADZONE} -c '{"database_file": "'${SUBTEST_TOP}/nsx1/zone.sqlite3'"}' \
+	. ${SUBTEST_TOP}//nsx1/root.db