3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2005 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 if test $BACKLDAP = "ldapno" ; then
27 echo "LDAP backend not available, test skipped"
31 if test "x$LVL" = "x0" ; then
32 echo "test020 needs a minimal log level; setting to LDAP_DEBUG_NONE..."
36 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
42 # - perform first set of searches at the proxy
43 # - verify cacheability
44 # - perform second set of searches at the proxy
45 # - verify answerability
47 echo "Starting master slapd on TCP/IP port $PORT1..."
48 . $CONFFILTER < $CACHEMASTERCONF > $CONF1
49 $SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 &
51 if test $WAIT != 0 ; then
57 echo "Using ldapsearch to check that master slapd is running..."
58 for i in 0 1 2 3 4 5; do
59 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
60 'objectclass=*' > /dev/null 2>&1
62 if test $RC = 0 ; then
65 echo "Waiting 5 seconds for slapd to start..."
69 if test $RC != 0 ; then
70 echo "ldapsearch failed ($RC)!"
71 test $KILLSERVERS != no && kill -HUP $KILLPIDS
75 echo "Using ldapadd to populate the master directory..."
76 $LDAPADD -x -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
77 $LDIFORDERED > /dev/null 2>&1
79 if test $RC != 0 ; then
80 echo "ldapadd failed ($RC)!"
81 test $KILLSERVERS != no && kill -HUP $KILLPIDS
85 echo "Starting proxy cache on TCP/IP port $PORT2..."
86 . $CONFFILTER < $PROXYCACHECONF > $CONF2
87 $SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
89 if test $WAIT != 0 ; then
90 echo CACHEPID $CACHEPID
93 KILLPIDS="$KILLPIDS $CACHEPID"
95 echo "Using ldapsearch to check that proxy slapd is running..."
96 for i in 0 1 2 3 4 5; do
97 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
98 'objectclass=*' > /dev/null 2>&1
100 if test $RC = 0 ; then
103 echo "Waiting 5 seconds for slapd to start..."
107 if test $RC != 0 ; then
108 echo "ldapsearch failed ($RC)!"
109 test $KILLSERVERS != no && kill -HUP $KILLPIDS
113 echo "Making queries on the proxy cache..."
114 echo "Query 1: filter:(sn=Jon) attrs: all"
115 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
116 'sn=Jon' > $SLAVEOUT 2>&1
118 if test $RC != 0 ; then
119 echo "ldapsearch failed ($RC)!"
120 test $KILLSERVERS != no && kill -HUP $KILLPIDS
124 echo "Query 2: filter:(|(cn=*Jon*)(sn=Jon*)) attrs:cn sn title uid"
125 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
126 '(|(cn=*Jon*)(sn=Jon*))' 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 3: filter:(sn=Smith*) attrs:cn sn title uid"
135 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
136 'sn=Smith*' 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 4: filter:(sn=Doe*) attrs:cn sn title uid"
145 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
146 'sn=Doe' cn sn title 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 5: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
155 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
156 'uid=bjorn' mail postaladdress telephonenumber cn 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 6: filter:(mail=*@mail.alumni.example.com) cn sn title uid"
165 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
166 'mail=*@mail.alumni.example.com' 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 echo "Query 7: filter:(mail=*) cn sn title uid"
175 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
176 'mail=*' cn sn title uid >> $SLAVEOUT 2>&1
178 if test $RC != 0 ; then
179 echo "ldapsearch failed ($RC)!"
180 test $KILLSERVERS != no && kill -HUP $KILLPIDS
184 # queries 2-6 are cacheable
186 grep CACHEABLE $LOG2 | awk '{
188 printf "Query %d not cacheable\n",NR
190 printf "Query %d cacheable\n",NR
192 CACHED=`grep CACHEABLE $LOG2 | awk '{
199 if test "$CACHEABILITY" = "$CACHED" ; then
200 echo "Successfully verified cacheability"
202 echo "Error in verifying cacheability"
203 test $KILLSERVERS != no && kill -HUP $KILLPIDS
207 echo "Query 8: filter:(|(cn=*Jones)(sn=Jones)) attrs:cn sn title uid"
208 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
209 '(|(cn=*Jones)(sn=Jones))' 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 9: filter:(sn=Smith) attrs:cn sn title uid"
218 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
219 'sn=Smith' cn sn title 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 10: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
228 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
229 'uid=bjorn' mail postaladdress telephonenumber cn uid >> $SLAVEOUT 2>&1
231 if test $RC != 0 ; then
232 echo "ldapsearch failed ($RC)!"
233 test $KILLSERVERS != no && kill -HUP $KILLPIDS
237 echo "Query 11: filter:(mail=jaj@mail.alumni.example.com) cn sn title uid"
238 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
239 'mail=jaj@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
242 if test $RC != 0 ; then
243 echo "ldapsearch failed ($RC)!"
244 test $KILLSERVERS != no && kill -HUP $KILLPIDS
248 #queries 8-11 are answerable
250 grep ANSWERABLE $LOG2 | awk '{
253 printf "Query %d not answerable\n",NR
255 printf "Query %d answerable\n",NR
258 ANSWERED=`grep ANSWERABLE $LOG2 | awk '{
267 test $KILLSERVERS != no && kill -HUP $KILLPIDS
269 if test "$ANSWERABILITY" = "$ANSWERED" ; then
270 echo "Successfully verified answerability"
272 echo "Error in verifying answerability"
276 echo "Comparing cache output..."
277 $CMP $SLAVEOUT $PROXYCACHEOUT > $CMPOUT
279 if test $? != 0 ; then
280 echo "Comparison failed"
284 echo ">>>>> Test succeeded"