From 47a4e0eeaaf6148d515d10a98825ff3cf10cabeb Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 5 Dec 2018 15:00:21 +1100 Subject: [PATCH] check that the time between notify messages is not too small --- bin/tests/system/notify/clean.sh | 7 ++++--- bin/tests/system/notify/tests.sh | 34 ++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/bin/tests/system/notify/clean.sh b/bin/tests/system/notify/clean.sh index ef42efa154..f10f563dd1 100644 --- a/bin/tests/system/notify/clean.sh +++ b/bin/tests/system/notify/clean.sh @@ -13,15 +13,17 @@ # Clean up after zone transfer tests. # -rm -f */named.memstats -rm -f */named.run */named.run.prev rm -f */named.conf +rm -f */named.memstats rm -f */named.port +rm -f */named.run */named.run.prev +rm -f awk.out.ns?.test* rm -f dig.out.?.ns5.test* rm -f dig.out.ns2.test* rm -f dig.out.ns3.test* rm -f dig.out.ns4.test* rm -f log.out +rm -f ns*/managed-keys.bind* ns*/*.mkeys* rm -f ns*/named.lock rm -f ns2/example.db rm -f ns2/x21.db* @@ -33,4 +35,3 @@ rm -f ns5/x21.bk-c rm -f ns5/x21.bk-c.jnl rm -f ns5/x21.db.jnl rm -f tmp -rm -f ns*/managed-keys.bind* ns*/*.mkeys* diff --git a/bin/tests/system/notify/tests.sh b/bin/tests/system/notify/tests.sh index c3032d033a..1be2b4712e 100644 --- a/bin/tests/system/notify/tests.sh +++ b/bin/tests/system/notify/tests.sh @@ -53,12 +53,34 @@ status=`expr $ret + $status` n=`expr $n + 1` echo_i "checking startup notify rate limit ($n)" ret=0 -grep 'x[0-9].*sending notify to' ns2/named.run | - sed 's/.*:\([0-9][0-9]\)\..*/\1/' | uniq -c | awk '{print $1}' > log.out -# the notifies should span at least 4 seconds -wc -l log.out | awk '$1 < 4 { exit(1) }' || ret=1 -# ... with no more than 5 in any one second -awk '$1 > 5 { exit(1) }' log.out || ret=1 +awk '/x[0-9].*sending notify to/ { + split($2, a, ":"); + this = a[1] * 3600 + a[2] * 60 + a[3]; + if (lasta1 && lasta1 > a[1]) { + fix = 3600 * 24; + } + this += fix; + if (last) { + delta = this - last; + print delta; + if (!maxdelta || delta > maxdelta) { + maxdelta = delta; + } + if (!mindelta || delta < mindelta) { + mindelta = delta; + } + } + lasta1 = a[1]; + last = this; + count++; +} +END { + print "mindelta:", mindelta + print "maxdelta:" maxdelta + print "count:", count; + if (mindelta < 0.180) exit(1); + if (count < 20) exit(1); +}' ns2/named.run > awk.out.ns2.test$n || ret=1 [ $ret = 0 ] || echo_i "failed" status=`expr $ret + $status`