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