## top-level directory of the distribution or, alternatively, at
## <http://www.OpenLDAP.org/license.html>.
-CACHETTL="1m"
-NCACHETTL="1m"
-SCACHETTL="1m"
-CACHE_ENTRY_LIMIT=6
+PCACHETTL=${PCACHETTL-"1m"}
+PCACHENTTL=${PCACHENTTL-"1m"}
+PCACHESTTL=${PCACHESTTL-"1m"}
+PCACHE_ENTRY_LIMIT=${PCACHE_ENTRY_LIMIT-"6"}
+PCACHE_CCPERIOD=${PCACHE_CCPERIOD-"2"}
+PCACHETTR=${PCACHETTR-"2"}
+PCACHEBTTR=${PCACHEBTTR-"5"}
. $SRCDIR/scripts/defines.sh
fi
echo "Starting proxy cache on TCP/IP port $PORT2..."
-. $CONFFILTER < $PROXYCACHECONF > $CONF2
+. $CONFFILTER < $PROXYCACHECONF | sed \
+ -e "s/@TTL@/${PCACHETTL}/" \
+ -e "s/@NTTL@/${PCACHENTTL}/" \
+ -e "s/@STTL@/${PCACHENTTL}/" \
+ -e "s/@TTR@/${PCACHETTR}/" \
+ -e "s/@ENTRY_LIMIT@/${PCACHE_ENTRY_LIMIT}/" \
+ -e "s/@CCPERIOD@/${PCACHE_CCPERIOD}/" \
+ -e "s/@BTTR@/${PCACHEBTTR}/" \
+ > $CONF2
+
$SLAPD -f $CONF2 -h $URI2 -d $LVL -d pcache > $LOG2 2>&1 &
CACHEPID=$!
if test $WAIT != 0 ; then
FILTER="(mail=*example.com)"
ATTRS="cn sn title uid"
USERDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
-PASSWD="bjorn"
+UPASSWD="bjorn"
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
- -D "$USERDN" -w "$PASSWD" \
+ -D "$USERDN" -w "$UPASSWD" \
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
RC=$?
case $RC in
FILTER="(uid=b*)"
ATTRS="mail"
USERDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
-PASSWD="bjorn"
+UPASSWD="bjorn"
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
- -D "$USERDN" -w "$PASSWD" \
+ -D "$USERDN" -w "$UPASSWD" \
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
RC=$?
case $RC in
FILTER="(mail=*example.com)"
ATTRS="cn sn title uid"
USERDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
-PASSWD="bjorn"
+UPASSWD="bjorn"
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
- -D "$USERDN" -w "$PASSWD" \
+ -D "$USERDN" -w "$UPASSWD" \
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
RC=$?
case $RC in
FILTER="(uid=b*)"
ATTRS="mail"
USERDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
-PASSWD="bjorn"
+UPASSWD="bjorn"
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
- -D "$USERDN" -w "$PASSWD" \
+ -D "$USERDN" -w "$UPASSWD" \
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
RC=$?
case $RC in
}
}'`
-test $KILLSERVERS != no && kill -HUP $KILLPIDS
-
if test "$ANSWERABILITY" = "$ANSWERED" ; then
echo "Successfully verified answerability"
else
echo "Error in verifying answerability"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit 1
fi
if test $? != 0 ; then
echo "Comparison failed"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit 1
fi
+echo ""
+echo "Testing cache refresh"
+
+CNT=`expr $CNT + 1`
+FILTER="(&(objectclass=person)(uid=dots))"
+ATTRS="cn mail telephonenumber"
+echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
+echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
+$LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
+ "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
+RC=$?
+if test $RC != 0 ; then
+ echo "ldapsearch failed ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+fi
+
+$LDAPMODIFY -x -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD <<EOF \
+ > /dev/null 2>&1
+dn: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
+changetype: modify
+replace: mail
+mail: dots@admin.example2.com
+-
+
+EOF
+
+SLEEP=`expr $PCACHETTR + $PCACHE_CCPERIOD`
+echo "Waiting $SLEEP seconds for cache to refresh"
+
+sleep $SLEEP
+
+echo "Checking entry again"
+$LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
+ "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
+RC=$?
+if test $RC != 0 ; then
+ echo "ldapsearch failed ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+fi
+
+grep "^mail: dots@admin" $SEARCHOUT > /dev/null
+RC=$?
+if test $RC != 0 ; then
+ echo "Refresh failed"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait
+ exit 0
+fi
+
+echo ""
+echo "Testing Bind caching"
+
+CNT=`expr $CNT + 1`
+USERDN="cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com"
+UPASSWD="jaj"
+echo "Query $CNT: $USERDN"
+echo "# Query $CNT: $USERDN" >> $SEARCHOUT
+$LDAPSEARCH -S "" -b "" -s base -h $LOCALHOST -p $PORT2 \
+ -D "$USERDN" -w "$UPASSWD" >> $SEARCHOUT 2>> $TESTOUT
+RC=$?
+if test $RC != 0 ; then
+ echo "ldapsearch failed ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+fi
+
+grep "CACHING BIND" $LOG2 > /dev/null
+RC=$?
+if test $RC != 0 ; then
+ echo "Refresh failed"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait
+ exit 0
+fi
+
+CNT=`expr $CNT + 1`
+USERDN="cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com"
+UPASSWD="jaj"
+echo "Query $CNT: (Bind should be cached)"
+echo "# Query $CNT: (Bind should be cached)" >> $SEARCHOUT
+$LDAPSEARCH -S "" -b "" -s base -h $LOCALHOST -p $PORT2 \
+ -D "$USERDN" -w "$UPASSWD" >> $SEARCHOUT 2>> $TESTOUT
+RC=$?
+if test $RC != 0 ; then
+ echo "ldapsearch failed ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+fi
+
+grep "CACHED BIND" $LOG2 > /dev/null
+RC=$?
+if test $RC != 0 ; then
+ echo "Refresh failed"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait
+ exit 0
+fi
+
+test $KILLSERVERS != no && kill -HUP $KILLPIDS
+
echo ">>>>> Test succeeded"
test $KILLSERVERS != no && wait