#!/bin/bash -e
port=$1
[ -z "$port" ] && port=5300
limit=$2
[ -z "$limit" ] && limit=100000
threads=$3
[ -z "$threads" ] && threads=2
mthreads=$4
[ -z "$mthreads" ] && mthreads=100
shards=$5
[ -z "$shards" ] && shards=1024
: ${RECURSOR:="../pdns/recursordist/pdns_recursor"}
: ${RECCONTROL:="../pdns/recursordist/rec_control"}
: ${CSV:="top-1m.csv"}
: ${IPv6:="0"}
: ${TRACE:="fail"}
: ${DNSBULKTEST:="../pdns/dnsbulktest"}
if [ $IPv6 = 1 ]
then
QLA6="::"
else
QLA6=""
fi
rm -f recursor.pid pdns_recursor.pid
/usr/bin/time --format '%Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k
%Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps
user CPU seconds%U
system CPU seconds%S
wallclock seconds%e
%% CPU used%P
' ${RECURSOR} --daemon=no --local-port=$port --socket-dir=./ --trace=$TRACE --config-dir=. --max-mthreads=$mthreads --query-local-address6="${QLA6}" --threads=$threads --cache-shards=$shards --disable-packetcache > recursor.log 2>&1 &
sleep 3
# warm up the cache
echo
echo === First run with limit=$limit threads=$threads mthreads=$mthreads shards=$shards ===
${DNSBULKTEST} --www=false -qe 127.0.0.1 $port $limit < ${CSV} > bulktest.results
kill -USR1 $(cat pdns_recursor.pid)
${RECCONTROL} --socket-dir=. --config-dir=. get-all
# rerun 1 with hot cache
echo
echo === Second run with limit=$limit threads=$threads mthreads=$mthreads shards=$shards ===
${DNSBULKTEST} --www=false -qe 127.0.0.1 $port $limit < ${CSV} > bulktest.results
kill -USR1 $(cat pdns_recursor.pid)
${RECCONTROL} --socket-dir=. --config-dir=. get-all
# rerun 2 with hot cache
echo
echo === Third run with limit=$limit threads=$threads mthreads=$mthreads shards=$shards ===
${DNSBULKTEST} --www=false -qe 127.0.0.1 $port $limit < ${CSV} > bulktest.results
kill -USR1 $(cat pdns_recursor.pid)
${RECCONTROL} --socket-dir=. --config-dir=. get-all
sleep 1
echo
echo "=== RECURSOR LOG ==="
cat recursor.log
echo "=== END RECURSOR LOG ==="
kill $(cat pdns_recursor.pid)
sleep 5
. ./bulktest.results
mkdir -p recursor-bulktest
rm -f failed_tests passed_tests
touch failed_tests passed_tests
: ${THRESHOLD:="95"}
ANANSWER=$[(100*(${DBT_QUEUED}-${DBT_ERRORS}-${DBT_TIMEOUTS}) )/${DBT_QUEUED}]
if [ "$ANANSWER" -ge $THRESHOLD ]
then
echo recursor-bulktest >> passed_tests
RETVAL=0
else
echo recursor-bulktest >> failed_tests
RETVAL=1
fi
echo "$DBT_OKPERCENTAGE% of domains resolved" > recursor-bulktest/diff
egrep 'PowerDNS.COM|^ recursor-bulktest/stdout
echo "% domains resolved$DBT_OKPERCENTAGE" >> recursor-bulktest/stdout
: ${context:="recursor-bulktest"}
export context
testsdir=. ./toxml
exit $RETVAL