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 if test $BACKLDAP = "ldapno" ; then
27 echo "LDAP backend not available, test skipped"
31 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
37 # - perform first set of searches at the proxy
38 # - verify cacheability
39 # - perform second set of searches at the proxy
40 # - verify answerability
42 echo "Starting master slapd on TCP/IP port $PORT1..."
43 . $CONFFILTER < $CACHEMASTERCONF > $CONF1
44 $SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 &
46 if test $WAIT != 0 ; then
52 echo "Using ldapsearch to check that master slapd is running..."
53 for i in 0 1 2 3 4 5; do
54 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
55 'objectclass=*' > /dev/null 2>&1
57 if test $RC = 0 ; then
60 echo "Waiting 5 seconds for slapd to start..."
64 if test $RC != 0 ; then
65 echo "ldapsearch failed ($RC)!"
66 test $KILLSERVERS != no && kill -HUP $KILLPIDS
70 echo "Using ldapadd to populate the master directory..."
71 $LDAPADD -x -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
72 $LDIFORDERED > /dev/null 2>&1
74 if test $RC != 0 ; then
75 echo "ldapadd failed ($RC)!"
76 test $KILLSERVERS != no && kill -HUP $KILLPIDS
80 echo "Starting proxy cache on TCP/IP port $PORT2..."
81 . $CONFFILTER < $PROXYCACHECONF > $CONF2
82 $SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
84 if test $WAIT != 0 ; then
85 echo CACHEPID $CACHEPID
88 KILLPIDS="$KILLPIDS $CACHEPID"
90 echo "Using ldapsearch to check that proxy slapd is running..."
91 for i in 0 1 2 3 4 5; do
92 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
93 'objectclass=*' > /dev/null 2>&1
95 if test $RC = 0 ; then
98 echo "Waiting 5 seconds for slapd to start..."
102 if test $RC != 0 ; then
103 echo "ldapsearch failed ($RC)!"
104 test $KILLSERVERS != no && kill -HUP $KILLPIDS
108 echo "Making queries on the proxy cache..."
109 echo "Query 1: filter:(sn=Jon) attrs: all"
110 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
111 'sn=Jon' > $SLAVEOUT 2>&1
113 if test $RC != 0 ; then
114 echo "ldapsearch failed ($RC)!"
115 test $KILLSERVERS != no && kill -HUP $KILLPIDS
119 echo "Query 2: filter:(|(cn=*Jon*)(sn=Jon*)) attrs:cn sn title uid"
120 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
121 '(|(cn=*Jon*)(sn=Jon*))' cn sn title uid >> $SLAVEOUT 2>&1
123 if test $RC != 0 ; then
124 echo "ldapsearch failed ($RC)!"
125 test $KILLSERVERS != no && kill -HUP $KILLPIDS
129 echo "Query 3: filter:(sn=Smith*) attrs:cn sn title uid"
130 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
131 'sn=Smith*' cn sn title uid >> $SLAVEOUT 2>&1
133 if test $RC != 0 ; then
134 echo "ldapsearch failed ($RC)!"
135 test $KILLSERVERS != no && kill -HUP $KILLPIDS
139 echo "Query 4: filter:(sn=Doe*) attrs:cn sn title uid"
140 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
141 'sn=Doe' cn sn title uid >> $SLAVEOUT 2>&1
143 if test $RC != 0 ; then
144 echo "ldapsearch failed ($RC)!"
145 test $KILLSERVERS != no && kill -HUP $KILLPIDS
149 echo "Query 5: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
150 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
151 'uid=bjorn' mail postaladdress telephonenumber cn uid >> $SLAVEOUT 2>&1
153 if test $RC != 0 ; then
154 echo "ldapsearch failed ($RC)!"
155 test $KILLSERVERS != no && kill -HUP $KILLPIDS
159 echo "Query 6: filter:(mail=*@mail.alumni.example.com) cn sn title uid"
160 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
161 'mail=*@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
163 if test $RC != 0 ; then
164 echo "ldapsearch failed ($RC)!"
165 test $KILLSERVERS != no && kill -HUP $KILLPIDS
169 echo "Query 7: filter:(mail=*) cn sn title uid"
170 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
171 'mail=*' cn sn title uid >> $SLAVEOUT 2>&1
173 if test $RC != 0 ; then
174 echo "ldapsearch failed ($RC)!"
175 test $KILLSERVERS != no && kill -HUP $KILLPIDS
179 # queries 2-6 are cacheable
181 grep CACHEABLE $LOG2 | awk '{
183 printf "Query %d not cacheable\n",NR
185 printf "Query %d cacheable\n",NR
187 CACHED=`grep CACHEABLE $LOG2 | awk '{
194 if test "$CACHEABILITY" = "$CACHED" ; then
195 echo "Successfully verified cacheability"
197 echo "Error in verifying cacheability"
198 test $KILLSERVERS != no && kill -HUP $KILLPIDS
202 echo "ANSWERABILITY RESULTS" >> $SLAVEOUT
205 echo "Query 8: filter:(|(cn=*Jones)(sn=Jones)) attrs:cn sn title uid"
206 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
207 '(|(cn=*Jones)(sn=Jones))' cn sn title uid >> $SLAVEOUT 2>&1
209 if test $RC != 0 ; then
210 echo "ldapsearch failed ($RC)!"
211 test $KILLSERVERS != no && kill -HUP $KILLPIDS
215 echo "Query 9: filter:(sn=Smith) attrs:cn sn title uid"
216 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
217 'sn=Smith' cn sn title uid >> $SLAVEOUT 2>&1
219 if test $RC != 0 ; then
220 echo "ldapsearch failed ($RC)!"
221 test $KILLSERVERS != no && kill -HUP $KILLPIDS
225 echo "Query 10: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
226 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
227 'uid=bjorn' mail postaladdress telephonenumber cn uid >> $SLAVEOUT 2>&1
229 if test $RC != 0 ; then
230 echo "ldapsearch failed ($RC)!"
231 test $KILLSERVERS != no && kill -HUP $KILLPIDS
235 echo "Query 11: filter:(mail=jaj@mail.alumni.example.com) cn sn title uid"
236 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
237 'mail=jaj@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
240 if test $RC != 0 ; then
241 echo "ldapsearch failed ($RC)!"
242 test $KILLSERVERS != no && kill -HUP $KILLPIDS
246 #queries 8-11 are answerable
248 grep ANSWERABLE $LOG2 | awk '{
251 printf "Query %d not answerable\n",NR
253 printf "Query %d answerable\n",NR
256 ANSWERED=`grep ANSWERABLE $LOG2 | awk '{
265 test $KILLSERVERS != no && kill -HUP $KILLPIDS
267 if test "$ANSWERABILITY" = "$ANSWERED" ; then
268 echo "Successfully verified answerability"
270 echo "Error in verifying answerability"
274 echo "Comparing cache output..."
275 $CMP $SLAVEOUT $PROXYCACHEOUT > $CMPOUT
277 if test $? != 0 ; then
278 echo "Comparison failed"
282 echo ">>>>> Test succeeded"