]> git.sur5r.net Git - openldap/blob - tests/scripts/test050-syncrepl-multimaster
check for overflows
[openldap] / tests / scripts / test050-syncrepl-multimaster
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2008 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
11 ##
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>.
15
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 if test $SYNCPROV = syncprovno; then 
20         echo "Syncrepl provider overlay not available, test skipped"
21         exit 0
22 fi 
23
24 PRODIR=$TESTDIR/pro
25 CONDIR=$TESTDIR/con
26 CONDIR2=$TESTDIR/con2
27 DBPRO=$PRODIR/db
28 DBCON=$CONDIR/db
29 DBCON2=$CONDIR2/db
30 CFPRO=$PRODIR/slapd.d
31 CFCON=$CONDIR/slapd.d
32 CFCON2=$CONDIR2/slapd.d
33
34 SYNCTYPE="type=refreshOnly interval=00:00:00:10"
35 #SYNCTYPE="type=refreshAndPersist"
36
37 mkdir -p $TESTDIR $PRODIR $CONDIR $CONDIR2 $DBPRO $DBCON $DBCON2 $CFPRO $CFCON $CFCON2
38
39 $SLAPPASSWD -g -n >$CONFIGPWF
40
41 #
42 # Test replication of dynamic config:
43 # - start producer
44 # - start consumer1
45 # - start consumer2
46 # - configure over ldap
47 # - populate over ldap
48 # - configure syncrepl over ldap
49 # - retrieve database over ldap and compare against expected results
50 #
51
52 echo "Initializing server configurations..."
53 $SLAPADD -F $CFCON2 -n 0 <<EOF
54 dn: cn=config
55 objectClass: olcGlobal
56 cn: config
57 olcServerID: 3
58
59 dn: olcDatabase={0}config,cn=config
60 objectClass: olcDatabaseConfig
61 olcDatabase: {0}config
62 olcRootPW:< file://$CONFIGPWF
63 EOF
64
65 $SLAPADD -F $CFCON -n 0 <<EOF
66 dn: cn=config
67 objectClass: olcGlobal
68 cn: config
69 olcServerID: 2
70
71 dn: olcDatabase={0}config,cn=config
72 objectClass: olcDatabaseConfig
73 olcDatabase: {0}config
74 olcRootPW:< file://$CONFIGPWF
75 EOF
76
77 $SLAPADD -F $CFPRO -n 0 <<EOF
78 dn: cn=config
79 objectClass: olcGlobal
80 cn: config
81 olcServerID: 1
82
83 dn: olcDatabase={0}config,cn=config
84 objectClass: olcDatabaseConfig
85 olcDatabase: {0}config
86 olcRootPW:< file://$CONFIGPWF
87 EOF
88
89 echo "Starting producer slapd on TCP/IP port $PORT1..."
90 cd $PRODIR
91 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
92 PID=$!
93 if test $WAIT != 0 ; then
94     echo PID $PID
95     read foo
96 fi
97 KILLPIDS="$PID"
98 cd $TESTWD
99
100 sleep 1
101
102 echo "Using ldapsearch to check that producer slapd is running..."
103 for i in 0 1 2 3 4 5; do
104         $LDAPSEARCH -s base -b "" -H $URI1 \
105                 'objectclass=*' > /dev/null 2>&1
106         RC=$?
107         if test $RC = 0 ; then
108                 break
109         fi
110         echo "Waiting 5 seconds for slapd to start..."
111         sleep 5
112 done
113
114 if test $RC != 0 ; then
115         echo "ldapsearch failed ($RC)!"
116         test $KILLSERVERS != no && kill -HUP $KILLPIDS
117         exit $RC
118 fi
119
120 echo "Inserting syncprov overlay on producer..."
121 if [ "$SYNCPROV" = syncprovmod ]; then
122         $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
123 dn: cn=module,cn=config
124 objectClass: olcModuleList
125 cn: module
126 olcModulePath: ../../../servers/slapd/overlays
127 olcModuleLoad: syncprov.la
128 EOF
129         RC=$?
130         if test $RC != 0 ; then
131                 echo "ldapadd failed for moduleLoad ($RC)!"
132                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
133                 exit $RC
134         fi
135 fi
136 #
137 # Note that we configure a timeout here; it's possible for both
138 # servers to attempt to bind to each other while a modify to
139 # cn=config is in progress. When the modify pauses the thread pool
140 # neither server will progress. The timeout will drop the syncrepl
141 # attempt and allow the modifies to complete.
142 #
143 read CONFIGPW < $CONFIGPWF
144 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
145 dn: cn=config
146 changetype: modify
147 replace: olcServerID
148 olcServerID: 1 $URI1
149 olcServerID: 2 $URI2
150 olcServerID: 3 $URI3
151
152 dn: olcOverlay=syncprov,olcDatabase={0}config,cn=config
153 changetype: add
154 objectClass: olcOverlayConfig
155 objectClass: olcSyncProvConfig
156 olcOverlay: syncprov
157
158 dn: olcDatabase={0}config,cn=config
159 changetype: modify
160 add: olcSyncRepl
161 olcSyncRepl: rid=001 provider=$URI1 binddn="cn=config" bindmethod=simple
162   credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
163   retry="5 5 300 5" timeout=3
164 olcSyncRepl: rid=002 provider=$URI2 binddn="cn=config" bindmethod=simple
165   credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
166   retry="5 5 300 5" timeout=3
167 olcSyncRepl: rid=003 provider=$URI3 binddn="cn=config" bindmethod=simple
168   credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
169   retry="5 5 300 5" timeout=3
170 -
171 add: olcMirrorMode
172 olcMirrorMode: TRUE
173 EOF
174 RC=$?
175 if test $RC != 0 ; then
176         echo "ldapmodify failed for syncrepl config ($RC)!"
177         test $KILLSERVERS != no && kill -HUP $KILLPIDS
178         exit $RC
179 fi
180
181 echo "Starting consumer1 slapd on TCP/IP port $PORT2..."
182 cd $CONDIR
183 $SLAPD -F ./slapd.d -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
184 SLAVEPID=$!
185 if test $WAIT != 0 ; then
186     echo SLAVEPID $SLAVEPID
187     read foo
188 fi
189 KILLPIDS="$KILLPIDS $SLAVEPID"
190 cd $TESTWD
191
192 sleep 1
193
194 echo "Using ldapsearch to check that consumer1 slapd is running..."
195 for i in 0 1 2 3 4 5; do
196         $LDAPSEARCH -s base -b "" -H $URI2 \
197                 'objectclass=*' > /dev/null 2>&1
198         RC=$?
199         if test $RC = 0 ; then
200                 break
201         fi
202         echo "Waiting 5 seconds for slapd to start..."
203         sleep 5
204 done
205
206 if test $RC != 0 ; then
207         echo "ldapsearch failed ($RC)!"
208         test $KILLSERVERS != no && kill -HUP $KILLPIDS
209         exit $RC
210 fi
211
212 echo "Configuring syncrepl on consumer1..."
213 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
214 dn: olcDatabase={0}config,cn=config
215 changetype: modify
216 add: olcSyncRepl
217 olcSyncRepl: rid=001 provider=$URI1 binddn="cn=config" bindmethod=simple
218   credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
219   retry="5 5 300 5" timeout=3
220 olcSyncRepl: rid=002 provider=$URI2 binddn="cn=config" bindmethod=simple
221   credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
222   retry="5 5 300 5" timeout=3
223 olcSyncRepl: rid=003 provider=$URI3 binddn="cn=config" bindmethod=simple
224   credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
225   retry="5 5 300 5" timeout=3
226 -
227 add: olcMirrorMode
228 olcMirrorMode: TRUE
229 EOF
230
231 echo "Starting consumer2 slapd on TCP/IP port $PORT3..."
232 cd $CONDIR2
233 $SLAPD -F ./slapd.d -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
234 SLAVE2PID=$!
235 if test $WAIT != 0 ; then
236     echo SLAVE2PID $SLAVE2PID
237     read foo
238 fi
239 KILLPIDS="$KILLPIDS $SLAVE2PID"
240 cd $TESTWD
241
242 sleep 1
243
244 echo "Using ldapsearch to check that consumer2 slapd is running..."
245 for i in 0 1 2 3 4 5; do
246         $LDAPSEARCH -s base -b "" -H $URI3 \
247                 'objectclass=*' > /dev/null 2>&1
248         RC=$?
249         if test $RC = 0 ; then
250                 break
251         fi
252         echo "Waiting 5 seconds for slapd to start..."
253         sleep 5
254 done
255
256 if test $RC != 0 ; then
257         echo "ldapsearch failed ($RC)!"
258         test $KILLSERVERS != no && kill -HUP $KILLPIDS
259         exit $RC
260 fi
261
262 echo "Configuring syncrepl on consumer2..."
263 $LDAPMODIFY -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
264 dn: olcDatabase={0}config,cn=config
265 changetype: modify
266 add: olcSyncRepl
267 olcSyncRepl: rid=001 provider=$URI1 binddn="cn=config" bindmethod=simple
268   credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
269   retry="5 5 300 5" timeout=3
270 olcSyncRepl: rid=002 provider=$URI2 binddn="cn=config" bindmethod=simple
271   credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
272   retry="5 5 300 5" timeout=3
273 olcSyncRepl: rid=003 provider=$URI3 binddn="cn=config" bindmethod=simple
274   credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
275   retry="5 5 300 5" timeout=3
276 -
277 add: olcMirrorMode
278 olcMirrorMode: TRUE
279 EOF
280
281 echo "Adding schema and databases on producer..."
282 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
283 include: file://$ABS_SCHEMADIR/core.ldif
284
285 include: file://$ABS_SCHEMADIR/cosine.ldif
286
287 include: file://$ABS_SCHEMADIR/inetorgperson.ldif
288
289 include: file://$ABS_SCHEMADIR/openldap.ldif
290
291 include: file://$ABS_SCHEMADIR/nis.ldif
292 EOF
293 RC=$?
294 if test $RC != 0 ; then
295         echo "ldapadd failed for schema config ($RC)!"
296         test $KILLSERVERS != no && kill -HUP $KILLPIDS
297         exit $RC
298 fi
299
300 if [ "$BACKENDTYPE" = mod ]; then
301         $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
302 dn: cn=module,cn=config
303 objectClass: olcModuleList
304 cn: module
305 olcModulePath: ../../../servers/slapd/back-$BACKEND
306 olcModuleLoad: back_$BACKEND.la
307 EOF
308         RC=$?
309         if test $RC != 0 ; then
310                 echo "ldapadd failed for backend config ($RC)!"
311                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
312                 exit $RC
313         fi
314 fi
315
316 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
317 dn: olcDatabase={1}$BACKEND,cn=config
318 objectClass: olcDatabaseConfig
319 objectClass: olc${BACKEND}Config
320 olcDatabase: {1}$BACKEND
321 olcSuffix: $BASEDN
322 olcDbDirectory: ./db
323 olcRootDN: $MANAGERDN
324 olcRootPW: $PASSWD
325 olcSyncRepl: rid=004 provider=$URI1 binddn="$MANAGERDN" bindmethod=simple
326   credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
327   retry="5 5 300 5" timeout=3
328 olcSyncRepl: rid=005 provider=$URI2 binddn="$MANAGERDN" bindmethod=simple
329   credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
330   retry="5 5 300 5" timeout=3
331 olcSyncRepl: rid=006 provider=$URI3 binddn="$MANAGERDN" bindmethod=simple
332   credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
333   retry="5 5 300 5" timeout=3
334 olcMirrorMode: TRUE
335
336 dn: olcOverlay=syncprov,olcDatabase={1}${BACKEND},cn=config
337 changetype: add
338 objectClass: olcOverlayConfig
339 objectClass: olcSyncProvConfig
340 olcOverlay: syncprov
341 EOF
342 RC=$?
343 if test $RC != 0 ; then
344         echo "ldapadd failed for database config ($RC)!"
345         test $KILLSERVERS != no && kill -HUP $KILLPIDS
346         exit $RC
347 fi
348
349 echo "Using ldapadd to populate producer..."
350 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDERED \
351         >> $TESTOUT 2>&1
352 RC=$?
353 if test $RC != 0 ; then
354         echo "ldapadd failed for producer database ($RC)!"
355         test $KILLSERVERS != no && kill -HUP $KILLPIDS
356         exit $RC
357 fi
358
359 SLEEP=20
360 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
361 sleep $SLEEP
362
363 echo "Using ldapadd to populate consumer1..."
364 $LDAPADD -D "$MANAGERDN" -H $URI2 -w $PASSWD -f $LDIFADD1 \
365         >> $TESTOUT 2>&1
366 RC=$?
367 if test $RC != 0 ; then
368         echo "ldapadd failed for consumer1 database ($RC)!"
369         test $KILLSERVERS != no && kill -HUP $KILLPIDS
370         exit $RC
371 fi
372
373 SLEEP=20
374 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
375 sleep $SLEEP
376
377 echo "Using ldapadd to populate consumer2..."
378 $LDAPADD -D "$MANAGERDN" -H $URI3 -w $PASSWD \
379         << EOMODS >> $TESTOUT 2>&1
380 dn: cn=Consumer 2 Test,dc=example,dc=com
381 changetype: add
382 objectClass: device
383 cn: Consumer 2 Test
384 EOMODS
385 RC=$?
386 if test $RC != 0 ; then
387         echo "ldapadd failed for consumer2 database ($RC)!"
388         test $KILLSERVERS != no && kill -HUP $KILLPIDS
389         exit $RC
390 fi
391
392 SLEEP=20
393 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
394 sleep $SLEEP
395
396 echo "Using ldapsearch to check that syncrepl received database changes..."
397 RC=32
398 for i in 0 1 2 3 4 5; do
399         RESULT=`$LDAPSEARCH -H $URI2 \
400                 -s base -b "cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com" \
401                 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
402         if test "x$RESULT" = "xOK" ; then
403                 RC=0
404                 break
405         fi
406         echo "Waiting 5 seconds for syncrepl to receive changes..."
407         sleep 5
408 done
409
410 if test $RC != 0 ; then
411         echo "ldapsearch failed ($RC)!"
412         test $KILLSERVERS != no && kill -HUP $KILLPIDS
413         exit $RC
414 fi
415
416 echo "Using ldapsearch to check that syncrepl received database changes on consumer2..."
417 RC=32
418 for i in 0 1 2 3 4 5; do
419         RESULT=`$LDAPSEARCH -H $URI3 \
420                 -s base -b "cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com" \
421                 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
422         if test "x$RESULT" = "xOK" ; then
423                 RC=0
424                 break
425         fi
426         echo "Waiting 5 seconds for syncrepl to receive changes..."
427         sleep 5
428 done
429
430 if test $RC != 0 ; then
431         echo "ldapsearch failed ($RC)!"
432         test $KILLSERVERS != no && kill -HUP $KILLPIDS
433         exit $RC
434 fi
435
436 echo "Using ldapsearch to read config from the producer..."
437 $LDAPSEARCH -b cn=config -D cn=config -H $URI1 -y $CONFIGPWF  \
438         'objectclass=*' > $MASTEROUT 2>&1
439 RC=$?
440
441 if test $RC != 0 ; then
442         echo "ldapsearch failed at producer ($RC)!"
443         test $KILLSERVERS != no && kill -HUP $KILLPIDS
444         exit $RC
445 fi
446
447 echo "Using ldapsearch to read config from consumer1..."
448 $LDAPSEARCH -b cn=config -D cn=config -H $URI2 -y $CONFIGPWF \
449         'objectclass=*' > $SLAVEOUT 2>&1
450 RC=$?
451
452 if test $RC != 0 ; then
453         echo "ldapsearch failed at consumer1 ($RC)!"
454         test $KILLSERVERS != no && kill -HUP $KILLPIDS
455         exit $RC
456 fi
457
458 echo "Using ldapsearch to read config from consumer2..."
459 $LDAPSEARCH -b cn=config -D cn=config -H $URI3 -y $CONFIGPWF \
460         'objectclass=*' > $SLAVE2OUT 2>&1
461 RC=$?
462
463 if test $RC != 0 ; then
464         echo "ldapsearch failed at consumer2 ($RC)!"
465         test $KILLSERVERS != no && kill -HUP $KILLPIDS
466         exit $RC
467 fi
468
469 echo "Filtering producer results..."
470 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
471 echo "Filtering consumer1 results..."
472 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
473 echo "Filtering consumer2 results..."
474 . $LDIFFILTER < $SLAVE2OUT > $SLAVE2FLT
475
476 echo "Comparing retrieved configs from producer and consumer1..."
477 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
478
479 if test $? != 0 ; then
480         echo "test failed - producer and consumer1 configs differ"
481         test $KILLSERVERS != no && kill -HUP $KILLPIDS
482         exit 1
483 fi
484
485 echo "Comparing retrieved configs from producer and consumer2..."
486 $CMP $MASTERFLT $SLAVE2FLT > $CMPOUT
487
488 if test $? != 0 ; then
489         echo "test failed - producer and consumer2 configs differ"
490         test $KILLSERVERS != no && kill -HUP $KILLPIDS
491         exit 1
492 fi
493
494 echo "Using ldapsearch to read all the entries from the producer..."
495 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI1 -w $PASSWD  \
496         'objectclass=*' > $MASTEROUT 2>&1
497 RC=$?
498
499 if test $RC != 0 ; then
500         echo "ldapsearch failed at producer ($RC)!"
501         test $KILLSERVERS != no && kill -HUP $KILLPIDS
502         exit $RC
503 fi
504
505 echo "Using ldapsearch to read all the entries from consumer1..."
506 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI2 -w $PASSWD  \
507         'objectclass=*' > $SLAVEOUT 2>&1
508 RC=$?
509
510 if test $RC != 0 ; then
511         echo "ldapsearch failed at consumer1 ($RC)!"
512         test $KILLSERVERS != no && kill -HUP $KILLPIDS
513         exit $RC
514 fi
515
516 echo "Using ldapsearch to read all the entries from consumer2..."
517 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI3 -w $PASSWD  \
518         'objectclass=*' > $SLAVE2OUT 2>&1
519 RC=$?
520
521 if test $RC != 0 ; then
522         echo "ldapsearch failed at consumer2 ($RC)!"
523         test $KILLSERVERS != no && kill -HUP $KILLPIDS
524         exit $RC
525 fi
526
527 # kill!
528 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
529 kill -HUP $KILLPIDS
530
531 echo "Filtering producer results..."
532 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
533 echo "Filtering consumer1 results..."
534 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
535 echo "Filtering consumer2 results..."
536 . $LDIFFILTER < $SLAVE2OUT > $SLAVE2FLT
537
538 echo "Comparing retrieved entries from producer and consumer1..."
539 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
540
541 if test $? != 0 ; then
542         echo "test failed - producer and consumer1 databases differ"
543         exit 1
544 fi
545
546 echo "Comparing retrieved entries from producer and consumer2..."
547 $CMP $MASTERFLT $SLAVE2FLT > $CMPOUT
548
549 if test $? != 0 ; then
550         echo "test failed - producer and consumer2 databases differ"
551         exit 1
552 fi
553
554 # kill!
555 # test $KILLSERVERS != no && wait
556 wait
557
558 echo "Restarting servers..."
559 echo "Starting producer slapd on TCP/IP port $PORT1..."
560 cd $PRODIR
561 echo "======================= RESTART =======================" >> $LOG1
562 $SLAPD -F ./slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
563 PID=$!
564 if test $WAIT != 0 ; then
565     echo PID $PID
566     read foo
567 fi
568 KILLPIDS="$PID"
569 cd $TESTWD
570 echo "Using ldapsearch to check that producer slapd is running..."
571 for i in 0 1 2 3 4 5; do
572         $LDAPSEARCH -s base -b "" -H $URI1 \
573                 'objectclass=*' > /dev/null 2>&1
574         RC=$?
575         if test $RC = 0 ; then
576                 break
577         fi
578         echo "Waiting 5 seconds for slapd to start..."
579         sleep 5
580 done
581
582 if test $RC != 0 ; then
583         echo "ldapsearch failed ($RC)!"
584         test $KILLSERVERS != no && kill -HUP $KILLPIDS
585         exit $RC
586 fi
587 #exit 0
588 echo "Starting consumer1 slapd on TCP/IP port $PORT2..."
589 cd $CONDIR
590 echo "======================= RESTART =======================" >> $LOG2
591 $SLAPD -F ./slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
592 SLAVEPID=$!
593 if test $WAIT != 0 ; then
594     echo SLAVEPID $SLAVEPID
595     read foo
596 fi
597 KILLPIDS="$KILLPIDS $SLAVEPID"
598 cd $TESTWD
599
600 sleep 1
601
602 echo "Using ldapsearch to check that consumer1 slapd is running..."
603 for i in 0 1 2 3 4 5; do
604         $LDAPSEARCH -s base -b "" -H $URI2 \
605                 'objectclass=*' > /dev/null 2>&1
606         RC=$?
607         if test $RC = 0 ; then
608                 break
609         fi
610         echo "Waiting 5 seconds for slapd to start..."
611         sleep 5
612 done
613
614 if test $RC != 0 ; then
615         echo "ldapsearch failed ($RC)!"
616         test $KILLSERVERS != no && kill -HUP $KILLPIDS
617         exit $RC
618 fi
619
620 echo "Starting consumer2 slapd on TCP/IP port $PORT3..."
621 cd $CONDIR2
622 echo "======================= RESTART =======================" >> $LOG3
623 $SLAPD -F ./slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
624 SLAVE2PID=$!
625 if test $WAIT != 0 ; then
626     echo SLAVE2PID $SLAVE2PID
627     read foo
628 fi
629 KILLPIDS="$KILLPIDS $SLAVE2PID"
630 cd $TESTWD
631
632 sleep 1
633
634 echo "Using ldapsearch to check that consumer2 slapd is running..."
635 for i in 0 1 2 3 4 5; do
636         $LDAPSEARCH -s base -b "" -H $URI3 \
637                 'objectclass=*' > /dev/null 2>&1
638         RC=$?
639         if test $RC = 0 ; then
640                 break
641         fi
642         echo "Waiting 5 seconds for slapd to start..."
643         sleep 5
644 done
645
646 if test $RC != 0 ; then
647         echo "ldapsearch failed ($RC)!"
648         test $KILLSERVERS != no && kill -HUP $KILLPIDS
649         exit $RC
650 fi
651
652 # Insert modifications and more tests here.
653 SLEEP=10
654 echo "Waiting $SLEEP seconds for servers to resync..."
655 sleep $SLEEP
656
657 test $KILLSERVERS != no && kill -HUP $KILLPIDS
658
659 echo ">>>>> Test succeeded"
660
661 test $KILLSERVERS != no && wait
662
663 exit 0