3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2009 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
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>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test $SYNCPROV = syncprovno; then
20 echo "Syncrepl provider overlay not available, test skipped"
34 CFCON2=$CONDIR2/slapd.d
35 CFCON3=$CONDIR3/slapd.d
37 mkdir -p $TESTDIR $PRODIR $CONDIR $CONDIR2 $CONDIR3 $DBPRO $DBCON $DBCON2 $DBCON3 $CFPRO $CFCON $CFCON2 $CFCON3
39 $SLAPPASSWD -g -n >$CONFIGPWF
41 if test x"$SYNCMODE" = x ; then
46 SYNCTYPE="type=refreshOnly interval=00:00:00:03"
49 SYNCTYPE="type=refreshAndPersist"
52 echo "unknown sync mode $SYNCMODE"
58 # Test replication of dynamic config:
63 # - configure over ldap
64 # - populate over ldap
65 # - configure syncrepl over ldap
66 # - retrieve database over ldap and compare against expected results
69 echo "Initializing server configurations..."
70 $SLAPADD -F $CFCON2 -n 0 <<EOF
72 objectClass: olcGlobal
76 dn: olcDatabase={0}config,cn=config
77 objectClass: olcDatabaseConfig
78 olcDatabase: {0}config
79 olcRootPW:< file://$CONFIGPWF
82 $SLAPADD -F $CFCON3 -n 0 <<EOF
84 objectClass: olcGlobal
88 dn: olcDatabase={0}config,cn=config
89 objectClass: olcDatabaseConfig
90 olcDatabase: {0}config
91 olcRootPW:< file://$CONFIGPWF
94 $SLAPADD -F $CFCON -n 0 <<EOF
96 objectClass: olcGlobal
100 dn: olcDatabase={0}config,cn=config
101 objectClass: olcDatabaseConfig
102 olcDatabase: {0}config
103 olcRootPW:< file://$CONFIGPWF
106 $SLAPADD -F $CFPRO -n 0 <<EOF
108 objectClass: olcGlobal
112 dn: olcDatabase={0}config,cn=config
113 objectClass: olcDatabaseConfig
114 olcDatabase: {0}config
115 olcRootPW:< file://$CONFIGPWF
118 echo "Starting producer slapd on TCP/IP port $PORT1..."
120 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
122 if test $WAIT != 0 ; then
131 echo "Using ldapsearch to check that producer slapd is running..."
132 for i in 0 1 2 3 4 5; do
133 $LDAPSEARCH -s base -b "" -H $URI1 \
134 'objectclass=*' > /dev/null 2>&1
136 if test $RC = 0 ; then
139 echo "Waiting 5 seconds for slapd to start..."
143 if test $RC != 0 ; then
144 echo "ldapsearch failed ($RC)!"
145 test $KILLSERVERS != no && kill -HUP $KILLPIDS
149 echo "Inserting syncprov overlay on producer..."
150 if [ "$SYNCPROV" = syncprovmod ]; then
151 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
152 dn: cn=module,cn=config
153 objectClass: olcModuleList
155 olcModulePath: ../../../servers/slapd/overlays
156 olcModuleLoad: syncprov.la
159 if test $RC != 0 ; then
160 echo "ldapadd failed for moduleLoad ($RC)!"
161 test $KILLSERVERS != no && kill -HUP $KILLPIDS
166 # Note that we configure a timeout here; it's possible for both
167 # servers to attempt to bind to each other while a modify to
168 # cn=config is in progress. When the modify pauses the thread pool
169 # neither server will progress. The timeout will drop the syncrepl
170 # attempt and allow the modifies to complete.
172 read CONFIGPW < $CONFIGPWF
173 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
182 dn: olcOverlay=syncprov,olcDatabase={0}config,cn=config
184 objectClass: olcOverlayConfig
185 objectClass: olcSyncProvConfig
188 dn: olcDatabase={0}config,cn=config
191 olcSyncRepl: rid=001 provider=$URI1 binddn="cn=config" bindmethod=simple
192 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
193 retry="3 5 300 5" timeout=3
194 olcSyncRepl: rid=002 provider=$URI2 binddn="cn=config" bindmethod=simple
195 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
196 retry="3 5 300 5" timeout=3
197 olcSyncRepl: rid=003 provider=$URI3 binddn="cn=config" bindmethod=simple
198 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
199 retry="3 5 300 5" timeout=3
200 olcSyncRepl: rid=004 provider=$URI4 binddn="cn=config" bindmethod=simple
201 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
202 retry="3 5 300 5" timeout=3
208 if test $RC != 0 ; then
209 echo "ldapmodify failed for syncrepl config ($RC)!"
210 test $KILLSERVERS != no && kill -HUP $KILLPIDS
214 echo "Starting consumer1 slapd on TCP/IP port $PORT2..."
216 $SLAPD -F ./slapd.d -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
218 if test $WAIT != 0 ; then
219 echo SLAVEPID $SLAVEPID
222 KILLPIDS="$KILLPIDS $SLAVEPID"
227 echo "Using ldapsearch to check that consumer1 slapd is running..."
228 for i in 0 1 2 3 4 5; do
229 $LDAPSEARCH -s base -b "" -H $URI2 \
230 'objectclass=*' > /dev/null 2>&1
232 if test $RC = 0 ; then
235 echo "Waiting 5 seconds for slapd to start..."
239 if test $RC != 0 ; then
240 echo "ldapsearch failed ($RC)!"
241 test $KILLSERVERS != no && kill -HUP $KILLPIDS
245 echo "Configuring syncrepl on consumer1..."
246 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
247 dn: olcDatabase={0}config,cn=config
250 olcSyncRepl: rid=001 provider=$URI1 binddn="cn=config" bindmethod=simple
251 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
252 retry="3 5 300 5" timeout=3
253 olcSyncRepl: rid=002 provider=$URI2 binddn="cn=config" bindmethod=simple
254 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
255 retry="3 5 300 5" timeout=3
256 olcSyncRepl: rid=003 provider=$URI3 binddn="cn=config" bindmethod=simple
257 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
258 retry="3 5 300 5" timeout=3
259 olcSyncRepl: rid=004 provider=$URI4 binddn="cn=config" bindmethod=simple
260 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
261 retry="3 5 300 5" timeout=3
267 echo "Starting consumer2 slapd on TCP/IP port $PORT3..."
269 $SLAPD -F ./slapd.d -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
271 if test $WAIT != 0 ; then
272 echo SLAVE2PID $SLAVE2PID
275 KILLPIDS="$KILLPIDS $SLAVE2PID"
280 echo "Using ldapsearch to check that consumer2 slapd is running..."
281 for i in 0 1 2 3 4 5; do
282 $LDAPSEARCH -s base -b "" -H $URI3 \
283 'objectclass=*' > /dev/null 2>&1
285 if test $RC = 0 ; then
288 echo "Waiting 5 seconds for slapd to start..."
292 if test $RC != 0 ; then
293 echo "ldapsearch failed ($RC)!"
294 test $KILLSERVERS != no && kill -HUP $KILLPIDS
298 echo "Configuring syncrepl on consumer2..."
299 $LDAPMODIFY -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
300 dn: olcDatabase={0}config,cn=config
303 olcSyncRepl: rid=001 provider=$URI1 binddn="cn=config" bindmethod=simple
304 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
305 retry="3 5 300 5" timeout=3
306 olcSyncRepl: rid=002 provider=$URI2 binddn="cn=config" bindmethod=simple
307 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
308 retry="3 5 300 5" timeout=3
309 olcSyncRepl: rid=003 provider=$URI3 binddn="cn=config" bindmethod=simple
310 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
311 retry="3 5 300 5" timeout=3
312 olcSyncRepl: rid=004 provider=$URI4 binddn="cn=config" bindmethod=simple
313 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
314 retry="3 5 300 5" timeout=3
320 echo "Starting consumer3 slapd on TCP/IP port $PORT4..."
322 $SLAPD -F ./slapd.d -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
324 if test $WAIT != 0 ; then
325 echo SLAVE3PID $SLAVE3PID
328 KILLPIDS="$KILLPIDS $SLAVE3PID"
333 echo "Using ldapsearch to check that consumer3 slapd is running..."
334 for i in 0 1 2 3 4 5; do
335 $LDAPSEARCH -s base -b "" -H $URI4 \
336 'objectclass=*' > /dev/null 2>&1
338 if test $RC = 0 ; then
341 echo "Waiting 5 seconds for slapd to start..."
345 if test $RC != 0 ; then
346 echo "ldapsearch failed ($RC)!"
347 test $KILLSERVERS != no && kill -HUP $KILLPIDS
351 echo "Configuring syncrepl on consumer3..."
352 $LDAPMODIFY -D cn=config -H $URI4 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
353 dn: olcDatabase={0}config,cn=config
356 olcSyncRepl: rid=001 provider=$URI1 binddn="cn=config" bindmethod=simple
357 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
358 retry="3 5 300 5" timeout=3
359 olcSyncRepl: rid=002 provider=$URI2 binddn="cn=config" bindmethod=simple
360 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
361 retry="3 5 300 5" timeout=3
362 olcSyncRepl: rid=003 provider=$URI3 binddn="cn=config" bindmethod=simple
363 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
364 retry="3 5 300 5" timeout=3
365 olcSyncRepl: rid=004 provider=$URI4 binddn="cn=config" bindmethod=simple
366 credentials=$CONFIGPW searchbase="cn=config" type=refreshAndPersist
367 retry="3 5 300 5" timeout=3
373 echo "Adding schema and databases on producer..."
374 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
375 include: file://$ABS_SCHEMADIR/core.ldif
377 include: file://$ABS_SCHEMADIR/cosine.ldif
379 include: file://$ABS_SCHEMADIR/inetorgperson.ldif
381 include: file://$ABS_SCHEMADIR/openldap.ldif
383 include: file://$ABS_SCHEMADIR/nis.ldif
386 if test $RC != 0 ; then
387 echo "ldapadd failed for schema config ($RC)!"
388 test $KILLSERVERS != no && kill -HUP $KILLPIDS
392 if [ "$BACKENDTYPE" = mod ]; then
393 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
394 dn: cn=module,cn=config
395 objectClass: olcModuleList
397 olcModulePath: ../../../servers/slapd/back-$BACKEND
398 olcModuleLoad: back_$BACKEND.la
401 if test $RC != 0 ; then
402 echo "ldapadd failed for backend config ($RC)!"
403 test $KILLSERVERS != no && kill -HUP $KILLPIDS
408 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
409 dn: olcDatabase={1}$BACKEND,cn=config
410 objectClass: olcDatabaseConfig
411 objectClass: olc${BACKEND}Config
412 olcDatabase: {1}$BACKEND
415 olcRootDN: $MANAGERDN
417 olcSyncRepl: rid=005 provider=$URI1 binddn="$MANAGERDN" bindmethod=simple
418 credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
419 retry="3 5 300 5" timeout=3
420 olcSyncRepl: rid=006 provider=$URI2 binddn="$MANAGERDN" bindmethod=simple
421 credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
422 retry="3 5 300 5" timeout=3
423 olcSyncRepl: rid=007 provider=$URI3 binddn="$MANAGERDN" bindmethod=simple
424 credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
425 retry="3 5 300 5" timeout=3
426 olcSyncRepl: rid=008 provider=$URI4 binddn="$MANAGERDN" bindmethod=simple
427 credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
428 retry="3 5 300 5" timeout=3
431 dn: olcOverlay=syncprov,olcDatabase={1}${BACKEND},cn=config
433 objectClass: olcOverlayConfig
434 objectClass: olcSyncProvConfig
438 if test $RC != 0 ; then
439 echo "ldapadd failed for database config ($RC)!"
440 test $KILLSERVERS != no && kill -HUP $KILLPIDS
446 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
447 dn: olcDatabase={1}$BACKEND,cn=config
450 olcDbIndex: objectClass,entryUUID,entryCSN eq
451 olcDbIndex: cn,uid pres,eq,sub
454 if test $RC != 0 ; then
455 echo "ldapadd modify for database config ($RC)!"
456 test $KILLSERVERS != no && kill -HUP $KILLPIDS
462 echo "Using ldapadd to populate producer..."
463 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDERED \
466 if test $RC != 0 ; then
467 echo "ldapadd failed for producer database ($RC)!"
468 test $KILLSERVERS != no && kill -HUP $KILLPIDS
472 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
475 echo "Using ldapsearch to read config from the producer..."
476 $LDAPSEARCH -b cn=config -D cn=config -H $URI1 -y $CONFIGPWF \
477 'objectclass=*' > $MASTEROUT 2>&1
480 if test $RC != 0 ; then
481 echo "ldapsearch failed at producer ($RC)!"
482 test $KILLSERVERS != no && kill -HUP $KILLPIDS
486 echo "Using ldapsearch to read config from consumer1..."
487 $LDAPSEARCH -b cn=config -D cn=config -H $URI2 -y $CONFIGPWF \
488 'objectclass=*' > $SLAVEOUT 2>&1
491 if test $RC != 0 ; then
492 echo "ldapsearch failed at consumer1 ($RC)!"
493 test $KILLSERVERS != no && kill -HUP $KILLPIDS
497 echo "Using ldapsearch to read config from consumer2..."
498 $LDAPSEARCH -b cn=config -D cn=config -H $URI3 -y $CONFIGPWF \
499 'objectclass=*' > $SLAVE2OUT 2>&1
502 if test $RC != 0 ; then
503 echo "ldapsearch failed at consumer2 ($RC)!"
504 test $KILLSERVERS != no && kill -HUP $KILLPIDS
508 echo "Using ldapsearch to read config from consumer3..."
509 $LDAPSEARCH -b cn=config -D cn=config -H $URI4 -y $CONFIGPWF \
510 'objectclass=*' > $SERVER4OUT 2>&1
513 if test $RC != 0 ; then
514 echo "ldapsearch failed at consumer3 ($RC)!"
515 test $KILLSERVERS != no && kill -HUP $KILLPIDS
519 echo "Filtering producer results..."
520 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
521 echo "Filtering consumer1 results..."
522 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
523 echo "Filtering consumer2 results..."
524 . $LDIFFILTER < $SLAVE2OUT > $SLAVE2FLT
525 echo "Filtering consumer3 results..."
526 . $LDIFFILTER < $SERVER4OUT > $SERVER4FLT
528 echo "Comparing retrieved configs from producer and consumer1..."
529 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
531 if test $? != 0 ; then
532 echo "test failed - producer and consumer1 configs differ"
533 test $KILLSERVERS != no && kill -HUP $KILLPIDS
537 echo "Comparing retrieved configs from producer and consumer2..."
538 $CMP $MASTERFLT $SLAVE2FLT > $CMPOUT
540 if test $? != 0 ; then
541 echo "test failed - producer and consumer2 configs differ"
542 test $KILLSERVERS != no && kill -HUP $KILLPIDS
546 echo "Comparing retrieved configs from producer and consumer3..."
547 $CMP $MASTERFLT $SERVER4FLT > $CMPOUT
549 if test $? != 0 ; then
550 echo "test failed - producer and consumer3 configs differ"
551 test $KILLSERVERS != no && kill -HUP $KILLPIDS
555 echo "Using ldapsearch to read all the entries from the producer..."
556 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI1 -w $PASSWD \
557 'objectclass=*' > $MASTEROUT 2>&1
560 if test $RC != 0 ; then
561 echo "ldapsearch failed at producer ($RC)!"
562 test $KILLSERVERS != no && kill -HUP $KILLPIDS
566 echo "Using ldapsearch to read all the entries from consumer1..."
567 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI2 -w $PASSWD \
568 'objectclass=*' > $SLAVEOUT 2>&1
571 if test $RC != 0 ; then
572 echo "ldapsearch failed at consumer1 ($RC)!"
573 test $KILLSERVERS != no && kill -HUP $KILLPIDS
577 echo "Using ldapsearch to read all the entries from consumer2..."
578 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI3 -w $PASSWD \
579 'objectclass=*' > $SLAVE2OUT 2>&1
582 if test $RC != 0 ; then
583 echo "ldapsearch failed at consumer2 ($RC)!"
584 test $KILLSERVERS != no && kill -HUP $KILLPIDS
588 echo "Using ldapsearch to read all the entries from consumer3..."
589 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI4 -w $PASSWD \
590 'objectclass=*' > $SERVER4OUT 2>&1
593 if test $RC != 0 ; then
594 echo "ldapsearch failed at consumer3 ($RC)!"
595 test $KILLSERVERS != no && kill -HUP $KILLPIDS
599 echo "Filtering producer results..."
600 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
601 echo "Filtering consumer1 results..."
602 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
603 echo "Filtering consumer2 results..."
604 . $LDIFFILTER < $SLAVE2OUT > $SLAVE2FLT
605 echo "Filtering consumer3 results..."
606 . $LDIFFILTER < $SERVER4OUT > $SERVER4FLT
608 echo "Comparing retrieved entries from producer and consumer1..."
609 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
611 if test $? != 0 ; then
612 echo "test failed - producer and consumer1 databases differ"
616 echo "Comparing retrieved entries from producer and consumer2..."
617 $CMP $MASTERFLT $SLAVE2FLT > $CMPOUT
619 if test $? != 0 ; then
620 echo "test failed - producer and consumer2 databases differ"
624 echo "Comparing retrieved entries from producer and consumer3..."
625 $CMP $MASTERFLT $SERVER4FLT > $CMPOUT
627 if test $? != 0 ; then
628 echo "test failed - producer and consumer3 databases differ"
632 echo "Using ldapadd to populate consumer1..."
633 $LDAPADD -D "$MANAGERDN" -H $URI2 -w $PASSWD -f $LDIFADD1 \
636 if test $RC != 0 ; then
637 echo "ldapadd failed for consumer1 database ($RC)!"
638 test $KILLSERVERS != no && kill -HUP $KILLPIDS
642 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
645 echo "Using ldapsearch to read all the entries from the producer..."
646 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI1 -w $PASSWD \
647 'objectclass=*' > $MASTEROUT 2>&1
650 if test $RC != 0 ; then
651 echo "ldapsearch failed at producer ($RC)!"
652 test $KILLSERVERS != no && kill -HUP $KILLPIDS
656 echo "Using ldapsearch to read all the entries from consumer1..."
657 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI2 -w $PASSWD \
658 'objectclass=*' > $SLAVEOUT 2>&1
661 if test $RC != 0 ; then
662 echo "ldapsearch failed at consumer1 ($RC)!"
663 test $KILLSERVERS != no && kill -HUP $KILLPIDS
667 echo "Using ldapsearch to read all the entries from consumer2..."
668 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI3 -w $PASSWD \
669 'objectclass=*' > $SLAVE2OUT 2>&1
672 if test $RC != 0 ; then
673 echo "ldapsearch failed at consumer2 ($RC)!"
674 test $KILLSERVERS != no && kill -HUP $KILLPIDS
678 echo "Using ldapsearch to read all the entries from consumer3..."
679 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI4 -w $PASSWD \
680 'objectclass=*' > $SERVER4OUT 2>&1
683 if test $RC != 0 ; then
684 echo "ldapsearch failed at consumer3 ($RC)!"
685 test $KILLSERVERS != no && kill -HUP $KILLPIDS
689 echo "Filtering producer results..."
690 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
691 echo "Filtering consumer1 results..."
692 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
693 echo "Filtering consumer2 results..."
694 . $LDIFFILTER < $SLAVE2OUT > $SLAVE2FLT
695 echo "Filtering consumer3 results..."
696 . $LDIFFILTER < $SERVER4OUT > $SERVER4FLT
698 echo "Comparing retrieved entries from producer and consumer1..."
699 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
701 if test $? != 0 ; then
702 echo "test failed - producer and consumer1 databases differ"
706 echo "Comparing retrieved entries from producer and consumer2..."
707 $CMP $MASTERFLT $SLAVE2FLT > $CMPOUT
709 if test $? != 0 ; then
710 echo "test failed - producer and consumer2 databases differ"
714 echo "Comparing retrieved entries from producer and consumer3..."
715 $CMP $MASTERFLT $SERVER4FLT > $CMPOUT
717 if test $? != 0 ; then
718 echo "test failed - producer and consumer3 databases differ"
722 echo "Using ldapadd to populate consumer2..."
723 $LDAPADD -D "$MANAGERDN" -H $URI3 -w $PASSWD \
724 << EOMODS >> $TESTOUT 2>&1
725 dn: cn=Consumer 2 Test,dc=example,dc=com
731 if test $RC != 0 ; then
732 echo "ldapadd failed for consumer2 database ($RC)!"
733 test $KILLSERVERS != no && kill -HUP $KILLPIDS
737 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
740 echo "Using ldapsearch to read all the entries from the producer..."
741 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI1 -w $PASSWD \
742 'objectclass=*' > $MASTEROUT 2>&1
745 if test $RC != 0 ; then
746 echo "ldapsearch failed at producer ($RC)!"
747 test $KILLSERVERS != no && kill -HUP $KILLPIDS
751 echo "Using ldapsearch to read all the entries from consumer1..."
752 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI2 -w $PASSWD \
753 'objectclass=*' > $SLAVEOUT 2>&1
756 if test $RC != 0 ; then
757 echo "ldapsearch failed at consumer1 ($RC)!"
758 test $KILLSERVERS != no && kill -HUP $KILLPIDS
762 echo "Using ldapsearch to read all the entries from consumer2..."
763 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI3 -w $PASSWD \
764 'objectclass=*' > $SLAVE2OUT 2>&1
767 if test $RC != 0 ; then
768 echo "ldapsearch failed at consumer2 ($RC)!"
769 test $KILLSERVERS != no && kill -HUP $KILLPIDS
773 echo "Using ldapsearch to read all the entries from consumer3..."
774 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI4 -w $PASSWD \
775 'objectclass=*' > $SERVER4OUT 2>&1
778 if test $RC != 0 ; then
779 echo "ldapsearch failed at consumer3 ($RC)!"
780 test $KILLSERVERS != no && kill -HUP $KILLPIDS
784 echo "Filtering producer results..."
785 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
786 echo "Filtering consumer1 results..."
787 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
788 echo "Filtering consumer2 results..."
789 . $LDIFFILTER < $SLAVE2OUT > $SLAVE2FLT
790 echo "Filtering consumer3 results..."
791 . $LDIFFILTER < $SERVER4OUT > $SERVER4FLT
793 echo "Comparing retrieved entries from producer and consumer1..."
794 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
796 if test $? != 0 ; then
797 echo "test failed - producer and consumer1 databases differ"
801 echo "Comparing retrieved entries from producer and consumer2..."
802 $CMP $MASTERFLT $SLAVE2FLT > $CMPOUT
804 if test $? != 0 ; then
805 echo "test failed - producer and consumer2 databases differ"
809 echo "Comparing retrieved entries from producer and consumer3..."
810 $CMP $MASTERFLT $SERVER4FLT > $CMPOUT
812 if test $? != 0 ; then
813 echo "test failed - producer and consumer3 databases differ"
817 echo "Using ldapmodify to add to the producer entries that will be deleted..."
818 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
819 >> $TESTOUT 2>&1 << EOADDS
820 dn: cn=To be deleted by producer,dc=example,dc=com
823 # no distinguished values, will be added by DSA
825 dn: cn=To be deleted by consumer1,dc=example,dc=com
828 # no distinguished values, will be added by DSA
830 dn: cn=To be deleted by consumer2,dc=example,dc=com
833 # no distinguished values, will be added by DSA
835 dn: cn=To be deleted by producer,dc=example,dc=com
839 if test $RC != 0 ; then
840 echo "ldapmodify failed for producer database ($RC)!"
841 test $KILLSERVERS != no && kill -HUP $KILLPIDS
845 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
848 echo "Using ldapsearch to read all the entries from the producer..."
849 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI1 -w $PASSWD \
850 'objectclass=*' > $MASTEROUT 2>&1
853 if test $RC != 0 ; then
854 echo "ldapsearch failed at producer ($RC)!"
855 test $KILLSERVERS != no && kill -HUP $KILLPIDS
859 echo "Using ldapsearch to read all the entries from consumer1..."
860 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI2 -w $PASSWD \
861 'objectclass=*' > $SLAVEOUT 2>&1
864 if test $RC != 0 ; then
865 echo "ldapsearch failed at consumer1 ($RC)!"
866 test $KILLSERVERS != no && kill -HUP $KILLPIDS
870 echo "Using ldapsearch to read all the entries from consumer2..."
871 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI3 -w $PASSWD \
872 'objectclass=*' > $SLAVE2OUT 2>&1
875 if test $RC != 0 ; then
876 echo "ldapsearch failed at consumer2 ($RC)!"
877 test $KILLSERVERS != no && kill -HUP $KILLPIDS
881 echo "Using ldapsearch to read all the entries from consumer3..."
882 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI4 -w $PASSWD \
883 'objectclass=*' > $SERVER4OUT 2>&1
886 if test $RC != 0 ; then
887 echo "ldapsearch failed at consumer3 ($RC)!"
888 test $KILLSERVERS != no && kill -HUP $KILLPIDS
892 echo "Filtering producer results..."
893 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
894 echo "Filtering consumer1 results..."
895 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
896 echo "Filtering consumer2 results..."
897 . $LDIFFILTER < $SLAVE2OUT > $SLAVE2FLT
898 echo "Filtering consumer3 results..."
899 . $LDIFFILTER < $SERVER4OUT > $SERVER4FLT
901 echo "Comparing retrieved entries from producer and consumer1..."
902 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
904 if test $? != 0 ; then
905 echo "test failed - producer and consumer1 databases differ"
909 echo "Comparing retrieved entries from producer and consumer2..."
910 $CMP $MASTERFLT $SLAVE2FLT > $CMPOUT
912 if test $? != 0 ; then
913 echo "test failed - producer and consumer2 databases differ"
917 echo "Comparing retrieved entries from producer and consumer3..."
918 $CMP $MASTERFLT $SERVER4FLT > $CMPOUT
920 if test $? != 0 ; then
921 echo "test failed - producer and consumer3 databases differ"
925 echo "Using ldapmodify to delete entries from consumer1..."
926 $LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \
927 >> $TESTOUT 2>&1 << EOADDS
928 dn: cn=To be deleted by consumer1,dc=example,dc=com
932 if test $RC != 0 ; then
933 echo "ldapmodify failed for consumer1 database ($RC)!"
934 test $KILLSERVERS != no && kill -HUP $KILLPIDS
938 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
941 echo "Using ldapmodify to delete entries from consumer2..."
942 $LDAPMODIFY -D "$MANAGERDN" -H $URI3 -w $PASSWD \
943 >> $TESTOUT 2>&1 << EOADDS
944 dn: cn=To be deleted by consumer2,dc=example,dc=com
948 if test $RC != 0 ; then
949 echo "ldapmodify failed for consumer2 database ($RC)!"
950 test $KILLSERVERS != no && kill -HUP $KILLPIDS
954 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
957 echo "Using ldapsearch to read all the entries from the producer..."
958 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI1 -w $PASSWD \
959 'objectclass=*' > $MASTEROUT 2>&1
962 if test $RC != 0 ; then
963 echo "ldapsearch failed at producer ($RC)!"
964 test $KILLSERVERS != no && kill -HUP $KILLPIDS
968 echo "Using ldapsearch to read all the entries from consumer1..."
969 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI2 -w $PASSWD \
970 'objectclass=*' > $SLAVEOUT 2>&1
973 if test $RC != 0 ; then
974 echo "ldapsearch failed at consumer1 ($RC)!"
975 test $KILLSERVERS != no && kill -HUP $KILLPIDS
979 echo "Using ldapsearch to read all the entries from consumer2..."
980 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI3 -w $PASSWD \
981 'objectclass=*' > $SLAVE2OUT 2>&1
984 if test $RC != 0 ; then
985 echo "ldapsearch failed at consumer2 ($RC)!"
986 test $KILLSERVERS != no && kill -HUP $KILLPIDS
990 echo "Using ldapsearch to read all the entries from consumer3..."
991 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI4 -w $PASSWD \
992 'objectclass=*' > $SERVER4OUT 2>&1
995 if test $RC != 0 ; then
996 echo "ldapsearch failed at consumer3 ($RC)!"
997 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1002 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
1005 echo "Filtering producer results..."
1006 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
1007 echo "Filtering consumer1 results..."
1008 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
1009 echo "Filtering consumer2 results..."
1010 . $LDIFFILTER < $SLAVE2OUT > $SLAVE2FLT
1011 echo "Filtering consumer3 results..."
1012 . $LDIFFILTER < $SERVER4OUT > $SERVER4FLT
1014 echo "Comparing retrieved entries from producer and consumer1..."
1015 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
1017 if test $? != 0 ; then
1018 echo "test failed - producer and consumer1 databases differ"
1022 echo "Comparing retrieved entries from producer and consumer2..."
1023 $CMP $MASTERFLT $SLAVE2FLT > $CMPOUT
1025 if test $? != 0 ; then
1026 echo "test failed - producer and consumer2 databases differ"
1030 echo "Comparing retrieved entries from producer and consumer3..."
1031 $CMP $MASTERFLT $SERVER4FLT > $CMPOUT
1033 if test $? != 0 ; then
1034 echo "test failed - producer and consumer3 databases differ"
1039 # test $KILLSERVERS != no && wait
1042 echo "Restarting servers..."
1043 echo "Starting producer slapd on TCP/IP port $PORT1..."
1045 echo "======================= RESTART =======================" >> $LOG1
1046 $SLAPD -F ./slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
1048 if test $WAIT != 0 ; then
1054 echo "Using ldapsearch to check that producer slapd is running..."
1055 for i in 0 1 2 3 4 5; do
1056 $LDAPSEARCH -s base -b "" -H $URI1 \
1057 'objectclass=*' > /dev/null 2>&1
1059 if test $RC = 0 ; then
1062 echo "Waiting 5 seconds for slapd to start..."
1066 if test $RC != 0 ; then
1067 echo "ldapsearch failed ($RC)!"
1068 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1072 echo "Starting consumer1 slapd on TCP/IP port $PORT2..."
1074 echo "======================= RESTART =======================" >> $LOG2
1075 $SLAPD -F ./slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
1077 if test $WAIT != 0 ; then
1078 echo SLAVEPID $SLAVEPID
1081 KILLPIDS="$KILLPIDS $SLAVEPID"
1086 echo "Using ldapsearch to check that consumer1 slapd is running..."
1087 for i in 0 1 2 3 4 5; do
1088 $LDAPSEARCH -s base -b "" -H $URI2 \
1089 'objectclass=*' > /dev/null 2>&1
1091 if test $RC = 0 ; then
1094 echo "Waiting 5 seconds for slapd to start..."
1098 if test $RC != 0 ; then
1099 echo "ldapsearch failed ($RC)!"
1100 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1104 echo "Starting consumer2 slapd on TCP/IP port $PORT3..."
1106 echo "======================= RESTART =======================" >> $LOG3
1107 $SLAPD -F ./slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1109 if test $WAIT != 0 ; then
1110 echo SLAVE2PID $SLAVE2PID
1113 KILLPIDS="$KILLPIDS $SLAVE2PID"
1118 echo "Using ldapsearch to check that consumer2 slapd is running..."
1119 for i in 0 1 2 3 4 5; do
1120 $LDAPSEARCH -s base -b "" -H $URI3 \
1121 'objectclass=*' > /dev/null 2>&1
1123 if test $RC = 0 ; then
1126 echo "Waiting 5 seconds for slapd to start..."
1130 if test $RC != 0 ; then
1131 echo "ldapsearch failed ($RC)!"
1132 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1136 echo "Starting consumer3 slapd on TCP/IP port $PORT4..."
1138 echo "======================= RESTART =======================" >> $LOG4
1139 $SLAPD -F ./slapd.d -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
1141 if test $WAIT != 0 ; then
1142 echo SLAVE3PID $SLAVE3PID
1145 KILLPIDS="$KILLPIDS $SLAVE3PID"
1150 echo "Using ldapsearch to check that consumer3 slapd is running..."
1151 for i in 0 1 2 3 4 5; do
1152 $LDAPSEARCH -s base -b "" -H $URI4 \
1153 'objectclass=*' > /dev/null 2>&1
1155 if test $RC = 0 ; then
1158 echo "Waiting 5 seconds for slapd to start..."
1162 if test $RC != 0 ; then
1163 echo "ldapsearch failed ($RC)!"
1164 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1168 # Insert modifications and more tests here.
1169 echo "Waiting $SLEEP1 seconds for servers to resync..."
1172 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1174 echo ">>>>> Test succeeded"
1176 test $KILLSERVERS != no && wait