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 echo "Making queries on the proxy cache..."
103 echo "Query 1: filter:(sn=Jon) attrs: all"
104 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
105 'sn=Jon' > $SLAVEOUT 2>&1
107 if test $RC != 0 ; then
108 echo "ldapsearch failed ($RC)!"
109 test $KILLSERVERS != no && kill -HUP $KILLPIDS
113 echo "Query 2: filter:(|(cn=*Jon*)(sn=Jon*)) attrs:cn sn title uid"
114 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
115 '(|(cn=*Jon*)(sn=Jon*))' cn sn title uid >> $SLAVEOUT 2>&1
117 if test $RC != 0 ; then
118 echo "ldapsearch failed ($RC)!"
119 test $KILLSERVERS != no && kill -HUP $KILLPIDS
123 echo "Query 3: filter:(sn=Smith*) attrs:cn sn title uid"
124 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
125 'sn=Smith*' cn sn title uid >> $SLAVEOUT 2>&1
127 if test $RC != 0 ; then
128 echo "ldapsearch failed ($RC)!"
129 test $KILLSERVERS != no && kill -HUP $KILLPIDS
133 echo "Query 4: filter:(sn=Doe*) attrs:cn sn title uid"
134 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
135 'sn=Doe' cn sn title uid >> $SLAVEOUT 2>&1
137 if test $RC != 0 ; then
138 echo "ldapsearch failed ($RC)!"
139 test $KILLSERVERS != no && kill -HUP $KILLPIDS
143 echo "Query 5: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
144 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
145 'uid=bjorn' mail postaladdress telephonenumber cn uid >> $SLAVEOUT 2>&1
147 if test $RC != 0 ; then
148 echo "ldapsearch failed ($RC)!"
149 test $KILLSERVERS != no && kill -HUP $KILLPIDS
153 echo "Query 6: filter:(mail=*@mail.alumni.example.com) cn sn title uid"
154 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
155 'mail=*@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
157 if test $RC != 0 ; then
158 echo "ldapsearch failed ($RC)!"
159 test $KILLSERVERS != no && kill -HUP $KILLPIDS
163 echo "Query 7: filter:(mail=*) cn sn title uid"
164 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
165 'mail=*' cn sn title uid >> $SLAVEOUT 2>&1
167 if test $RC != 0 ; then
168 echo "ldapsearch failed ($RC)!"
169 test $KILLSERVERS != no && kill -HUP $KILLPIDS
173 # queries 2-6 are cacheable
175 grep CACHEABLE $LOG2 | awk '{
177 printf "Query %d not cacheable\n",NR
179 printf "Query %d cacheable\n",NR
181 CACHED=`grep CACHEABLE $LOG2 | awk '{
188 if test "$CACHEABILITY" = "$CACHED" ; then
189 echo "Successfully verified cacheability"
191 echo "Error in verifying cacheability"
192 test $KILLSERVERS != no && kill -HUP $KILLPIDS
196 echo "ANSWERABILITY RESULTS" >> $SLAVEOUT
199 echo "Query 8: filter:(|(cn=*Jones)(sn=Jones)) attrs:cn sn title uid"
200 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
201 '(|(cn=*Jones)(sn=Jones))' cn sn title uid >> $SLAVEOUT 2>&1
203 if test $RC != 0 ; then
204 echo "ldapsearch failed ($RC)!"
205 test $KILLSERVERS != no && kill -HUP $KILLPIDS
209 echo "Query 9: filter:(sn=Smith) attrs:cn sn title uid"
210 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
211 'sn=Smith' cn sn title uid >> $SLAVEOUT 2>&1
213 if test $RC != 0 ; then
214 echo "ldapsearch failed ($RC)!"
215 test $KILLSERVERS != no && kill -HUP $KILLPIDS
219 echo "Query 10: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
220 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
221 'uid=bjorn' mail postaladdress telephonenumber cn uid >> $SLAVEOUT 2>&1
223 if test $RC != 0 ; then
224 echo "ldapsearch failed ($RC)!"
225 test $KILLSERVERS != no && kill -HUP $KILLPIDS
229 echo "Query 11: filter:(mail=jaj@mail.alumni.example.com) cn sn title uid"
230 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
231 'mail=jaj@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
234 if test $RC != 0 ; then
235 echo "ldapsearch failed ($RC)!"
236 test $KILLSERVERS != no && kill -HUP $KILLPIDS
240 #queries 8-11 are answerable
242 grep ANSWERABLE $LOG2 | awk '{
245 printf "Query %d not answerable\n",NR
247 printf "Query %d answerable\n",NR
250 ANSWERED=`grep ANSWERABLE $LOG2 | awk '{
259 test $KILLSERVERS != no && kill -HUP $KILLPIDS
261 if test "$ANSWERABILITY" = "$ANSWERED" ; then
262 echo "Successfully verified answerability"
264 echo "Error in verifying answerability"
268 echo "Comparing cache output..."
269 $CMP $SLAVEOUT $PROXYCACHEOUT > $CMPOUT
271 if test $? != 0 ; then
272 echo "Comparison failed"
276 echo ">>>>> Test succeeded"