From 61cfb80f8d3c65a3782ce7793c996c4021f5f0ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= Date: Sun, 22 Nov 2015 18:31:30 +0000 Subject: [PATCH] ITS#7100 Test for entryTtl reflecting time to live --- tests/scripts/test046-dds | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/tests/scripts/test046-dds b/tests/scripts/test046-dds index a0aa866c44..792ca5e954 100755 --- a/tests/scripts/test046-dds +++ b/tests/scripts/test046-dds @@ -150,6 +150,7 @@ fi SEARCH=0 SEARCH=`expr $SEARCH + 1` +sleep $SLEEP0 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ '(objectClass=dynamicObject)' '*' entryTtl \ @@ -253,6 +254,7 @@ if test $RC != 0 ; then fi SEARCH=`expr $SEARCH + 1` +sleep $SLEEP0 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ '(objectClass=dynamicObject)' '*' entryTtl \ @@ -307,6 +309,7 @@ if test $RC != 0 ; then fi SEARCH=`expr $SEARCH + 1` +sleep $SLEEP0 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ '(objectClass=dynamicObject)' '*' entryTtl \ @@ -332,6 +335,7 @@ if test $RC != 0 ; then fi SEARCH=`expr $SEARCH + 1` +sleep $SLEEP0 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ '(objectClass=dynamicObject)' '*' entryTtl \ @@ -355,6 +359,7 @@ if test $RC != 0 ; then fi SEARCH=`expr $SEARCH + 1` +sleep $SLEEP0 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ '(objectClass=dynamicObject)' '*' entryTtl \ @@ -371,6 +376,7 @@ echo "Waiting $SLEEP seconds for remaining entry to expire..." sleep $SLEEP SEARCH=`expr $SEARCH + 1` +sleep $SLEEP0 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \ '(objectClass=dynamicObject)' '*' entryTtl \ @@ -530,18 +536,38 @@ test $KILLSERVERS != no && kill -HUP $KILLPIDS LDIF=$DDSOUT +# dds removes entryTtl and re-adds it, changing the order of attributes echo "Filtering ldapsearch results..." -$LDIFFILTER < $SEARCHOUT > $SEARCHFLT +$LDIFFILTER -s a < $SEARCHOUT > $SEARCHFLT +grep -i -v -e '^entryttl: ' < $SEARCHFLT > $SEARCHFLT2 echo "Filtering original ldif used to create database..." -$LDIFFILTER < $LDIF > $LDIFFLT +$LDIFFILTER -s a < $LDIF > $LDIFFLT +grep -i -v -e '^entryttl: ' < $LDIFFLT > $LDIFFLT2 echo "Comparing filter output..." -$CMP $SEARCHFLT $LDIFFLT > $CMPOUT +$CMP $SEARCHFLT2 $LDIFFLT2 > $CMPOUT if test $? != 0 ; then echo "Comparison failed" exit 1 fi +echo "Listing entryTtl values from ldapsearch results..." +grep -i -e '^entryttl: ' < $SEARCHFLT | awk '{ print $2 }' > $SEARCHFLT2 +echo "Listing entryTtl values from original ldif used to create database..." +grep -i -e '^entryttl: ' < $LDIFFLT | awk '{ print $2 }' > $LDIFFLT2 + +if ! type paste >/dev/null 2>&1; then + echo "Cannot find 'paste' command, skipping entryTtl checks..." +else + echo "Checking entryTtl appears to decrease with time..." + paste $SEARCHFLT2 $LDIFFLT2 | while read resultTTL savedTTL; do + if [ `expr $savedTTL - $resultTTL` -lt $SLEEP0 ]; then + echo "TTL has not reduced accordingly" + exit 1 + fi + done +fi + echo ">>>>> Test succeeded" test $KILLSERVERS != no && wait -- 2.39.5