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 echo "Making queries on the proxy cache..."
98 echo "Query 1: filter:(sn=Jon) attrs: all"
99 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
100 'sn=Jon' > $SLAVEOUT 2>&1
102 if test $RC != 0 ; then
103 echo "ldapsearch failed ($RC)!"
104 test $KILLSERVERS != no && kill -HUP $KILLPIDS
108 echo "Query 2: filter:(|(cn=*Jon*)(sn=Jon*)) attrs:cn sn title uid"
109 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
110 '(|(cn=*Jon*)(sn=Jon*))' cn sn title uid >> $SLAVEOUT 2>&1
112 if test $RC != 0 ; then
113 echo "ldapsearch failed ($RC)!"
114 test $KILLSERVERS != no && kill -HUP $KILLPIDS
118 echo "Query 3: filter:(sn=Smith*) attrs:cn sn title uid"
119 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
120 'sn=Smith*' cn sn title uid >> $SLAVEOUT 2>&1
122 if test $RC != 0 ; then
123 echo "ldapsearch failed ($RC)!"
124 test $KILLSERVERS != no && kill -HUP $KILLPIDS
128 echo "Query 4: filter:(sn=Doe*) attrs:cn sn title uid"
129 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
130 'sn=Doe' cn sn title uid >> $SLAVEOUT 2>&1
132 if test $RC != 0 ; then
133 echo "ldapsearch failed ($RC)!"
134 test $KILLSERVERS != no && kill -HUP $KILLPIDS
138 echo "Query 5: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
139 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
140 'uid=bjorn' mail postaladdress telephonenumber cn 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 6: filter:(mail=*@example.com) cn sn title uid"
149 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
150 'mail=*@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
152 if test $RC != 0 ; then
153 echo "ldapsearch failed ($RC)!"
154 test $KILLSERVERS != no && kill -HUP $KILLPIDS
158 echo "Query 7: filter:(mail=*) cn sn title uid"
159 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
160 'mail=*' cn sn title uid >> $SLAVEOUT 2>&1
162 if test $RC != 0 ; then
163 echo "ldapsearch failed ($RC)!"
164 test $KILLSERVERS != no && kill -HUP $KILLPIDS
168 # queries 2-6 are cacheable
170 grep CACHEABLE $LOG2 | awk '{
172 printf "Query %d not cacheable\n",NR
174 printf "Query %d cacheable\n",NR
176 CACHED=`grep CACHEABLE $LOG2 | awk '{
183 if test "$CACHEABILITY" = "$CACHED" ; then
184 echo "Successfully verified cacheability"
186 echo "Error in verifying cacheability"
187 test $KILLSERVERS != no && kill -HUP $KILLPIDS
191 echo "Query 8: filter:(|(cn=*Jones)(sn=Jones)) attrs:cn sn title uid"
192 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
193 '(|(cn=*Jones)(sn=Jones))' cn sn title uid >> $SLAVEOUT 2>&1
195 if test $RC != 0 ; then
196 echo "ldapsearch failed ($RC)!"
197 test $KILLSERVERS != no && kill -HUP $KILLPIDS
201 echo "Query 9: filter:(sn=Smith) attrs:cn sn title uid"
202 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
203 'sn=Smith' cn sn title uid >> $SLAVEOUT 2>&1
205 if test $RC != 0 ; then
206 echo "ldapsearch failed ($RC)!"
207 test $KILLSERVERS != no && kill -HUP $KILLPIDS
211 echo "Query 10: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
212 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
213 'uid=bjorn' mail postaladdress telephonenumber cn uid >> $SLAVEOUT 2>&1
215 if test $RC != 0 ; then
216 echo "ldapsearch failed ($RC)!"
217 test $KILLSERVERS != no && kill -HUP $KILLPIDS
221 echo "Query 11: filter:(mail=*@example.com) cn sn title uid"
222 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
223 'mail=jaj@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
226 if test $RC != 0 ; then
227 echo "ldapsearch failed ($RC)!"
228 test $KILLSERVERS != no && kill -HUP $KILLPIDS
232 #queries 8-11 are answerable
234 grep ANSWERABLE $LOG2 | awk '{
237 printf "Query %d not answerable\n",NR
239 printf "Query %d answerable\n",NR
242 ANSWERED=`grep ANSWERABLE $LOG2 | awk '{
251 test $KILLSERVERS != no && kill -HUP $KILLPIDS
253 if test "$ANSWERABILITY" = "$ANSWERED" ; then
254 echo "Successfully verified answerability"
256 echo "Error in verifying answerability"
260 echo ">>>>> Test succeeded"