mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
245 lines
5.6 KiB
Plaintext
245 lines
5.6 KiB
Plaintext
|
#! /bin/sh
|
||
|
|
||
|
CACHETTL=60
|
||
|
CACHE_ENTRY_LIMIT=10
|
||
|
|
||
|
SRCDIR="."
|
||
|
if test $# -ge 1 ; then
|
||
|
SRCDIR=$1; shift
|
||
|
fi
|
||
|
|
||
|
. $SRCDIR/scripts/args.sh
|
||
|
|
||
|
echo "running defines.sh"
|
||
|
. $SRCDIR/scripts/defines.sh
|
||
|
|
||
|
BACKEND=ldbm
|
||
|
|
||
|
# 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=$!
|
||
|
|
||
|
sleep 5
|
||
|
|
||
|
echo "Using ldapadd to populate the master directory..."
|
||
|
$LDAPADD -x -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
|
||
|
$LDIFORDERED > out 2>&1
|
||
|
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=$!
|
||
|
|
||
|
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
|
||
|
|
||
|
echo "Query 2: filter:(|(cn=*Jon*)(sn=Jon*)) attrs:cn sn title"
|
||
|
$LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
||
|
'(|(cn=*Jon*)(sn=Jon*))' cn sn title >> $SLAVEOUT 2>&1
|
||
|
RC=$?
|
||
|
if test $RC != 0 ; then
|
||
|
echo "ldapsearch failed ($RC)!"
|
||
|
kill -HUP $PID $CACHEPID
|
||
|
exit $RC
|
||
|
fi
|
||
|
sleep 3
|
||
|
|
||
|
echo "Query 3: filter:(sn=Smith*) attrs:cn sn title"
|
||
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
||
|
'sn=Smith*' cn sn title >> $SLAVEOUT 2>&1
|
||
|
RC=$?
|
||
|
if test $RC != 0 ; then
|
||
|
echo "ldapsearch failed ($RC)!"
|
||
|
kill -HUP $PID $CACHEPID
|
||
|
exit $RC
|
||
|
fi
|
||
|
sleep 3
|
||
|
|
||
|
echo "Query 4: filter:(sn=Doe*) attrs:cn sn title"
|
||
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
||
|
'sn=Doe' cn sn title >> $SLAVEOUT 2>&1
|
||
|
RC=$?
|
||
|
if test $RC != 0 ; then
|
||
|
echo "ldapsearch failed ($RC)!"
|
||
|
kill -HUP $PID $CACHEPID
|
||
|
exit $RC
|
||
|
fi
|
||
|
sleep 3
|
||
|
|
||
|
echo "Query 5: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber"
|
||
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
||
|
'uid=bjorn' mail postaladdress telephonenumber >> $SLAVEOUT 2>&1
|
||
|
RC=$?
|
||
|
if test $RC != 0 ; then
|
||
|
echo "ldapsearch failed ($RC)!"
|
||
|
kill -HUP $PID $CACHEPID
|
||
|
exit $RC
|
||
|
fi
|
||
|
sleep 3
|
||
|
|
||
|
echo "Query 6: filter:(mail=*@example.com) cn sn title"
|
||
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
||
|
'mail=*@mail.alumni.example.com' cn sn title >> $SLAVEOUT 2>&1
|
||
|
RC=$?
|
||
|
if test $RC != 0 ; then
|
||
|
echo "ldapsearch failed ($RC)!"
|
||
|
kill -HUP $PID $CACHEPID
|
||
|
exit $RC
|
||
|
fi
|
||
|
sleep 3
|
||
|
|
||
|
echo "Query 7: filter:(mail=*) cn sn title"
|
||
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
||
|
'mail=*' cn sn title >> $SLAVEOUT 2>&1
|
||
|
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
|
||
|
|
||
|
echo "Query 8: filter:(|(cn=*Jones)(sn=Jones)) attrs:cn sn title"
|
||
|
$LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
||
|
'(|(cn=*Jones)(sn=Jones))' cn sn title >> $SLAVEOUT 2>&1
|
||
|
RC=$?
|
||
|
if test $RC != 0 ; then
|
||
|
echo "ldapsearch failed ($RC)!"
|
||
|
kill -HUP $PID $CACHEPID
|
||
|
exit $RC
|
||
|
fi
|
||
|
sleep 3
|
||
|
|
||
|
echo "Query 9: filter:(sn=Smith) attrs:cn sn title"
|
||
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
||
|
'sn=Smith' cn sn title >> $SLAVEOUT 2>&1
|
||
|
RC=$?
|
||
|
if test $RC != 0 ; then
|
||
|
echo "ldapsearch failed ($RC)!"
|
||
|
kill -HUP $PID $CACHEPID
|
||
|
exit $RC
|
||
|
fi
|
||
|
sleep 3
|
||
|
|
||
|
echo "Query 10: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber"
|
||
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
||
|
'uid=bjorn' mail postaladdress telephonenumber >> $SLAVEOUT 2>&1
|
||
|
RC=$?
|
||
|
if test $RC != 0 ; then
|
||
|
echo "ldapsearch failed ($RC)!"
|
||
|
kill -HUP $PID $CACHEPID
|
||
|
exit $RC
|
||
|
fi
|
||
|
sleep 3
|
||
|
|
||
|
echo "Query 11: filter:(mail=*@example.com) cn sn title"
|
||
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
|
||
|
'mail=jaj@mail.alumni.example.com' cn sn title >> $SLAVEOUT 2>&1
|
||
|
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
|