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 # This script tests a configuration scenario as described in these URLs:
18 # http://www.openldap.org/lists/openldap-devel/200806/msg00041.html
19 # http://www.openldap.org/lists/openldap-devel/200806/msg00054.html
21 # Search for "TEST:" to find each major test this script performs.
23 # The configuration here consist of 3 "sites", each with a "master" and
24 # a "search" server. One of the sites is the "central", the other two
25 # are called "site1" and "site2".
27 # The following notations are used in variable names below to identify
28 # these servers, the first number defines the $URL# and $PORT# variable
31 # 1: SMC_* Site Master Central
32 # 2: SM1_* Site Master 1
33 # 3: SM2_* Site Master 2
34 # 4: SSC_* Search Site Central
35 # 5: SS1_* Search Site 1
36 # 6: SS2_* Search Site 2
38 # The master servers all have a set of subordinate databases glued below
39 # the same suffix database. Each of the masters are the master for at
40 # least one of these subordinate databases, but there are never more
41 # than one master for any single database. I.e, this is neither a
42 # traditional single-master configuration, nor what most people think
43 # of as multi-master, but more what can be called multiple masters.
45 # The central master replicates to the two other masters, and receives
46 # updates from them of the backends they are the master for. There is
47 # no direct connection between the other two master servers. All of the
48 # masters have the syncprov overlay configured on the glue database.
50 # The search servers replicates from the master server at their site.
51 # They all have a single database with the glue suffix, but their
52 # database configuration doesn't matter much in this test. (This
53 # database layout was originally created before gluing was introduced
54 # in OpenLDAP, which is why the search servers doesn't use it).
56 # The primary objective for gluing the backend databases is not to make
57 # them look like one huge database but to create a common search suffix
58 # for the clients. Searching is mostly done on the search servers, only
59 # updates are done on the masters.
61 # It varies which backends that are replicated to which server (hence
62 # the name asymmetric in this test). Access control rules on the
63 # masters are used to control what their consumers receives. The table
64 # below gives an overview of which backend (the columns) that are
65 # replicated to which server (the rows). A "M" defines the master for
66 # the backend, a "S" is a slave, and "-" means it is not replicated
67 # there. Oh, the table probably looks wrong without the 4-position
68 # tab-stops OpenLDAP uses...
70 # glue ou1 ou2 sm1ou1 sm1ou2 sm2ou1 sm2ou2
78 # On the central master syncrepl is configured on the subordinate
79 # databases, as it varies which backends that exists on its providers.
80 # Had it been used on the glue database then syncrepl would have removed
81 # the backends replicated from site1 but not present on site2 when it
82 # synchronizes with site2 (and vice versa).
84 # All the other servers uses syncrepl on the glue database, since
85 # replicating more than one subordinate database from the same master
86 # creates (as of the writing of this test script) race conditions that
87 # causes the replication to fail, as the race tests at the end shows.
89 # The databases controlled by syncrepl all have $UPDATEDN as their
90 # RootDN, while the master servers has other RootDN values for the
91 # backends they are the backend for them self. This violates the current
92 # guidelines for gluing databases, which states that the same rootdn
93 # should be used on all of them. Unfortunately, this cannot be done on
94 # site masters 1 and 2. The backends they manage locally are either not
95 # present on the central master, or when so they are not replicated back
96 # to their source, which causes syncrepl to try to remove the content of
97 # these backends when it synchronizes with the central master. The
98 # differing rootdn values used on the backends controlled by syncrepl
99 # and those managed locally prevents it from succeeding in this. As
100 # noted above, moving syncrepl to the subordinate databases is currently
101 # not an option since that creates race conditions.
103 # The binddn values used in the syncrepl configurations are chosen to
104 # make the configuration and access control rules easiest to set up. It
105 # occasionally uses a DN that is also used as a RootDN. This is not a
106 # good practice and should not be taken as an example for real
109 # This script will print the content of any invalid contextCSN values it
110 # detects if the environment variable CSN_VERBOSE is non-empty. The
111 # environment variable RACE_TESTS can be set to the number of race test
112 # iterations the script should perform.
118 echo "This test does not support the $BACKEND backend"
122 echo "running defines.sh"
123 . $SRCDIR/scripts/defines.sh
125 if test $SYNCPROV = syncprovno; then
126 echo "Syncrepl provider overlay not available, test skipped"
139 for dir in $SMC_DIR $SM1_DIR $SM2_DIR $SS1_DIR $SS2_DIR $SSC_DIR; do
140 mkdir -p $dir $dir/slapd.d $dir/db
143 mkdir -p $SMC_DIR/ou1 $SMC_DIR/sm1ou1 $SMC_DIR/sm1ou2
144 mkdir -p $SMC_DIR/ou2 $SMC_DIR/sm2ou1
145 mkdir -p $SM1_DIR/ou1 $SM1_DIR/sm1ou1 $SM1_DIR/sm1ou2
146 mkdir -p $SM2_DIR/ou2 $SM2_DIR/sm1ou1 $SM2_DIR/sm2ou1 $SM2_DIR/sm2ou2
152 $SLAPPASSWD -g -n >$CONFIGPWF
156 if test $WAIT != 0 ; then
162 echo "Initializing master configurations..."
163 for dir in $SMC_DIR $SM1_DIR $SM2_DIR; do
164 $SLAPADD -F $dir/slapd.d -n 0 <<EOF
166 objectClass: olcGlobal
170 dn: olcDatabase={0}config,cn=config
171 objectClass: olcDatabaseConfig
172 olcDatabase: {0}config
173 olcRootPW:< file://$CONFIGPWF
179 echo "Initializing search configurations..."
180 for dir in $SS1_DIR $SS2_DIR $SSC_DIR; do
181 $SLAPADD -F $dir/slapd.d -n 0 <<EOF
183 objectClass: olcGlobal
186 dn: olcDatabase={0}config,cn=config
187 objectClass: olcDatabaseConfig
188 olcDatabase: {0}config
189 olcRootPW:< file://$CONFIGPWF
194 echo "Starting central master slapd on TCP/IP port $PORT1..."
196 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
198 if test $WAIT != 0 ; then
202 KILLPIDS="$KILLPIDS $SMC_PID"
205 echo "Using ldapsearch to check that central master slapd is running..."
206 for i in 1 2 3 4 5; do
207 $LDAPSEARCH -s base -b "" -H $URI1 \
208 'objectclass=*' > /dev/null 2>&1
210 test $RC = 0 && break
211 echo "Waiting $i seconds for slapd to start..."
214 if test $RC != 0 ; then
215 echo "ldapsearch failed ($RC)!"
216 test $KILLSERVERS != no && kill -HUP $KILLPIDS
220 echo "Starting site1 master slapd on TCP/IP port $PORT2..."
222 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
224 if test $WAIT != 0 ; then
228 KILLPIDS="$KILLPIDS $SM1_PID"
231 echo "Using ldapsearch to check that site1 master is running..."
232 for i in 1 2 3 4 5; do
233 $LDAPSEARCH -s base -b "" -H $URI2 \
234 'objectclass=*' > /dev/null 2>&1
236 test $RC = 0 && break
237 echo "Waiting $i seconds for slapd to start..."
240 if test $RC != 0 ; then
241 echo "ldapsearch failed ($RC)!"
242 test $KILLSERVERS != no && kill -HUP $KILLPIDS
246 echo "Starting site2 master slapd on TCP/IP port $PORT3..."
248 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
250 if test $WAIT != 0 ; then
254 KILLPIDS="$KILLPIDS $SM2_PID"
257 echo "Using ldapsearch to check that site2 master is running..."
258 for i in 1 2 3 4 5; do
259 $LDAPSEARCH -s base -b "" -H $URI3 \
260 'objectclass=*' > /dev/null 2>&1
262 test $RC = 0 && break
263 echo "Waiting $i seconds for slapd to start..."
266 if test $RC != 0 ; then
267 echo "ldapsearch failed ($RC)!"
268 test $KILLSERVERS != no && kill -HUP $KILLPIDS
272 echo "Starting central search slapd on TCP/IP port $PORT4..."
274 $SLAPD -F slapd.d -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
276 if test $WAIT != 0 ; then
280 KILLPIDS="$KILLPIDS $SSC_PID"
283 echo "Using ldapsearch to check that central search slapd is running..."
284 for i in 1 2 3 4 5; do
285 $LDAPSEARCH -s base -b "" -H $URI4 \
286 'objectclass=*' > /dev/null 2>&1
288 test $RC = 0 && break
289 echo "Waiting $i seconds for slapd to start..."
292 if test $RC != 0 ; then
293 echo "ldapsearch failed ($RC)!"
294 test $KILLSERVERS != no && kill -HUP $KILLPIDS
299 echo "Starting site1 search slapd on TCP/IP port $PORT5..."
301 $SLAPD -F slapd.d -h $URI5 -d $LVL $TIMING > $LOG5 2>&1 &
303 if test $WAIT != 0 ; then
307 KILLPIDS="$KILLPIDS $SS1_PID"
310 echo "Using ldapsearch to check that site1 search slapd is running..."
311 for i in 1 2 3 4 5; do
312 $LDAPSEARCH -s base -b "" -H $URI5 \
313 'objectclass=*' > /dev/null 2>&1
315 test $RC = 0 && break
316 echo "Waiting $i seconds for slapd to start..."
319 if test $RC != 0 ; then
320 echo "ldapsearch failed ($RC)!"
321 test $KILLSERVERS != no && kill -HUP $KILLPIDS
326 echo "Starting site2 search slapd on TCP/IP port $PORT6..."
328 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING > $LOG6 2>&1 &
330 if test $WAIT != 0 ; then
334 KILLPIDS="$KILLPIDS $SS2_PID"
337 echo "Using ldapsearch to check that site2 search slapd is running..."
338 for i in 1 2 3 4 5; do
339 $LDAPSEARCH -s base -b "" -H $URI6 \
340 'objectclass=*' > /dev/null 2>&1
342 test $RC = 0 && break
343 echo "Waiting $i seconds for slapd to start..."
346 if test $RC != 0 ; then
347 echo "ldapsearch failed ($RC)!"
348 test $KILLSERVERS != no && kill -HUP $KILLPIDS
352 for uri in $URI1 $URI2 $URI3 $URI4 $URI5 $URI6; do
353 echo "Adding schema on $uri..."
354 $LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
355 include: file://$ABS_SCHEMADIR/core.ldif
357 include: file://$ABS_SCHEMADIR/cosine.ldif
359 include: file://$ABS_SCHEMADIR/inetorgperson.ldif
361 include: file://$ABS_SCHEMADIR/openldap.ldif
363 include: file://$ABS_SCHEMADIR/nis.ldif
366 if test $RC != 0 ; then
367 echo "ldapadd failed for schema config ($RC)!"
368 test $KILLSERVERS != no && kill -HUP $KILLPIDS
372 [ "$BACKENDTYPE" = mod ] || continue
374 echo "Adding backend module on $uri..."
375 $LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
376 dn: cn=module,cn=config
377 objectClass: olcModuleList
379 olcModulePath: ../../../servers/slapd/back-$BACKEND
380 olcModuleLoad: back_$BACKEND.la
383 if test $RC != 0 ; then
384 echo "ldapadd failed for backend module ($RC)!"
385 test $KILLSERVERS != no && kill -HUP $KILLPIDS
390 echo "Adding database config on central master..."
391 if [ "$SYNCPROV" = syncprovmod ]; then
392 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
393 dn: cn=module,cn=config
394 objectClass: olcModuleList
396 olcModulePath: ../../../servers/slapd/overlays
397 olcModuleLoad: syncprov.la
401 if test $RC != 0 ; then
402 echo "ldapadd failed for moduleLoad ($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
413 olcDbDirectory: $SMC_DIR/db
415 olcRootDN: $MANAGERDN
418 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
419 objectClass: olcOverlayConfig
422 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
423 objectClass: olcOverlayConfig
424 objectClass: olcSyncProvConfig
425 olcOverlay: {1}syncprov
428 dn: olcDatabase={1}$BACKEND,cn=config
429 objectClass: olcDatabaseConfig
430 objectClass: olc${BACKEND}Config
431 olcDatabase: {1}$BACKEND
432 olcDbDirectory: $SMC_DIR/ou1
434 olcSuffix: ou=ou1,$BASEDN
435 olcRootDN: $MANAGERDN
437 dn: olcDatabase={2}$BACKEND,cn=config
438 objectClass: olcDatabaseConfig
439 objectClass: olc${BACKEND}Config
440 olcDatabase: {2}$BACKEND
441 olcDbDirectory: $SMC_DIR/ou2
443 olcSuffix: ou=ou2,$BASEDN
444 olcRootDN: $MANAGERDN
446 dn: olcDatabase={3}$BACKEND,cn=config
447 objectClass: olcDatabaseConfig
448 objectClass: olc${BACKEND}Config
449 olcDatabase: {3}$BACKEND
450 olcDbDirectory: $SMC_DIR/sm1ou1
452 olcSuffix: ou=sm1ou1,$BASEDN
455 dn: olcDatabase={4}$BACKEND,cn=config
456 objectClass: olcDatabaseConfig
457 objectClass: olc${BACKEND}Config
458 olcDatabase: {4}$BACKEND
459 olcDbDirectory: $SMC_DIR/sm1ou2
461 olcSuffix: ou=sm1ou2,$BASEDN
464 dn: olcDatabase={5}$BACKEND,cn=config
465 objectClass: olcDatabaseConfig
466 objectClass: olc${BACKEND}Config
467 olcDatabase: {5}$BACKEND
468 olcDbDirectory: $SMC_DIR/sm2ou1
470 olcSuffix: ou=sm2ou1,$BASEDN
475 if test $RC != 0 ; then
476 echo "ldapadd failed for central master database config ($RC)!"
477 test $KILLSERVERS != no && kill -HUP $KILLPIDS
481 echo "Adding database config on site1 master..."
482 if [ "$SYNCPROV" = syncprovmod ]; then
483 $LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
484 dn: cn=module,cn=config
485 objectClass: olcModuleList
487 olcModulePath: ../../../servers/slapd/overlays
488 olcModuleLoad: syncprov.la
492 if test $RC != 0 ; then
493 echo "ldapadd failed for moduleLoad ($RC)!"
494 test $KILLSERVERS != no && kill -HUP $KILLPIDS
499 $LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
500 dn: olcDatabase={1}$BACKEND,cn=config
501 objectClass: olcDatabaseConfig
502 objectClass: olc${BACKEND}Config
503 olcDatabase: {1}$BACKEND
504 olcDbDirectory: $SM1_DIR/db
508 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
509 objectClass: olcOverlayConfig
512 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
513 objectClass: olcOverlayConfig
514 objectClass: olcSyncProvConfig
515 olcOverlay: {1}syncprov
517 dn: olcDatabase={1}$BACKEND,cn=config
518 objectClass: olcDatabaseConfig
519 objectClass: olc${BACKEND}Config
520 olcDatabase: {1}$BACKEND
521 olcDbDirectory: $SM1_DIR/ou1
523 olcSuffix: ou=ou1,$BASEDN
526 dn: olcDatabase={2}$BACKEND,cn=config
527 objectClass: olcDatabaseConfig
528 objectClass: olc${BACKEND}Config
529 olcDatabase: {2}$BACKEND
530 olcDbDirectory: $SM1_DIR/sm1ou1
532 olcSuffix: ou=sm1ou1,$BASEDN
533 olcRootDN: ou=sm1ou1,$BASEDN
536 dn: olcDatabase={3}$BACKEND,cn=config
537 objectClass: olcDatabaseConfig
538 objectClass: olc${BACKEND}Config
539 olcDatabase: {3}$BACKEND
540 olcDbDirectory: $SM1_DIR/sm1ou2
542 olcSuffix: ou=sm1ou2,$BASEDN
543 olcRootDN: ou=sm1ou1,$BASEDN
548 if test $RC != 0 ; then
549 echo "ldapadd failed for site1 master database config ($RC)!"
550 test $KILLSERVERS != no && kill -HUP $KILLPIDS
554 echo "Adding database config on site2 master..."
555 if [ "$SYNCPROV" = syncprovmod ]; then
556 $LDAPADD -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
557 dn: cn=module,cn=config
558 objectClass: olcModuleList
560 olcModulePath: ../../../servers/slapd/overlays
561 olcModuleLoad: syncprov.la
565 if test $RC != 0 ; then
566 echo "ldapadd failed for moduleLoad ($RC)!"
567 test $KILLSERVERS != no && kill -HUP $KILLPIDS
572 $LDAPADD -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
573 dn: olcDatabase={1}$BACKEND,cn=config
574 objectClass: olcDatabaseConfig
575 objectClass: olc${BACKEND}Config
576 olcDatabase: {1}$BACKEND
577 olcDbDirectory: $SM2_DIR/db
581 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
582 objectClass: olcOverlayConfig
585 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
586 objectClass: olcOverlayConfig
587 objectClass: olcSyncProvConfig
588 olcOverlay: {1}syncprov
591 dn: olcDatabase={1}$BACKEND,cn=config
592 objectClass: olcDatabaseConfig
593 objectClass: olc${BACKEND}Config
594 olcDatabase: {1}$BACKEND
595 olcDbDirectory: $SM2_DIR/ou2
597 olcSuffix: ou=ou2,$BASEDN
600 dn: olcDatabase={2}$BACKEND,cn=config
601 objectClass: olcDatabaseConfig
602 objectClass: olc${BACKEND}Config
603 olcDatabase: {2}$BACKEND
604 olcDbDirectory: $SM2_DIR/sm1ou1
606 olcSuffix: ou=sm1ou1,$BASEDN
609 dn: olcDatabase={3}$BACKEND,cn=config
610 objectClass: olcDatabaseConfig
611 objectClass: olc${BACKEND}Config
612 olcDatabase: {3}$BACKEND
613 olcDbDirectory: $SM2_DIR/sm2ou1
615 olcSuffix: ou=sm2ou1,$BASEDN
616 olcRootDN: ou=sm2ou1,$BASEDN
619 dn: olcDatabase={4}$BACKEND,cn=config
620 objectClass: olcDatabaseConfig
621 objectClass: olc${BACKEND}Config
622 olcDatabase: {4}$BACKEND
623 olcDbDirectory: $SM2_DIR/sm2ou2
625 olcSuffix: ou=sm2ou2,$BASEDN
626 olcRootDN: ou=sm2ou1,$BASEDN
631 if test $RC != 0 ; then
632 echo "ldapadd failed for site2 master database config ($RC)!"
633 test $KILLSERVERS != no && kill -HUP $KILLPIDS
637 echo "Adding access rules on central master..."
638 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
639 dn: olcDatabase={-1}frontend,cn=config
642 olcAccess: to dn.exact=dc=example,dc=com
644 olcAccess: to dn.subtree=ou=ou1,dc=example,dc=com
646 olcAccess: to dn.subtree=ou=ou2,dc=example,dc=com
647 by dn.exact=ou=ou1,dc=example,dc=com none
648 by dn.exact=ou=ou2,dc=example,dc=com read
649 by dn.exact=dc=example,dc=com none
651 olcAccess: to dn.subtree=ou=sm1ou1,dc=example,dc=com
652 by dn.exact=ou=ou1,dc=example,dc=com none
653 by dn.exact=ou=ou2,dc=example,dc=com read
654 by dn.exact=dc=example,dc=com none
656 olcAccess: to dn.subtree=ou=sm1ou2,dc=example,dc=com
657 by dn.exact=ou=ou1,dc=example,dc=com none
658 by dn.exact=ou=ou2,dc=example,dc=com none
659 by dn.exact=dc=example,dc=com read
661 olcAccess: to dn.subtree=ou=sm2ou1,dc=example,dc=com
662 by dn.exact=ou=ou1,dc=example,dc=com none
663 by dn.exact=ou=ou2,dc=example,dc=com none
664 by dn.exact=dc=example,dc=com none
666 olcAccess: to * by * read
670 if test $RC != 0 ; then
671 echo "ldapmodify failed for central master access config ($RC)!"
672 test $KILLSERVERS != no && kill -HUP $KILLPIDS
676 echo "Adding access rules on site1 master..."
677 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
678 dn: olcDatabase={-1}frontend,cn=config
681 olcAccess: to dn.subtree=dc=example,dc=com
683 olcAccess: to * by * read
687 if test $RC != 0 ; then
688 echo "ldapmodify failed for site1 master access config ($RC)!"
689 test $KILLSERVERS != no && kill -HUP $KILLPIDS
693 echo "Adding access rules on site2 master..."
694 $LDAPMODIFY -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
695 dn: olcDatabase={-1}frontend,cn=config
698 olcAccess: to dn.exact=dc=example,dc=com
700 olcAccess: to dn.subtree=ou=ou2,dc=example,dc=com
702 olcAccess: to dn.subtree=ou=sm1ou1,dc=example,dc=com
705 olcAccess: to dn.subtree=ou=sm2ou1,dc=example,dc=com
707 olcAccess: to dn.subtree=ou=sm2ou2,dc=example,dc=com
708 by dn.exact=dc=example,dc=com read
711 olcAccess: to * by * read
715 if test $RC != 0 ; then
716 echo "ldapmodify failed for site2 master access config ($RC)!"
717 test $KILLSERVERS != no && kill -HUP $KILLPIDS
721 echo "Adding database config on central search..."
722 $LDAPADD -D cn=config -H $URI4 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
723 dn: olcDatabase={1}$BACKEND,cn=config
724 objectClass: olcDatabaseConfig
725 objectClass: olc${BACKEND}Config
726 olcDatabase: {1}$BACKEND
727 olcDbDirectory: $SSC_DIR/db
733 if test $RC != 0 ; then
734 echo "ldapadd failed for central search database config ($RC)!"
735 test $KILLSERVERS != no && kill -HUP $KILLPIDS
739 echo "Adding database config on site1 search..."
740 $LDAPADD -D cn=config -H $URI5 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
741 dn: olcDatabase={1}$BACKEND,cn=config
742 objectClass: olcDatabaseConfig
743 objectClass: olc${BACKEND}Config
744 olcDatabase: {1}$BACKEND
745 olcDbDirectory: $SS1_DIR/db
751 if test $RC != 0 ; then
752 echo "ldapadd failed for site1 search database config ($RC)!"
753 test $KILLSERVERS != no && kill -HUP $KILLPIDS
757 echo "Adding database config on site2 search..."
758 $LDAPADD -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
759 dn: olcDatabase={1}$BACKEND,cn=config
760 objectClass: olcDatabaseConfig
761 objectClass: olc${BACKEND}Config
762 olcDatabase: {1}$BACKEND
763 olcDbDirectory: $SS2_DIR/db
769 if test $RC != 0 ; then
770 echo "ldapadd failed for site2 search database config ($RC)!"
771 test $KILLSERVERS != no && kill -HUP $KILLPIDS
775 echo "Populating central master..."
776 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
777 dn: dc=example,dc=com
779 objectClass: organization
780 objectClass: dcObject
783 userPassword: $PASSWD
785 dn: ou=ou1,dc=example,dc=com
787 objectClass: organizationalUnit
789 userPassword: $PASSWD
791 dn: ou=ou2,dc=example,dc=com
793 objectClass: organizationalUnit
795 userPassword: $PASSWD
799 if test $RC != 0 ; then
800 echo "ldapadd failed to populate central master entry ($RC)!"
801 test $KILLSERVERS != no && kill -HUP $KILLPIDS
805 echo "Adding syncrepl on site1 master..."
806 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
807 dn: olcDatabase={4}$BACKEND,cn=config
810 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
811 binddn="ou=ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
812 type=refreshAndPersist retry="$RETRY" timeout=1
816 if test $RC != 0 ; then
817 echo "ldapmodify failed to add syncrepl on site1 master ($RC)!"
818 test $KILLSERVERS != no && kill -HUP $KILLPIDS
822 echo "Adding syncrepl on site2 master..."
823 $LDAPMODIFY -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
824 dn: olcDatabase={5}$BACKEND,cn=config
827 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
828 binddn="ou=ou2,$BASEDN" bindmethod=simple credentials=$PASSWD
829 type=refreshAndPersist retry="$RETRY" timeout=1
833 if test $RC != 0 ; then
834 echo "ldapmodify failed to add syncrepl on site2 master ($RC)!"
835 test $KILLSERVERS != no && kill -HUP $KILLPIDS
840 echo "Using ldapsearch to check that site1 master received changes..."
842 for i in 1 2 3 4 5; do
843 RESULT=`$LDAPSEARCH -H $URI2 \
844 -s base -b "ou=ou1,$BASEDN" \
845 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
846 if test "x$RESULT" = "xOK" ; then
850 echo "Waiting $i seconds for syncrepl to receive changes..."
853 if test $RC != 0 ; then
854 echo "ldapsearch failed ($RC)!"
855 test $KILLSERVERS != no && kill -HUP $KILLPIDS
859 echo "Using ldapsearch to check that site2 master received changes..."
861 for i in 1 2 3 4 5; do
862 RESULT=`$LDAPSEARCH -H $URI3 \
863 -s base -b "ou=ou1,$BASEDN" \
864 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
865 if test "x$RESULT" = "xOK" ; then
869 echo "Waiting $i seconds for syncrepl to receive changes..."
872 if test $RC != 0 ; then
873 echo "ldapsearch failed ($RC)!"
874 test $KILLSERVERS != no && kill -HUP $KILLPIDS
880 echo "Populating site1 master..."
881 $LDAPADD -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
882 dn: ou=sm1ou1,dc=example,dc=com
884 objectClass: organizationalUnit
887 dn: ou=sm1ou2,dc=example,dc=com
889 objectClass: organizationalUnit
894 if test $RC != 0 ; then
895 echo "ldapadd failed to populate site1 master ($RC)!"
896 test $KILLSERVERS != no && kill -HUP $KILLPIDS
902 echo "Populating site2 master..."
903 $LDAPADD -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
904 dn: ou=sm2ou1,dc=example,dc=com
906 objectClass: organizationalUnit
909 dn: ou=sm2ou2,dc=example,dc=com
911 objectClass: organizationalUnit
916 if test $RC != 0 ; then
917 echo "ldapadd failed to populate site2 master ($RC)!"
918 test $KILLSERVERS != no && kill -HUP $KILLPIDS
925 # Stop site1 master when adding syncrepl to the central master. When
926 # site1 master is started again both it and the central master will have
927 # the same number of contextCSN values, but the ones on central master
928 # will be the newest. The central master will not update its contextCSN
929 # values unless the bug in ITS#5597 have been fixed.
930 echo "Stopping site1 master..."
933 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SM1_PID / /"`;
936 echo "Adding syncrepl on central master..."
937 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
938 dn: olcDatabase={3}$BACKEND,cn=config
941 olcSyncRepl: rid=3 provider=$URI2 searchbase="ou=sm1ou1,$BASEDN"
942 binddn="ou=sm1ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
943 type=refreshAndPersist retry="$RETRY" timeout=1
945 dn: olcDatabase={5}$BACKEND,cn=config
948 olcSyncRepl: rid=5 provider=$URI3 searchbase="ou=sm2ou1,$BASEDN"
949 binddn="ou=sm2ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
950 type=refreshAndPersist retry="$RETRY" timeout=1
954 if test $RC != 0 ; then
955 echo "ldapmodify failed to add syncrepl on central master ($RC)!"
956 test $KILLSERVERS != no && kill -HUP $KILLPIDS
960 echo "Using ldapsearch to check that central master received site2 entries..."
962 for i in 1 2 3 4 5; do
963 RESULT=`$LDAPSEARCH -H $URI1 \
964 -s base -b "ou=sm2ou1,$BASEDN" \
965 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
966 if test "x$RESULT" = "xOK" ; then
970 echo "Waiting $i seconds for syncrepl to receive changes..."
973 if test $RC != 0 ; then
974 echo "ldapsearch failed ($RC)!"
975 test $KILLSERVERS != no && kill -HUP $KILLPIDS
979 if test -z "$SM1_PID" ; then
980 echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
982 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
984 if test $WAIT != 0 ; then
988 KILLPIDS="$KILLPIDS $SM1_PID"
993 echo "Using ldapsearch to check that site1 master is running..."
994 for i in 1 2 3 4 5; do
995 $LDAPSEARCH -s base -b "" -H $URI2 \
996 'objectclass=*' > /dev/null 2>&1
998 test $RC = 0 && break
999 echo "Waiting $i seconds for slapd to start..."
1002 if test $RC != 0 ; then
1003 echo "ldapsearch failed ($RC)!"
1004 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1008 echo "Using ldapsearch to check that central master received site1 entries..."
1010 for i in 1 2 3 4 5; do
1011 RESULT=`$LDAPSEARCH -H $URI1 \
1012 -s base -b "ou=sm1ou1,$BASEDN" \
1013 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1014 if test "x$RESULT" = "xOK" ; then
1018 echo "Waiting $i seconds for syncrepl to receive changes..."
1021 if test $RC != 0 ; then
1022 echo "ldapsearch failed ($RC)!"
1023 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1027 # Test done, now some more intialization...
1029 echo "Adding syncrepl consumer on central search..."
1030 $LDAPMODIFY -D cn=config -H $URI4 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1031 dn: olcDatabase={1}$BACKEND,cn=config
1034 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
1035 binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1036 type=refreshAndPersist retry="$RETRY" timeout=1
1040 if test $RC != 0 ; then
1041 echo "ldapmodify failed to add syncrepl on site1 search ($RC)!"
1042 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1046 echo "Adding syncrepl consumer on site1 search..."
1047 $LDAPMODIFY -D cn=config -H $URI5 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1048 dn: olcDatabase={1}$BACKEND,cn=config
1051 olcSyncRepl: rid=1 provider=$URI2 searchbase="$BASEDN"
1052 binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1053 type=refreshAndPersist retry="$RETRY" timeout=1
1057 if test $RC != 0 ; then
1058 echo "ldapmodify failed to add syncrepl on site1 search ($RC)!"
1059 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1063 echo "Adding syncrepl consumer on site2 search..."
1064 $LDAPMODIFY -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1065 dn: olcDatabase={1}$BACKEND,cn=config
1068 olcSyncRepl: rid=1 provider=$URI3 searchbase="$BASEDN"
1069 binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1070 type=refreshAndPersist retry="$RETRY" timeout=1
1074 if test $RC != 0 ; then
1075 echo "ldapmodify failed to add syncrepl on site2 search ($RC)!"
1076 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1081 echo "Using ldapsearch to check that central search received changes..."
1083 for i in 1 2 3 4 5; do
1084 RESULT=`$LDAPSEARCH -H $URI4 \
1085 -s base -b "$BASEDN" \
1086 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1087 if test "x$RESULT" = "xOK" ; then
1091 echo "Waiting $i seconds for syncrepl to receive changes..."
1094 if test $RC != 0 ; then
1095 echo "ldapsearch failed ($RC)!"
1096 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1100 echo "Using ldapsearch to check that site1 search received changes..."
1102 for i in 1 2 3 4 5; do
1103 RESULT=`$LDAPSEARCH -H $URI5 \
1104 -s base -b "$BASEDN" \
1105 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1106 if test "x$RESULT" = "xOK" ; then
1110 echo "Waiting $i seconds for syncrepl to receive changes..."
1113 if test $RC != 0 ; then
1114 echo "ldapsearch failed ($RC)!"
1115 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1119 echo "Using ldapsearch to check that site2 search received changes..."
1121 for i in 1 2 3 4 5; do
1122 RESULT=`$LDAPSEARCH -H $URI6 \
1123 -s base -b "$BASEDN" \
1124 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1125 if test "x$RESULT" = "xOK" ; then
1129 echo "Waiting $i seconds for syncrepl to receive changes..."
1132 if test $RC != 0 ; then
1133 echo "ldapsearch failed ($RC)!"
1134 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1138 # Create a script that will check the contextCSN values of all servers,
1139 # and restart them to re-synchronize if it finds any errors:
1140 cat > $TESTDIR/checkcsn.sh <<'EOF'
1145 CSN1=`$LDAPSEARCH -H $URI1 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1146 CSN2=`$LDAPSEARCH -H $URI2 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1147 CSN3=`$LDAPSEARCH -H $URI3 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1148 CSN4=`$LDAPSEARCH -H $URI4 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1149 CSN5=`$LDAPSEARCH -H $URI5 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1150 CSN6=`$LDAPSEARCH -H $URI6 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1152 if test -z "$CSN1" ; then
1153 echo "ERROR: contextCSN empty on central master"
1154 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1156 nCSN=`echo "$CSN1" | wc -l`
1157 if test "$nCSN" -ne 3 ; then
1158 echo "ERROR: Wrong contextCSN count on central master, should be 3"
1159 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1160 if test -n "$CSN_VERBOSE"; then
1164 if test -z "$CSN2" -o "$CSN1" != "$CSN2" ; then
1165 echo "ERROR: contextCSN mismatch between central master and site1 master"
1166 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1167 if test -n "$CSN_VERBOSE"; then
1168 echo "contextCSN on central master:"
1170 echo "contextCSN on site1 master:"
1174 if test -z "$CSN3" -o "$CSN1" != "$CSN3" ; then
1175 echo "ERROR: contextCSN mismatch between central master and site2 master"
1176 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1177 if test -n "$CSN_VERBOSE"; then
1178 echo "contextCSN on central master:"
1180 echo "contextCSN on site2 master:"
1184 if test -z "$CSN4" -o "$CSN1" != "$CSN4" ; then
1185 echo "ERROR: contextCSN mismatch between central master and central search"
1186 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1187 if test -n "$CSN_VERBOSE"; then
1188 echo "contextCSN on central master:"
1190 echo "contextCSN on central search:"
1194 if test -z "$CSN5" -o "$CSN2" != "$CSN5" ; then
1195 echo "ERROR: contextCSN mismatch between site1 master and site1 search"
1196 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1197 if test -n "$CSN_VERBOSE"; then
1198 echo "contextCSN on site1 master:"
1200 echo "contextCSN on site1 search:"
1204 if test -z "$CSN6" -o "$CSN3" != "$CSN6" ; then
1205 echo "ERROR: contextCSN mismatch between site2 master and site2 search:"
1206 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1207 if test -n "$CSN_VERBOSE"; then
1208 echo "contextCSN on site2 master:"
1210 echo "contextCSN on site2 search:"
1215 if test $CSN_ERRORS != 0 ; then
1216 echo "Stopping all servers to synchronize contextCSN..."
1218 for pid in $KILLPIDS ; do wait $pid ; done
1221 echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
1223 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
1225 if test $WAIT != 0 ; then
1229 KILLPIDS="$KILLPIDS $SM1_PID"
1232 echo "Using ldapsearch to check that site1 master is running..."
1233 for i in 1 2 3 4 5; do
1234 $LDAPSEARCH -s base -b "" -H $URI2 \
1235 'objectclass=*' > /dev/null 2>&1
1237 test $RC = 0 && break
1238 echo "Waiting $i seconds for slapd to start..."
1241 if test $RC != 0 ; then
1242 echo "ldapsearch failed ($RC)!"
1243 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1247 echo "Restarting site2 master slapd on TCP/IP port $PORT3..."
1249 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1251 if test $WAIT != 0 ; then
1255 KILLPIDS="$KILLPIDS $SM2_PID "
1258 echo "Using ldapsearch to check that site2 master is running..."
1259 for i in 1 2 3 4 5; do
1260 $LDAPSEARCH -s base -b "" -H $URI3 \
1261 'objectclass=*' > /dev/null 2>&1
1263 test $RC = 0 && break
1264 echo "Waiting $i seconds for slapd to start..."
1267 if test $RC != 0 ; then
1268 echo "ldapsearch failed ($RC)!"
1269 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1273 echo "Restarting central master slapd on TCP/IP port $PORT1..."
1275 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
1277 if test $WAIT != 0 ; then
1281 KILLPIDS="$KILLPIDS $SMC_PID"
1284 echo "Using ldapsearch to check that central master slapd is running..."
1285 for i in 1 2 3 4 5; do
1286 $LDAPSEARCH -s base -b "" -H $URI1 \
1287 'objectclass=*' > /dev/null 2>&1
1289 test $RC = 0 && break
1290 echo "Waiting $i seconds for slapd to start..."
1293 if test $RC != 0 ; then
1294 echo "ldapsearch failed ($RC)!"
1295 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1299 echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1302 echo "Stopping site1 and site2 master..."
1303 kill -HUP $SM1_PID $SM2_PID
1304 for pid in $SM1_PID $SM2_PID ; do wait $pid ; done
1305 KILLPIDS=" $SMC_PID"
1307 echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
1309 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
1311 if test $WAIT != 0 ; then
1315 KILLPIDS="$KILLPIDS $SM1_PID"
1318 echo "Using ldapsearch to check that site1 master is running..."
1319 for i in 1 2 3 4 5; do
1320 $LDAPSEARCH -s base -b "" -H $URI2 \
1321 'objectclass=*' > /dev/null 2>&1
1323 test $RC = 0 && break
1324 echo "Waiting $i seconds for slapd to start..."
1327 if test $RC != 0 ; then
1328 echo "ldapsearch failed ($RC)!"
1329 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1333 echo "Restarting site2 master slapd on TCP/IP port $PORT3..."
1335 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1337 if test $WAIT != 0 ; then
1341 KILLPIDS="$KILLPIDS $SM2_PID"
1344 echo "Using ldapsearch to check that site2 master is running..."
1345 for i in 1 2 3 4 5; do
1346 $LDAPSEARCH -s base -b "" -H $URI3 \
1347 'objectclass=*' > /dev/null 2>&1
1349 test $RC = 0 && break
1350 echo "Waiting $i seconds for slapd to start..."
1353 if test $RC != 0 ; then
1354 echo "ldapsearch failed ($RC)!"
1355 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1359 echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1362 echo "Restarting central search slapd on TCP/IP port $PORT4..."
1364 $SLAPD -F slapd.d -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
1366 if test $WAIT != 0 ; then
1370 KILLPIDS="$KILLPIDS $SSC_PID"
1373 echo "Using ldapsearch to check that central search slapd is running..."
1374 for i in 1 2 3 4 5; do
1375 $LDAPSEARCH -s base -b "" -H $URI4 \
1376 'objectclass=*' > /dev/null 2>&1
1378 test $RC = 0 && break
1379 echo "Waiting $i seconds for slapd to start..."
1382 if test $RC != 0 ; then
1383 echo "ldapsearch failed ($RC)!"
1384 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1388 echo "Restarting site1 search slapd on TCP/IP port $PORT5..."
1390 $SLAPD -F slapd.d -h $URI5 -d $LVL $TIMING >> $LOG5 2>&1 &
1392 if test $WAIT != 0 ; then
1396 KILLPIDS="$KILLPIDS $SS1_PID"
1399 echo "Using ldapsearch to check that site1 search slapd is running..."
1400 for i in 1 2 3 4 5; do
1401 $LDAPSEARCH -s base -b "" -H $URI5 \
1402 'objectclass=*' > /dev/null 2>&1
1404 test $RC = 0 && break
1405 echo "Waiting $i seconds for slapd to start..."
1408 if test $RC != 0 ; then
1409 echo "ldapsearch failed ($RC)!"
1410 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1414 echo "Restarting site2 search slapd on TCP/IP port $PORT6..."
1416 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING >> $LOG6 2>&1 &
1418 if test $WAIT != 0 ; then
1422 KILLPIDS="$KILLPIDS $SS2_PID"
1425 echo "Using ldapsearch to check that site2 search slapd is running..."
1426 for i in 1 2 3 4 5; do
1427 $LDAPSEARCH -s base -b "" -H $URI6 \
1428 'objectclass=*' > /dev/null 2>&1
1430 test $RC = 0 && break
1431 echo "Waiting $i seconds for slapd to start..."
1434 if test $RC != 0 ; then
1435 echo "ldapsearch failed ($RC)!"
1436 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1440 echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1443 echo "Checking contextCSN after restart..."
1444 CSN1=`$LDAPSEARCH -H $URI1 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1445 CSN2=`$LDAPSEARCH -H $URI2 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1446 CSN3=`$LDAPSEARCH -H $URI3 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1447 CSN4=`$LDAPSEARCH -H $URI4 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1448 CSN5=`$LDAPSEARCH -H $URI5 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1449 CSN6=`$LDAPSEARCH -H $URI6 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1450 if test -z "$CSN1" ; then
1451 echo "ERROR: contextCSN empty on central master"
1452 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1455 if test -z "$CSN2" -o "$CSN1" != "$CSN2" ; then
1456 echo "ERROR: contextCSN mismatch between central master and site1 master"
1457 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1458 if test -n "$CSN_VERBOSE"; then
1459 echo "contextCSN on central master:"
1461 echo "contextCSN on site1 master:"
1465 if test -z "$CSN3" -o "$CSN1" != "$CSN3" ; then
1466 echo "ERROR: contextCSN mismatch between central master and site2 master"
1467 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1468 if test -n "$CSN_VERBOSE"; then
1469 echo "contextCSN on central master:"
1471 echo "contextCSN on site2 master:"
1475 if test -z "$CSN4" -o "$CSN1" != "$CSN4" ; then
1476 echo "ERROR: contextCSN mismatch between central master and central search"
1477 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1478 if test -n "$CSN_VERBOSE"; then
1479 echo "contextCSN on central master:"
1481 echo "contextCSN on central search:"
1485 if test -z "$CSN5" -o "$CSN2" != "$CSN5" ; then
1486 echo "ERROR: contextCSN mismatch between site1 master and site1 search"
1487 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1488 if test -n "$CSN_VERBOSE"; then
1489 echo "contextCSN on site1 master:"
1491 echo "contextCSN on site1 search:"
1495 if test -z "$CSN6" -o "$CSN3" != "$CSN6" ; then
1496 echo "ERROR: contextCSN mismatch between site2 master and site2 search:"
1497 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1498 if test -n "$CSN_VERBOSE"; then
1499 echo "contextCSN on site2 master:"
1501 echo "contextCSN on site2 search:"
1507 ERRORS=`expr $ERRORS + $CSN_ERRORS`
1511 chmod +x $TESTDIR/checkcsn.sh
1514 echo "Checking contextCSN after initial replication..."
1515 . $TESTDIR/checkcsn.sh
1520 # Test that updates to the first backend on central master, which should
1521 # be replicated to all servers actually is so, and that the contextCSN is
1522 # updated everywhere:
1523 echo "Using ldapmodify to modify first backend on central master..."
1524 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1525 dn: ou=ou1,dc=example,dc=com
1528 description: Modify$MNUM
1532 if test $RC != 0 ; then
1533 echo "ldapmodify failed ($RC)!"
1534 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1539 echo "Using ldapsearch to check replication to central search..."
1541 for i in 1 2 3 4 5; do
1542 RESULT=`$LDAPSEARCH -H $URI4 \
1543 -s base -b "ou=ou1,$BASEDN" \
1544 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1545 if test "x$RESULT" = "xOK" ; then
1549 echo "Waiting $i seconds for syncrepl to receive changes..."
1552 if test $RC != 0 ; then
1553 echo "ldapsearch failed ($RC)!"
1554 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1558 echo "Using ldapsearch to check replication to site1 search..."
1560 for i in 1 2 3 4 5; do
1561 RESULT=`$LDAPSEARCH -H $URI5 \
1562 -s base -b "ou=ou1,$BASEDN" \
1563 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1564 if test "x$RESULT" = "xOK" ; then
1568 echo "Waiting $i seconds for syncrepl to receive changes..."
1571 if test $RC != 0 ; then
1572 echo "ldapsearch failed ($RC)!"
1573 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1577 echo "Using ldapsearch to check replication to site2 search..."
1579 for i in 1 2 3 4 5; do
1580 RESULT=`$LDAPSEARCH -H $URI6 \
1581 -s base -b "ou=ou1,$BASEDN" \
1582 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1583 if test "x$RESULT" = "xOK" ; then
1587 echo "Waiting $i seconds for syncrepl to receive changes..."
1590 if test $RC != 0 ; then
1591 echo "ldapsearch failed ($RC)!"
1592 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1596 echo "Checking contextCSN after modify of first backend on central master..."
1597 . $TESTDIR/checkcsn.sh
1600 # Test that updates to the second backend on central master is only
1601 # replicated to those search servers that should receive that backend.
1602 # The contextCSN should still be updated everywhere:
1603 MNUM=`expr $MNUM + 1`
1604 echo "Using ldapmodify to modify second backend on central master..."
1605 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1606 dn: ou=ou2,dc=example,dc=com
1609 description: Modify$MNUM
1613 if test $RC != 0 ; then
1614 echo "ldapmodify failed ($RC)!"
1615 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1620 echo "Using ldapsearch to check replication to site2 search..."
1622 for i in 1 2 3 4 5; do
1623 RESULT=`$LDAPSEARCH -H $URI6 \
1624 -s base -b "ou=ou2,$BASEDN" \
1625 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1626 if test "x$RESULT" = "xOK" ; then
1630 echo "Waiting $i seconds for syncrepl to receive changes..."
1633 if test $RC != 0 ; then
1634 echo "ldapsearch failed ($RC)!"
1635 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1639 echo "Using ldapsearch to check no replication to site1 master..."
1640 for i in 1 2 3 4 5; do
1641 RESULT=`$LDAPSEARCH -H $URI2 \
1642 -s base -b "ou=ou2,$BASEDN" \
1643 "(description=Modify$NMUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1644 if test "x$RESULT" = "xNOK" ; then
1645 echo "Change was replicated to site1 search!"
1646 test $KILLSERVERS != no && KILL -HUP $KILLPIDS
1652 echo "Using ldapsearch to check no replication to central search..."
1653 for i in 1 2 3 4 5; do
1654 RESULT=`$LDAPSEARCH -H $URI4 \
1655 -s base -b "ou=ou2,$BASEDN" \
1656 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1657 if test "x$RESULT" = "xNOK" ; then
1658 echo "Change was replicated to central search!"
1659 test $KILLSERVERS != no && KILL -HUP $KILLPIDS
1665 echo "Checking contextCSN after modify of second backend on central master..."
1666 . $TESTDIR/checkcsn.sh
1669 # Test that updates to the first backend on site1 master, which should be
1670 # replicated everywhere except to central and site2 search. The contextCSN
1671 # should be updated on all servers:
1672 MNUM=`expr $MNUM + 1`
1673 echo "Using ldapmodify to modify first backend on site1 master..."
1674 $LDAPMODIFY -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1675 dn: ou=sm1ou1,dc=example,dc=com
1678 description: Modify$MNUM
1682 if test $RC != 0 ; then
1683 echo "ldapmodify failed ($RC)!"
1684 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1689 echo "Using ldapsearch to check replication to site1 search..."
1691 for i in 1 2 3 4 5; do
1692 RESULT=`$LDAPSEARCH -H $URI5 \
1693 -s base -b "ou=sm1ou1,$BASEDN" \
1694 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1695 if test "x$RESULT" = "xOK" ; then
1699 echo "Waiting $i seconds for syncrepl to receive changes..."
1702 if test $RC != 0 ; then
1703 echo "ldapsearch failed ($RC)!"
1704 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1708 echo "Using ldapsearch to check replication to site2 master..."
1710 for i in 1 2 3 4 5; do
1711 RESULT=`$LDAPSEARCH -H $URI3 \
1712 -s base -b "ou=sm1ou1,$BASEDN" \
1713 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1714 if test "x$RESULT" = "xOK" ; then
1718 echo "Waiting $i seconds for syncrepl to receive changes..."
1721 if test $RC != 0 ; then
1722 echo "ldapsearch failed ($RC)!"
1723 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1727 echo "Using ldapsearch to check no replication to site2 search..."
1728 for i in 1 2 3 4 5; do
1729 RESULT=`$LDAPSEARCH -H $URI6 \
1730 -s base -b "ou=sm1ou2,$BASEDN" \
1731 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1732 if test "x$RESULT" = "xNOK" ; then
1733 echo "Change was replicated to central search!"
1734 test $KILLSERVERS != no && KILL -HUP $KILLPIDS
1740 echo "Using ldapsearch to check no replication to central search..."
1741 for i in 1 2 3 4 5; do
1742 RESULT=`$LDAPSEARCH -H $URI4 \
1743 -s base -b "ou=sm1ou2,$BASEDN" \
1744 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1745 if test "x$RESULT" = "xNOK" ; then
1746 echo "Change was replicated to central search!"
1747 test $KILLSERVERS != no && KILL -HUP $KILLPIDS
1753 echo "Checking contextCSN after modify of first backend on site1 master..."
1754 . $TESTDIR/checkcsn.sh
1758 # Test updates to the second backend on site1 master, which should only be
1759 # replicated to site1 search. The contextCSN should be updated everywhere.
1760 MNUM=`expr $MNUM + 1`
1761 echo "Using ldapmodify to modify second backend on site1 master..."
1762 $LDAPMODIFY -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1763 dn: ou=sm1ou2,dc=example,dc=com
1766 description: Modify$MNUM
1770 if test $RC != 0 ; then
1771 echo "ldapmodify failed ($RC)!"
1772 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1778 echo "Using ldapsearch to check replication to site1 search..."
1780 for i in 1 2 3 4 5; do
1781 RESULT=`$LDAPSEARCH -H $URI5 \
1782 -s base -b "ou=sm1ou2,$BASEDN" \
1783 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1784 if test "x$RESULT" = "xOK" ; then
1788 echo "Waiting $i seconds for syncrepl to receive changes..."
1791 if test $RC != 0 ; then
1792 echo "ldapsearch failed ($RC)!"
1793 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1797 echo "Using ldapsearch to check no replication to central master..."
1798 for i in 1 2 3 4 5; do
1799 RESULT=`$LDAPSEARCH -H $URI1 \
1800 -s base -b "ou=sm1ou2,$BASEDN" \
1801 "(description=Modify$NMUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1802 if test "x$RESULT" = "xNOK" ; then
1803 echo "Change was replicated to site2 search!"
1804 test $KILLSERVERS != no && KILL -HUP $KILLPIDS
1810 echo "Checking contextCSN after modify of second backend on site1 master..."
1811 . $TESTDIR/checkcsn.sh
1815 # Test updates to first backend on site2 master, which should be
1816 # replicated to the central servers, but not site1. The contextCSN
1817 # should be updated everywhere:
1818 MNUM=`expr $MNUM + 1`
1819 echo "Using ldapmodify to modify first backend on site2 master..."
1820 $LDAPMODIFY -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1821 dn: ou=sm2ou1,dc=example,dc=com
1824 description: Modify$MNUM
1828 if test $RC != 0 ; then
1829 echo "ldapmodify failed ($RC)!"
1830 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1835 echo "Using ldapsearch to check replication to central master..."
1837 for i in 1 2 3 4 5; do
1838 RESULT=`$LDAPSEARCH -H $URI1 \
1839 -s base -b "ou=sm2ou1,$BASEDN" \
1840 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1841 if test "x$RESULT" = "xOK" ; then
1845 echo "Waiting $i seconds for syncrepl to receive changes..."
1848 if test $RC != 0 ; then
1849 echo "ldapsearch failed ($RC)!"
1850 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1854 echo "Using ldapsearch to check replication to site2 search..."
1856 for i in 1 2 3 4 5; do
1857 RESULT=`$LDAPSEARCH -H $URI6 \
1858 -s base -b "ou=sm2ou1,$BASEDN" \
1859 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1860 if test "x$RESULT" = "xOK" ; then
1864 echo "Waiting $i seconds for syncrepl to receive changes..."
1867 if test $RC != 0 ; then
1868 echo "ldapsearch failed ($RC)!"
1869 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1873 echo "Using ldapsearch to check no replication to site1 master..."
1874 for i in 1 2 3 4 5; do
1875 RESULT=`$LDAPSEARCH -H $URI2 \
1876 -s base -b "ou=sm2ou1,$BASEDN" \
1877 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1878 if test "x$RESULT" = "xNOK" ; then
1879 echo "Change was replicated to site2 search!"
1880 test $KILLSERVERS != no && KILL -HUP $KILLPIDS
1886 echo "Using ldapsearch to check no replication to central search..."
1887 for i in 1 2 3 4 5; do
1888 RESULT=`$LDAPSEARCH -H $URI4 \
1889 -s base -b "ou=sm2ou1,$BASEDN" \
1890 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1891 if test "x$RESULT" = "xNOK" ; then
1892 echo "Change was replicated to site2 search!"
1893 test $KILLSERVERS != no && KILL -HUP $KILLPIDS
1899 echo "Checking contextCSN after modify of first backend on site2 master..."
1900 . $TESTDIR/checkcsn.sh
1904 # Test updates to the second backend on site2 master, which should only be
1905 # replicated to site2 search. As always, contextCSN should be updated
1907 MNUM=`expr $MNUM + 1`
1908 echo "Using ldapmodify to modify second backend on site2 master..."
1909 $LDAPMODIFY -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1910 dn: ou=sm2ou2,dc=example,dc=com
1913 description: Modify$MNUM
1917 if test $RC != 0 ; then
1918 echo "ldapmodify failed ($RC)!"
1919 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1924 echo "Using ldapsearch to check replication to site2 search..."
1926 for i in 1 2 3 4 5; do
1927 RESULT=`$LDAPSEARCH -H $URI6 \
1928 -s base -b "ou=sm2ou2,$BASEDN" \
1929 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1930 if test "x$RESULT" = "xOK" ; then
1934 echo "Waiting $i seconds for syncrepl to receive changes..."
1937 if test $RC != 0 ; then
1938 echo "ldapsearch failed ($RC)!"
1939 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1943 echo "Using ldapsearch to check no replication to central master..."
1944 for i in 1 2 3 4 5; do
1945 RESULT=`$LDAPSEARCH -H $URI4 \
1946 -s base -b "ou=sm2ou2,$BASEDN" \
1947 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1948 if test "x$RESULT" = "xNOK" ; then
1949 echo "Change was replicated to central search!"
1950 test $KILLSERVERS != no && KILL -HUP $KILLPIDS
1956 echo "Checking contextCSN after modify of second backend on site2 master..."
1957 . $TESTDIR/checkcsn.sh
1960 # Test that all contextCSN values are updated on the slaves when they
1961 # starts with an empty database. Start site2 master first, then site2
1962 # search and finally central master so that the site2 search's syncrepl
1963 # connection has been set up when site2 master receives the database:
1964 echo "Stopping central master and site2 servers to test start with emtpy db..."
1965 kill -HUP $SMC_PID $SM2_PID $SS2_PID
1966 for pid in $SMC_PID $SM2_PID $SS2_PID; do wait $pid ; done
1967 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
1968 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SM2_PID / /"`;
1969 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SS2_PID / /"`;
1973 rm -rf $SM2_DIR/db/*
1974 rm -rf $SS2_DIR/db/*
1976 echo "Starting site2 master slapd on TCP/IP port $PORT3..."
1978 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1980 if test $WAIT != 0 ; then
1984 KILLPIDS="$KILLPIDS $SM2_PID"
1987 echo "Using ldapsearch to check that site2 master slapd is running..."
1988 for i in 1 2 3 4 5; do
1989 $LDAPSEARCH -s base -b "" -H $URI3 \
1990 'objectclass=*' > /dev/null 2>&1
1992 test $RC = 0 && break
1993 echo "Waiting $i seconds for slapd to start..."
1996 if test $RC != 0 ; then
1997 echo "ldapsearch failed ($RC)!"
1998 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2002 echo "Starting site2 search slapd on TCP/IP port $PORT6..."
2004 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING >> $LOG6 2>&1 &
2006 if test $WAIT != 0 ; then
2010 KILLPIDS="$KILLPIDS $SS2_PID"
2013 echo "Using ldapsearch to check that site2 search slapd is running..."
2014 for i in 1 2 3 4 5; do
2015 $LDAPSEARCH -s base -b "" -H $URI6 \
2016 'objectclass=*' > /dev/null 2>&1
2018 test $RC = 0 && break
2019 echo "Waiting $i seconds for slapd to start..."
2022 if test $RC != 0 ; then
2023 echo "ldapsearch failed ($RC)!"
2024 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2028 echo "Starting central master slapd on TCP/IP port $PORT1..."
2030 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2032 if test $WAIT != 0 ; then
2036 KILLPIDS="$KILLPIDS $SMC_PID"
2039 echo "Using ldapsearch to check that central master slapd is running..."
2040 for i in 1 2 3 4 5; do
2041 $LDAPSEARCH -s base -b "" -H $URI1 \
2042 'objectclass=*' > /dev/null 2>&1
2044 test $RC = 0 && break
2045 echo "Waiting $i seconds for slapd to start..."
2048 if test $RC != 0 ; then
2049 echo "ldapsearch failed ($RC)!"
2050 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2054 echo "Using ldapsearch to check that site2 master received base..."
2056 for i in 1 2 3 4 5; do
2057 RESULT=`$LDAPSEARCH -H $URI3 \
2058 -s base -b "$BASEDN" \
2059 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2060 if test "x$RESULT" = "xOK" ; then
2064 echo "Waiting $i seconds for syncrepl to receive changes..."
2067 if test $RC != 0 ; then
2068 echo "ldapsearch failed ($RC)!"
2069 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2073 echo "Using ldapsearch to check that site2 search received base..."
2075 for i in 1 2 3 4 5; do
2076 RESULT=`$LDAPSEARCH -H $URI6 \
2077 -s base -b "$BASEDN" \
2078 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2079 if test "x$RESULT" = "xOK" ; then
2083 echo "Waiting $i seconds for syncrepl to receive changes..."
2086 if test $RC != 0 ; then
2087 echo "ldapsearch failed ($RC)!"
2088 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2094 echo "Checking contextCSN after site2 servers repopulated..."
2095 . $TESTDIR/checkcsn.sh
2097 if test $ERRORS -ne 0; then
2098 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2099 echo "Found $ERRORS errors"
2104 # Adding syncrepl of the second site1 master backend on central master
2105 # will not initialize the database unless the contextCSN attribute is
2106 # stored in the suffix of the database and not the suffix of the glue
2108 echo "Adding syncrepl of second site1 master backend on central master..."
2109 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
2110 dn: olcDatabase={4}$BACKEND,cn=config
2113 olcSyncRepl: rid=4 provider=$URI2 searchbase="ou=sm1ou2,$BASEDN"
2114 binddn="ou=sm1ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
2115 type=refreshAndPersist retry="$RETRY" timeout=1
2118 if test $RC != 0 ; then
2119 echo "ldapmodify failed to add syncrepl on central master ($RC)!"
2120 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2125 echo "Using ldapsearch to check that central master received second site1 backend..."
2127 for i in 1 2 3 4 5; do
2128 RESULT=`$LDAPSEARCH -H $URI1 \
2129 -s base -b "ou=sm1ou2,$BASEDN" \
2130 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2131 if test "x$RESULT" = "xOK" ; then
2135 echo "Waiting $i seconds for syncrepl to receive changes..."
2138 if test $RC != 0 ; then
2139 echo "ERROR: Second site1 backend not replicated to central master"
2140 ERRORS=`expr $ERRORS + 1`
2142 echo "Restarting central master slapd on TCP/IP port $PORT1..."
2145 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2148 $SLAPD -F slapd.d -h $URI1 -c rid=4,csn=0 -d $LVL $TIMING >> $LOG1 2>&1 &
2150 if test $WAIT != 0 ; then
2154 KILLPIDS="$KILLPIDS $SMC_PID"
2156 echo "Using ldapsearch to check that central master slapd is running..."
2157 for i in 1 2 3 4 5; do
2158 $LDAPSEARCH -s base -b "" -H $URI1 \
2159 'objectclass=*' > /dev/null 2>&1
2161 test $RC = 0 && break
2162 echo "Waiting $i seconds for slapd to start..."
2165 if test $RC != 0 ; then
2166 echo "ldapsearch failed ($RC)!"
2167 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2171 echo "Using ldapsearch to check that central master received second site1 backend..."
2173 for i in 1 2 3 4 5; do
2174 RESULT=`$LDAPSEARCH -H $URI1 \
2175 -s base -b "ou=sm1ou2,$BASEDN" \
2176 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2177 if test "x$RESULT" = "xOK" ; then
2181 echo "Waiting $i seconds for syncrepl to receive changes..."
2184 if test $RC != 0 ; then
2185 echo "ldapsearch failed ($RC)!"
2186 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2191 echo "Using ldapsearch to check that central search received second site1 backend..."
2193 for i in 1 2 3 4 5; do
2194 RESULT=`$LDAPSEARCH -H $URI4 \
2195 -s base -b "ou=sm1ou2,$BASEDN" \
2196 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2197 if test "x$RESULT" = "xOK" ; then
2201 echo "Waiting $i seconds for syncrepl to receive changes..."
2204 if test $RC != 0 ; then
2205 echo "ERROR: Second site1 backend not replicated to central search"
2206 ERRORS=`expr $ERRORS + 1`
2208 echo "Restarting central search slapd on TCP/IP port $PORT4..."
2211 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SSC_PID / /"`;
2214 $SLAPD -F slapd.d -h $URI4 -c rid=1,csn=0 -d $LVL $TIMING >> $LOG4 2>&1 &
2216 if test $WAIT != 0 ; then
2220 KILLPIDS="$KILLPIDS $SSC_PID"
2222 echo "Using ldapsearch to check that central search slapd is running..."
2223 for i in 1 2 3 4 5; do
2224 $LDAPSEARCH -s base -b "" -H $URI4 \
2225 'objectclass=*' > /dev/null 2>&1
2227 test $RC = 0 && break
2228 echo "Waiting $i seconds for slapd to start..."
2231 if test $RC != 0 ; then
2232 echo "ldapsearch failed ($RC)!"
2233 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2237 echo "Using ldapsearch to check that central search received second site1 backend..."
2239 for i in 1 2 3 4 5; do
2240 RESULT=`$LDAPSEARCH -H $URI4 \
2241 -s base -b "ou=sm1ou2,$BASEDN" \
2242 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2243 if test "x$RESULT" = "xOK" ; then
2247 echo "Waiting $i seconds for syncrepl to receive changes..."
2250 if test $RC != 0 ; then
2251 echo "ldapsearch failed ($RC)!"
2252 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2259 # Run race tests when more than one backend is replicated from the same
2260 # producer. This will usually fail long before 100 iterations unless
2261 # syncrepl stores the contextCSN in the suffix of its own database, and
2262 # that syncprov follows these rules before updating its own CSN when it
2263 # detects updates from syncrepl:
2264 # 1) A contextCSN value must have been stored in the suffix of all the
2265 # syncrepl configured databases within the glued syncprov database.
2266 # 2) Of all contextCSN values stored by syncrepl with the same SID,
2267 # syncprov must always select the one with the lowest csn value.
2268 test -z "$RACE_TESTS" && RACE_TESTS=10
2272 SUB_DN=ou=sub,ou=sm1ou2,dc=example,dc=com
2274 while test $RACE_ERROR -eq 0 -a $RACE_NUM -lt $RACE_TESTS ; do
2275 RACE_NUM=`expr $RACE_NUM + 1`
2276 echo "Running $RACE_NUM of $RACE_TESTS syncrepl race tests..."
2278 echo "Stopping central master..."
2281 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2283 MNUM=`expr $MNUM + 1`
2284 echo "Using ldapadd to add entry on site1 master..."
2285 $LDAPADD -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
2288 objectClass: organizationalUnit
2293 if test $RC != 0 ; then
2294 echo "ldapadd failed ($RC)!"
2295 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2299 echo "Starting central master again..."
2301 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2303 KILLPIDS="$KILLPIDS $SMC_PID"
2305 echo "Using ldapsearch to check that central master received entry..."
2306 for i in 1 2 3 4 5; do
2307 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI1 > /dev/null 2>&1
2309 test $RC = 0 && break
2312 if test $RC != 0 ; then
2313 echo "ERROR: entry not replicated to central master!"
2318 echo "Using ldapsearch to check that central search received entry..."
2319 for i in 1 2 3 4 5; do
2320 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI4 > /dev/null 2>&1
2322 test $RC = 0 && break
2325 if test $RC != 0 ; then
2326 echo "ERROR: entry not replicated to central master!"
2331 echo "Stopping central master..."
2334 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2336 echo "Using ldapdelete to delete entry on site1 master..."
2337 $LDAPDELETE -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD "$SUB_DN"
2339 if test $RC != 0 ; then
2340 echo "ldapdelete failed ($RC)!"
2341 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2345 echo "Starting central master again..."
2347 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2349 KILLPIDS="$KILLPIDS $SMC_PID"
2352 echo "Using ldapsearch to check that entry was deleted on central master..."
2354 for i in 1 2 3 4 5; do
2355 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI1 > /dev/null 2>&1
2357 if test $RC != 0; then break; fi
2361 if test $RC = 0; then
2362 echo "ERROR: Entry not removed on central master!"
2367 echo "Using ldapsearch to check that entry was deleted on central search..."
2369 for i in 1 2 3 4 5; do
2370 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI4 > /dev/null 2>&1
2372 if test $RC != 0; then break; fi
2376 if test $RC = 0; then
2377 echo "ERROR: Entry not removed on central search!"
2383 if test $RACE_ERROR != 0; then
2384 echo "Race error found after $RACE_NUM of $RACE_TESTS iterations"
2385 ERRORS=`expr $ERRORS + $RACE_ERROR`
2387 echo "No race errors found after $RACE_TESTS iterations"
2390 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2392 if test $ERRORS -ne 0; then
2393 echo "Found $ERRORS errors"
2394 echo ">>>>>> Exiting with a false success status for now"
2398 echo ">>>>> Test succeeded"