2003-06-21 08:21:57 +08:00
|
|
|
#! /bin/sh
|
2003-06-27 07:52:52 +08:00
|
|
|
# $OpenLDAP$
|
2003-06-21 08:21:57 +08:00
|
|
|
|
|
|
|
CACHETTL=60
|
|
|
|
CACHE_ENTRY_LIMIT=10
|
|
|
|
|
|
|
|
SRCDIR="."
|
|
|
|
if test $# -ge 1 ; then
|
|
|
|
SRCDIR=$1; shift
|
|
|
|
fi
|
|
|
|
|
2003-06-27 07:52:52 +08:00
|
|
|
. $SRCDIR/scripts/args.sh $*
|
|
|
|
|
2003-08-14 07:44:56 +08:00
|
|
|
if test $PROXYCACHE = no; then
|
|
|
|
echo "Proxy caching requires back-meta AND (back-ldbm OR back-bdb)"
|
2003-06-27 07:52:52 +08:00
|
|
|
exit 0
|
2003-08-14 07:44:56 +08:00
|
|
|
fi
|
2003-06-21 08:21:57 +08:00
|
|
|
|
|
|
|
echo "running defines.sh"
|
|
|
|
. $SRCDIR/scripts/defines.sh
|
|
|
|
|
|
|
|
# Test proxy caching:
|
|
|
|
# - start master
|
|
|
|
# - start proxy cache
|
|
|
|
# - populate master
|
|
|
|
# - perform first set of searches at the proxy
|
|
|
|
# - verify cacheability
|
|
|
|
# - perform second set of searches at the proxy
|
|
|
|
# - verify answerability
|
|
|
|
|
|
|
|
#if test ! -x $SLAPD ; then
|
|
|
|
# echo ">>>>> $SLAPD is not executable or does not exist."
|
|
|
|
# echo ">>>>> Test skipped."
|
|
|
|
# exit 0
|
|
|
|
#fi
|
|
|
|
|
|
|
|
if test ! -d $DBDIR
|
|
|
|
then
|
|
|
|
mkdir $DBDIR
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test ! -d $CACHEDIR
|
|
|
|
then
|
|
|
|
mkdir $CACHEDIR
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Cleaning up in $DBDIR..."
|
|
|
|
rm -f $DBDIR/[!C]*
|
|
|
|
echo "Cleaning up in $CACHEDIR..."
|
|
|
|
rm -rf $CACHEDIR/[!C]*
|
|
|
|
echo $DBDIR
|
|
|
|
|
|
|
|
echo "Starting master slapd on TCP/IP port $PORT..."
|
|
|
|
. $CONFFILTER < $CACHEMASTERCONF > $DBCONF
|
|
|
|
$SLAPD -f $DBCONF -h $MASTERURI -d $LVL > $MASTERLOG 2>&1 &
|
|
|
|
PID=$!
|
2003-06-27 07:52:52 +08:00
|
|
|
if test $WAIT != 0 ; then
|
|
|
|
echo PID $PID
|
|
|
|
read foo
|
|
|
|
fi
|
2003-06-21 08:21:57 +08:00
|
|
|
|
2003-08-14 07:44:56 +08:00
|
|
|
sleep 10
|
2003-06-21 08:21:57 +08:00
|
|
|
|
|
|
|
echo "Using ldapadd to populate the master directory..."
|
|
|
|
$LDAPADD -x -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
|
2003-06-27 07:52:52 +08:00
|
|
|
$LDIFORDERED > /dev/null 2>&1
|
2003-06-21 08:21:57 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapadd failed ($RC)!"
|
|
|
|
kill -HUP $PID
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Starting proxy cache on TCP/IP port $SLAVEPORT..."
|
|
|
|
. $CONFFILTER < $PROXYCACHECONF > $CACHECONF
|
|
|
|
$SLAPD -f $CACHECONF -h $SLAVEURI -d $LVL > $SLAVELOG 2>&1 &
|
|
|
|
CACHEPID=$!
|
2003-06-27 07:52:52 +08:00
|
|
|
if test $WAIT != 0 ; then
|
|
|
|
echo CACHEPID $CACHEPID
|
|
|
|
read foo
|
|
|
|
fi
|
2003-06-21 08:21:57 +08:00
|
|
|
|
|
|
|
sleep 8
|
|
|
|
echo "Making queries on the proxy cache..."
|
|
|
|
echo "Query 1: filter:(sn=Jon) attrs: all"
|
|
|
|
$LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
|
|
|
'sn=Jon' > $SLAVEOUT 2>&1
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
kill -HUP $PID $CACHEPID
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
sleep 3
|
|
|
|
|
2003-08-14 07:44:56 +08:00
|
|
|
echo "Query 2: filter:(|(cn=*Jon*)(sn=Jon*)) attrs:cn sn title uid"
|
2003-06-21 08:21:57 +08:00
|
|
|
$LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
2003-08-14 07:44:56 +08:00
|
|
|
'(|(cn=*Jon*)(sn=Jon*))' cn sn title uid >> $SLAVEOUT 2>&1
|
2003-06-21 08:21:57 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
kill -HUP $PID $CACHEPID
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
sleep 3
|
|
|
|
|
2003-08-14 07:44:56 +08:00
|
|
|
echo "Query 3: filter:(sn=Smith*) attrs:cn sn title uid"
|
2003-06-21 08:21:57 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
2003-08-14 07:44:56 +08:00
|
|
|
'sn=Smith*' cn sn title uid >> $SLAVEOUT 2>&1
|
2003-06-21 08:21:57 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
kill -HUP $PID $CACHEPID
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
sleep 3
|
|
|
|
|
2003-08-14 07:44:56 +08:00
|
|
|
echo "Query 4: filter:(sn=Doe*) attrs:cn sn title uid"
|
2003-06-21 08:21:57 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
2003-08-14 07:44:56 +08:00
|
|
|
'sn=Doe' cn sn title uid >> $SLAVEOUT 2>&1
|
2003-06-21 08:21:57 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
kill -HUP $PID $CACHEPID
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
sleep 3
|
|
|
|
|
2003-08-14 07:44:56 +08:00
|
|
|
echo "Query 5: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
|
2003-06-21 08:21:57 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
2003-08-14 07:44:56 +08:00
|
|
|
'uid=bjorn' mail postaladdress telephonenumber cn uid >> $SLAVEOUT 2>&1
|
2003-06-21 08:21:57 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
kill -HUP $PID $CACHEPID
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
sleep 3
|
|
|
|
|
2003-08-14 07:44:56 +08:00
|
|
|
echo "Query 6: filter:(mail=*@example.com) cn sn title uid"
|
2003-06-21 08:21:57 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
2003-08-14 07:44:56 +08:00
|
|
|
'mail=*@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
|
2003-06-21 08:21:57 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
kill -HUP $PID $CACHEPID
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
sleep 3
|
|
|
|
|
2003-08-14 07:44:56 +08:00
|
|
|
echo "Query 7: filter:(mail=*) cn sn title uid"
|
2003-06-21 08:21:57 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
2003-08-14 07:44:56 +08:00
|
|
|
'mail=*' cn sn title uid >> $SLAVEOUT 2>&1
|
2003-06-21 08:21:57 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
kill -HUP $PID $CACHEPID
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
sleep 3
|
|
|
|
# queries 2-6 are cacheable
|
|
|
|
CACHEABILITY=0111110
|
|
|
|
grep CACHEABLE $SLAVELOG | awk '{
|
|
|
|
if ($2 == "NOT")
|
|
|
|
printf "Query %d not cacheable\n",NR
|
|
|
|
else
|
|
|
|
printf "Query %d cacheable\n",NR
|
|
|
|
}'
|
|
|
|
CACHED=`grep CACHEABLE $SLAVELOG | awk '{
|
|
|
|
if ($2 == "NOT")
|
|
|
|
printf "0"
|
|
|
|
else
|
|
|
|
printf "1"
|
|
|
|
}'`
|
|
|
|
|
|
|
|
if test $CACHEABILITY = $CACHED
|
|
|
|
then
|
|
|
|
echo "successfully verified cacheability"
|
|
|
|
else
|
|
|
|
echo "error in verifying cacheability"
|
|
|
|
kill -HUP $PID $CACHEPID
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2003-08-14 07:44:56 +08:00
|
|
|
echo "Query 8: filter:(|(cn=*Jones)(sn=Jones)) attrs:cn sn title uid"
|
2003-06-21 08:21:57 +08:00
|
|
|
$LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
2003-08-14 07:44:56 +08:00
|
|
|
'(|(cn=*Jones)(sn=Jones))' cn sn title uid >> $SLAVEOUT 2>&1
|
2003-06-21 08:21:57 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
kill -HUP $PID $CACHEPID
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
sleep 3
|
|
|
|
|
2003-08-14 07:44:56 +08:00
|
|
|
echo "Query 9: filter:(sn=Smith) attrs:cn sn title uid"
|
2003-06-21 08:21:57 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
2003-08-14 07:44:56 +08:00
|
|
|
'sn=Smith' cn sn title uid >> $SLAVEOUT 2>&1
|
2003-06-21 08:21:57 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
kill -HUP $PID $CACHEPID
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
sleep 3
|
|
|
|
|
2003-08-14 07:44:56 +08:00
|
|
|
echo "Query 10: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
|
2003-06-21 08:21:57 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
2003-08-14 07:44:56 +08:00
|
|
|
'uid=bjorn' mail postaladdress telephonenumber cn uid >> $SLAVEOUT 2>&1
|
2003-06-21 08:21:57 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
kill -HUP $PID $CACHEPID
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
sleep 3
|
|
|
|
|
2003-08-14 07:44:56 +08:00
|
|
|
echo "Query 11: filter:(mail=*@example.com) cn sn title uid"
|
2003-06-21 08:21:57 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
2003-08-14 07:44:56 +08:00
|
|
|
'mail=jaj@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
|
2003-06-21 08:21:57 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
kill -HUP $PID $CACHEPID
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
sleep 3
|
|
|
|
#queries 8-11 are answerable
|
|
|
|
ANSWERABILITY=1111
|
|
|
|
grep ANSWERABLE $SLAVELOG | awk '{
|
|
|
|
if (NR > 7) {
|
|
|
|
if ($2 == "NOT")
|
|
|
|
printf "Query %d not answerable\n",NR
|
|
|
|
else
|
|
|
|
printf "Query %d answerable\n",NR
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
ANSWERED=`grep ANSWERABLE $SLAVELOG | awk '{
|
|
|
|
if (NR > 7) {
|
|
|
|
if ($2 == "NOT")
|
|
|
|
printf "0"
|
|
|
|
else
|
|
|
|
printf "1"
|
|
|
|
}
|
|
|
|
}'`
|
|
|
|
if test $ANSWERABILITY = $ANSWERED
|
|
|
|
then
|
|
|
|
echo "successfully verified answerability"
|
|
|
|
else
|
|
|
|
echo "error in verifying answerability"
|
|
|
|
kill -HUP $PID $CACHEPID
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Proxy cache successfully tested"
|
|
|
|
kill -HUP $PID $CACHEPID
|