3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2011 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.
114 if test "$BACKEND" = ldif ; then
115 echo "$BACKEND backend does not support access controls, test skipped"
119 echo "Test 058 is currently disabled"
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: $TESTWD/../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: $TESTWD/../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 nullExclude="" nullOK="" wantNoObj=32
409 test $BACKEND = null && nullExclude="# " nullOK="OK" wantNoObj=0
411 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
412 dn: olcDatabase={1}$BACKEND,cn=config
413 objectClass: olcDatabaseConfig
414 ${nullExclude}objectClass: olc${BACKEND}Config
415 olcDatabase: {1}$BACKEND
416 ${nullExclude}olcDbDirectory: $SMC_DIR/db
418 olcRootDN: $MANAGERDN
421 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
422 objectClass: olcOverlayConfig
425 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
426 objectClass: olcOverlayConfig
427 objectClass: olcSyncProvConfig
428 olcOverlay: {1}syncprov
431 dn: olcDatabase={1}$BACKEND,cn=config
432 objectClass: olcDatabaseConfig
433 ${nullExclude}objectClass: olc${BACKEND}Config
434 olcDatabase: {1}$BACKEND
435 ${nullExclude}olcDbDirectory: $SMC_DIR/ou1
437 olcSuffix: ou=ou1,$BASEDN
438 olcRootDN: $MANAGERDN
440 dn: olcDatabase={2}$BACKEND,cn=config
441 objectClass: olcDatabaseConfig
442 ${nullExclude}objectClass: olc${BACKEND}Config
443 olcDatabase: {2}$BACKEND
444 ${nullExclude}olcDbDirectory: $SMC_DIR/ou2
446 olcSuffix: ou=ou2,$BASEDN
447 olcRootDN: $MANAGERDN
449 dn: olcDatabase={3}$BACKEND,cn=config
450 objectClass: olcDatabaseConfig
451 ${nullExclude}objectClass: olc${BACKEND}Config
452 olcDatabase: {3}$BACKEND
453 ${nullExclude}olcDbDirectory: $SMC_DIR/sm1ou1
455 olcSuffix: ou=sm1ou1,$BASEDN
458 dn: olcDatabase={4}$BACKEND,cn=config
459 objectClass: olcDatabaseConfig
460 ${nullExclude}objectClass: olc${BACKEND}Config
461 olcDatabase: {4}$BACKEND
462 ${nullExclude}olcDbDirectory: $SMC_DIR/sm1ou2
464 olcSuffix: ou=sm1ou2,$BASEDN
467 dn: olcDatabase={5}$BACKEND,cn=config
468 objectClass: olcDatabaseConfig
469 ${nullExclude}objectClass: olc${BACKEND}Config
470 olcDatabase: {5}$BACKEND
471 ${nullExclude}olcDbDirectory: $SMC_DIR/sm2ou1
473 olcSuffix: ou=sm2ou1,$BASEDN
478 if test $RC != 0 ; then
479 echo "ldapadd failed for central master database config ($RC)!"
480 test $KILLSERVERS != no && kill -HUP $KILLPIDS
484 echo "Adding database config on site1 master..."
485 if [ "$SYNCPROV" = syncprovmod ]; then
486 $LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
487 dn: cn=module,cn=config
488 objectClass: olcModuleList
490 olcModulePath: $TESTWD/../servers/slapd/overlays
491 olcModuleLoad: syncprov.la
495 if test $RC != 0 ; then
496 echo "ldapadd failed for moduleLoad ($RC)!"
497 test $KILLSERVERS != no && kill -HUP $KILLPIDS
502 $LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
503 dn: olcDatabase={1}$BACKEND,cn=config
504 objectClass: olcDatabaseConfig
505 ${nullExclude}objectClass: olc${BACKEND}Config
506 olcDatabase: {1}$BACKEND
507 ${nullExclude}olcDbDirectory: $SM1_DIR/db
511 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
512 objectClass: olcOverlayConfig
515 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
516 objectClass: olcOverlayConfig
517 objectClass: olcSyncProvConfig
518 olcOverlay: {1}syncprov
520 dn: olcDatabase={1}$BACKEND,cn=config
521 objectClass: olcDatabaseConfig
522 ${nullExclude}objectClass: olc${BACKEND}Config
523 olcDatabase: {1}$BACKEND
524 ${nullExclude}olcDbDirectory: $SM1_DIR/ou1
526 olcSuffix: ou=ou1,$BASEDN
529 dn: olcDatabase={2}$BACKEND,cn=config
530 objectClass: olcDatabaseConfig
531 ${nullExclude}objectClass: olc${BACKEND}Config
532 olcDatabase: {2}$BACKEND
533 ${nullExclude}olcDbDirectory: $SM1_DIR/sm1ou1
535 olcSuffix: ou=sm1ou1,$BASEDN
536 olcRootDN: ou=sm1ou1,$BASEDN
539 dn: olcDatabase={3}$BACKEND,cn=config
540 objectClass: olcDatabaseConfig
541 ${nullExclude}objectClass: olc${BACKEND}Config
542 olcDatabase: {3}$BACKEND
543 ${nullExclude}olcDbDirectory: $SM1_DIR/sm1ou2
545 olcSuffix: ou=sm1ou2,$BASEDN
546 olcRootDN: ou=sm1ou1,$BASEDN
551 if test $RC != 0 ; then
552 echo "ldapadd failed for site1 master database config ($RC)!"
553 test $KILLSERVERS != no && kill -HUP $KILLPIDS
557 echo "Adding database config on site2 master..."
558 if [ "$SYNCPROV" = syncprovmod ]; then
559 $LDAPADD -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
560 dn: cn=module,cn=config
561 objectClass: olcModuleList
563 olcModulePath: $TESTWD/../servers/slapd/overlays
564 olcModuleLoad: syncprov.la
568 if test $RC != 0 ; then
569 echo "ldapadd failed for moduleLoad ($RC)!"
570 test $KILLSERVERS != no && kill -HUP $KILLPIDS
575 $LDAPADD -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
576 dn: olcDatabase={1}$BACKEND,cn=config
577 objectClass: olcDatabaseConfig
578 ${nullExclude}objectClass: olc${BACKEND}Config
579 olcDatabase: {1}$BACKEND
580 ${nullExclude}olcDbDirectory: $SM2_DIR/db
584 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
585 objectClass: olcOverlayConfig
588 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
589 objectClass: olcOverlayConfig
590 objectClass: olcSyncProvConfig
591 olcOverlay: {1}syncprov
594 dn: olcDatabase={1}$BACKEND,cn=config
595 objectClass: olcDatabaseConfig
596 ${nullExclude}objectClass: olc${BACKEND}Config
597 olcDatabase: {1}$BACKEND
598 ${nullExclude}olcDbDirectory: $SM2_DIR/ou2
600 olcSuffix: ou=ou2,$BASEDN
603 dn: olcDatabase={2}$BACKEND,cn=config
604 objectClass: olcDatabaseConfig
605 ${nullExclude}objectClass: olc${BACKEND}Config
606 olcDatabase: {2}$BACKEND
607 ${nullExclude}olcDbDirectory: $SM2_DIR/sm1ou1
609 olcSuffix: ou=sm1ou1,$BASEDN
612 dn: olcDatabase={3}$BACKEND,cn=config
613 objectClass: olcDatabaseConfig
614 ${nullExclude}objectClass: olc${BACKEND}Config
615 olcDatabase: {3}$BACKEND
616 ${nullExclude}olcDbDirectory: $SM2_DIR/sm2ou1
618 olcSuffix: ou=sm2ou1,$BASEDN
619 olcRootDN: ou=sm2ou1,$BASEDN
622 dn: olcDatabase={4}$BACKEND,cn=config
623 objectClass: olcDatabaseConfig
624 ${nullExclude}objectClass: olc${BACKEND}Config
625 olcDatabase: {4}$BACKEND
626 ${nullExclude}olcDbDirectory: $SM2_DIR/sm2ou2
628 olcSuffix: ou=sm2ou2,$BASEDN
629 olcRootDN: ou=sm2ou1,$BASEDN
634 if test $RC != 0 ; then
635 echo "ldapadd failed for site2 master database config ($RC)!"
636 test $KILLSERVERS != no && kill -HUP $KILLPIDS
640 echo "Adding access rules on central master..."
641 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
642 dn: olcDatabase={-1}frontend,cn=config
645 olcAccess: to dn.exact=dc=example,dc=com
647 olcAccess: to dn.subtree=ou=ou1,dc=example,dc=com
649 olcAccess: to dn.subtree=ou=ou2,dc=example,dc=com
650 by dn.exact=ou=ou1,dc=example,dc=com none
651 by dn.exact=ou=ou2,dc=example,dc=com read
652 by dn.exact=dc=example,dc=com none
654 olcAccess: to dn.subtree=ou=sm1ou1,dc=example,dc=com
655 by dn.exact=ou=ou1,dc=example,dc=com none
656 by dn.exact=ou=ou2,dc=example,dc=com read
657 by dn.exact=dc=example,dc=com none
659 olcAccess: to dn.subtree=ou=sm1ou2,dc=example,dc=com
660 by dn.exact=ou=ou1,dc=example,dc=com none
661 by dn.exact=ou=ou2,dc=example,dc=com none
662 by dn.exact=dc=example,dc=com read
664 olcAccess: to dn.subtree=ou=sm2ou1,dc=example,dc=com
665 by dn.exact=ou=ou1,dc=example,dc=com none
666 by dn.exact=ou=ou2,dc=example,dc=com none
667 by dn.exact=dc=example,dc=com none
669 olcAccess: to * by * read
673 if test $RC != 0 ; then
674 echo "ldapmodify failed for central master access config ($RC)!"
675 test $KILLSERVERS != no && kill -HUP $KILLPIDS
679 echo "Adding access rules on site1 master..."
680 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
681 dn: olcDatabase={-1}frontend,cn=config
684 olcAccess: to dn.subtree=dc=example,dc=com
686 olcAccess: to * by * read
690 if test $RC != 0 ; then
691 echo "ldapmodify failed for site1 master access config ($RC)!"
692 test $KILLSERVERS != no && kill -HUP $KILLPIDS
696 echo "Adding access rules on site2 master..."
697 $LDAPMODIFY -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
698 dn: olcDatabase={-1}frontend,cn=config
701 olcAccess: to dn.exact=dc=example,dc=com
703 olcAccess: to dn.subtree=ou=ou2,dc=example,dc=com
705 olcAccess: to dn.subtree=ou=sm1ou1,dc=example,dc=com
708 olcAccess: to dn.subtree=ou=sm2ou1,dc=example,dc=com
710 olcAccess: to dn.subtree=ou=sm2ou2,dc=example,dc=com
711 by dn.exact=dc=example,dc=com read
714 olcAccess: to * by * read
718 if test $RC != 0 ; then
719 echo "ldapmodify failed for site2 master access config ($RC)!"
720 test $KILLSERVERS != no && kill -HUP $KILLPIDS
724 echo "Adding database config on central search..."
725 $LDAPADD -D cn=config -H $URI4 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
726 dn: olcDatabase={1}$BACKEND,cn=config
727 objectClass: olcDatabaseConfig
728 ${nullExclude}objectClass: olc${BACKEND}Config
729 olcDatabase: {1}$BACKEND
730 ${nullExclude}olcDbDirectory: $SSC_DIR/db
736 if test $RC != 0 ; then
737 echo "ldapadd failed for central search database config ($RC)!"
738 test $KILLSERVERS != no && kill -HUP $KILLPIDS
742 echo "Adding database config on site1 search..."
743 $LDAPADD -D cn=config -H $URI5 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
744 dn: olcDatabase={1}$BACKEND,cn=config
745 objectClass: olcDatabaseConfig
746 ${nullExclude}objectClass: olc${BACKEND}Config
747 olcDatabase: {1}$BACKEND
748 ${nullExclude}olcDbDirectory: $SS1_DIR/db
754 if test $RC != 0 ; then
755 echo "ldapadd failed for site1 search database config ($RC)!"
756 test $KILLSERVERS != no && kill -HUP $KILLPIDS
760 echo "Adding database config on site2 search..."
761 $LDAPADD -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
762 dn: olcDatabase={1}$BACKEND,cn=config
763 objectClass: olcDatabaseConfig
764 ${nullExclude}objectClass: olc${BACKEND}Config
765 olcDatabase: {1}$BACKEND
766 ${nullExclude}olcDbDirectory: $SS2_DIR/db
772 if test $RC != 0 ; then
773 echo "ldapadd failed for site2 search database config ($RC)!"
774 test $KILLSERVERS != no && kill -HUP $KILLPIDS
778 echo "Populating central master..."
779 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
780 dn: dc=example,dc=com
782 objectClass: organization
783 objectClass: dcObject
786 userPassword: $PASSWD
788 dn: ou=ou1,dc=example,dc=com
790 objectClass: organizationalUnit
792 userPassword: $PASSWD
794 dn: ou=ou2,dc=example,dc=com
796 objectClass: organizationalUnit
798 userPassword: $PASSWD
802 if test $RC != 0 ; then
803 echo "ldapadd failed to populate central master entry ($RC)!"
804 test $KILLSERVERS != no && kill -HUP $KILLPIDS
808 echo "Adding syncrepl on site1 master..."
809 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
810 dn: olcDatabase={4}$BACKEND,cn=config
813 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
814 binddn="ou=ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
815 type=refreshAndPersist retry="$RETRY" timeout=1
819 if test $RC != 0 ; then
820 echo "ldapmodify failed to add syncrepl on site1 master ($RC)!"
821 test $KILLSERVERS != no && kill -HUP $KILLPIDS
825 echo "Adding syncrepl on site2 master..."
826 $LDAPMODIFY -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
827 dn: olcDatabase={5}$BACKEND,cn=config
830 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
831 binddn="ou=ou2,$BASEDN" bindmethod=simple credentials=$PASSWD
832 type=refreshAndPersist retry="$RETRY" timeout=1
836 if test $RC != 0 ; then
837 echo "ldapmodify failed to add syncrepl on site2 master ($RC)!"
838 test $KILLSERVERS != no && kill -HUP $KILLPIDS
843 echo "Using ldapsearch to check that site1 master received changes..."
845 for i in 1 2 3 4 5; do
846 RESULT=`$LDAPSEARCH -H $URI2 \
847 -s base -b "ou=ou1,$BASEDN" \
848 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
849 if test "x$RESULT$nullOK" = "xOK" ; then
853 echo "Waiting $i seconds for syncrepl to receive changes..."
856 if test $RC != 0 ; then
857 echo "ldapsearch failed ($RC)!"
858 test $KILLSERVERS != no && kill -HUP $KILLPIDS
862 echo "Using ldapsearch to check that site2 master received changes..."
864 for i in 1 2 3 4 5; do
865 RESULT=`$LDAPSEARCH -H $URI3 \
866 -s base -b "ou=ou1,$BASEDN" \
867 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
868 if test "x$RESULT$nullOK" = "xOK" ; then
872 echo "Waiting $i seconds for syncrepl to receive changes..."
875 if test $RC != 0 ; then
876 echo "ldapsearch failed ($RC)!"
877 test $KILLSERVERS != no && kill -HUP $KILLPIDS
883 echo "Populating site1 master..."
884 $LDAPADD -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
885 dn: ou=sm1ou1,dc=example,dc=com
887 objectClass: organizationalUnit
890 dn: ou=sm1ou2,dc=example,dc=com
892 objectClass: organizationalUnit
897 if test $RC != 0 ; then
898 echo "ldapadd failed to populate site1 master ($RC)!"
899 test $KILLSERVERS != no && kill -HUP $KILLPIDS
905 echo "Populating site2 master..."
906 $LDAPADD -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
907 dn: ou=sm2ou1,dc=example,dc=com
909 objectClass: organizationalUnit
912 dn: ou=sm2ou2,dc=example,dc=com
914 objectClass: organizationalUnit
919 if test $RC != 0 ; then
920 echo "ldapadd failed to populate site2 master ($RC)!"
921 test $KILLSERVERS != no && kill -HUP $KILLPIDS
928 # Stop site1 master when adding syncrepl to the central master. When
929 # site1 master is started again both it and the central master will have
930 # the same number of contextCSN values, but the ones on central master
931 # will be the newest. The central master will not update its contextCSN
932 # values unless the bug in ITS#5597 have been fixed.
933 echo "Stopping site1 master..."
936 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SM1_PID / /"`;
939 echo "Adding syncrepl on central master..."
940 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
941 dn: olcDatabase={3}$BACKEND,cn=config
944 olcSyncRepl: rid=3 provider=$URI2 searchbase="ou=sm1ou1,$BASEDN"
945 binddn="ou=sm1ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
946 type=refreshAndPersist retry="$RETRY" timeout=1
948 dn: olcDatabase={5}$BACKEND,cn=config
951 olcSyncRepl: rid=5 provider=$URI3 searchbase="ou=sm2ou1,$BASEDN"
952 binddn="ou=sm2ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
953 type=refreshAndPersist retry="$RETRY" timeout=1
957 if test $RC != 0 ; then
958 echo "ldapmodify failed to add syncrepl on central master ($RC)!"
959 test $KILLSERVERS != no && kill -HUP $KILLPIDS
963 echo "Using ldapsearch to check that central master received site2 entries..."
965 for i in 1 2 3 4 5; do
966 RESULT=`$LDAPSEARCH -H $URI1 \
967 -s base -b "ou=sm2ou1,$BASEDN" \
968 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
969 if test "x$RESULT$nullOK" = "xOK" ; then
973 echo "Waiting $i seconds for syncrepl to receive changes..."
976 if test $RC != 0 ; then
977 echo "ldapsearch failed ($RC)!"
978 test $KILLSERVERS != no && kill -HUP $KILLPIDS
982 if test -z "$SM1_PID" ; then
983 echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
985 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
987 if test $WAIT != 0 ; then
991 KILLPIDS="$KILLPIDS $SM1_PID"
996 echo "Using ldapsearch to check that site1 master is running..."
997 for i in 1 2 3 4 5; do
998 $LDAPSEARCH -s base -b "" -H $URI2 \
999 'objectclass=*' > /dev/null 2>&1
1001 test $RC = 0 && break
1002 echo "Waiting $i seconds for slapd to start..."
1005 if test $RC != 0 ; then
1006 echo "ldapsearch failed ($RC)!"
1007 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1011 echo "Using ldapsearch to check that central master received site1 entries..."
1013 for i in 1 2 3 4 5; do
1014 RESULT=`$LDAPSEARCH -H $URI1 \
1015 -s base -b "ou=sm1ou1,$BASEDN" \
1016 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1017 if test "x$RESULT$nullOK" = "xOK" ; then
1021 echo "Waiting $i seconds for syncrepl to receive changes..."
1024 if test $RC != 0 ; then
1025 echo "ldapsearch failed ($RC)!"
1026 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1030 # Test done, now some more intialization...
1032 echo "Adding syncrepl consumer on central search..."
1033 $LDAPMODIFY -D cn=config -H $URI4 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1034 dn: olcDatabase={1}$BACKEND,cn=config
1037 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
1038 binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1039 type=refreshAndPersist retry="$RETRY" timeout=1
1043 if test $RC != 0 ; then
1044 echo "ldapmodify failed to add syncrepl on site1 search ($RC)!"
1045 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1049 echo "Adding syncrepl consumer on site1 search..."
1050 $LDAPMODIFY -D cn=config -H $URI5 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1051 dn: olcDatabase={1}$BACKEND,cn=config
1054 olcSyncRepl: rid=1 provider=$URI2 searchbase="$BASEDN"
1055 binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1056 type=refreshAndPersist retry="$RETRY" timeout=1
1060 if test $RC != 0 ; then
1061 echo "ldapmodify failed to add syncrepl on site1 search ($RC)!"
1062 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1066 echo "Adding syncrepl consumer on site2 search..."
1067 $LDAPMODIFY -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1068 dn: olcDatabase={1}$BACKEND,cn=config
1071 olcSyncRepl: rid=1 provider=$URI3 searchbase="$BASEDN"
1072 binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1073 type=refreshAndPersist retry="$RETRY" timeout=1
1077 if test $RC != 0 ; then
1078 echo "ldapmodify failed to add syncrepl on site2 search ($RC)!"
1079 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1084 echo "Using ldapsearch to check that central search received changes..."
1086 for i in 1 2 3 4 5; do
1087 RESULT=`$LDAPSEARCH -H $URI4 \
1088 -s base -b "$BASEDN" \
1089 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1090 if test "x$RESULT$nullOK" = "xOK" ; then
1094 echo "Waiting $i seconds for syncrepl to receive changes..."
1097 if test $RC != 0 ; then
1098 echo "ldapsearch failed ($RC)!"
1099 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1103 echo "Using ldapsearch to check that site1 search received changes..."
1105 for i in 1 2 3 4 5; do
1106 RESULT=`$LDAPSEARCH -H $URI5 \
1107 -s base -b "$BASEDN" \
1108 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1109 if test "x$RESULT$nullOK" = "xOK" ; then
1113 echo "Waiting $i seconds for syncrepl to receive changes..."
1116 if test $RC != 0 ; then
1117 echo "ldapsearch failed ($RC)!"
1118 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1122 echo "Using ldapsearch to check that site2 search received changes..."
1124 for i in 1 2 3 4 5; do
1125 RESULT=`$LDAPSEARCH -H $URI6 \
1126 -s base -b "$BASEDN" \
1127 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1128 if test "x$RESULT$nullOK" = "xOK" ; then
1132 echo "Waiting $i seconds for syncrepl to receive changes..."
1135 if test $RC != 0 ; then
1136 echo "ldapsearch failed ($RC)!"
1137 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1141 # Create a script that will check the contextCSN values of all servers,
1142 # and restart them to re-synchronize if it finds any errors:
1143 cat > $TESTDIR/checkcsn.sh <<'EOF'
1148 CSN1=`$LDAPSEARCH -H $URI1 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1149 CSN2=`$LDAPSEARCH -H $URI2 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1150 CSN3=`$LDAPSEARCH -H $URI3 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1151 CSN4=`$LDAPSEARCH -H $URI4 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1152 CSN5=`$LDAPSEARCH -H $URI5 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1153 CSN6=`$LDAPSEARCH -H $URI6 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1155 if test -z "$CSN1" ; then
1156 echo "ERROR: contextCSN empty on central master"
1157 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1159 nCSN=`echo "$CSN1" | wc -l`
1160 if test "$nCSN" -ne 3 ; then
1161 echo "ERROR: Wrong contextCSN count on central master, should be 3"
1162 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1163 if test -n "$CSN_VERBOSE"; then
1167 if test -z "$CSN2" -o "$CSN1" != "$CSN2" ; then
1168 echo "ERROR: contextCSN mismatch between central master and site1 master"
1169 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1170 if test -n "$CSN_VERBOSE"; then
1171 echo "contextCSN on central master:"
1173 echo "contextCSN on site1 master:"
1177 if test -z "$CSN3" -o "$CSN1" != "$CSN3" ; then
1178 echo "ERROR: contextCSN mismatch between central master and site2 master"
1179 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1180 if test -n "$CSN_VERBOSE"; then
1181 echo "contextCSN on central master:"
1183 echo "contextCSN on site2 master:"
1187 if test -z "$CSN4" -o "$CSN1" != "$CSN4" ; then
1188 echo "ERROR: contextCSN mismatch between central master and central search"
1189 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1190 if test -n "$CSN_VERBOSE"; then
1191 echo "contextCSN on central master:"
1193 echo "contextCSN on central search:"
1197 if test -z "$CSN5" -o "$CSN2" != "$CSN5" ; then
1198 echo "ERROR: contextCSN mismatch between site1 master and site1 search"
1199 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1200 if test -n "$CSN_VERBOSE"; then
1201 echo "contextCSN on site1 master:"
1203 echo "contextCSN on site1 search:"
1207 if test -z "$CSN6" -o "$CSN3" != "$CSN6" ; then
1208 echo "ERROR: contextCSN mismatch between site2 master and site2 search:"
1209 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1210 if test -n "$CSN_VERBOSE"; then
1211 echo "contextCSN on site2 master:"
1213 echo "contextCSN on site2 search:"
1218 if test $CSN_ERRORS != 0 ; then
1219 echo "Stopping all servers to synchronize contextCSN..."
1221 for pid in $KILLPIDS ; do wait $pid ; done
1224 echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
1226 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
1228 if test $WAIT != 0 ; then
1232 KILLPIDS="$KILLPIDS $SM1_PID"
1235 echo "Using ldapsearch to check that site1 master is running..."
1236 for i in 1 2 3 4 5; do
1237 $LDAPSEARCH -s base -b "" -H $URI2 \
1238 'objectclass=*' > /dev/null 2>&1
1240 test $RC = 0 && break
1241 echo "Waiting $i seconds for slapd to start..."
1244 if test $RC != 0 ; then
1245 echo "ldapsearch failed ($RC)!"
1246 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1250 echo "Restarting site2 master slapd on TCP/IP port $PORT3..."
1252 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1254 if test $WAIT != 0 ; then
1258 KILLPIDS="$KILLPIDS $SM2_PID "
1261 echo "Using ldapsearch to check that site2 master is running..."
1262 for i in 1 2 3 4 5; do
1263 $LDAPSEARCH -s base -b "" -H $URI3 \
1264 'objectclass=*' > /dev/null 2>&1
1266 test $RC = 0 && break
1267 echo "Waiting $i seconds for slapd to start..."
1270 if test $RC != 0 ; then
1271 echo "ldapsearch failed ($RC)!"
1272 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1276 echo "Restarting central master slapd on TCP/IP port $PORT1..."
1278 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
1280 if test $WAIT != 0 ; then
1284 KILLPIDS="$KILLPIDS $SMC_PID"
1287 echo "Using ldapsearch to check that central master slapd is running..."
1288 for i in 1 2 3 4 5; do
1289 $LDAPSEARCH -s base -b "" -H $URI1 \
1290 'objectclass=*' > /dev/null 2>&1
1292 test $RC = 0 && break
1293 echo "Waiting $i seconds for slapd to start..."
1296 if test $RC != 0 ; then
1297 echo "ldapsearch failed ($RC)!"
1298 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1302 echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1305 echo "Stopping site1 and site2 master..."
1306 kill -HUP $SM1_PID $SM2_PID
1307 for pid in $SM1_PID $SM2_PID ; do wait $pid ; done
1308 KILLPIDS=" $SMC_PID"
1310 echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
1312 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
1314 if test $WAIT != 0 ; then
1318 KILLPIDS="$KILLPIDS $SM1_PID"
1321 echo "Using ldapsearch to check that site1 master is running..."
1322 for i in 1 2 3 4 5; do
1323 $LDAPSEARCH -s base -b "" -H $URI2 \
1324 'objectclass=*' > /dev/null 2>&1
1326 test $RC = 0 && break
1327 echo "Waiting $i seconds for slapd to start..."
1330 if test $RC != 0 ; then
1331 echo "ldapsearch failed ($RC)!"
1332 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1336 echo "Restarting site2 master slapd on TCP/IP port $PORT3..."
1338 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1340 if test $WAIT != 0 ; then
1344 KILLPIDS="$KILLPIDS $SM2_PID"
1347 echo "Using ldapsearch to check that site2 master is running..."
1348 for i in 1 2 3 4 5; do
1349 $LDAPSEARCH -s base -b "" -H $URI3 \
1350 'objectclass=*' > /dev/null 2>&1
1352 test $RC = 0 && break
1353 echo "Waiting $i seconds for slapd to start..."
1356 if test $RC != 0 ; then
1357 echo "ldapsearch failed ($RC)!"
1358 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1362 echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1365 echo "Restarting central search slapd on TCP/IP port $PORT4..."
1367 $SLAPD -F slapd.d -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
1369 if test $WAIT != 0 ; then
1373 KILLPIDS="$KILLPIDS $SSC_PID"
1376 echo "Using ldapsearch to check that central search slapd is running..."
1377 for i in 1 2 3 4 5; do
1378 $LDAPSEARCH -s base -b "" -H $URI4 \
1379 'objectclass=*' > /dev/null 2>&1
1381 test $RC = 0 && break
1382 echo "Waiting $i seconds for slapd to start..."
1385 if test $RC != 0 ; then
1386 echo "ldapsearch failed ($RC)!"
1387 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1391 echo "Restarting site1 search slapd on TCP/IP port $PORT5..."
1393 $SLAPD -F slapd.d -h $URI5 -d $LVL $TIMING >> $LOG5 2>&1 &
1395 if test $WAIT != 0 ; then
1399 KILLPIDS="$KILLPIDS $SS1_PID"
1402 echo "Using ldapsearch to check that site1 search slapd is running..."
1403 for i in 1 2 3 4 5; do
1404 $LDAPSEARCH -s base -b "" -H $URI5 \
1405 'objectclass=*' > /dev/null 2>&1
1407 test $RC = 0 && break
1408 echo "Waiting $i seconds for slapd to start..."
1411 if test $RC != 0 ; then
1412 echo "ldapsearch failed ($RC)!"
1413 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1417 echo "Restarting site2 search slapd on TCP/IP port $PORT6..."
1419 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING >> $LOG6 2>&1 &
1421 if test $WAIT != 0 ; then
1425 KILLPIDS="$KILLPIDS $SS2_PID"
1428 echo "Using ldapsearch to check that site2 search slapd is running..."
1429 for i in 1 2 3 4 5; do
1430 $LDAPSEARCH -s base -b "" -H $URI6 \
1431 'objectclass=*' > /dev/null 2>&1
1433 test $RC = 0 && break
1434 echo "Waiting $i seconds for slapd to start..."
1437 if test $RC != 0 ; then
1438 echo "ldapsearch failed ($RC)!"
1439 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1443 echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1446 echo "Checking contextCSN after restart..."
1447 CSN1=`$LDAPSEARCH -H $URI1 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1448 CSN2=`$LDAPSEARCH -H $URI2 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1449 CSN3=`$LDAPSEARCH -H $URI3 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1450 CSN4=`$LDAPSEARCH -H $URI4 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1451 CSN5=`$LDAPSEARCH -H $URI5 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1452 CSN6=`$LDAPSEARCH -H $URI6 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1453 if test -z "$CSN1" ; then
1454 echo "ERROR: contextCSN empty on central master"
1455 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1458 if test -z "$CSN2" -o "$CSN1" != "$CSN2" ; then
1459 echo "ERROR: contextCSN mismatch between central master and site1 master"
1460 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1461 if test -n "$CSN_VERBOSE"; then
1462 echo "contextCSN on central master:"
1464 echo "contextCSN on site1 master:"
1468 if test -z "$CSN3" -o "$CSN1" != "$CSN3" ; then
1469 echo "ERROR: contextCSN mismatch between central master and site2 master"
1470 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1471 if test -n "$CSN_VERBOSE"; then
1472 echo "contextCSN on central master:"
1474 echo "contextCSN on site2 master:"
1478 if test -z "$CSN4" -o "$CSN1" != "$CSN4" ; then
1479 echo "ERROR: contextCSN mismatch between central master and central search"
1480 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1481 if test -n "$CSN_VERBOSE"; then
1482 echo "contextCSN on central master:"
1484 echo "contextCSN on central search:"
1488 if test -z "$CSN5" -o "$CSN2" != "$CSN5" ; then
1489 echo "ERROR: contextCSN mismatch between site1 master and site1 search"
1490 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1491 if test -n "$CSN_VERBOSE"; then
1492 echo "contextCSN on site1 master:"
1494 echo "contextCSN on site1 search:"
1498 if test -z "$CSN6" -o "$CSN3" != "$CSN6" ; then
1499 echo "ERROR: contextCSN mismatch between site2 master and site2 search:"
1500 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1501 if test -n "$CSN_VERBOSE"; then
1502 echo "contextCSN on site2 master:"
1504 echo "contextCSN on site2 search:"
1510 ERRORS=`expr $ERRORS + $CSN_ERRORS`
1514 test $BACKEND = null && echo : > $TESTDIR/checkcsn.sh
1516 chmod +x $TESTDIR/checkcsn.sh
1519 echo "Checking contextCSN after initial replication..."
1520 . $TESTDIR/checkcsn.sh
1525 # Test that updates to the first backend on central master, which should
1526 # be replicated to all servers actually is so, and that the contextCSN is
1527 # updated everywhere:
1528 echo "Using ldapmodify to modify first backend on central master..."
1529 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1530 dn: ou=ou1,dc=example,dc=com
1533 description: Modify$MNUM
1537 if test $RC != 0 ; then
1538 echo "ldapmodify failed ($RC)!"
1539 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1544 echo "Using ldapsearch to check replication to central search..."
1546 for i in 1 2 3 4 5; do
1547 RESULT=`$LDAPSEARCH -H $URI4 \
1548 -s base -b "ou=ou1,$BASEDN" \
1549 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1550 if test "x$RESULT$nullOK" = "xOK" ; then
1554 echo "Waiting $i seconds for syncrepl to receive changes..."
1557 if test $RC != 0 ; then
1558 echo "ldapsearch failed ($RC)!"
1559 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1563 echo "Using ldapsearch to check replication to site1 search..."
1565 for i in 1 2 3 4 5; do
1566 RESULT=`$LDAPSEARCH -H $URI5 \
1567 -s base -b "ou=ou1,$BASEDN" \
1568 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1569 if test "x$RESULT$nullOK" = "xOK" ; then
1573 echo "Waiting $i seconds for syncrepl to receive changes..."
1576 if test $RC != 0 ; then
1577 echo "ldapsearch failed ($RC)!"
1578 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1582 echo "Using ldapsearch to check replication to site2 search..."
1584 for i in 1 2 3 4 5; do
1585 RESULT=`$LDAPSEARCH -H $URI6 \
1586 -s base -b "ou=ou1,$BASEDN" \
1587 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1588 if test "x$RESULT$nullOK" = "xOK" ; then
1592 echo "Waiting $i seconds for syncrepl to receive changes..."
1595 if test $RC != 0 ; then
1596 echo "ldapsearch failed ($RC)!"
1597 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1601 echo "Checking contextCSN after modify of first backend on central master..."
1602 . $TESTDIR/checkcsn.sh
1605 # Test that updates to the second backend on central master is only
1606 # replicated to those search servers that should receive that backend.
1607 # The contextCSN should still be updated everywhere:
1608 MNUM=`expr $MNUM + 1`
1609 echo "Using ldapmodify to modify second backend on central master..."
1610 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1611 dn: ou=ou2,dc=example,dc=com
1614 description: Modify$MNUM
1618 if test $RC != 0 ; then
1619 echo "ldapmodify failed ($RC)!"
1620 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1625 echo "Using ldapsearch to check replication to site2 search..."
1627 for i in 1 2 3 4 5; do
1628 RESULT=`$LDAPSEARCH -H $URI6 \
1629 -s base -b "ou=ou2,$BASEDN" \
1630 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1631 if test "x$RESULT$nullOK" = "xOK" ; then
1635 echo "Waiting $i seconds for syncrepl to receive changes..."
1638 if test $RC != 0 ; then
1639 echo "ldapsearch failed ($RC)!"
1640 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1644 echo "Using ldapsearch to check no replication to site1 master..."
1645 for i in 1 2 3 4 5; do
1646 RESULT=`$LDAPSEARCH -H $URI2 \
1647 -s base -b "ou=ou2,$BASEDN" \
1648 "(description=Modify$NMUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1649 if test "x$RESULT" = "xNOK" ; then
1650 echo "Change was replicated to site1 search!"
1651 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1657 echo "Using ldapsearch to check no replication to central search..."
1658 for i in 1 2 3 4 5; do
1659 RESULT=`$LDAPSEARCH -H $URI4 \
1660 -s base -b "ou=ou2,$BASEDN" \
1661 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1662 if test "x$RESULT" = "xNOK" ; then
1663 echo "Change was replicated to central search!"
1664 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1670 echo "Checking contextCSN after modify of second backend on central master..."
1671 . $TESTDIR/checkcsn.sh
1674 # Test that updates to the first backend on site1 master, which should be
1675 # replicated everywhere except to central and site2 search. The contextCSN
1676 # should be updated on all servers:
1677 MNUM=`expr $MNUM + 1`
1678 echo "Using ldapmodify to modify first backend on site1 master..."
1679 $LDAPMODIFY -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1680 dn: ou=sm1ou1,dc=example,dc=com
1683 description: Modify$MNUM
1687 if test $RC != 0 ; then
1688 echo "ldapmodify failed ($RC)!"
1689 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1694 echo "Using ldapsearch to check replication to site1 search..."
1696 for i in 1 2 3 4 5; do
1697 RESULT=`$LDAPSEARCH -H $URI5 \
1698 -s base -b "ou=sm1ou1,$BASEDN" \
1699 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1700 if test "x$RESULT$nullOK" = "xOK" ; then
1704 echo "Waiting $i seconds for syncrepl to receive changes..."
1707 if test $RC != 0 ; then
1708 echo "ldapsearch failed ($RC)!"
1709 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1713 echo "Using ldapsearch to check replication to site2 master..."
1715 for i in 1 2 3 4 5; do
1716 RESULT=`$LDAPSEARCH -H $URI3 \
1717 -s base -b "ou=sm1ou1,$BASEDN" \
1718 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1719 if test "x$RESULT$nullOK" = "xOK" ; then
1723 echo "Waiting $i seconds for syncrepl to receive changes..."
1726 if test $RC != 0 ; then
1727 echo "ldapsearch failed ($RC)!"
1728 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1732 echo "Using ldapsearch to check no replication to site2 search..."
1733 for i in 1 2 3 4 5; do
1734 RESULT=`$LDAPSEARCH -H $URI6 \
1735 -s base -b "ou=sm1ou2,$BASEDN" \
1736 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1737 if test "x$RESULT" = "xNOK" ; then
1738 echo "Change was replicated to central search!"
1739 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1745 echo "Using ldapsearch to check no replication to central search..."
1746 for i in 1 2 3 4 5; do
1747 RESULT=`$LDAPSEARCH -H $URI4 \
1748 -s base -b "ou=sm1ou2,$BASEDN" \
1749 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1750 if test "x$RESULT" = "xNOK" ; then
1751 echo "Change was replicated to central search!"
1752 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1758 echo "Checking contextCSN after modify of first backend on site1 master..."
1759 . $TESTDIR/checkcsn.sh
1763 # Test updates to the second backend on site1 master, which should only be
1764 # replicated to site1 search. The contextCSN should be updated everywhere.
1765 MNUM=`expr $MNUM + 1`
1766 echo "Using ldapmodify to modify second backend on site1 master..."
1767 $LDAPMODIFY -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1768 dn: ou=sm1ou2,dc=example,dc=com
1771 description: Modify$MNUM
1775 if test $RC != 0 ; then
1776 echo "ldapmodify failed ($RC)!"
1777 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1783 echo "Using ldapsearch to check replication to site1 search..."
1785 for i in 1 2 3 4 5; do
1786 RESULT=`$LDAPSEARCH -H $URI5 \
1787 -s base -b "ou=sm1ou2,$BASEDN" \
1788 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1789 if test "x$RESULT$nullOK" = "xOK" ; then
1793 echo "Waiting $i seconds for syncrepl to receive changes..."
1796 if test $RC != 0 ; then
1797 echo "ldapsearch failed ($RC)!"
1798 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1802 echo "Using ldapsearch to check no replication to central master..."
1803 for i in 1 2 3 4 5; do
1804 RESULT=`$LDAPSEARCH -H $URI1 \
1805 -s base -b "ou=sm1ou2,$BASEDN" \
1806 "(description=Modify$NMUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1807 if test "x$RESULT" = "xNOK" ; then
1808 echo "Change was replicated to site2 search!"
1809 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1815 echo "Checking contextCSN after modify of second backend on site1 master..."
1816 . $TESTDIR/checkcsn.sh
1820 # Test updates to first backend on site2 master, which should be
1821 # replicated to the central servers, but not site1. The contextCSN
1822 # should be updated everywhere:
1823 MNUM=`expr $MNUM + 1`
1824 echo "Using ldapmodify to modify first backend on site2 master..."
1825 $LDAPMODIFY -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1826 dn: ou=sm2ou1,dc=example,dc=com
1829 description: Modify$MNUM
1833 if test $RC != 0 ; then
1834 echo "ldapmodify failed ($RC)!"
1835 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1840 echo "Using ldapsearch to check replication to central master..."
1842 for i in 1 2 3 4 5; do
1843 RESULT=`$LDAPSEARCH -H $URI1 \
1844 -s base -b "ou=sm2ou1,$BASEDN" \
1845 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1846 if test "x$RESULT$nullOK" = "xOK" ; then
1850 echo "Waiting $i seconds for syncrepl to receive changes..."
1853 if test $RC != 0 ; then
1854 echo "ldapsearch failed ($RC)!"
1855 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1859 echo "Using ldapsearch to check replication to site2 search..."
1861 for i in 1 2 3 4 5; do
1862 RESULT=`$LDAPSEARCH -H $URI6 \
1863 -s base -b "ou=sm2ou1,$BASEDN" \
1864 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1865 if test "x$RESULT$nullOK" = "xOK" ; then
1869 echo "Waiting $i seconds for syncrepl to receive changes..."
1872 if test $RC != 0 ; then
1873 echo "ldapsearch failed ($RC)!"
1874 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1878 echo "Using ldapsearch to check no replication to site1 master..."
1879 for i in 1 2 3 4 5; do
1880 RESULT=`$LDAPSEARCH -H $URI2 \
1881 -s base -b "ou=sm2ou1,$BASEDN" \
1882 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1883 if test "x$RESULT" = "xNOK" ; then
1884 echo "Change was replicated to site2 search!"
1885 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1891 echo "Using ldapsearch to check no replication to central search..."
1892 for i in 1 2 3 4 5; do
1893 RESULT=`$LDAPSEARCH -H $URI4 \
1894 -s base -b "ou=sm2ou1,$BASEDN" \
1895 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1896 if test "x$RESULT" = "xNOK" ; then
1897 echo "Change was replicated to site2 search!"
1898 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1904 echo "Checking contextCSN after modify of first backend on site2 master..."
1905 . $TESTDIR/checkcsn.sh
1909 # Test updates to the second backend on site2 master, which should only be
1910 # replicated to site2 search. As always, contextCSN should be updated
1912 MNUM=`expr $MNUM + 1`
1913 echo "Using ldapmodify to modify second backend on site2 master..."
1914 $LDAPMODIFY -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1915 dn: ou=sm2ou2,dc=example,dc=com
1918 description: Modify$MNUM
1922 if test $RC != 0 ; then
1923 echo "ldapmodify failed ($RC)!"
1924 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1929 echo "Using ldapsearch to check replication to site2 search..."
1931 for i in 1 2 3 4 5; do
1932 RESULT=`$LDAPSEARCH -H $URI6 \
1933 -s base -b "ou=sm2ou2,$BASEDN" \
1934 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1935 if test "x$RESULT$nullOK" = "xOK" ; then
1939 echo "Waiting $i seconds for syncrepl to receive changes..."
1942 if test $RC != 0 ; then
1943 echo "ldapsearch failed ($RC)!"
1944 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1948 echo "Using ldapsearch to check no replication to central master..."
1949 for i in 1 2 3 4 5; do
1950 RESULT=`$LDAPSEARCH -H $URI4 \
1951 -s base -b "ou=sm2ou2,$BASEDN" \
1952 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1953 if test "x$RESULT" = "xNOK" ; then
1954 echo "Change was replicated to central search!"
1955 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1961 echo "Checking contextCSN after modify of second backend on site2 master..."
1962 . $TESTDIR/checkcsn.sh
1965 # Test that all contextCSN values are updated on the slaves when they
1966 # starts with an empty database. Start site2 master first, then site2
1967 # search and finally central master so that the site2 search's syncrepl
1968 # connection has been set up when site2 master receives the database:
1969 echo "Stopping central master and site2 servers to test start with emtpy db..."
1970 kill -HUP $SMC_PID $SM2_PID $SS2_PID
1971 for pid in $SMC_PID $SM2_PID $SS2_PID; do wait $pid ; done
1972 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
1973 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SM2_PID / /"`;
1974 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SS2_PID / /"`;
1978 rm -rf $SM2_DIR/db/*
1979 rm -rf $SS2_DIR/db/*
1981 echo "Starting site2 master slapd on TCP/IP port $PORT3..."
1983 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1985 if test $WAIT != 0 ; then
1989 KILLPIDS="$KILLPIDS $SM2_PID"
1992 echo "Using ldapsearch to check that site2 master slapd is running..."
1993 for i in 1 2 3 4 5; do
1994 $LDAPSEARCH -s base -b "" -H $URI3 \
1995 'objectclass=*' > /dev/null 2>&1
1997 test $RC = 0 && break
1998 echo "Waiting $i seconds for slapd to start..."
2001 if test $RC != 0 ; then
2002 echo "ldapsearch failed ($RC)!"
2003 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2007 echo "Starting site2 search slapd on TCP/IP port $PORT6..."
2009 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING >> $LOG6 2>&1 &
2011 if test $WAIT != 0 ; then
2015 KILLPIDS="$KILLPIDS $SS2_PID"
2018 echo "Using ldapsearch to check that site2 search slapd is running..."
2019 for i in 1 2 3 4 5; do
2020 $LDAPSEARCH -s base -b "" -H $URI6 \
2021 'objectclass=*' > /dev/null 2>&1
2023 test $RC = 0 && break
2024 echo "Waiting $i seconds for slapd to start..."
2027 if test $RC != 0 ; then
2028 echo "ldapsearch failed ($RC)!"
2029 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2033 echo "Starting central master slapd on TCP/IP port $PORT1..."
2035 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2037 if test $WAIT != 0 ; then
2041 KILLPIDS="$KILLPIDS $SMC_PID"
2044 echo "Using ldapsearch to check that central master slapd is running..."
2045 for i in 1 2 3 4 5; do
2046 $LDAPSEARCH -s base -b "" -H $URI1 \
2047 'objectclass=*' > /dev/null 2>&1
2049 test $RC = 0 && break
2050 echo "Waiting $i seconds for slapd to start..."
2053 if test $RC != 0 ; then
2054 echo "ldapsearch failed ($RC)!"
2055 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2059 echo "Using ldapsearch to check that site2 master received base..."
2061 for i in 1 2 3 4 5; do
2062 RESULT=`$LDAPSEARCH -H $URI3 \
2063 -s base -b "$BASEDN" \
2064 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2065 if test "x$RESULT$nullOK" = "xOK" ; then
2069 echo "Waiting $i seconds for syncrepl to receive changes..."
2072 if test $RC != 0 ; then
2073 echo "ldapsearch failed ($RC)!"
2074 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2078 echo "Using ldapsearch to check that site2 search received base..."
2080 for i in 1 2 3 4 5; do
2081 RESULT=`$LDAPSEARCH -H $URI6 \
2082 -s base -b "$BASEDN" \
2083 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2084 if test "x$RESULT$nullOK" = "xOK" ; then
2088 echo "Waiting $i seconds for syncrepl to receive changes..."
2091 if test $RC != 0 ; then
2092 echo "ldapsearch failed ($RC)!"
2093 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2099 echo "Checking contextCSN after site2 servers repopulated..."
2100 . $TESTDIR/checkcsn.sh
2102 if test $ERRORS -ne 0; then
2103 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2104 echo "Found $ERRORS errors"
2109 # Adding syncrepl of the second site1 master backend on central master
2110 # will not initialize the database unless the contextCSN attribute is
2111 # stored in the suffix of the database and not the suffix of the glue
2113 echo "Adding syncrepl of second site1 master backend on central master..."
2114 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
2115 dn: olcDatabase={4}$BACKEND,cn=config
2118 olcSyncRepl: rid=4 provider=$URI2 searchbase="ou=sm1ou2,$BASEDN"
2119 binddn="ou=sm1ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
2120 type=refreshAndPersist retry="$RETRY" timeout=1
2123 if test $RC != 0 ; then
2124 echo "ldapmodify failed to add syncrepl on central master ($RC)!"
2125 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2130 echo "Using ldapsearch to check that central master received second site1 backend..."
2132 for i in 1 2 3 4 5; do
2133 RESULT=`$LDAPSEARCH -H $URI1 \
2134 -s base -b "ou=sm1ou2,$BASEDN" \
2135 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2136 if test "x$RESULT$nullOK" = "xOK" ; then
2140 echo "Waiting $i seconds for syncrepl to receive changes..."
2143 if test $RC != 0 ; then
2144 echo "ERROR: Second site1 backend not replicated to central master"
2145 ERRORS=`expr $ERRORS + 1`
2147 echo "Restarting central master slapd on TCP/IP port $PORT1..."
2150 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2153 $SLAPD -F slapd.d -h $URI1 -c rid=4,csn=0 -d $LVL $TIMING >> $LOG1 2>&1 &
2155 if test $WAIT != 0 ; then
2159 KILLPIDS="$KILLPIDS $SMC_PID"
2161 echo "Using ldapsearch to check that central master slapd is running..."
2162 for i in 1 2 3 4 5; do
2163 $LDAPSEARCH -s base -b "" -H $URI1 \
2164 'objectclass=*' > /dev/null 2>&1
2166 test $RC = 0 && break
2167 echo "Waiting $i seconds for slapd to start..."
2170 if test $RC != 0 ; then
2171 echo "ldapsearch failed ($RC)!"
2172 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2176 echo "Using ldapsearch to check that central master received second site1 backend..."
2178 for i in 1 2 3 4 5; do
2179 RESULT=`$LDAPSEARCH -H $URI1 \
2180 -s base -b "ou=sm1ou2,$BASEDN" \
2181 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2182 if test "x$RESULT$nullOK" = "xOK" ; then
2186 echo "Waiting $i seconds for syncrepl to receive changes..."
2189 if test $RC != 0 ; then
2190 echo "ldapsearch failed ($RC)!"
2191 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2196 echo "Using ldapsearch to check that central search received second site1 backend..."
2198 for i in 1 2 3 4 5; do
2199 RESULT=`$LDAPSEARCH -H $URI4 \
2200 -s base -b "ou=sm1ou2,$BASEDN" \
2201 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2202 if test "x$RESULT$nullOK" = "xOK" ; then
2206 echo "Waiting $i seconds for syncrepl to receive changes..."
2209 if test $RC != 0 ; then
2210 echo "ERROR: Second site1 backend not replicated to central search"
2211 ERRORS=`expr $ERRORS + 1`
2213 echo "Restarting central search slapd on TCP/IP port $PORT4..."
2216 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SSC_PID / /"`;
2219 $SLAPD -F slapd.d -h $URI4 -c rid=1,csn=0 -d $LVL $TIMING >> $LOG4 2>&1 &
2221 if test $WAIT != 0 ; then
2225 KILLPIDS="$KILLPIDS $SSC_PID"
2227 echo "Using ldapsearch to check that central search slapd is running..."
2228 for i in 1 2 3 4 5; do
2229 $LDAPSEARCH -s base -b "" -H $URI4 \
2230 'objectclass=*' > /dev/null 2>&1
2232 test $RC = 0 && break
2233 echo "Waiting $i seconds for slapd to start..."
2236 if test $RC != 0 ; then
2237 echo "ldapsearch failed ($RC)!"
2238 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2242 echo "Using ldapsearch to check that central search received second site1 backend..."
2244 for i in 1 2 3 4 5; do
2245 RESULT=`$LDAPSEARCH -H $URI4 \
2246 -s base -b "ou=sm1ou2,$BASEDN" \
2247 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2248 if test "x$RESULT$nullOK" = "xOK" ; then
2252 echo "Waiting $i seconds for syncrepl to receive changes..."
2255 if test $RC != 0 ; then
2256 echo "ldapsearch failed ($RC)!"
2257 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2264 # Run race tests when more than one backend is replicated from the same
2265 # provider. This will usually fail long before 100 iterations unless
2266 # syncrepl stores the contextCSN in the suffix of its own database, and
2267 # that syncprov follows these rules before updating its own CSN when it
2268 # detects updates from syncrepl:
2269 # 1) A contextCSN value must have been stored in the suffix of all the
2270 # syncrepl configured databases within the glued syncprov database.
2271 # 2) Of all contextCSN values stored by syncrepl with the same SID,
2272 # syncprov must always select the one with the lowest csn value.
2273 test -z "$RACE_TESTS" && RACE_TESTS=10
2277 SUB_DN=ou=sub,ou=sm1ou2,dc=example,dc=com
2279 while test $RACE_ERROR -eq 0 -a $RACE_NUM -lt $RACE_TESTS ; do
2280 RACE_NUM=`expr $RACE_NUM + 1`
2281 echo "Running $RACE_NUM of $RACE_TESTS syncrepl race tests..."
2283 echo "Stopping central master..."
2286 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2288 MNUM=`expr $MNUM + 1`
2289 echo "Using ldapadd to add entry on site1 master..."
2290 $LDAPADD -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
2293 objectClass: organizationalUnit
2298 if test $RC != 0 ; then
2299 echo "ldapadd failed ($RC)!"
2300 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2304 echo "Starting central master again..."
2306 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2308 KILLPIDS="$KILLPIDS $SMC_PID"
2310 echo "Using ldapsearch to check that central master received entry..."
2311 for i in 1 2 3 4 5; do
2312 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI1 > /dev/null 2>&1
2314 test $RC = 0 && break
2317 if test $RC != 0 ; then
2318 echo "ERROR: entry not replicated to central master!"
2323 echo "Using ldapsearch to check that central search received entry..."
2324 for i in 1 2 3 4 5; do
2325 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI4 > /dev/null 2>&1
2327 test $RC = 0 && break
2330 if test $RC != 0 ; then
2331 echo "ERROR: entry not replicated to central master!"
2336 echo "Stopping central master..."
2339 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2341 echo "Using ldapdelete to delete entry on site1 master..."
2342 $LDAPDELETE -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD "$SUB_DN"
2344 if test $RC != 0 ; then
2345 echo "ldapdelete failed ($RC)!"
2346 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2350 echo "Starting central master again..."
2352 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2354 KILLPIDS="$KILLPIDS $SMC_PID"
2357 echo "Using ldapsearch to check that entry was deleted on central master..."
2359 for i in 1 2 3 4 5; do
2360 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI1 > /dev/null 2>&1
2362 if test $RC = $wantNoObj; then break; fi
2366 if test $RC != $wantNoObj; then
2367 if test $RC != 0; then
2368 echo "ldapsearch failed ($RC)!"
2369 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2372 echo "ERROR: Entry not removed on central master!"
2377 echo "Using ldapsearch to check that entry was deleted on central search..."
2379 for i in 1 2 3 4 5; do
2380 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI4 > /dev/null 2>&1
2382 if test $RC != 0; then break; fi
2386 if test $RC != $wantNoObj; then
2387 echo "ERROR: Entry not removed on central search! (RC=$RC)"
2393 if test $RACE_ERROR != 0; then
2394 echo "Race error found after $RACE_NUM of $RACE_TESTS iterations"
2395 ERRORS=`expr $ERRORS + $RACE_ERROR`
2397 echo "No race errors found after $RACE_TESTS iterations"
2400 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2402 if test $ERRORS -ne 0; then
2403 echo "Found $ERRORS errors"
2404 echo ">>>>>> Exiting with a false success status for now"
2408 echo ">>>>> Test succeeded"