2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Address ShellCheck warnings

Address all outstanding warnings that ShellCheck reports for
bin/tests/system/tcp/tests.sh.
This commit is contained in:
Michał Kępień
2019-11-07 12:25:39 +01:00
committed by Evan Hunt
parent 9841635b7f
commit 23ca0ec55b

View File

@@ -12,11 +12,16 @@
set -e
SYSTEMTESTTOP=..
. $SYSTEMTESTTOP/conf.sh
# shellcheck source=../conf.sh
. "$SYSTEMTESTTOP/conf.sh"
DIGOPTS="-p ${PORT}"
RNDCCMD="$RNDC -p ${CONTROLPORT} -c ../common/rndc.conf"
SEND="$PERL $SYSTEMTESTTOP/send.pl 10.53.0.6 ${CONTROLPORT}"
dig_with_opts() {
"${DIG}" -p "${PORT}" "$@"
}
rndccmd() {
"${RNDC}" -p "${CONTROLPORT}" -c ../common/rndc.conf -s "$@"
}
status=0
n=0
@@ -24,26 +29,26 @@ n=0
n=$((n + 1))
echo_i "initializing TCP statistics ($n)"
ret=0
$RNDCCMD -s 10.53.0.1 stats || ret=1
$RNDCCMD -s 10.53.0.2 stats || ret=1
rndccmd 10.53.0.1 stats || ret=1
rndccmd 10.53.0.2 stats || ret=1
mv ns1/named.stats ns1/named.stats.test$n
mv ns2/named.stats ns2/named.stats.test$n
ntcp10=`grep "TCP requests received" ns1/named.stats.test$n | tail -1 | awk '{print $1}'`
ntcp20=`grep "TCP requests received" ns2/named.stats.test$n | tail -1 | awk '{print $1}'`
ntcp10="$(grep "TCP requests received" ns1/named.stats.test$n | tail -1 | awk '{print $1}')"
ntcp20="$(grep "TCP requests received" ns2/named.stats.test$n | tail -1 | awk '{print $1}')"
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "checking TCP request statistics (resolver) ($n)"
ret=0
$DIG $DIGOPTS @10.53.0.3 txt.example. > dig.out.test$n
dig_with_opts @10.53.0.3 txt.example. > dig.out.test$n
sleep 1
$RNDCCMD -s 10.53.0.1 stats || ret=1
$RNDCCMD -s 10.53.0.2 stats || ret=1
rndccmd 10.53.0.1 stats || ret=1
rndccmd 10.53.0.2 stats || ret=1
mv ns1/named.stats ns1/named.stats.test$n
mv ns2/named.stats ns2/named.stats.test$n
ntcp11=`grep "TCP requests received" ns1/named.stats.test$n | tail -1 | awk '{print $1}'`
ntcp21=`grep "TCP requests received" ns2/named.stats.test$n | tail -1 | awk '{print $1}'`
ntcp11="$(grep "TCP requests received" ns1/named.stats.test$n | tail -1 | awk '{print $1}')"
ntcp21="$(grep "TCP requests received" ns2/named.stats.test$n | tail -1 | awk '{print $1}')"
if [ "$ntcp10" -ge "$ntcp11" ]; then ret=1; fi
if [ "$ntcp20" -ne "$ntcp21" ]; then ret=1; fi
if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -52,14 +57,14 @@ status=$((status + ret))
n=$((n + 1))
echo_i "checking TCP request statistics (forwarder) ($n)"
ret=0
$DIG $DIGOPTS @10.53.0.4 txt.example. > dig.out.test$n
dig_with_opts @10.53.0.4 txt.example. > dig.out.test$n
sleep 1
$RNDCCMD -s 10.53.0.1 stats || ret=1
$RNDCCMD -s 10.53.0.2 stats || ret=1
rndccmd 10.53.0.1 stats || ret=1
rndccmd 10.53.0.2 stats || ret=1
mv ns1/named.stats ns1/named.stats.test$n
mv ns2/named.stats ns2/named.stats.test$n
ntcp12=`grep "TCP requests received" ns1/named.stats.test$n | tail -1 | awk '{print $1}'`
ntcp22=`grep "TCP requests received" ns2/named.stats.test$n | tail -1 | awk '{print $1}'`
ntcp12="$(grep "TCP requests received" ns1/named.stats.test$n | tail -1 | awk '{print $1}')"
ntcp22="$(grep "TCP requests received" ns2/named.stats.test$n | tail -1 | awk '{print $1}')"
if [ "$ntcp11" -ne "$ntcp12" ]; then ret=1; fi
if [ "$ntcp21" -ge "$ntcp22" ];then ret=1; fi
if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -67,7 +72,7 @@ status=$((status + ret))
# -------- TCP high-water tests ----------
refresh_tcp_stats() {
$RNDCCMD -s 10.53.0.5 status > rndc.out.$n || ret=1
rndccmd 10.53.0.5 status > rndc.out.$n || ret=1
TCP_CUR="$(sed -n "s/^tcp clients: \([0-9][0-9]*\).*/\1/p" rndc.out.$n)"
TCP_LIMIT="$(sed -n "s/^tcp clients: .*\/\([0-9][0-9]*\)/\1/p" rndc.out.$n)"
TCP_HIGH="$(sed -n "s/^TCP high-water: \([0-9][0-9]*\)/\1/p" rndc.out.$n)"
@@ -76,7 +81,7 @@ refresh_tcp_stats() {
wait_for_log() {
msg=$1
file=$2
for i in 1 2 3 4 5 6 7 8 9 10; do
for _ in 1 2 3 4 5 6 7 8 9 10; do
nextpart "$file" | grep "$msg" > /dev/null && return
sleep 1
done
@@ -87,7 +92,7 @@ wait_for_log() {
# Send a command to the tool script listening on 10.53.0.6.
send_command() {
nextpart ans6/ans.run > /dev/null
echo "$*" | $SEND
echo "$*" | "${PERL}" "${SYSTEMTESTTOP}/send.pl" 10.53.0.6 "${CONTROLPORT}"
wait_for_log "result=OK" ans6/ans.run
}