test003-cnconfig revision 1.1 1 1.1 christos #! /bin/sh
2 1.1 christos # $OpenLDAP$
3 1.1 christos ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 1.1 christos ##
5 1.1 christos ## Copyright 1998-2021 The OpenLDAP Foundation.
6 1.1 christos ## All rights reserved.
7 1.1 christos ##
8 1.1 christos ## Redistribution and use in source and binary forms, with or without
9 1.1 christos ## modification, are permitted only as authorized by the OpenLDAP
10 1.1 christos ## Public License.
11 1.1 christos ##
12 1.1 christos ## A copy of this license is available in the file LICENSE in the
13 1.1 christos ## top-level directory of the distribution or, alternatively, at
14 1.1 christos ## <http://www.OpenLDAP.org/license.html>.
15 1.1 christos
16 1.1 christos echo "running defines.sh"
17 1.1 christos . $SRCDIR/scripts/defines.sh
18 1.1 christos
19 1.1 christos mkdir -p $TESTDIR $DBDIR1 $DBDIR2
20 1.1 christos
21 1.1 christos $SLAPPASSWD -g -n >$CONFIGPWF
22 1.1 christos echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
23 1.1 christos
24 1.1 christos if test $AC_lloadd = lloaddyes ; then
25 1.1 christos echo "Load balancer module not available, skipping..."
26 1.1 christos exit 0
27 1.1 christos fi
28 1.1 christos
29 1.1 christos echo "Starting the first slapd on TCP/IP port $PORT2..."
30 1.1 christos . $CONFFILTER $BACKEND < $CONF > $CONF2
31 1.1 christos $SLAPADD -f $CONF2 -l $LDIFORDERED
32 1.1 christos RC=$?
33 1.1 christos if test $RC != 0 ; then
34 1.1 christos echo "slapadd failed ($RC)!"
35 1.1 christos exit $RC
36 1.1 christos fi
37 1.1 christos
38 1.1 christos echo "Running slapindex to index slapd database..."
39 1.1 christos $SLAPINDEX -f $CONF2
40 1.1 christos RC=$?
41 1.1 christos if test $RC != 0 ; then
42 1.1 christos echo "warning: slapindex failed ($RC)"
43 1.1 christos echo " assuming no indexing support"
44 1.1 christos fi
45 1.1 christos
46 1.1 christos $SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
47 1.1 christos PID=$!
48 1.1 christos if test $WAIT != 0 ; then
49 1.1 christos echo PID $PID
50 1.1 christos read foo
51 1.1 christos fi
52 1.1 christos PID2="$PID"
53 1.1 christos KILLPIDS="$PID"
54 1.1 christos
55 1.1 christos echo "Testing slapd searching..."
56 1.1 christos for i in 0 1 2 3 4 5; do
57 1.1 christos $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
58 1.1 christos '(objectclass=*)' > /dev/null 2>&1
59 1.1 christos RC=$?
60 1.1 christos if test $RC = 0 ; then
61 1.1 christos break
62 1.1 christos fi
63 1.1 christos echo "Waiting $SLEEP1 seconds for slapd to start..."
64 1.1 christos sleep $SLEEP1
65 1.1 christos done
66 1.1 christos if test $RC != 0 ; then
67 1.1 christos echo "ldapsearch failed ($RC)!"
68 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
69 1.1 christos exit $RC
70 1.1 christos fi
71 1.1 christos
72 1.1 christos echo "Running slapadd to build slapd database..."
73 1.1 christos . $CONFFILTER $BACKEND < $CONFTWO > $CONF3
74 1.1 christos $SLAPADD -f $CONF3 -l $LDIFORDERED
75 1.1 christos RC=$?
76 1.1 christos if test $RC != 0 ; then
77 1.1 christos echo "slapadd failed ($RC)!"
78 1.1 christos exit $RC
79 1.1 christos fi
80 1.1 christos
81 1.1 christos echo "Running slapindex to index slapd database..."
82 1.1 christos $SLAPINDEX -f $CONF3
83 1.1 christos RC=$?
84 1.1 christos if test $RC != 0 ; then
85 1.1 christos echo "warning: slapindex failed ($RC)"
86 1.1 christos echo " assuming no indexing support"
87 1.1 christos fi
88 1.1 christos
89 1.1 christos echo "Starting second slapd on TCP/IP port $PORT3..."
90 1.1 christos $SLAPD -f $CONF3 -h $URI3 -d $LVL > $LOG3 2>&1 &
91 1.1 christos PID=$!
92 1.1 christos if test $WAIT != 0 ; then
93 1.1 christos echo PID $PID
94 1.1 christos read foo
95 1.1 christos fi
96 1.1 christos PID3="$PID"
97 1.1 christos KILLPIDS="$KILLPIDS $PID"
98 1.1 christos
99 1.1 christos sleep $SLEEP0
100 1.1 christos
101 1.1 christos echo "Testing slapd searching..."
102 1.1 christos for i in 0 1 2 3 4 5; do
103 1.1 christos $LDAPSEARCH -s base -b "$MONITOR" -H $URI3 \
104 1.1 christos '(objectclass=*)' > /dev/null 2>&1
105 1.1 christos RC=$?
106 1.1 christos if test $RC = 0 ; then
107 1.1 christos break
108 1.1 christos fi
109 1.1 christos echo "Waiting $SLEEP1 seconds for slapd to start..."
110 1.1 christos sleep $SLEEP1
111 1.1 christos done
112 1.1 christos if test $RC != 0 ; then
113 1.1 christos echo "ldapsearch failed ($RC)!"
114 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
115 1.1 christos exit $RC
116 1.1 christos fi
117 1.1 christos
118 1.1 christos echo "Starting lloadd on TCP/IP port $PORT1..."
119 1.1 christos . $CONFFILTER $BACKEND < $LLOADDUNREACHABLECONF > $CONF1.lloadd
120 1.1 christos . $CONFFILTER $BACKEND < $SLAPDLLOADCONF > $CONF1.slapd
121 1.1 christos $SLAPD -f $CONF1.slapd -h $URI6 -d $LVL > $LOG1 2>&1 &
122 1.1 christos PID=$!
123 1.1 christos if test $WAIT != 0 ; then
124 1.1 christos echo PID $PID
125 1.1 christos read foo
126 1.1 christos fi
127 1.1 christos KILLPIDS="$KILLPIDS $PID"
128 1.1 christos
129 1.1 christos echo "Testing lloadd searching..."
130 1.1 christos for i in 0 1 2 3 4 5; do
131 1.1 christos $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
132 1.1 christos '(objectclass=*)' > /dev/null 2>&1
133 1.1 christos RC=$?
134 1.1 christos if test $RC = 0 ; then
135 1.1 christos break
136 1.1 christos fi
137 1.1 christos echo "Waiting $SLEEP1 seconds for lloadd to start..."
138 1.1 christos sleep $SLEEP1
139 1.1 christos done
140 1.1 christos
141 1.1 christos if test $RC != 0 ; then
142 1.1 christos echo "ldapsearch failed ($RC)!"
143 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
144 1.1 christos exit $RC
145 1.1 christos fi
146 1.1 christos
147 1.1 christos
148 1.1 christos echo "Testing cn=config searching..."
149 1.1 christos $LDAPSEARCH -H $URI6 -D cn=config -y $CONFIGPWF \
150 1.1 christos -s sub -b "olcBackend={0}lload,cn=config" '(objectclass=*)' > /dev/null 2>&1
151 1.1 christos RC=$?
152 1.1 christos if test $RC != 0 ; then
153 1.1 christos echo "ldapsearch failed ($RC)!"
154 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
155 1.1 christos exit $RC
156 1.1 christos fi
157 1.1 christos
158 1.1 christos echo "Deleting backends"
159 1.1 christos
160 1.1 christos for i in 1 2 3 4 ; do
161 1.1 christos echo "cn={0}server "$i",olcBackend={0}lload,cn=config"
162 1.1 christos $LDAPDELETE -H $URI6 -D cn=config -y $CONFIGPWF \
163 1.1 christos "cn={0}server "$i",olcBackend={0}lload,cn=config" > /dev/null 2>&1
164 1.1 christos RC=$?
165 1.1 christos if test $RC != 0 ; then
166 1.1 christos echo "deleting server failed ($RC)!"
167 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
168 1.1 christos exit $RC
169 1.1 christos fi
170 1.1 christos done
171 1.1 christos
172 1.1 christos echo "Testing cn=config searching..."
173 1.1 christos $LDAPSEARCH -H $URI6 -D cn=config -y $CONFIGPWF \
174 1.1 christos -s sub -b "olcBackend={0}lload,cn=config" '(objectclass=*)' > /dev/null 2>&1
175 1.1 christos
176 1.1 christos
177 1.1 christos echo "# Testing exact searching..."
178 1.1 christos
179 1.1 christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
180 1.1 christos '(sn=jENSEN)' >> $SEARCHOUT 2>&1
181 1.1 christos RC=$?
182 1.1 christos if test $RC != 52 ; then
183 1.1 christos echo "ldapsearch failed ($RC)!"
184 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
185 1.1 christos exit $RC
186 1.1 christos fi
187 1.1 christos
188 1.1 christos echo "Testing adding Server "
189 1.1 christos $LDAPADD -D cn=config -H $URI6 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
190 1.1 christos dn: cn=server 7,olcBackend={0}lload,cn=config
191 1.1 christos objectClass: olcBkLloadBackendConfig
192 1.1 christos cn: server 7
193 1.1 christos olcBkLloadBackendUri: $URI3
194 1.1 christos olcBkLloadBindconns: 2
195 1.1 christos olcBkLloadMaxPendingConns: 3
196 1.1 christos olcBkLloadMaxPendingOps: 5
197 1.1 christos olcBkLloadNumconns: 3
198 1.1 christos olcBkLloadRetry: 5000
199 1.1 christos EOF
200 1.1 christos RC=$?
201 1.1 christos if test $RC != 0 ; then
202 1.1 christos echo "ldapadd failed for cn=server 7 ($RC)!"
203 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
204 1.1 christos exit $RC
205 1.1 christos fi
206 1.1 christos
207 1.1 christos echo "Verifying balancer operation..."
208 1.1 christos for i in 0 1 2 3 4 5; do
209 1.1 christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
210 1.1 christos '(sn=jENSEN)' >> $SEARCHOUT 2>&1
211 1.1 christos RC=$?
212 1.1 christos if test $RC = 0 ; then
213 1.1 christos break
214 1.1 christos fi
215 1.1 christos echo "Waiting $SLEEP1 seconds for backend to start..."
216 1.1 christos sleep $SLEEP1
217 1.1 christos done
218 1.1 christos
219 1.1 christos echo "Testing bindconf modify"
220 1.1 christos $LDAPMODIFY -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
221 1.1 christos dn: olcBackend={0}lload,cn=config
222 1.1 christos changetype: modify
223 1.1 christos replace: olcBkLloadBindconf
224 1.1 christos olcBkLloadBindconf: bindmethod=simple timeout=0 network-timeout=0 binddn="cn=wrongmanager,dc=example,dc=com" credentials="secret"
225 1.1 christos EOF
226 1.1 christos
227 1.1 christos RC=$?
228 1.1 christos if test $RC != 0 ; then
229 1.1 christos echo "modify failed for bindconf ($RC)!"
230 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
231 1.1 christos exit $RC
232 1.1 christos fi
233 1.1 christos
234 1.1 christos echo "# Sending a search request..."
235 1.1 christos
236 1.1 christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
237 1.1 christos '(sn=jENSEN)' >> $SEARCHOUT 2>&1
238 1.1 christos RC=$?
239 1.1 christos if test $RC != 52 ; then
240 1.1 christos echo "ldapsearch failed ($RC)!"
241 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
242 1.1 christos exit $RC
243 1.1 christos fi
244 1.1 christos
245 1.1 christos echo "Restoring bindconf value"
246 1.1 christos $LDAPMODIFY -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
247 1.1 christos dn: olcBackend={0}lload,cn=config
248 1.1 christos changetype: modify
249 1.1 christos replace: olcBkLloadBindconf
250 1.1 christos olcBkLloadBindconf: bindmethod=simple timeout=0 network-timeout=0 binddn="cn=Manager,dc=example,dc=com" credentials="secret"
251 1.1 christos EOF
252 1.1 christos
253 1.1 christos RC=$?
254 1.1 christos if test $RC != 0 ; then
255 1.1 christos echo "modify failed for bindconf ($RC)!"
256 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
257 1.1 christos exit $RC
258 1.1 christos fi
259 1.1 christos
260 1.1 christos
261 1.1 christos echo "Verifying balancer operation..."
262 1.1 christos for i in 0 1 2 3 4 5; do
263 1.1 christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
264 1.1 christos '(sn=jENSEN)' >> $SEARCHOUT 2>&1
265 1.1 christos RC=$?
266 1.1 christos if test $RC = 0 ; then
267 1.1 christos break
268 1.1 christos fi
269 1.1 christos echo "Waiting $SLEEP1 seconds for backend to start..."
270 1.1 christos sleep $SLEEP1
271 1.1 christos done
272 1.1 christos
273 1.1 christos echo "Testing global attributes"
274 1.1 christos echo "Testing olcBkLloadMaxPDUPerCycle modify"
275 1.1 christos $LDAPMODIFY -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
276 1.1 christos dn: olcBackend={0}lload,cn=config
277 1.1 christos changetype: modify
278 1.1 christos replace: olcBkLloadMaxPDUPerCycle
279 1.1 christos olcBkLloadMaxPDUPerCycle: 2000
280 1.1 christos EOF
281 1.1 christos
282 1.1 christos RC=$?
283 1.1 christos if test $RC != 0 ; then
284 1.1 christos echo "modify failed for olcBkLloadMaxPDUPerCycle($RC)!"
285 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
286 1.1 christos exit $RC
287 1.1 christos fi
288 1.1 christos
289 1.1 christos echo "Sending a search request..."
290 1.1 christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
291 1.1 christos '(sn=jENSEN)' >> $SEARCHOUT 2>&1
292 1.1 christos RC=$?
293 1.1 christos if test $RC != 0 ; then
294 1.1 christos echo "ldapsearch failed ($RC)!"
295 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
296 1.1 christos exit $RC
297 1.1 christos fi
298 1.1 christos
299 1.1 christos echo "Testing olcBkLloadSockbufMaxClient modify"
300 1.1 christos $LDAPMODIFY -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
301 1.1 christos dn: olcBackend={0}lload,cn=config
302 1.1 christos changetype: modify
303 1.1 christos replace: olcBkLloadSockbufMaxClient
304 1.1 christos olcBkLloadSockbufMaxClient: 20000
305 1.1 christos EOF
306 1.1 christos
307 1.1 christos RC=$?
308 1.1 christos if test $RC != 0 ; then
309 1.1 christos echo "modify failed for olcBkLloadSockbufMaxClient($RC)!"
310 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
311 1.1 christos exit $RC
312 1.1 christos fi
313 1.1 christos
314 1.1 christos echo "Sending a search request..."
315 1.1 christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
316 1.1 christos '(sn=jENSEN)' >> $SEARCHOUT 2>&1
317 1.1 christos RC=$?
318 1.1 christos if test $RC != 0 ; then
319 1.1 christos echo "ldapsearch failed ($RC)!"
320 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
321 1.1 christos exit $RC
322 1.1 christos fi
323 1.1 christos
324 1.1 christos echo "Testing olcBkLloadSockbufMaxUpstream modify"
325 1.1 christos $LDAPMODIFY -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
326 1.1 christos dn: olcBackend={0}lload,cn=config
327 1.1 christos changetype: modify
328 1.1 christos replace: olcBkLloadSockbufMaxUpstream
329 1.1 christos olcBkLloadSockbufMaxUpstream: 200000
330 1.1 christos EOF
331 1.1 christos
332 1.1 christos RC=$?
333 1.1 christos if test $RC != 0 ; then
334 1.1 christos echo "modify failed for olcBkLloadSockbufMaxUpstream($RC)!"
335 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
336 1.1 christos exit $RC
337 1.1 christos fi
338 1.1 christos
339 1.1 christos echo "Sending a search request..."
340 1.1 christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
341 1.1 christos '(sn=jENSEN)' >> $SEARCHOUT 2>&1
342 1.1 christos RC=$?
343 1.1 christos if test $RC != 0 ; then
344 1.1 christos echo "ldapsearch failed ($RC)!"
345 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
346 1.1 christos exit $RC
347 1.1 christos fi
348 1.1 christos
349 1.1 christos echo "Testing olcBkLloadIOTimeout modify"
350 1.1 christos $LDAPMODIFY -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
351 1.1 christos dn: olcBackend={0}lload,cn=config
352 1.1 christos changetype: modify
353 1.1 christos replace: olcBkLloadIOTimeout
354 1.1 christos olcBkLloadIOTimeout: 20000
355 1.1 christos EOF
356 1.1 christos
357 1.1 christos RC=$?
358 1.1 christos if test $RC != 0 ; then
359 1.1 christos echo "modify failed for olcBkLloadWriteTimeout($RC)!"
360 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
361 1.1 christos exit $RC
362 1.1 christos fi
363 1.1 christos
364 1.1 christos echo "Sending a search request..."
365 1.1 christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
366 1.1 christos '(sn=jENSEN)' >> $SEARCHOUT 2>&1
367 1.1 christos RC=$?
368 1.1 christos if test $RC != 0 ; then
369 1.1 christos echo "ldapsearch failed ($RC)!"
370 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
371 1.1 christos exit $RC
372 1.1 christos fi
373 1.1 christos
374 1.1 christos echo "Testing backend attributes"
375 1.1 christos echo "Testing olcBkLloadBindconns modify"
376 1.1 christos $LDAPMODIFY -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
377 1.1 christos dn: cn={0}server 7,olcBackend={0}lload,cn=config
378 1.1 christos changetype: modify
379 1.1 christos replace: olcBkLloadBindconns
380 1.1 christos olcBkLloadBindconns: 20
381 1.1 christos EOF
382 1.1 christos
383 1.1 christos RC=$?
384 1.1 christos if test $RC != 0 ; then
385 1.1 christos echo "modify failed for olcBkLloadBindconns($RC)!"
386 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
387 1.1 christos exit $RC
388 1.1 christos fi
389 1.1 christos
390 1.1 christos echo "Testing exact searching..."
391 1.1 christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
392 1.1 christos '(sn=jENSEN)' >> $SEARCHOUT 2>&1
393 1.1 christos RC=$?
394 1.1 christos if test $RC != 0 ; then
395 1.1 christos echo "ldapsearch failed ($RC)!"
396 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
397 1.1 christos exit $RC
398 1.1 christos fi
399 1.1 christos
400 1.1 christos
401 1.1 christos echo "Testing olcBkLloadMaxPendingConns modify"
402 1.1 christos $LDAPMODIFY -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
403 1.1 christos dn: cn={0}server 7,olcBackend={0}lload,cn=config
404 1.1 christos changetype: modify
405 1.1 christos replace: olcBkLloadMaxPendingConns
406 1.1 christos olcBkLloadMaxPendingConns: 30
407 1.1 christos EOF
408 1.1 christos
409 1.1 christos RC=$?
410 1.1 christos if test $RC != 0 ; then
411 1.1 christos echo "modify failed for olcBkLloadMaxPendingConns($RC)!"
412 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
413 1.1 christos exit $RC
414 1.1 christos fi
415 1.1 christos
416 1.1 christos echo "Testing exact searching..."
417 1.1 christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
418 1.1 christos '(sn=jENSEN)' >> $SEARCHOUT 2>&1
419 1.1 christos RC=$?
420 1.1 christos if test $RC != 0 ; then
421 1.1 christos echo "ldapsearch failed ($RC)!"
422 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
423 1.1 christos exit $RC
424 1.1 christos fi
425 1.1 christos
426 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
427 1.1 christos
428 1.1 christos
429 1.1 christos echo ">>>>> Test succeeded"
430 1.1 christos
431 1.1 christos test $KILLSERVERS != no && wait
432 1.1 christos
433 1.1 christos exit 0
434