fi
KILLPIDS="$PID"
-sleep 1
+sleep $SLEEP0
echo "Using ldapsearch to check that slapd is running..."
for i in 0 1 2 3 4 5; do
if test $RC = 0 ; then
break
fi
- echo "Waiting 5 seconds for slapd to start..."
- sleep 5
+ echo "Waiting $SLEEP1 seconds for slapd to start..."
+ sleep $SLEEP1
done
if test $RC != 0 ; then
echo "ldapsearch failed ($RC)!"
fi
KILLPIDS="$KILLPIDS $PID"
-sleep 1
+sleep $SLEEP0
echo "Using ldapsearch to check that slapd is running..."
for i in 0 1 2 3 4 5; do
if test $RC = 0 ; then
break
fi
- echo "Waiting 5 seconds for slapd to start..."
- sleep 5
+ echo "Waiting $SLEEP1 seconds for slapd to start..."
+ sleep $SLEEP1
done
if test $RC != 0 ; then
echo "ldapsearch failed ($RC)!"
fi
KILLPIDS="$KILLPIDS $PID"
-sleep 1
+sleep $SLEEP0
echo "Using ldapsearch to check that slapd is running..."
for i in 0 1 2 3 4 5; do
if test $RC = 0 ; then
break
fi
- echo "Waiting 5 seconds for slapd to start..."
- sleep 5
+ echo "Waiting $SLEEP1 seconds for slapd to start..."
+ sleep $SLEEP1
done
if test $RC != 0 ; then
echo "ldapsearch failed ($RC)!"
fi
echo "Filtering ldapsearch results..."
$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
-$LDIFFILTER < data/asyncmeta.closed.out > $LDIFFLT
+$LDIFFILTER < $DATADIR/asyncmeta.closed.out > $LDIFFLT
echo "Comparing filter output..."
$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
-
+if test $? != 0 ; then
+ echo "Comparison failed - the connections are not closed"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit 1
+fi
#run 3 searches
for i in 0 1 2; do
BASEDN="o=Example,c=US"
echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
$LDAPSEARCH -S "" -H $URI3 -b "$BASEDN" >> $SEARCHOUT 2>&1
RC=$?
- #if test $RC != 0 ; then
- # echo "Search failed ($RC)!"
- # test $KILLSERVERS != no && kill -HUP $KILLPIDS
- # exit $RC
- #fi
case $RC in
0)
;;
exit $RC
;;
esac
- sleep 2
done
# search cn=monitor - no connections should be closed yet
-SEARCHDN="cn=Connections,cn=database 1,cn=databases,cn=monitor"
+sleep $SLEEP0
echo "Verifying that all target connections are open..."
cat /dev/null > $SEARCHOUT
echo " base=\"$SEARCHDN\"..."
-echo "# base=\"$SEARCHDN\"..." >> $SEARCHOUT
$LDAPSEARCH -H $URI3 \
-b "$SEARCHDN" \
'olmTargetConnFlags' >> $SEARCHOUT 2>&1
fi
echo "Filtering ldapsearch results..."
$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
-$LDIFFILTER < data/asyncmeta.allopen.out > $LDIFFLT
+$LDIFFILTER < $DATADIR/asyncmeta.allopen.out > $LDIFFLT
+
echo "Comparing filter output..."
$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
-
-# wait 6 seconds and search cn=monitor - connection group 1 is closed
+if test $? != 0 ; then
+ echo "Comparison failed - the connections are not open"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit 1
+fi
+# wait 7 seconds (the con ttl time + 1) and search cn=monitor
+# connection group 1 should be closed
+echo "Waiting for the time-to-live time..."
+sleep $SLEEP1
SEARCHDN="cn=Connections,cn=database 1,cn=databases,cn=monitor"
echo "Verifying that connection group 1 is closed..."
-sleep 5
cat /dev/null > $SEARCHOUT
-echo " base=\"$SEARCHDN\"..."
+echo " base=\"cn=Connection Group 1,$SEARCHDN\"..."
echo "# base=\"$SEARCHDN\"..." >> $SEARCHOUT
$LDAPSEARCH -H $URI3 \
- -b "$SEARCHDN" \
+ -b "cn=Connection Group 1,$SEARCHDN" \
"olmTargetConnFlags=closed" 'olmTargetConnFlags' >> $SEARCHOUT 2>&1
RC=$?
if test $RC != 0 ; then
fi
echo "Filtering ldapsearch results..."
$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
-$LDIFFILTER < data/asyncmeta.1.out > $LDIFFLT
+$LDIFFILTER < $DATADIR/asyncmeta.1.out > $LDIFFLT
echo "Comparing filter output..."
$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
-SEARCHDN="cn=Connections,cn=database 1,cn=databases,cn=monitor"
+if test $? != 0 ; then
+ echo "Comparison failed - connection group 1 is not closed"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit 1
+fi
+# wait 7 seconds (the con ttl interval + 1) and search cn=monitor
+# connection group 2 should be closed
+echo "Waiting for the connection reset interval..."
+sleep $SLEEP1
echo "Verifying that target connection group 2 is closed..."
-sleep 6
cat /dev/null > $SEARCHOUT
-echo " base=\"$SEARCHDN\"..."
-echo "# base=\"$SEARCHDN\"..." >> $SEARCHOUT
+echo " base=\"cn=Connection Group 2,$SEARCHDN\"..."
$LDAPSEARCH -H $URI3 \
-b "cn=Connection Group 2,$SEARCHDN" \
"olmTargetConnFlags=closed" 'olmTargetConnFlags' >> $SEARCHOUT 2>&1
echo "Filtering ldapsearch results..."
$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
-$LDIFFILTER < data/asyncmeta.2.out > $LDIFFLT
+$LDIFFILTER < $DATADIR/asyncmeta.2.out > $LDIFFLT
echo "Comparing filter output..."
$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
-
-SEARCHDN="cn=Connections,cn=database 1,cn=databases,cn=monitor"
-echo "Verifying that all target connections are closed..."
-# wait 6 seconds, search, all connections should be closed
-sleep 6
-cat /dev/null > $SEARCHOUT
-
-echo " base=\"$SEARCHDN\"..."
-echo "# base=\"$SEARCHDN\"..." >> $SEARCHOUT
-$LDAPSEARCH -H $URI3 \
- -b "$SEARCHDN" \
- "olmTargetConnFlags=closed" 'olmTargetConnFlags' >> $SEARCHOUT 2>&1
-RC=$?
-if test $RC != 0 ; then
- echo "Unable to read monitor ($RC)!"
+if test $? != 0 ; then
+ echo "Comparison failed - connection group 2 is not closed"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
- exit $RC
+ exit 1
fi
-echo "Filtering ldapsearch results..."
-$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
-$LDIFFILTER < data/asyncmeta.closed.out > $LDIFFLT
-echo "Comparing filter output..."
-$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
+# wait 7 seconds (the con ttl interval + 1) and search cn=monitor
+# all connections should be closed
+# sometimes the timeout loop may be delayed, so we give it a couple of
+# retries before giving up
+echo "Waiting for the connection reset interval..."
+sleep $SLEEP1
+echo "Verifying that all target connections are closed..."
+for i in 0 1 2; do
+ cat /dev/null > $SEARCHOUT
+ echo " base=\"$SEARCHDN\"..."
+ echo "# base=\"$SEARCHDN\"..." >> $SEARCHOUT
+ $LDAPSEARCH -H $URI3 \
+ -b "$SEARCHDN" \
+ "olmTargetConnFlags=closed" 'olmTargetConnFlags' >> $SEARCHOUT 2>&1
+ RC=$?
+ if test $RC != 0 ; then
+ echo "Unable to read monitor ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+ fi
+ echo "Filtering ldapsearch results..."
+ $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
+ $LDIFFILTER < $DATADIR/asyncmeta.closed.out > $LDIFFLT
+ echo "Comparing filter output..."
+ $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
+ if test $? != 0 ; then
+ if test $i != 2 ; then
+ echo "Comparison failed - the connections are not closed, retrying in $SLEEP0 seconds..."
+ sleep $SLEEP0
+ else
+ echo "Comparison failed - the connections are not closed, test failed"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit 1
+ fi
+ else
+ echo "Comparison successfull, all connections are closed"
+ break
+ fi
+done
cat /dev/null > $SEARCHOUT
test $KILLSERVERS != no && kill -HUP $KILLPIDS