7 . $SRCDIR/scripts/defines.sh
9 if test $PROXYCACHE = no; then
10 echo "Proxy caching requires back-meta AND (back-ldbm OR back-bdb)"
14 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
20 # - perform first set of searches at the proxy
21 # - verify cacheability
22 # - perform second set of searches at the proxy
23 # - verify answerability
25 echo "Starting master slapd on TCP/IP port $PORT1..."
26 . $CONFFILTER < $CACHEMASTERCONF > $CONF1
27 $SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 &
29 if test $WAIT != 0 ; then
35 echo "Using ldapsearch to check that master slapd is running..."
36 for i in 0 1 2 3 4 5; do
37 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
38 'objectclass=*' > /dev/null 2>&1
40 if test $RC = 0 ; then
43 echo "Waiting 5 seconds for slapd to start..."
47 if test $RC != 0 ; then
48 echo "ldapsearch failed ($RC)!"
49 test $KILLSERVERS != no && kill -HUP $KILLPIDS
53 echo "Using ldapadd to populate the master directory..."
54 $LDAPADD -x -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
55 $LDIFORDERED > /dev/null 2>&1
57 if test $RC != 0 ; then
58 echo "ldapadd failed ($RC)!"
59 test $KILLSERVERS != no && kill -HUP $KILLPIDS
63 echo "Starting proxy cache on TCP/IP port $PORT2..."
64 . $CONFFILTER < $PROXYCACHECONF > $CONF2
65 $SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
67 if test $WAIT != 0 ; then
68 echo CACHEPID $CACHEPID
71 KILLPIDS="$KILLPIDS $CACHEPID"
73 echo "Using ldapsearch to check that proxy slapd is running..."
74 for i in 0 1 2 3 4 5; do
75 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
76 'objectclass=*' > /dev/null 2>&1
78 if test $RC = 0 ; then
81 echo "Waiting 5 seconds for slapd to start..."
85 echo "Making queries on the proxy cache..."
86 echo "Query 1: filter:(sn=Jon) attrs: all"
87 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
88 'sn=Jon' > $SLAVEOUT 2>&1
90 if test $RC != 0 ; then
91 echo "ldapsearch failed ($RC)!"
92 test $KILLSERVERS != no && kill -HUP $KILLPIDS
96 echo "Query 2: filter:(|(cn=*Jon*)(sn=Jon*)) attrs:cn sn title uid"
97 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
98 '(|(cn=*Jon*)(sn=Jon*))' cn sn title uid >> $SLAVEOUT 2>&1
100 if test $RC != 0 ; then
101 echo "ldapsearch failed ($RC)!"
102 test $KILLSERVERS != no && kill -HUP $KILLPIDS
106 echo "Query 3: filter:(sn=Smith*) attrs:cn sn title uid"
107 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
108 'sn=Smith*' cn sn title uid >> $SLAVEOUT 2>&1
110 if test $RC != 0 ; then
111 echo "ldapsearch failed ($RC)!"
112 test $KILLSERVERS != no && kill -HUP $KILLPIDS
116 echo "Query 4: filter:(sn=Doe*) attrs:cn sn title uid"
117 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
118 'sn=Doe' cn sn title uid >> $SLAVEOUT 2>&1
120 if test $RC != 0 ; then
121 echo "ldapsearch failed ($RC)!"
122 test $KILLSERVERS != no && kill -HUP $KILLPIDS
126 echo "Query 5: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
127 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
128 'uid=bjorn' mail postaladdress telephonenumber cn uid >> $SLAVEOUT 2>&1
130 if test $RC != 0 ; then
131 echo "ldapsearch failed ($RC)!"
132 test $KILLSERVERS != no && kill -HUP $KILLPIDS
136 echo "Query 6: filter:(mail=*@example.com) cn sn title uid"
137 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
138 'mail=*@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
140 if test $RC != 0 ; then
141 echo "ldapsearch failed ($RC)!"
142 test $KILLSERVERS != no && kill -HUP $KILLPIDS
146 echo "Query 7: filter:(mail=*) cn sn title uid"
147 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
148 'mail=*' cn sn title uid >> $SLAVEOUT 2>&1
150 if test $RC != 0 ; then
151 echo "ldapsearch failed ($RC)!"
152 test $KILLSERVERS != no && kill -HUP $KILLPIDS
156 # queries 2-6 are cacheable
158 grep CACHEABLE $LOG2 | awk '{
160 printf "Query %d not cacheable\n",NR
162 printf "Query %d cacheable\n",NR
164 CACHED=`grep CACHEABLE $LOG2 | awk '{
171 if test $CACHEABILITY = $CACHED ; then
172 echo "Successfully verified cacheability"
174 echo "Error in verifying cacheability"
175 test $KILLSERVERS != no && kill -HUP $KILLPIDS
179 echo "Query 8: filter:(|(cn=*Jones)(sn=Jones)) attrs:cn sn title uid"
180 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
181 '(|(cn=*Jones)(sn=Jones))' cn sn title uid >> $SLAVEOUT 2>&1
183 if test $RC != 0 ; then
184 echo "ldapsearch failed ($RC)!"
185 test $KILLSERVERS != no && kill -HUP $KILLPIDS
189 echo "Query 9: filter:(sn=Smith) attrs:cn sn title uid"
190 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
191 'sn=Smith' cn sn title uid >> $SLAVEOUT 2>&1
193 if test $RC != 0 ; then
194 echo "ldapsearch failed ($RC)!"
195 test $KILLSERVERS != no && kill -HUP $KILLPIDS
199 echo "Query 10: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
200 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
201 'uid=bjorn' mail postaladdress telephonenumber cn 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 11: filter:(mail=*@example.com) cn sn title uid"
210 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
211 'mail=jaj@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
214 if test $RC != 0 ; then
215 echo "ldapsearch failed ($RC)!"
216 test $KILLSERVERS != no && kill -HUP $KILLPIDS
220 #queries 8-11 are answerable
222 grep ANSWERABLE $LOG2 | awk '{
225 printf "Query %d not answerable\n",NR
227 printf "Query %d answerable\n",NR
230 ANSWERED=`grep ANSWERABLE $LOG2 | awk '{
239 test $KILLSERVERS != no && kill -HUP $KILLPIDS
241 if test $ANSWERABILITY = $ANSWERED ; then
242 echo "Successfully verified answerability"
244 echo "Error in verifying answerability"
248 echo ">>>>> Test succeeded"