Home | History | Annotate | Line # | Download | only in sfcache
tests.sh revision 1.1
      1 #!/bin/sh
      2 #
      3 # Copyright (C) Internet Systems Consortium, Inc. ("ISC")
      4 #
      5 # This Source Code Form is subject to the terms of the Mozilla Public
      6 # License, v. 2.0. If a copy of the MPL was not distributed with this
      7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      8 #
      9 # See the COPYRIGHT file distributed with this work for additional
     10 # information regarding copyright ownership.
     11 
     12 SYSTEMTESTTOP=..
     13 . $SYSTEMTESTTOP/conf.sh
     14 
     15 status=0
     16 n=0
     17 
     18 rm -f dig.out.*
     19 
     20 DIGOPTS="+tcp +noadd +nosea +nostat +nocmd -p ${PORT}"
     21 RNDCCMD="$RNDC -c $SYSTEMTESTTOP/common/rndc.conf -p ${CONTROLPORT} -s"
     22 
     23 echo_i "checking DNSSEC SERVFAIL is cached ($n)"
     24 ret=0
     25 $DIG $DIGOPTS +dnssec foo.example. a @10.53.0.5 > dig.out.ns5.test$n || ret=1
     26 $RNDCCMD 10.53.0.5 dumpdb -all 2>&1 | sed 's/^/I:ns5 /'
     27 for i in 1 2 3 4 5 6 7 8 9 10; do
     28     awk '/Zone/{out=0} { if (out) print } /SERVFAIL/{out=1}' ns5/named_dump.db > sfcache.$n
     29     [ -s "sfcache.$n" ] && break
     30     sleep 1
     31 done
     32 grep "^; foo.example/A" sfcache.$n > /dev/null || ret=1
     33 n=`expr $n + 1`
     34 if [ $ret != 0 ]; then echo_i "failed"; fi
     35 status=`expr $status + $ret`
     36 
     37 echo_i "checking SERVFAIL is returned from cache ($n)"
     38 ret=0
     39 $DIG $DIGOPTS +dnssec foo.example. a @10.53.0.5 > dig.out.ns5.test$n || ret=1
     40 grep "SERVFAIL" dig.out.ns5.test$n > /dev/null || ret=1
     41 n=`expr $n + 1`
     42 if [ $ret != 0 ]; then echo_i "failed"; fi
     43 status=`expr $status + $ret`
     44 
     45 echo_i "checking that +cd bypasses cache check ($n)"
     46 ret=0
     47 $DIG $DIGOPTS +dnssec +cd foo.example. a @10.53.0.5 > dig.out.ns5.test$n || ret=1
     48 grep "SERVFAIL" dig.out.ns5.test$n > /dev/null && ret=1
     49 n=`expr $n + 1`
     50 if [ $ret != 0 ]; then echo_i "failed"; fi
     51 status=`expr $status + $ret`
     52 
     53 echo_i "disabling server to force non-dnssec SERVFAIL"
     54 $PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . ns2
     55 awk '/SERVFAIL/ { next; out=1 } /Zone/ { out=0 } { if (out) print }' ns5/named_dump.db
     56 echo_i "checking SERVFAIL is cached ($n)"
     57 ret=0
     58 $DIG $DIGOPTS bar.example. a @10.53.0.5 > dig.out.ns5.test$n || ret=1
     59 $RNDCCMD 10.53.0.5 dumpdb -all 2>&1 | sed 's/^/I:ns5 /'
     60 for i in 1 2 3 4 5 6 7 8 9 10; do
     61     awk '/Zone/{out=0} { if (out) print } /SERVFAIL/{out=1}' ns5/named_dump.db > sfcache.$n
     62     [ -s "sfcache.$n" ] && break
     63     sleep 1
     64 done
     65 grep "^; bar.example/A" sfcache.$n > /dev/null || ret=1
     66 n=`expr $n + 1`
     67 if [ $ret != 0 ]; then echo_i "failed"; fi
     68 status=`expr $status + $ret`
     69 
     70 echo_i "checking SERVFAIL is returned from cache ($n)"
     71 ret=0
     72 nextpart ns5/named.run > /dev/null
     73 $DIG $DIGOPTS bar.example. a @10.53.0.5 > dig.out.ns5.test$n || ret=1
     74 grep "SERVFAIL" dig.out.ns5.test$n > /dev/null || ret=1
     75 nextpart ns5/named.run > ns5/named.run.part$n
     76 grep 'servfail cache hit bar.example/A (CD=0)' ns5/named.run.part$n > /dev/null || ret=1
     77 n=`expr $n + 1`
     78 if [ $ret != 0 ]; then echo_i "failed"; fi
     79 status=`expr $status + $ret`
     80 
     81 echo_i "checking cache is bypassed with +cd query ($n)"
     82 ret=0
     83 $DIG $DIGOPTS +cd bar.example. a @10.53.0.5 > dig.out.ns5.test$n || ret=1
     84 grep "SERVFAIL" dig.out.ns5.test$n > /dev/null || ret=1
     85 nextpart ns5/named.run > ns5/named.run.part$n
     86 grep 'servfail cache hit' ns5/named.run.part$n > /dev/null && ret=1
     87 n=`expr $n + 1`
     88 if [ $ret != 0 ]; then echo_i "failed"; fi
     89 status=`expr $status + $ret`
     90 
     91 echo_i "checking cache is used for subsequent +cd query ($n)"
     92 ret=0
     93 $DIG $DIGOPTS +dnssec bar.example. a @10.53.0.5 > dig.out.ns5.test$n || ret=1
     94 grep "SERVFAIL" dig.out.ns5.test$n > /dev/null || ret=1
     95 nextpart ns5/named.run > ns5/named.run.part$n
     96 grep 'servfail cache hit bar.example/A (CD=1)' ns5/named.run.part$n > /dev/null || ret=1
     97 n=`expr $n + 1`
     98 if [ $ret != 0 ]; then echo_i "failed"; fi
     99 status=`expr $status + $ret`
    100 
    101 echo_i "exit status: $status"
    102 [ $status -eq 0 ] || exit 1
    103