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