3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2004 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
19 . $SRCDIR/scripts/defines.sh
21 if test $PROXYCACHE = pcacheno; then
22 echo "Proxy cache overlay not available, test skipped"
26 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
32 # - perform first set of searches at the proxy
33 # - verify cacheability
34 # - perform second set of searches at the proxy
35 # - verify answerability
37 echo "Starting master slapd on TCP/IP port $PORT1..."
38 . $CONFFILTER < $CACHEMASTERCONF > $CONF1
39 $SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 &
41 if test $WAIT != 0 ; then
47 echo "Using ldapsearch to check that master slapd is running..."
48 for i in 0 1 2 3 4 5; do
49 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
50 'objectclass=*' > /dev/null 2>&1
52 if test $RC = 0 ; then
55 echo "Waiting 5 seconds for slapd to start..."
59 if test $RC != 0 ; then
60 echo "ldapsearch failed ($RC)!"
61 test $KILLSERVERS != no && kill -HUP $KILLPIDS
65 echo "Using ldapadd to populate the master directory..."
66 $LDAPADD -x -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
67 $LDIFORDERED > /dev/null 2>&1
69 if test $RC != 0 ; then
70 echo "ldapadd failed ($RC)!"
71 test $KILLSERVERS != no && kill -HUP $KILLPIDS
75 echo "Starting proxy cache on TCP/IP port $PORT2..."
76 . $CONFFILTER < $PROXYCACHECONF > $CONF2
77 $SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
79 if test $WAIT != 0 ; then
80 echo CACHEPID $CACHEPID
83 KILLPIDS="$KILLPIDS $CACHEPID"
85 echo "Using ldapsearch to check that proxy slapd is running..."
86 for i in 0 1 2 3 4 5; do
87 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
88 'objectclass=*' > /dev/null 2>&1
90 if test $RC = 0 ; then
93 echo "Waiting 5 seconds for slapd to start..."
97 if test $RC != 0 ; then
98 echo "ldapsearch failed ($RC)!"
99 test $KILLSERVERS != no && kill -HUP $KILLPIDS
103 echo "Making queries on the proxy cache..."
104 echo "Query 1: filter:(sn=Jon) attrs: all"
105 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
106 'sn=Jon' > $SLAVEOUT 2>&1
108 if test $RC != 0 ; then
109 echo "ldapsearch failed ($RC)!"
110 test $KILLSERVERS != no && kill -HUP $KILLPIDS
114 echo "Query 2: filter:(|(cn=*Jon*)(sn=Jon*)) attrs:cn sn title uid"
115 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
116 '(|(cn=*Jon*)(sn=Jon*))' cn sn title uid >> $SLAVEOUT 2>&1
118 if test $RC != 0 ; then
119 echo "ldapsearch failed ($RC)!"
120 test $KILLSERVERS != no && kill -HUP $KILLPIDS
124 echo "Query 3: filter:(sn=Smith*) attrs:cn sn title uid"
125 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
126 'sn=Smith*' cn sn title uid >> $SLAVEOUT 2>&1
128 if test $RC != 0 ; then
129 echo "ldapsearch failed ($RC)!"
130 test $KILLSERVERS != no && kill -HUP $KILLPIDS
134 echo "Query 4: filter:(sn=Doe*) attrs:cn sn title uid"
135 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
136 'sn=Doe' cn sn title uid >> $SLAVEOUT 2>&1
138 if test $RC != 0 ; then
139 echo "ldapsearch failed ($RC)!"
140 test $KILLSERVERS != no && kill -HUP $KILLPIDS
144 echo "Query 5: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
145 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
146 'uid=bjorn' mail postaladdress telephonenumber cn uid >> $SLAVEOUT 2>&1
148 if test $RC != 0 ; then
149 echo "ldapsearch failed ($RC)!"
150 test $KILLSERVERS != no && kill -HUP $KILLPIDS
154 echo "Query 6: filter:(mail=*@example.com) cn sn title uid"
155 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
156 'mail=*@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
158 if test $RC != 0 ; then
159 echo "ldapsearch failed ($RC)!"
160 test $KILLSERVERS != no && kill -HUP $KILLPIDS
164 echo "Query 7: filter:(mail=*) cn sn title uid"
165 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
166 'mail=*' cn sn title uid >> $SLAVEOUT 2>&1
168 if test $RC != 0 ; then
169 echo "ldapsearch failed ($RC)!"
170 test $KILLSERVERS != no && kill -HUP $KILLPIDS
174 # queries 2-6 are cacheable
176 grep CACHEABLE $LOG2 | awk '{
178 printf "Query %d not cacheable\n",NR
180 printf "Query %d cacheable\n",NR
182 CACHED=`grep CACHEABLE $LOG2 | awk '{
189 if test "$CACHEABILITY" = "$CACHED" ; then
190 echo "Successfully verified cacheability"
192 echo "Error in verifying cacheability"
193 test $KILLSERVERS != no && kill -HUP $KILLPIDS
197 echo "Query 8: filter:(|(cn=*Jones)(sn=Jones)) attrs:cn sn title uid"
198 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
199 '(|(cn=*Jones)(sn=Jones))' cn sn title uid >> $SLAVEOUT 2>&1
201 if test $RC != 0 ; then
202 echo "ldapsearch failed ($RC)!"
203 test $KILLSERVERS != no && kill -HUP $KILLPIDS
207 echo "Query 9: filter:(sn=Smith) attrs:cn sn title uid"
208 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
209 'sn=Smith' cn sn title uid >> $SLAVEOUT 2>&1
211 if test $RC != 0 ; then
212 echo "ldapsearch failed ($RC)!"
213 test $KILLSERVERS != no && kill -HUP $KILLPIDS
217 echo "Query 10: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
218 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
219 'uid=bjorn' mail postaladdress telephonenumber cn uid >> $SLAVEOUT 2>&1
221 if test $RC != 0 ; then
222 echo "ldapsearch failed ($RC)!"
223 test $KILLSERVERS != no && kill -HUP $KILLPIDS
227 echo "Query 11: filter:(mail=*@example.com) cn sn title uid"
228 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
229 'mail=jaj@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
232 if test $RC != 0 ; then
233 echo "ldapsearch failed ($RC)!"
234 test $KILLSERVERS != no && kill -HUP $KILLPIDS
238 #queries 8-11 are answerable
240 grep ANSWERABLE $LOG2 | awk '{
243 printf "Query %d not answerable\n",NR
245 printf "Query %d answerable\n",NR
248 ANSWERED=`grep ANSWERABLE $LOG2 | awk '{
257 test $KILLSERVERS != no && kill -HUP $KILLPIDS
259 if test "$ANSWERABILITY" = "$ANSWERED" ; then
260 echo "Successfully verified answerability"
262 echo "Error in verifying answerability"
266 echo ">>>>> Test succeeded"