3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2006 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
54 echo "Using ldapsearch to check that master slapd is running..."
55 for i in 0 1 2 3 4 5; do
56 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
57 'objectclass=*' > /dev/null 2>&1
59 if test $RC = 0 ; then
62 echo "Waiting 5 seconds for slapd to start..."
66 if test $RC != 0 ; then
67 echo "ldapsearch failed ($RC)!"
68 test $KILLSERVERS != no && kill -HUP $KILLPIDS
72 echo "Using ldapadd to populate the master directory..."
73 $LDAPADD -x -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
74 $LDIFORDERED > /dev/null 2>&1
76 if test $RC != 0 ; then
77 echo "ldapadd failed ($RC)!"
78 test $KILLSERVERS != no && kill -HUP $KILLPIDS
82 echo "Starting proxy cache on TCP/IP port $PORT2..."
83 . $CONFFILTER < $PROXYCACHECONF > $CONF2
84 $SLAPD -f $CONF2 -h $URI2 -d $LVL -d pcache > $LOG2 2>&1 &
86 if test $WAIT != 0 ; then
87 echo CACHEPID $CACHEPID
90 KILLPIDS="$KILLPIDS $CACHEPID"
94 echo "Using ldapsearch to check that proxy slapd is running..."
95 for i in 0 1 2 3 4 5; do
96 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
97 'objectclass=*' > /dev/null 2>&1
99 if test $RC = 0 ; then
102 echo "Waiting 5 seconds for slapd to start..."
106 if test $RC != 0 ; then
107 echo "ldapsearch failed ($RC)!"
108 test $KILLSERVERS != no && kill -HUP $KILLPIDS
112 cat /dev/null > $SLAVEOUT
114 echo "Making queries on the proxy cache..."
115 echo "Query 1: filter:(sn=Jon) attrs: all"
116 echo "# Query 1: filter:(sn=Jon) attrs: all" >> $SLAVEOUT
117 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
118 'sn=Jon' >> $SLAVEOUT 2>&1
120 if test $RC != 0 ; then
121 echo "ldapsearch failed ($RC)!"
122 test $KILLSERVERS != no && kill -HUP $KILLPIDS
126 echo "Query 2: filter:(|(cn=*Jon*)(sn=Jon*)) attrs:cn sn title uid"
127 echo "# Query 2: filter:(|(cn=*Jon*)(sn=Jon*)) attrs:cn sn title uid" >> $SLAVEOUT
128 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
129 '(|(cn=*Jon*)(sn=Jon*))' cn sn title uid >> $SLAVEOUT 2>&1
131 if test $RC != 0 ; then
132 echo "ldapsearch failed ($RC)!"
133 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 echo "Query 3: filter:(sn=Smith*) attrs:cn sn uid"
138 echo "# Query 3: filter:(sn=Smith*) attrs:cn sn uid" >> $SLAVEOUT
139 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
140 'sn=Smith*' cn sn uid >> $SLAVEOUT 2>&1
142 if test $RC != 0 ; then
143 echo "ldapsearch failed ($RC)!"
144 test $KILLSERVERS != no && kill -HUP $KILLPIDS
148 echo "Query 4: filter:(sn=Doe*) attrs:cn sn title uid"
149 echo "# Query 4: filter:(sn=Doe*) attrs:cn sn title uid" >> $SLAVEOUT
150 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
151 'sn=Doe' cn sn title 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 5: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
160 echo "# Query 5: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid" >> $SLAVEOUT
161 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
162 'uid=bjorn' mail postaladdress telephonenumber cn uid >> $SLAVEOUT 2>&1
164 if test $RC != 0 ; then
165 echo "ldapsearch failed ($RC)!"
166 test $KILLSERVERS != no && kill -HUP $KILLPIDS
170 echo "Query 6: filter:(mail=*@mail.alumni.example.com) cn sn title uid"
171 echo "# Query 6: filter:(mail=*@mail.alumni.example.com) cn sn title uid" >> $SLAVEOUT
172 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
173 'mail=*@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
175 if test $RC != 0 ; then
176 echo "ldapsearch failed ($RC)!"
177 test $KILLSERVERS != no && kill -HUP $KILLPIDS
181 echo "Query 7: filter:(mail=*) cn sn title uid"
182 echo "# Query 7: filter:(mail=*) cn sn title uid" >> $SLAVEOUT
183 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
184 'mail=*' cn sn title uid >> $SLAVEOUT 2>&1
186 if test $RC != 0 ; then
187 echo "ldapsearch failed ($RC)!"
188 test $KILLSERVERS != no && kill -HUP $KILLPIDS
192 # queries 2-6 are cacheable
194 grep CACHEABLE $LOG2 | awk '{
196 printf "Query %d not cacheable\n",NR
198 printf "Query %d cacheable\n",NR
200 CACHED=`grep CACHEABLE $LOG2 | awk '{
207 if test "$CACHEABILITY" = "$CACHED" ; then
208 echo "Successfully verified cacheability"
210 echo "Error in verifying cacheability"
211 test $KILLSERVERS != no && kill -HUP $KILLPIDS
215 echo "Query 8: filter:(|(cn=*Jones)(sn=Jones)) attrs:cn sn title uid"
216 echo "# Query 8: filter:(|(cn=*Jones)(sn=Jones)) attrs:cn sn title uid" >> $SLAVEOUT
217 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
218 '(|(cn=*Jones)(sn=Jones))' cn sn title uid >> $SLAVEOUT 2>&1
220 if test $RC != 0 ; then
221 echo "ldapsearch failed ($RC)!"
222 test $KILLSERVERS != no && kill -HUP $KILLPIDS
226 echo "Query 9: filter:(sn=Smith) attrs:cn sn title uid"
227 echo "# Query 9: filter:(sn=Smith) attrs:cn sn title uid" >> $SLAVEOUT
228 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
229 'sn=Smith' cn sn title 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 10: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
238 echo "# Query 10: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid" >> $SLAVEOUT
239 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
240 'uid=bjorn' mail postaladdress telephonenumber cn uid >> $SLAVEOUT 2>&1
242 if test $RC != 0 ; then
243 echo "ldapsearch failed ($RC)!"
244 test $KILLSERVERS != no && kill -HUP $KILLPIDS
248 echo "Query 11: filter:(mail=jaj@mail.alumni.example.com) cn sn title uid"
249 echo "# Query 11: filter:(mail=jaj@mail.alumni.example.com) cn sn title uid" >> $SLAVEOUT
250 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
251 'mail=jaj@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
254 if test $RC != 0 ; then
255 echo "ldapsearch failed ($RC)!"
256 test $KILLSERVERS != no && kill -HUP $KILLPIDS
260 #queries 8-11 are answerable
262 grep ANSWERABLE $LOG2 | awk '{
265 printf "Query %d not answerable\n",NR
267 printf "Query %d answerable\n",NR
270 ANSWERED=`grep ANSWERABLE $LOG2 | awk '{
279 test $KILLSERVERS != no && kill -HUP $KILLPIDS
281 if test "$ANSWERABILITY" = "$ANSWERED" ; then
282 echo "Successfully verified answerability"
284 echo "Error in verifying answerability"
288 echo "Filtering ldapsearch results..."
289 . $LDIFFILTER < $SLAVEOUT > $SEARCHFLT
290 echo "Filtering original ldif..."
291 . $LDIFFILTER < $PROXYCACHEOUT > $LDIFFLT
292 echo "Comparing filter output..."
293 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
295 if test $? != 0 ; then
296 echo "Comparison failed"
300 echo ">>>>> Test succeeded"
302 test $KILLSERVERS != no && wait