xref: /netbsd-src/external/mpl/bind/dist/bin/tests/system/keepalive/tests.sh (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
1#!/bin/sh
2
3# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
4#
5# SPDX-License-Identifier: MPL-2.0
6#
7# This Source Code Form is subject to the terms of the Mozilla Public
8# License, v. 2.0.  If a copy of the MPL was not distributed with this
9# file, you can obtain one at https://mozilla.org/MPL/2.0/.
10#
11# See the COPYRIGHT file distributed with this work for additional
12# information regarding copyright ownership.
13
14SYSTEMTESTTOP=..
15. $SYSTEMTESTTOP/conf.sh
16
17DIGOPTS="-p ${PORT}"
18RNDCCMD="$RNDC  -c ../common/rndc.conf -s 10.53.0.2 -p ${CONTROLPORT}"
19
20n=0
21status=0
22
23echo_i "checking that dig handles TCP keepalive ($n)"
24ret=0
25n=`expr $n + 1`
26$DIG $DIGOPTS +qr +keepalive foo.example @10.53.0.2 > dig.out.test$n
27grep "; TCP KEEPALIVE" dig.out.test$n > /dev/null || ret=1
28if [ $ret != 0 ]; then echo_i "failed"; fi
29status=`expr $status + $ret`
30
31echo_i "checking that dig added TCP keepalive ($n)"
32ret=0
33n=`expr $n + 1`
34$RNDCCMD stats
35grep "EDNS TCP keepalive option received" ns2/named.stats > /dev/null || ret=1
36if [ $ret != 0 ]; then echo_i "failed"; fi
37status=`expr $status + $ret`
38
39echo_i "checking that TCP keepalive is added for TCP responses ($n)"
40ret=0
41n=`expr $n + 1`
42$DIG $DIGOPTS +vc +keepalive foo.example @10.53.0.2 > dig.out.test$n
43grep "; TCP KEEPALIVE" dig.out.test$n > /dev/null || ret=1
44if [ $ret != 0 ]; then echo_i "failed"; fi
45status=`expr $status + $ret`
46
47echo_i "checking that TCP keepalive requires TCP ($n)"
48ret=0
49n=`expr $n + 1`
50$DIG $DIGOPTS +keepalive foo.example @10.53.0.2 > dig.out.test$n
51grep "; TCP KEEPALIVE" dig.out.test$n > /dev/null && ret=1
52if [ $ret != 0 ]; then echo_i "failed"; fi
53status=`expr $status + $ret`
54
55echo_i "checking default value ($n)"
56ret=0
57n=`expr $n + 1`
58$DIG $DIGOPTS +vc +keepalive foo.example @10.53.0.3 > dig.out.test$n
59grep "; TCP KEEPALIVE: 30.0 secs" dig.out.test$n > /dev/null || ret=1
60if [ $ret != 0 ]; then echo_i "failed"; fi
61status=`expr $status + $ret`
62
63echo_i "checking configured value ($n)"
64ret=0
65n=`expr $n + 1`
66$DIG $DIGOPTS +vc +keepalive foo.example @10.53.0.2 > dig.out.test$n
67grep "; TCP KEEPALIVE: 15.0 secs" dig.out.test$n > /dev/null || ret=1
68if [ $ret != 0 ]; then echo_i "failed"; fi
69status=`expr $status + $ret`
70
71echo_i "checking re-configured value ($n)"
72ret=0
73n=`expr $n + 1`
74$RNDCCMD tcp-timeouts 300 300 300 200 > output
75$DIFF -b output expected || ret=1
76$DIG $DIGOPTS +vc +keepalive foo.example @10.53.0.2 > dig.out.test$n
77grep "; TCP KEEPALIVE: 20.0 secs" dig.out.test$n > /dev/null || ret=1
78if [ $ret != 0 ]; then echo_i "failed"; fi
79status=`expr $status + $ret`
80
81echo_i "checking server config entry ($n)"
82ret=0
83n=`expr $n + 1`
84$RNDCCMD stats
85oka=`grep  "EDNS TCP keepalive option received" ns2/named.stats | \
86    tail -1 | awk '{ print $1}'`
87$DIG $DIGOPTS bar.example @10.53.0.3 > dig.out.test$n
88$RNDCCMD stats
89nka=`grep  "EDNS TCP keepalive option received" ns2/named.stats | \
90    tail -1 | awk '{ print $1}'`
91#echo oka ':' $oka
92#echo nka ':' $nka
93if [ "$oka" -eq "$nka" ]; then ret=1; fi
94if [ $ret != 0 ]; then echo_i "failed"; fi
95status=`expr $status + $ret`
96
97echo_i "exit status: $status"
98[ $status -eq 0 ] || exit 1
99