]> git.sur5r.net Git - openldap/blob - tests/scripts/test019-proxycaching
Cascading replication test script
[openldap] / tests / scripts / test019-proxycaching
1 #! /bin/sh
2
3 CACHETTL=60
4 CACHE_ENTRY_LIMIT=10
5
6 SRCDIR="."
7 if test $# -ge 1 ; then
8         SRCDIR=$1; shift
9 fi
10
11 . $SRCDIR/scripts/args.sh
12
13 echo "running defines.sh"
14 . $SRCDIR/scripts/defines.sh
15
16 BACKEND=ldbm
17
18 # Test proxy caching:
19 # - start master
20 # - start proxy cache
21 # - populate master 
22 # - perform first set of searches at the proxy
23 # - verify cacheability
24 # - perform second set of searches at the proxy 
25 # - verify answerability
26
27 #if test ! -x $SLAPD ; then
28 #       echo ">>>>> $SLAPD is not executable or does not exist."
29 #       echo ">>>>> Test skipped."
30 #       exit 0
31 #fi
32
33 if test ! -d $DBDIR
34 then 
35         mkdir $DBDIR
36 fi
37
38 if test ! -d $CACHEDIR
39 then 
40         mkdir $CACHEDIR
41 fi
42
43 echo "Cleaning up in $DBDIR..."
44 rm -f $DBDIR/[!C]*
45 echo "Cleaning up in $CACHEDIR..."
46 rm -rf $CACHEDIR/[!C]*
47 echo $DBDIR
48
49 echo "Starting master slapd on TCP/IP port $PORT..."
50 . $CONFFILTER < $CACHEMASTERCONF > $DBCONF
51 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL > $MASTERLOG 2>&1 &
52 PID=$!
53
54 sleep 5
55
56 echo "Using ldapadd to populate the master directory..."
57 $LDAPADD -x -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
58         $LDIFORDERED > out 2>&1
59 RC=$?
60 if test $RC != 0 ; then
61         echo "ldapadd failed ($RC)!"
62         kill -HUP $PID 
63         exit $RC
64 fi
65
66 echo "Starting proxy cache on TCP/IP port $SLAVEPORT..."
67 . $CONFFILTER < $PROXYCACHECONF > $CACHECONF
68 $SLAPD -f $CACHECONF -h $SLAVEURI -d $LVL > $SLAVELOG 2>&1 &
69 CACHEPID=$!
70
71 sleep 8
72 echo "Making queries on the proxy cache..." 
73 echo "Query 1: filter:(sn=Jon) attrs: all" 
74 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
75         'sn=Jon' > $SLAVEOUT 2>&1
76 RC=$?
77 if test $RC != 0 ; then
78         echo "ldapsearch failed ($RC)!"
79         kill -HUP $PID $CACHEPID
80         exit $RC
81 fi
82 sleep 3
83
84 echo "Query 2: filter:(|(cn=*Jon*)(sn=Jon*)) attrs:cn sn title"  
85 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
86         '(|(cn=*Jon*)(sn=Jon*))' cn sn title >> $SLAVEOUT 2>&1
87 RC=$?
88 if test $RC != 0 ; then
89         echo "ldapsearch failed ($RC)!"
90         kill -HUP $PID $CACHEPID
91         exit $RC
92 fi
93 sleep 3
94
95 echo "Query 3: filter:(sn=Smith*) attrs:cn sn title"  
96 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
97         'sn=Smith*' cn sn title >> $SLAVEOUT 2>&1
98 RC=$?
99 if test $RC != 0 ; then
100         echo "ldapsearch failed ($RC)!"
101         kill -HUP $PID $CACHEPID
102         exit $RC
103 fi
104 sleep 3
105
106 echo "Query 4: filter:(sn=Doe*) attrs:cn sn title"  
107 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
108         'sn=Doe' cn sn title >> $SLAVEOUT 2>&1
109 RC=$?
110 if test $RC != 0 ; then
111         echo "ldapsearch failed ($RC)!"
112         kill -HUP $PID $CACHEPID
113         exit $RC
114 fi
115 sleep 3
116  
117 echo "Query 5: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber"  
118 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
119         'uid=bjorn' mail postaladdress telephonenumber >> $SLAVEOUT 2>&1
120 RC=$?
121 if test $RC != 0 ; then
122         echo "ldapsearch failed ($RC)!"
123         kill -HUP $PID $CACHEPID
124         exit $RC
125 fi
126 sleep 3
127
128 echo "Query 6: filter:(mail=*@example.com) cn sn title"  
129 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
130         'mail=*@mail.alumni.example.com' cn sn title >> $SLAVEOUT 2>&1
131 RC=$?
132 if test $RC != 0 ; then
133         echo "ldapsearch failed ($RC)!"
134         kill -HUP $PID $CACHEPID
135         exit $RC
136 fi
137 sleep 3
138
139 echo "Query 7: filter:(mail=*) cn sn title"  
140 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
141         'mail=*' cn sn title >> $SLAVEOUT 2>&1
142 RC=$?
143 if test $RC != 0 ; then
144         echo "ldapsearch failed ($RC)!"
145         kill -HUP $PID $CACHEPID
146         exit $RC
147 fi
148 sleep 3
149 # queries 2-6 are cacheable
150 CACHEABILITY=0111110
151 grep CACHEABLE $SLAVELOG | awk '{ 
152                                   if ($2 == "NOT") 
153                                     printf "Query %d not cacheable\n",NR
154                                   else 
155                                     printf "Query %d cacheable\n",NR
156                                 }' 
157 CACHED=`grep CACHEABLE $SLAVELOG | awk '{ 
158                                           if ($2 == "NOT") 
159                                             printf "0" 
160                                           else 
161                                             printf "1" 
162                                         }'`
163
164 if test $CACHEABILITY = $CACHED
165 then
166         echo "successfully verified cacheability"
167 else 
168         echo "error in verifying cacheability"
169         kill -HUP $PID $CACHEPID
170         exit 1
171 fi
172
173 echo "Query 8: filter:(|(cn=*Jones)(sn=Jones)) attrs:cn sn title"  
174 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
175         '(|(cn=*Jones)(sn=Jones))' cn sn title >> $SLAVEOUT 2>&1
176 RC=$?
177 if test $RC != 0 ; then
178         echo "ldapsearch failed ($RC)!"
179         kill -HUP $PID $CACHEPID
180         exit $RC
181 fi
182 sleep 3
183
184 echo "Query 9: filter:(sn=Smith) attrs:cn sn title"  
185 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
186         'sn=Smith' cn sn title >> $SLAVEOUT 2>&1
187 RC=$?
188 if test $RC != 0 ; then
189         echo "ldapsearch failed ($RC)!"
190         kill -HUP $PID $CACHEPID
191         exit $RC
192 fi
193 sleep 3
194
195 echo "Query 10: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber"  
196 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
197         'uid=bjorn' mail postaladdress telephonenumber >> $SLAVEOUT 2>&1
198 RC=$?
199 if test $RC != 0 ; then
200         echo "ldapsearch failed ($RC)!"
201         kill -HUP $PID $CACHEPID
202         exit $RC
203 fi
204 sleep 3
205
206 echo "Query 11: filter:(mail=*@example.com) cn sn title"  
207 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
208         'mail=jaj@mail.alumni.example.com' cn sn title >> $SLAVEOUT 2>&1
209 RC=$?
210 if test $RC != 0 ; then
211         echo "ldapsearch failed ($RC)!"
212         kill -HUP $PID $CACHEPID
213         exit $RC
214 fi
215 sleep 3
216 #queries 8-11 are answerable
217 ANSWERABILITY=1111
218 grep ANSWERABLE $SLAVELOG | awk '{ 
219                                     if (NR > 7) { 
220                                       if ($2 == "NOT") 
221                                         printf "Query %d not answerable\n",NR
222                                       else 
223                                         printf "Query %d answerable\n",NR 
224                                      }
225                                   }' 
226 ANSWERED=`grep ANSWERABLE $SLAVELOG | awk '{ 
227                                              if (NR > 7) { 
228                                                if ($2 == "NOT") 
229                                                  printf "0" 
230                                                else 
231                                                  printf "1"
232                                              } 
233                                            }'`
234 if test $ANSWERABILITY = $ANSWERED
235 then
236         echo "successfully verified answerability"
237 else 
238         echo "error in verifying answerability"
239         kill -HUP $PID $CACHEPID
240         exit 1
241 fi
242
243 echo "Proxy cache successfully tested" 
244 kill -HUP $PID $CACHEPID