xref: /netbsd-src/external/mpl/bind/dist/bin/tests/system/keepalive/tests.sh (revision 8ecbf5f02b752fcb7debe1a8fab1dc82602bc760)
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
12SYSTEMTESTTOP=..
13. $SYSTEMTESTTOP/conf.sh
14
15DIGOPTS="-p ${PORT}"
16RNDCCMD="$RNDC  -c ../common/rndc.conf -s 10.53.0.2 -p ${CONTROLPORT}"
17
18n=0
19status=0
20
21echo_i "checking that dig handles TCP keepalive ($n)"
22ret=0
23n=`expr $n + 1`
24$DIG $DIGOPTS +qr +keepalive foo.example @10.53.0.2 > dig.out.test$n
25grep "; TCP KEEPALIVE" dig.out.test$n > /dev/null || ret=1
26if [ $ret != 0 ]; then echo_i "failed"; fi
27status=`expr $status + $ret`
28
29echo_i "checking that dig added TCP keepalive ($n)"
30ret=0
31n=`expr $n + 1`
32$RNDCCMD stats
33grep "EDNS TCP keepalive option received" ns2/named.stats > /dev/null || ret=1
34if [ $ret != 0 ]; then echo_i "failed"; fi
35status=`expr $status + $ret`
36
37echo_i "checking that TCP keepalive is added for TCP responses ($n)"
38ret=0
39n=`expr $n + 1`
40$DIG $DIGOPTS +vc +keepalive foo.example @10.53.0.2 > dig.out.test$n
41grep "; TCP KEEPALIVE" dig.out.test$n > /dev/null || ret=1
42if [ $ret != 0 ]; then echo_i "failed"; fi
43status=`expr $status + $ret`
44
45echo_i "checking that TCP keepalive requires TCP ($n)"
46ret=0
47n=`expr $n + 1`
48$DIG $DIGOPTS +keepalive foo.example @10.53.0.2 > dig.out.test$n
49grep "; TCP KEEPALIVE" dig.out.test$n > /dev/null && ret=1
50if [ $ret != 0 ]; then echo_i "failed"; fi
51status=`expr $status + $ret`
52
53echo_i "checking default value ($n)"
54ret=0
55n=`expr $n + 1`
56$DIG $DIGOPTS +vc +keepalive foo.example @10.53.0.3 > dig.out.test$n
57grep "; TCP KEEPALIVE: 30.0 secs" dig.out.test$n > /dev/null || ret=1
58if [ $ret != 0 ]; then echo_i "failed"; fi
59status=`expr $status + $ret`
60
61echo_i "checking configured value ($n)"
62ret=0
63n=`expr $n + 1`
64$DIG $DIGOPTS +vc +keepalive foo.example @10.53.0.2 > dig.out.test$n
65grep "; TCP KEEPALIVE: 15.0 secs" dig.out.test$n > /dev/null || ret=1
66if [ $ret != 0 ]; then echo_i "failed"; fi
67status=`expr $status + $ret`
68
69echo_i "checking re-configured value ($n)"
70ret=0
71n=`expr $n + 1`
72$RNDCCMD tcp-timeouts 300 300 300 200 > output
73$DIFF -b output expected || ret=1
74$DIG $DIGOPTS +vc +keepalive foo.example @10.53.0.2 > dig.out.test$n
75grep "; TCP KEEPALIVE: 20.0 secs" dig.out.test$n > /dev/null || ret=1
76if [ $ret != 0 ]; then echo_i "failed"; fi
77status=`expr $status + $ret`
78
79echo_i "checking server config entry ($n)"
80ret=0
81n=`expr $n + 1`
82$RNDCCMD stats
83oka=`grep  "EDNS TCP keepalive option received" ns2/named.stats | \
84    tail -1 | awk '{ print $1}'`
85$DIG $DIGOPTS bar.example @10.53.0.3 > dig.out.test$n
86$RNDCCMD stats
87nka=`grep  "EDNS TCP keepalive option received" ns2/named.stats | \
88    tail -1 | awk '{ print $1}'`
89#echo oka ':' $oka
90#echo nka ':' $nka
91if [ "$oka" -eq "$nka" ]; then ret=1; fi
92if [ $ret != 0 ]; then echo_i "failed"; fi
93status=`expr $status + $ret`
94
95echo_i "exit status: $status"
96[ $status -eq 0 ] || exit 1
97