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.
114 case "$BACKEND" in ldif | null)
115 # LDIF lacks ACL support, NULL lacks cn=config support
116 echo "This test does not support the $BACKEND backend"
120 echo "running defines.sh"
121 . $SRCDIR/scripts/defines.sh
123 if test $SYNCPROV = syncprovno; then
124 echo "Syncrepl provider overlay not available, test skipped"
137 for dir in $SMC_DIR $SM1_DIR $SM2_DIR $SS1_DIR $SS2_DIR $SSC_DIR; do
138 mkdir -p $dir $dir/slapd.d $dir/db
141 mkdir -p $SMC_DIR/ou1 $SMC_DIR/sm1ou1 $SMC_DIR/sm1ou2
142 mkdir -p $SMC_DIR/ou2 $SMC_DIR/sm2ou1
143 mkdir -p $SM1_DIR/ou1 $SM1_DIR/sm1ou1 $SM1_DIR/sm1ou2
144 mkdir -p $SM2_DIR/ou2 $SM2_DIR/sm1ou1 $SM2_DIR/sm2ou1 $SM2_DIR/sm2ou2
150 $SLAPPASSWD -g -n >$CONFIGPWF
154 if test $WAIT != 0 ; then
160 echo "Initializing master configurations..."
161 for dir in $SMC_DIR $SM1_DIR $SM2_DIR; do
162 $SLAPADD -F $dir/slapd.d -n 0 <<EOF
164 objectClass: olcGlobal
168 dn: olcDatabase={0}config,cn=config
169 objectClass: olcDatabaseConfig
170 olcDatabase: {0}config
171 olcRootPW:< file://$CONFIGPWF
177 echo "Initializing search configurations..."
178 for dir in $SS1_DIR $SS2_DIR $SSC_DIR; do
179 $SLAPADD -F $dir/slapd.d -n 0 <<EOF
181 objectClass: olcGlobal
184 dn: olcDatabase={0}config,cn=config
185 objectClass: olcDatabaseConfig
186 olcDatabase: {0}config
187 olcRootPW:< file://$CONFIGPWF
192 echo "Starting central master slapd on TCP/IP port $PORT1..."
194 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
196 if test $WAIT != 0 ; then
200 KILLPIDS="$KILLPIDS $SMC_PID"
203 echo "Using ldapsearch to check that central master slapd is running..."
204 for i in 1 2 3 4 5; do
205 $LDAPSEARCH -s base -b "" -H $URI1 \
206 'objectclass=*' > /dev/null 2>&1
208 test $RC = 0 && break
209 echo "Waiting $i seconds for slapd to start..."
212 if test $RC != 0 ; then
213 echo "ldapsearch failed ($RC)!"
214 test $KILLSERVERS != no && kill -HUP $KILLPIDS
218 echo "Starting site1 master slapd on TCP/IP port $PORT2..."
220 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
222 if test $WAIT != 0 ; then
226 KILLPIDS="$KILLPIDS $SM1_PID"
229 echo "Using ldapsearch to check that site1 master is running..."
230 for i in 1 2 3 4 5; do
231 $LDAPSEARCH -s base -b "" -H $URI2 \
232 'objectclass=*' > /dev/null 2>&1
234 test $RC = 0 && break
235 echo "Waiting $i seconds for slapd to start..."
238 if test $RC != 0 ; then
239 echo "ldapsearch failed ($RC)!"
240 test $KILLSERVERS != no && kill -HUP $KILLPIDS
244 echo "Starting site2 master slapd on TCP/IP port $PORT3..."
246 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
248 if test $WAIT != 0 ; then
252 KILLPIDS="$KILLPIDS $SM2_PID"
255 echo "Using ldapsearch to check that site2 master is running..."
256 for i in 1 2 3 4 5; do
257 $LDAPSEARCH -s base -b "" -H $URI3 \
258 'objectclass=*' > /dev/null 2>&1
260 test $RC = 0 && break
261 echo "Waiting $i seconds for slapd to start..."
264 if test $RC != 0 ; then
265 echo "ldapsearch failed ($RC)!"
266 test $KILLSERVERS != no && kill -HUP $KILLPIDS
270 echo "Starting central search slapd on TCP/IP port $PORT4..."
272 $SLAPD -F slapd.d -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
274 if test $WAIT != 0 ; then
278 KILLPIDS="$KILLPIDS $SSC_PID"
281 echo "Using ldapsearch to check that central search slapd is running..."
282 for i in 1 2 3 4 5; do
283 $LDAPSEARCH -s base -b "" -H $URI4 \
284 'objectclass=*' > /dev/null 2>&1
286 test $RC = 0 && break
287 echo "Waiting $i seconds for slapd to start..."
290 if test $RC != 0 ; then
291 echo "ldapsearch failed ($RC)!"
292 test $KILLSERVERS != no && kill -HUP $KILLPIDS
297 echo "Starting site1 search slapd on TCP/IP port $PORT5..."
299 $SLAPD -F slapd.d -h $URI5 -d $LVL $TIMING > $LOG5 2>&1 &
301 if test $WAIT != 0 ; then
305 KILLPIDS="$KILLPIDS $SS1_PID"
308 echo "Using ldapsearch to check that site1 search slapd is running..."
309 for i in 1 2 3 4 5; do
310 $LDAPSEARCH -s base -b "" -H $URI5 \
311 'objectclass=*' > /dev/null 2>&1
313 test $RC = 0 && break
314 echo "Waiting $i seconds for slapd to start..."
317 if test $RC != 0 ; then
318 echo "ldapsearch failed ($RC)!"
319 test $KILLSERVERS != no && kill -HUP $KILLPIDS
324 echo "Starting site2 search slapd on TCP/IP port $PORT6..."
326 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING > $LOG6 2>&1 &
328 if test $WAIT != 0 ; then
332 KILLPIDS="$KILLPIDS $SS2_PID"
335 echo "Using ldapsearch to check that site2 search slapd is running..."
336 for i in 1 2 3 4 5; do
337 $LDAPSEARCH -s base -b "" -H $URI6 \
338 'objectclass=*' > /dev/null 2>&1
340 test $RC = 0 && break
341 echo "Waiting $i seconds for slapd to start..."
344 if test $RC != 0 ; then
345 echo "ldapsearch failed ($RC)!"
346 test $KILLSERVERS != no && kill -HUP $KILLPIDS
350 for uri in $URI1 $URI2 $URI3 $URI4 $URI5 $URI6; do
351 echo "Adding schema on $uri..."
352 $LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
353 include: file://$ABS_SCHEMADIR/core.ldif
355 include: file://$ABS_SCHEMADIR/cosine.ldif
357 include: file://$ABS_SCHEMADIR/inetorgperson.ldif
359 include: file://$ABS_SCHEMADIR/openldap.ldif
361 include: file://$ABS_SCHEMADIR/nis.ldif
364 if test $RC != 0 ; then
365 echo "ldapadd failed for schema config ($RC)!"
366 test $KILLSERVERS != no && kill -HUP $KILLPIDS
370 [ "$BACKENDTYPE" = mod ] || continue
372 echo "Adding backend module on $uri..."
373 $LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
374 dn: cn=module,cn=config
375 objectClass: olcModuleList
377 olcModulePath: ../../../servers/slapd/back-$BACKEND
378 olcModuleLoad: back_$BACKEND.la
381 if test $RC != 0 ; then
382 echo "ldapadd failed for backend module ($RC)!"
383 test $KILLSERVERS != no && kill -HUP $KILLPIDS
388 echo "Adding database config on central master..."
389 if [ "$SYNCPROV" = syncprovmod ]; then
390 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
391 dn: cn=module,cn=config
392 objectClass: olcModuleList
394 olcModulePath: ../../../servers/slapd/overlays
395 olcModuleLoad: syncprov.la
399 if test $RC != 0 ; then
400 echo "ldapadd failed for moduleLoad ($RC)!"
401 test $KILLSERVERS != no && kill -HUP $KILLPIDS
406 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
407 dn: olcDatabase={1}$BACKEND,cn=config
408 objectClass: olcDatabaseConfig
409 objectClass: olc${BACKEND}Config
410 olcDatabase: {1}$BACKEND
411 olcDbDirectory: $SMC_DIR/db
413 olcRootDN: $MANAGERDN
416 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
417 objectClass: olcOverlayConfig
420 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
421 objectClass: olcOverlayConfig
422 objectClass: olcSyncProvConfig
423 olcOverlay: {1}syncprov
426 dn: olcDatabase={1}$BACKEND,cn=config
427 objectClass: olcDatabaseConfig
428 objectClass: olc${BACKEND}Config
429 olcDatabase: {1}$BACKEND
430 olcDbDirectory: $SMC_DIR/ou1
432 olcSuffix: ou=ou1,$BASEDN
433 olcRootDN: $MANAGERDN
435 dn: olcDatabase={2}$BACKEND,cn=config
436 objectClass: olcDatabaseConfig
437 objectClass: olc${BACKEND}Config
438 olcDatabase: {2}$BACKEND
439 olcDbDirectory: $SMC_DIR/ou2
441 olcSuffix: ou=ou2,$BASEDN
442 olcRootDN: $MANAGERDN
444 dn: olcDatabase={3}$BACKEND,cn=config
445 objectClass: olcDatabaseConfig
446 objectClass: olc${BACKEND}Config
447 olcDatabase: {3}$BACKEND
448 olcDbDirectory: $SMC_DIR/sm1ou1
450 olcSuffix: ou=sm1ou1,$BASEDN
453 dn: olcDatabase={4}$BACKEND,cn=config
454 objectClass: olcDatabaseConfig
455 objectClass: olc${BACKEND}Config
456 olcDatabase: {4}$BACKEND
457 olcDbDirectory: $SMC_DIR/sm1ou2
459 olcSuffix: ou=sm1ou2,$BASEDN
462 dn: olcDatabase={5}$BACKEND,cn=config
463 objectClass: olcDatabaseConfig
464 objectClass: olc${BACKEND}Config
465 olcDatabase: {5}$BACKEND
466 olcDbDirectory: $SMC_DIR/sm2ou1
468 olcSuffix: ou=sm2ou1,$BASEDN
473 if test $RC != 0 ; then
474 echo "ldapadd failed for central master database config ($RC)!"
475 test $KILLSERVERS != no && kill -HUP $KILLPIDS
479 echo "Adding database config on site1 master..."
480 if [ "$SYNCPROV" = syncprovmod ]; then
481 $LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
482 dn: cn=module,cn=config
483 objectClass: olcModuleList
485 olcModulePath: ../../../servers/slapd/overlays
486 olcModuleLoad: syncprov.la
490 if test $RC != 0 ; then
491 echo "ldapadd failed for moduleLoad ($RC)!"
492 test $KILLSERVERS != no && kill -HUP $KILLPIDS
497 $LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
498 dn: olcDatabase={1}$BACKEND,cn=config
499 objectClass: olcDatabaseConfig
500 objectClass: olc${BACKEND}Config
501 olcDatabase: {1}$BACKEND
502 olcDbDirectory: $SM1_DIR/db
506 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
507 objectClass: olcOverlayConfig
510 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
511 objectClass: olcOverlayConfig
512 objectClass: olcSyncProvConfig
513 olcOverlay: {1}syncprov
515 dn: olcDatabase={1}$BACKEND,cn=config
516 objectClass: olcDatabaseConfig
517 objectClass: olc${BACKEND}Config
518 olcDatabase: {1}$BACKEND
519 olcDbDirectory: $SM1_DIR/ou1
521 olcSuffix: ou=ou1,$BASEDN
524 dn: olcDatabase={2}$BACKEND,cn=config
525 objectClass: olcDatabaseConfig
526 objectClass: olc${BACKEND}Config
527 olcDatabase: {2}$BACKEND
528 olcDbDirectory: $SM1_DIR/sm1ou1
530 olcSuffix: ou=sm1ou1,$BASEDN
531 olcRootDN: ou=sm1ou1,$BASEDN
534 dn: olcDatabase={3}$BACKEND,cn=config
535 objectClass: olcDatabaseConfig
536 objectClass: olc${BACKEND}Config
537 olcDatabase: {3}$BACKEND
538 olcDbDirectory: $SM1_DIR/sm1ou2
540 olcSuffix: ou=sm1ou2,$BASEDN
541 olcRootDN: ou=sm1ou1,$BASEDN
546 if test $RC != 0 ; then
547 echo "ldapadd failed for site1 master database config ($RC)!"
548 test $KILLSERVERS != no && kill -HUP $KILLPIDS
552 echo "Adding database config on site2 master..."
553 if [ "$SYNCPROV" = syncprovmod ]; then
554 $LDAPADD -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
555 dn: cn=module,cn=config
556 objectClass: olcModuleList
558 olcModulePath: ../../../servers/slapd/overlays
559 olcModuleLoad: syncprov.la
563 if test $RC != 0 ; then
564 echo "ldapadd failed for moduleLoad ($RC)!"
565 test $KILLSERVERS != no && kill -HUP $KILLPIDS
570 $LDAPADD -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
571 dn: olcDatabase={1}$BACKEND,cn=config
572 objectClass: olcDatabaseConfig
573 objectClass: olc${BACKEND}Config
574 olcDatabase: {1}$BACKEND
575 olcDbDirectory: $SM2_DIR/db
579 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
580 objectClass: olcOverlayConfig
583 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
584 objectClass: olcOverlayConfig
585 objectClass: olcSyncProvConfig
586 olcOverlay: {1}syncprov
589 dn: olcDatabase={1}$BACKEND,cn=config
590 objectClass: olcDatabaseConfig
591 objectClass: olc${BACKEND}Config
592 olcDatabase: {1}$BACKEND
593 olcDbDirectory: $SM2_DIR/ou2
595 olcSuffix: ou=ou2,$BASEDN
598 dn: olcDatabase={2}$BACKEND,cn=config
599 objectClass: olcDatabaseConfig
600 objectClass: olc${BACKEND}Config
601 olcDatabase: {2}$BACKEND
602 olcDbDirectory: $SM2_DIR/sm1ou1
604 olcSuffix: ou=sm1ou1,$BASEDN
607 dn: olcDatabase={3}$BACKEND,cn=config
608 objectClass: olcDatabaseConfig
609 objectClass: olc${BACKEND}Config
610 olcDatabase: {3}$BACKEND
611 olcDbDirectory: $SM2_DIR/sm2ou1
613 olcSuffix: ou=sm2ou1,$BASEDN
614 olcRootDN: ou=sm2ou1,$BASEDN
617 dn: olcDatabase={4}$BACKEND,cn=config
618 objectClass: olcDatabaseConfig
619 objectClass: olc${BACKEND}Config
620 olcDatabase: {4}$BACKEND
621 olcDbDirectory: $SM2_DIR/sm2ou2
623 olcSuffix: ou=sm2ou2,$BASEDN
624 olcRootDN: ou=sm2ou1,$BASEDN
629 if test $RC != 0 ; then
630 echo "ldapadd failed for site2 master database config ($RC)!"
631 test $KILLSERVERS != no && kill -HUP $KILLPIDS
635 echo "Adding access rules on central master..."
636 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
637 dn: olcDatabase={-1}frontend,cn=config
640 olcAccess: to dn.exact=dc=example,dc=com
642 olcAccess: to dn.subtree=ou=ou1,dc=example,dc=com
644 olcAccess: to dn.subtree=ou=ou2,dc=example,dc=com
645 by dn.exact=ou=ou1,dc=example,dc=com none
646 by dn.exact=ou=ou2,dc=example,dc=com read
647 by dn.exact=dc=example,dc=com none
649 olcAccess: to dn.subtree=ou=sm1ou1,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=sm1ou2,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 none
657 by dn.exact=dc=example,dc=com read
659 olcAccess: to dn.subtree=ou=sm2ou1,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 none
664 olcAccess: to * by * read
668 if test $RC != 0 ; then
669 echo "ldapmodify failed for central master access config ($RC)!"
670 test $KILLSERVERS != no && kill -HUP $KILLPIDS
674 echo "Adding access rules on site1 master..."
675 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
676 dn: olcDatabase={-1}frontend,cn=config
679 olcAccess: to dn.subtree=dc=example,dc=com
681 olcAccess: to * by * read
685 if test $RC != 0 ; then
686 echo "ldapmodify failed for site1 master access config ($RC)!"
687 test $KILLSERVERS != no && kill -HUP $KILLPIDS
691 echo "Adding access rules on site2 master..."
692 $LDAPMODIFY -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
693 dn: olcDatabase={-1}frontend,cn=config
696 olcAccess: to dn.exact=dc=example,dc=com
698 olcAccess: to dn.subtree=ou=ou2,dc=example,dc=com
700 olcAccess: to dn.subtree=ou=sm1ou1,dc=example,dc=com
703 olcAccess: to dn.subtree=ou=sm2ou1,dc=example,dc=com
705 olcAccess: to dn.subtree=ou=sm2ou2,dc=example,dc=com
706 by dn.exact=dc=example,dc=com read
709 olcAccess: to * by * read
713 if test $RC != 0 ; then
714 echo "ldapmodify failed for site2 master access config ($RC)!"
715 test $KILLSERVERS != no && kill -HUP $KILLPIDS
719 echo "Adding database config on central search..."
720 $LDAPADD -D cn=config -H $URI4 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
721 dn: olcDatabase={1}$BACKEND,cn=config
722 objectClass: olcDatabaseConfig
723 objectClass: olc${BACKEND}Config
724 olcDatabase: {1}$BACKEND
725 olcDbDirectory: $SSC_DIR/db
731 if test $RC != 0 ; then
732 echo "ldapadd failed for central search database config ($RC)!"
733 test $KILLSERVERS != no && kill -HUP $KILLPIDS
737 echo "Adding database config on site1 search..."
738 $LDAPADD -D cn=config -H $URI5 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
739 dn: olcDatabase={1}$BACKEND,cn=config
740 objectClass: olcDatabaseConfig
741 objectClass: olc${BACKEND}Config
742 olcDatabase: {1}$BACKEND
743 olcDbDirectory: $SS1_DIR/db
749 if test $RC != 0 ; then
750 echo "ldapadd failed for site1 search database config ($RC)!"
751 test $KILLSERVERS != no && kill -HUP $KILLPIDS
755 echo "Adding database config on site2 search..."
756 $LDAPADD -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
757 dn: olcDatabase={1}$BACKEND,cn=config
758 objectClass: olcDatabaseConfig
759 objectClass: olc${BACKEND}Config
760 olcDatabase: {1}$BACKEND
761 olcDbDirectory: $SS2_DIR/db
767 if test $RC != 0 ; then
768 echo "ldapadd failed for site2 search database config ($RC)!"
769 test $KILLSERVERS != no && kill -HUP $KILLPIDS
773 echo "Populating central master..."
774 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
775 dn: dc=example,dc=com
777 objectClass: organization
778 objectClass: dcObject
781 userPassword: $PASSWD
783 dn: ou=ou1,dc=example,dc=com
785 objectClass: organizationalUnit
787 userPassword: $PASSWD
789 dn: ou=ou2,dc=example,dc=com
791 objectClass: organizationalUnit
793 userPassword: $PASSWD
797 if test $RC != 0 ; then
798 echo "ldapadd failed to populate central master entry ($RC)!"
799 test $KILLSERVERS != no && kill -HUP $KILLPIDS
803 echo "Adding syncrepl on site1 master..."
804 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
805 dn: olcDatabase={4}$BACKEND,cn=config
808 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
809 binddn="ou=ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
810 type=refreshAndPersist retry="$RETRY" timeout=1
814 if test $RC != 0 ; then
815 echo "ldapmodify failed to add syncrepl on site1 master ($RC)!"
816 test $KILLSERVERS != no && kill -HUP $KILLPIDS
820 echo "Adding syncrepl on site2 master..."
821 $LDAPMODIFY -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
822 dn: olcDatabase={5}$BACKEND,cn=config
825 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
826 binddn="ou=ou2,$BASEDN" bindmethod=simple credentials=$PASSWD
827 type=refreshAndPersist retry="$RETRY" timeout=1
831 if test $RC != 0 ; then
832 echo "ldapmodify failed to add syncrepl on site2 master ($RC)!"
833 test $KILLSERVERS != no && kill -HUP $KILLPIDS
838 echo "Using ldapsearch to check that site1 master received changes..."
840 for i in 1 2 3 4 5; do
841 RESULT=`$LDAPSEARCH -H $URI2 \
842 -s base -b "ou=ou1,$BASEDN" \
843 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
844 if test "x$RESULT" = "xOK" ; then
848 echo "Waiting $i seconds for syncrepl to receive changes..."
851 if test $RC != 0 ; then
852 echo "ldapsearch failed ($RC)!"
853 test $KILLSERVERS != no && kill -HUP $KILLPIDS
857 echo "Using ldapsearch to check that site2 master received changes..."
859 for i in 1 2 3 4 5; do
860 RESULT=`$LDAPSEARCH -H $URI3 \
861 -s base -b "ou=ou1,$BASEDN" \
862 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
863 if test "x$RESULT" = "xOK" ; then
867 echo "Waiting $i seconds for syncrepl to receive changes..."
870 if test $RC != 0 ; then
871 echo "ldapsearch failed ($RC)!"
872 test $KILLSERVERS != no && kill -HUP $KILLPIDS
878 echo "Populating site1 master..."
879 $LDAPADD -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
880 dn: ou=sm1ou1,dc=example,dc=com
882 objectClass: organizationalUnit
885 dn: ou=sm1ou2,dc=example,dc=com
887 objectClass: organizationalUnit
892 if test $RC != 0 ; then
893 echo "ldapadd failed to populate site1 master ($RC)!"
894 test $KILLSERVERS != no && kill -HUP $KILLPIDS
900 echo "Populating site2 master..."
901 $LDAPADD -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
902 dn: ou=sm2ou1,dc=example,dc=com
904 objectClass: organizationalUnit
907 dn: ou=sm2ou2,dc=example,dc=com
909 objectClass: organizationalUnit
914 if test $RC != 0 ; then
915 echo "ldapadd failed to populate site2 master ($RC)!"
916 test $KILLSERVERS != no && kill -HUP $KILLPIDS
923 # Stop site1 master when adding syncrepl to the central master. When
924 # site1 master is started again both it and the central master will have
925 # the same number of contextCSN values, but the ones on central master
926 # will be the newest. The central master will not update its contextCSN
927 # values unless the bug in ITS#5597 have been fixed.
928 echo "Stopping site1 master..."
931 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SM1_PID / /"`;
934 echo "Adding syncrepl on central master..."
935 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
936 dn: olcDatabase={3}$BACKEND,cn=config
939 olcSyncRepl: rid=3 provider=$URI2 searchbase="ou=sm1ou1,$BASEDN"
940 binddn="ou=sm1ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
941 type=refreshAndPersist retry="$RETRY" timeout=1
943 dn: olcDatabase={5}$BACKEND,cn=config
946 olcSyncRepl: rid=5 provider=$URI3 searchbase="ou=sm2ou1,$BASEDN"
947 binddn="ou=sm2ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
948 type=refreshAndPersist retry="$RETRY" timeout=1
952 if test $RC != 0 ; then
953 echo "ldapmodify failed to add syncrepl on central master ($RC)!"
954 test $KILLSERVERS != no && kill -HUP $KILLPIDS
958 echo "Using ldapsearch to check that central master received site2 entries..."
960 for i in 1 2 3 4 5; do
961 RESULT=`$LDAPSEARCH -H $URI1 \
962 -s base -b "ou=sm2ou1,$BASEDN" \
963 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
964 if test "x$RESULT" = "xOK" ; then
968 echo "Waiting $i seconds for syncrepl to receive changes..."
971 if test $RC != 0 ; then
972 echo "ldapsearch failed ($RC)!"
973 test $KILLSERVERS != no && kill -HUP $KILLPIDS
977 if test -z "$SM1_PID" ; then
978 echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
980 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
982 if test $WAIT != 0 ; then
986 KILLPIDS="$KILLPIDS $SM1_PID"
991 echo "Using ldapsearch to check that site1 master is running..."
992 for i in 1 2 3 4 5; do
993 $LDAPSEARCH -s base -b "" -H $URI2 \
994 'objectclass=*' > /dev/null 2>&1
996 test $RC = 0 && break
997 echo "Waiting $i seconds for slapd to start..."
1000 if test $RC != 0 ; then
1001 echo "ldapsearch failed ($RC)!"
1002 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1006 echo "Using ldapsearch to check that central master received site1 entries..."
1008 for i in 1 2 3 4 5; do
1009 RESULT=`$LDAPSEARCH -H $URI1 \
1010 -s base -b "ou=sm1ou1,$BASEDN" \
1011 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1012 if test "x$RESULT" = "xOK" ; then
1016 echo "Waiting $i seconds for syncrepl to receive changes..."
1019 if test $RC != 0 ; then
1020 echo "ldapsearch failed ($RC)!"
1021 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1025 # Test done, now some more intialization...
1027 echo "Adding syncrepl consumer on central search..."
1028 $LDAPMODIFY -D cn=config -H $URI4 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1029 dn: olcDatabase={1}$BACKEND,cn=config
1032 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
1033 binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1034 type=refreshAndPersist retry="$RETRY" timeout=1
1038 if test $RC != 0 ; then
1039 echo "ldapmodify failed to add syncrepl on site1 search ($RC)!"
1040 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1044 echo "Adding syncrepl consumer on site1 search..."
1045 $LDAPMODIFY -D cn=config -H $URI5 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1046 dn: olcDatabase={1}$BACKEND,cn=config
1049 olcSyncRepl: rid=1 provider=$URI2 searchbase="$BASEDN"
1050 binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1051 type=refreshAndPersist retry="$RETRY" timeout=1
1055 if test $RC != 0 ; then
1056 echo "ldapmodify failed to add syncrepl on site1 search ($RC)!"
1057 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1061 echo "Adding syncrepl consumer on site2 search..."
1062 $LDAPMODIFY -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1063 dn: olcDatabase={1}$BACKEND,cn=config
1066 olcSyncRepl: rid=1 provider=$URI3 searchbase="$BASEDN"
1067 binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1068 type=refreshAndPersist retry="$RETRY" timeout=1
1072 if test $RC != 0 ; then
1073 echo "ldapmodify failed to add syncrepl on site2 search ($RC)!"
1074 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1079 echo "Using ldapsearch to check that central search received changes..."
1081 for i in 1 2 3 4 5; do
1082 RESULT=`$LDAPSEARCH -H $URI4 \
1083 -s base -b "$BASEDN" \
1084 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1085 if test "x$RESULT" = "xOK" ; then
1089 echo "Waiting $i seconds for syncrepl to receive changes..."
1092 if test $RC != 0 ; then
1093 echo "ldapsearch failed ($RC)!"
1094 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1098 echo "Using ldapsearch to check that site1 search received changes..."
1100 for i in 1 2 3 4 5; do
1101 RESULT=`$LDAPSEARCH -H $URI5 \
1102 -s base -b "$BASEDN" \
1103 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1104 if test "x$RESULT" = "xOK" ; then
1108 echo "Waiting $i seconds for syncrepl to receive changes..."
1111 if test $RC != 0 ; then
1112 echo "ldapsearch failed ($RC)!"
1113 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1117 echo "Using ldapsearch to check that site2 search received changes..."
1119 for i in 1 2 3 4 5; do
1120 RESULT=`$LDAPSEARCH -H $URI6 \
1121 -s base -b "$BASEDN" \
1122 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1123 if test "x$RESULT" = "xOK" ; then
1127 echo "Waiting $i seconds for syncrepl to receive changes..."
1130 if test $RC != 0 ; then
1131 echo "ldapsearch failed ($RC)!"
1132 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1136 # Create a script that will check the contextCSN values of all servers,
1137 # and restart them to re-synchronize if it finds any errors:
1138 cat > $TESTDIR/checkcsn.sh <<'EOF'
1143 CSN1=`$LDAPSEARCH -H $URI1 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1144 CSN2=`$LDAPSEARCH -H $URI2 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1145 CSN3=`$LDAPSEARCH -H $URI3 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1146 CSN4=`$LDAPSEARCH -H $URI4 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1147 CSN5=`$LDAPSEARCH -H $URI5 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1148 CSN6=`$LDAPSEARCH -H $URI6 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1150 if test -z "$CSN1" ; then
1151 echo "ERROR: contextCSN empty on central master"
1152 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1154 nCSN=`echo "$CSN1" | wc -l`
1155 if test "$nCSN" -ne 3 ; then
1156 echo "ERROR: Wrong contextCSN count on central master, should be 3"
1157 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1158 if test -n "$CSN_VERBOSE"; then
1162 if test -z "$CSN2" -o "$CSN1" != "$CSN2" ; then
1163 echo "ERROR: contextCSN mismatch between central master and site1 master"
1164 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1165 if test -n "$CSN_VERBOSE"; then
1166 echo "contextCSN on central master:"
1168 echo "contextCSN on site1 master:"
1172 if test -z "$CSN3" -o "$CSN1" != "$CSN3" ; then
1173 echo "ERROR: contextCSN mismatch between central master and site2 master"
1174 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1175 if test -n "$CSN_VERBOSE"; then
1176 echo "contextCSN on central master:"
1178 echo "contextCSN on site2 master:"
1182 if test -z "$CSN4" -o "$CSN1" != "$CSN4" ; then
1183 echo "ERROR: contextCSN mismatch between central master and central search"
1184 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1185 if test -n "$CSN_VERBOSE"; then
1186 echo "contextCSN on central master:"
1188 echo "contextCSN on central search:"
1192 if test -z "$CSN5" -o "$CSN2" != "$CSN5" ; then
1193 echo "ERROR: contextCSN mismatch between site1 master and site1 search"
1194 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1195 if test -n "$CSN_VERBOSE"; then
1196 echo "contextCSN on site1 master:"
1198 echo "contextCSN on site1 search:"
1202 if test -z "$CSN6" -o "$CSN3" != "$CSN6" ; then
1203 echo "ERROR: contextCSN mismatch between site2 master and site2 search:"
1204 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1205 if test -n "$CSN_VERBOSE"; then
1206 echo "contextCSN on site2 master:"
1208 echo "contextCSN on site2 search:"
1213 if test $CSN_ERRORS != 0 ; then
1214 echo "Stopping all servers to synchronize contextCSN..."
1216 for pid in $KILLPIDS ; do wait $pid ; done
1219 echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
1221 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
1223 if test $WAIT != 0 ; then
1227 KILLPIDS="$KILLPIDS $SM1_PID"
1230 echo "Using ldapsearch to check that site1 master is running..."
1231 for i in 1 2 3 4 5; do
1232 $LDAPSEARCH -s base -b "" -H $URI2 \
1233 'objectclass=*' > /dev/null 2>&1
1235 test $RC = 0 && break
1236 echo "Waiting $i seconds for slapd to start..."
1239 if test $RC != 0 ; then
1240 echo "ldapsearch failed ($RC)!"
1241 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1245 echo "Restarting site2 master slapd on TCP/IP port $PORT3..."
1247 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1249 if test $WAIT != 0 ; then
1253 KILLPIDS="$KILLPIDS $SM2_PID "
1256 echo "Using ldapsearch to check that site2 master is running..."
1257 for i in 1 2 3 4 5; do
1258 $LDAPSEARCH -s base -b "" -H $URI3 \
1259 'objectclass=*' > /dev/null 2>&1
1261 test $RC = 0 && break
1262 echo "Waiting $i seconds for slapd to start..."
1265 if test $RC != 0 ; then
1266 echo "ldapsearch failed ($RC)!"
1267 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1271 echo "Restarting central master slapd on TCP/IP port $PORT1..."
1273 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
1275 if test $WAIT != 0 ; then
1279 KILLPIDS="$KILLPIDS $SMC_PID"
1282 echo "Using ldapsearch to check that central master slapd is running..."
1283 for i in 1 2 3 4 5; do
1284 $LDAPSEARCH -s base -b "" -H $URI1 \
1285 'objectclass=*' > /dev/null 2>&1
1287 test $RC = 0 && break
1288 echo "Waiting $i seconds for slapd to start..."
1291 if test $RC != 0 ; then
1292 echo "ldapsearch failed ($RC)!"
1293 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1297 echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1300 echo "Stopping site1 and site2 master..."
1301 kill -HUP $SM1_PID $SM2_PID
1302 for pid in $SM1_PID $SM2_PID ; do wait $pid ; done
1303 KILLPIDS=" $SMC_PID"
1305 echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
1307 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
1309 if test $WAIT != 0 ; then
1313 KILLPIDS="$KILLPIDS $SM1_PID"
1316 echo "Using ldapsearch to check that site1 master is running..."
1317 for i in 1 2 3 4 5; do
1318 $LDAPSEARCH -s base -b "" -H $URI2 \
1319 'objectclass=*' > /dev/null 2>&1
1321 test $RC = 0 && break
1322 echo "Waiting $i seconds for slapd to start..."
1325 if test $RC != 0 ; then
1326 echo "ldapsearch failed ($RC)!"
1327 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1331 echo "Restarting site2 master slapd on TCP/IP port $PORT3..."
1333 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1335 if test $WAIT != 0 ; then
1339 KILLPIDS="$KILLPIDS $SM2_PID"
1342 echo "Using ldapsearch to check that site2 master is running..."
1343 for i in 1 2 3 4 5; do
1344 $LDAPSEARCH -s base -b "" -H $URI3 \
1345 'objectclass=*' > /dev/null 2>&1
1347 test $RC = 0 && break
1348 echo "Waiting $i seconds for slapd to start..."
1351 if test $RC != 0 ; then
1352 echo "ldapsearch failed ($RC)!"
1353 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1357 echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1360 echo "Restarting central search slapd on TCP/IP port $PORT4..."
1362 $SLAPD -F slapd.d -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
1364 if test $WAIT != 0 ; then
1368 KILLPIDS="$KILLPIDS $SSC_PID"
1371 echo "Using ldapsearch to check that central search slapd is running..."
1372 for i in 1 2 3 4 5; do
1373 $LDAPSEARCH -s base -b "" -H $URI4 \
1374 'objectclass=*' > /dev/null 2>&1
1376 test $RC = 0 && break
1377 echo "Waiting $i seconds for slapd to start..."
1380 if test $RC != 0 ; then
1381 echo "ldapsearch failed ($RC)!"
1382 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1386 echo "Restarting site1 search slapd on TCP/IP port $PORT5..."
1388 $SLAPD -F slapd.d -h $URI5 -d $LVL $TIMING >> $LOG5 2>&1 &
1390 if test $WAIT != 0 ; then
1394 KILLPIDS="$KILLPIDS $SS1_PID"
1397 echo "Using ldapsearch to check that site1 search slapd is running..."
1398 for i in 1 2 3 4 5; do
1399 $LDAPSEARCH -s base -b "" -H $URI5 \
1400 'objectclass=*' > /dev/null 2>&1
1402 test $RC = 0 && break
1403 echo "Waiting $i seconds for slapd to start..."
1406 if test $RC != 0 ; then
1407 echo "ldapsearch failed ($RC)!"
1408 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1412 echo "Restarting site2 search slapd on TCP/IP port $PORT6..."
1414 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING >> $LOG6 2>&1 &
1416 if test $WAIT != 0 ; then
1420 KILLPIDS="$KILLPIDS $SS2_PID"
1423 echo "Using ldapsearch to check that site2 search slapd is running..."
1424 for i in 1 2 3 4 5; do
1425 $LDAPSEARCH -s base -b "" -H $URI6 \
1426 'objectclass=*' > /dev/null 2>&1
1428 test $RC = 0 && break
1429 echo "Waiting $i seconds for slapd to start..."
1432 if test $RC != 0 ; then
1433 echo "ldapsearch failed ($RC)!"
1434 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1438 echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1441 echo "Checking contextCSN after restart..."
1442 CSN1=`$LDAPSEARCH -H $URI1 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1443 CSN2=`$LDAPSEARCH -H $URI2 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1444 CSN3=`$LDAPSEARCH -H $URI3 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1445 CSN4=`$LDAPSEARCH -H $URI4 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1446 CSN5=`$LDAPSEARCH -H $URI5 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1447 CSN6=`$LDAPSEARCH -H $URI6 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1448 if test -z "$CSN1" ; then
1449 echo "ERROR: contextCSN empty on central master"
1450 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1453 if test -z "$CSN2" -o "$CSN1" != "$CSN2" ; then
1454 echo "ERROR: contextCSN mismatch between central master and site1 master"
1455 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1456 if test -n "$CSN_VERBOSE"; then
1457 echo "contextCSN on central master:"
1459 echo "contextCSN on site1 master:"
1463 if test -z "$CSN3" -o "$CSN1" != "$CSN3" ; then
1464 echo "ERROR: contextCSN mismatch between central master and site2 master"
1465 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1466 if test -n "$CSN_VERBOSE"; then
1467 echo "contextCSN on central master:"
1469 echo "contextCSN on site2 master:"
1473 if test -z "$CSN4" -o "$CSN1" != "$CSN4" ; then
1474 echo "ERROR: contextCSN mismatch between central master and central search"
1475 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1476 if test -n "$CSN_VERBOSE"; then
1477 echo "contextCSN on central master:"
1479 echo "contextCSN on central search:"
1483 if test -z "$CSN5" -o "$CSN2" != "$CSN5" ; then
1484 echo "ERROR: contextCSN mismatch between site1 master and site1 search"
1485 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1486 if test -n "$CSN_VERBOSE"; then
1487 echo "contextCSN on site1 master:"
1489 echo "contextCSN on site1 search:"
1493 if test -z "$CSN6" -o "$CSN3" != "$CSN6" ; then
1494 echo "ERROR: contextCSN mismatch between site2 master and site2 search:"
1495 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1496 if test -n "$CSN_VERBOSE"; then
1497 echo "contextCSN on site2 master:"
1499 echo "contextCSN on site2 search:"
1505 ERRORS=`expr $ERRORS + $CSN_ERRORS`
1509 chmod +x $TESTDIR/checkcsn.sh
1512 echo "Checking contextCSN after initial replication..."
1513 . $TESTDIR/checkcsn.sh
1518 # Test that updates to the first backend on central master, which should
1519 # be replicated to all servers actually is so, and that the contextCSN is
1520 # updated everywhere:
1521 echo "Using ldapmodify to modify first backend on central master..."
1522 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1523 dn: ou=ou1,dc=example,dc=com
1526 description: Modify$MNUM
1530 if test $RC != 0 ; then
1531 echo "ldapmodify failed ($RC)!"
1532 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1537 echo "Using ldapsearch to check replication to central search..."
1539 for i in 1 2 3 4 5; do
1540 RESULT=`$LDAPSEARCH -H $URI4 \
1541 -s base -b "ou=ou1,$BASEDN" \
1542 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1543 if test "x$RESULT" = "xOK" ; then
1547 echo "Waiting $i seconds for syncrepl to receive changes..."
1550 if test $RC != 0 ; then
1551 echo "ldapsearch failed ($RC)!"
1552 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1556 echo "Using ldapsearch to check replication to site1 search..."
1558 for i in 1 2 3 4 5; do
1559 RESULT=`$LDAPSEARCH -H $URI5 \
1560 -s base -b "ou=ou1,$BASEDN" \
1561 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1562 if test "x$RESULT" = "xOK" ; then
1566 echo "Waiting $i seconds for syncrepl to receive changes..."
1569 if test $RC != 0 ; then
1570 echo "ldapsearch failed ($RC)!"
1571 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1575 echo "Using ldapsearch to check replication to site2 search..."
1577 for i in 1 2 3 4 5; do
1578 RESULT=`$LDAPSEARCH -H $URI6 \
1579 -s base -b "ou=ou1,$BASEDN" \
1580 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1581 if test "x$RESULT" = "xOK" ; then
1585 echo "Waiting $i seconds for syncrepl to receive changes..."
1588 if test $RC != 0 ; then
1589 echo "ldapsearch failed ($RC)!"
1590 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1594 echo "Checking contextCSN after modify of first backend on central master..."
1595 . $TESTDIR/checkcsn.sh
1598 # Test that updates to the second backend on central master is only
1599 # replicated to those search servers that should receive that backend.
1600 # The contextCSN should still be updated everywhere:
1601 MNUM=`expr $MNUM + 1`
1602 echo "Using ldapmodify to modify second backend on central master..."
1603 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1604 dn: ou=ou2,dc=example,dc=com
1607 description: Modify$MNUM
1611 if test $RC != 0 ; then
1612 echo "ldapmodify failed ($RC)!"
1613 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1618 echo "Using ldapsearch to check replication to site2 search..."
1620 for i in 1 2 3 4 5; do
1621 RESULT=`$LDAPSEARCH -H $URI6 \
1622 -s base -b "ou=ou2,$BASEDN" \
1623 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1624 if test "x$RESULT" = "xOK" ; then
1628 echo "Waiting $i seconds for syncrepl to receive changes..."
1631 if test $RC != 0 ; then
1632 echo "ldapsearch failed ($RC)!"
1633 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1637 echo "Using ldapsearch to check no replication to site1 master..."
1638 for i in 1 2 3 4 5; do
1639 RESULT=`$LDAPSEARCH -H $URI2 \
1640 -s base -b "ou=ou2,$BASEDN" \
1641 "(description=Modify$NMUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1642 if test "x$RESULT" = "xNOK" ; then
1643 echo "Change was replicated to site1 search!"
1644 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1650 echo "Using ldapsearch to check no replication to central search..."
1651 for i in 1 2 3 4 5; do
1652 RESULT=`$LDAPSEARCH -H $URI4 \
1653 -s base -b "ou=ou2,$BASEDN" \
1654 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1655 if test "x$RESULT" = "xNOK" ; then
1656 echo "Change was replicated to central search!"
1657 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1663 echo "Checking contextCSN after modify of second backend on central master..."
1664 . $TESTDIR/checkcsn.sh
1667 # Test that updates to the first backend on site1 master, which should be
1668 # replicated everywhere except to central and site2 search. The contextCSN
1669 # should be updated on all servers:
1670 MNUM=`expr $MNUM + 1`
1671 echo "Using ldapmodify to modify first backend on site1 master..."
1672 $LDAPMODIFY -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1673 dn: ou=sm1ou1,dc=example,dc=com
1676 description: Modify$MNUM
1680 if test $RC != 0 ; then
1681 echo "ldapmodify failed ($RC)!"
1682 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1687 echo "Using ldapsearch to check replication to site1 search..."
1689 for i in 1 2 3 4 5; do
1690 RESULT=`$LDAPSEARCH -H $URI5 \
1691 -s base -b "ou=sm1ou1,$BASEDN" \
1692 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1693 if test "x$RESULT" = "xOK" ; then
1697 echo "Waiting $i seconds for syncrepl to receive changes..."
1700 if test $RC != 0 ; then
1701 echo "ldapsearch failed ($RC)!"
1702 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1706 echo "Using ldapsearch to check replication to site2 master..."
1708 for i in 1 2 3 4 5; do
1709 RESULT=`$LDAPSEARCH -H $URI3 \
1710 -s base -b "ou=sm1ou1,$BASEDN" \
1711 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1712 if test "x$RESULT" = "xOK" ; then
1716 echo "Waiting $i seconds for syncrepl to receive changes..."
1719 if test $RC != 0 ; then
1720 echo "ldapsearch failed ($RC)!"
1721 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1725 echo "Using ldapsearch to check no replication to site2 search..."
1726 for i in 1 2 3 4 5; do
1727 RESULT=`$LDAPSEARCH -H $URI6 \
1728 -s base -b "ou=sm1ou2,$BASEDN" \
1729 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1730 if test "x$RESULT" = "xNOK" ; then
1731 echo "Change was replicated to central search!"
1732 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1738 echo "Using ldapsearch to check no replication to central search..."
1739 for i in 1 2 3 4 5; do
1740 RESULT=`$LDAPSEARCH -H $URI4 \
1741 -s base -b "ou=sm1ou2,$BASEDN" \
1742 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1743 if test "x$RESULT" = "xNOK" ; then
1744 echo "Change was replicated to central search!"
1745 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1751 echo "Checking contextCSN after modify of first backend on site1 master..."
1752 . $TESTDIR/checkcsn.sh
1756 # Test updates to the second backend on site1 master, which should only be
1757 # replicated to site1 search. The contextCSN should be updated everywhere.
1758 MNUM=`expr $MNUM + 1`
1759 echo "Using ldapmodify to modify second backend on site1 master..."
1760 $LDAPMODIFY -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1761 dn: ou=sm1ou2,dc=example,dc=com
1764 description: Modify$MNUM
1768 if test $RC != 0 ; then
1769 echo "ldapmodify failed ($RC)!"
1770 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1776 echo "Using ldapsearch to check replication to site1 search..."
1778 for i in 1 2 3 4 5; do
1779 RESULT=`$LDAPSEARCH -H $URI5 \
1780 -s base -b "ou=sm1ou2,$BASEDN" \
1781 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1782 if test "x$RESULT" = "xOK" ; then
1786 echo "Waiting $i seconds for syncrepl to receive changes..."
1789 if test $RC != 0 ; then
1790 echo "ldapsearch failed ($RC)!"
1791 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1795 echo "Using ldapsearch to check no replication to central master..."
1796 for i in 1 2 3 4 5; do
1797 RESULT=`$LDAPSEARCH -H $URI1 \
1798 -s base -b "ou=sm1ou2,$BASEDN" \
1799 "(description=Modify$NMUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1800 if test "x$RESULT" = "xNOK" ; then
1801 echo "Change was replicated to site2 search!"
1802 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1808 echo "Checking contextCSN after modify of second backend on site1 master..."
1809 . $TESTDIR/checkcsn.sh
1813 # Test updates to first backend on site2 master, which should be
1814 # replicated to the central servers, but not site1. The contextCSN
1815 # should be updated everywhere:
1816 MNUM=`expr $MNUM + 1`
1817 echo "Using ldapmodify to modify first backend on site2 master..."
1818 $LDAPMODIFY -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1819 dn: ou=sm2ou1,dc=example,dc=com
1822 description: Modify$MNUM
1826 if test $RC != 0 ; then
1827 echo "ldapmodify failed ($RC)!"
1828 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1833 echo "Using ldapsearch to check replication to central master..."
1835 for i in 1 2 3 4 5; do
1836 RESULT=`$LDAPSEARCH -H $URI1 \
1837 -s base -b "ou=sm2ou1,$BASEDN" \
1838 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1839 if test "x$RESULT" = "xOK" ; then
1843 echo "Waiting $i seconds for syncrepl to receive changes..."
1846 if test $RC != 0 ; then
1847 echo "ldapsearch failed ($RC)!"
1848 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1852 echo "Using ldapsearch to check replication to site2 search..."
1854 for i in 1 2 3 4 5; do
1855 RESULT=`$LDAPSEARCH -H $URI6 \
1856 -s base -b "ou=sm2ou1,$BASEDN" \
1857 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1858 if test "x$RESULT" = "xOK" ; then
1862 echo "Waiting $i seconds for syncrepl to receive changes..."
1865 if test $RC != 0 ; then
1866 echo "ldapsearch failed ($RC)!"
1867 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1871 echo "Using ldapsearch to check no replication to site1 master..."
1872 for i in 1 2 3 4 5; do
1873 RESULT=`$LDAPSEARCH -H $URI2 \
1874 -s base -b "ou=sm2ou1,$BASEDN" \
1875 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1876 if test "x$RESULT" = "xNOK" ; then
1877 echo "Change was replicated to site2 search!"
1878 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1884 echo "Using ldapsearch to check no replication to central search..."
1885 for i in 1 2 3 4 5; do
1886 RESULT=`$LDAPSEARCH -H $URI4 \
1887 -s base -b "ou=sm2ou1,$BASEDN" \
1888 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1889 if test "x$RESULT" = "xNOK" ; then
1890 echo "Change was replicated to site2 search!"
1891 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1897 echo "Checking contextCSN after modify of first backend on site2 master..."
1898 . $TESTDIR/checkcsn.sh
1902 # Test updates to the second backend on site2 master, which should only be
1903 # replicated to site2 search. As always, contextCSN should be updated
1905 MNUM=`expr $MNUM + 1`
1906 echo "Using ldapmodify to modify second backend on site2 master..."
1907 $LDAPMODIFY -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1908 dn: ou=sm2ou2,dc=example,dc=com
1911 description: Modify$MNUM
1915 if test $RC != 0 ; then
1916 echo "ldapmodify failed ($RC)!"
1917 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1922 echo "Using ldapsearch to check replication to site2 search..."
1924 for i in 1 2 3 4 5; do
1925 RESULT=`$LDAPSEARCH -H $URI6 \
1926 -s base -b "ou=sm2ou2,$BASEDN" \
1927 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1928 if test "x$RESULT" = "xOK" ; then
1932 echo "Waiting $i seconds for syncrepl to receive changes..."
1935 if test $RC != 0 ; then
1936 echo "ldapsearch failed ($RC)!"
1937 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1941 echo "Using ldapsearch to check no replication to central master..."
1942 for i in 1 2 3 4 5; do
1943 RESULT=`$LDAPSEARCH -H $URI4 \
1944 -s base -b "ou=sm2ou2,$BASEDN" \
1945 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1946 if test "x$RESULT" = "xNOK" ; then
1947 echo "Change was replicated to central search!"
1948 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1954 echo "Checking contextCSN after modify of second backend on site2 master..."
1955 . $TESTDIR/checkcsn.sh
1958 # Test that all contextCSN values are updated on the slaves when they
1959 # starts with an empty database. Start site2 master first, then site2
1960 # search and finally central master so that the site2 search's syncrepl
1961 # connection has been set up when site2 master receives the database:
1962 echo "Stopping central master and site2 servers to test start with emtpy db..."
1963 kill -HUP $SMC_PID $SM2_PID $SS2_PID
1964 for pid in $SMC_PID $SM2_PID $SS2_PID; do wait $pid ; done
1965 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
1966 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SM2_PID / /"`;
1967 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SS2_PID / /"`;
1971 rm -rf $SM2_DIR/db/*
1972 rm -rf $SS2_DIR/db/*
1974 echo "Starting site2 master slapd on TCP/IP port $PORT3..."
1976 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1978 if test $WAIT != 0 ; then
1982 KILLPIDS="$KILLPIDS $SM2_PID"
1985 echo "Using ldapsearch to check that site2 master slapd is running..."
1986 for i in 1 2 3 4 5; do
1987 $LDAPSEARCH -s base -b "" -H $URI3 \
1988 'objectclass=*' > /dev/null 2>&1
1990 test $RC = 0 && break
1991 echo "Waiting $i seconds for slapd to start..."
1994 if test $RC != 0 ; then
1995 echo "ldapsearch failed ($RC)!"
1996 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2000 echo "Starting site2 search slapd on TCP/IP port $PORT6..."
2002 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING >> $LOG6 2>&1 &
2004 if test $WAIT != 0 ; then
2008 KILLPIDS="$KILLPIDS $SS2_PID"
2011 echo "Using ldapsearch to check that site2 search slapd is running..."
2012 for i in 1 2 3 4 5; do
2013 $LDAPSEARCH -s base -b "" -H $URI6 \
2014 'objectclass=*' > /dev/null 2>&1
2016 test $RC = 0 && break
2017 echo "Waiting $i seconds for slapd to start..."
2020 if test $RC != 0 ; then
2021 echo "ldapsearch failed ($RC)!"
2022 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2026 echo "Starting central master slapd on TCP/IP port $PORT1..."
2028 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2030 if test $WAIT != 0 ; then
2034 KILLPIDS="$KILLPIDS $SMC_PID"
2037 echo "Using ldapsearch to check that central master slapd is running..."
2038 for i in 1 2 3 4 5; do
2039 $LDAPSEARCH -s base -b "" -H $URI1 \
2040 'objectclass=*' > /dev/null 2>&1
2042 test $RC = 0 && break
2043 echo "Waiting $i seconds for slapd to start..."
2046 if test $RC != 0 ; then
2047 echo "ldapsearch failed ($RC)!"
2048 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2052 echo "Using ldapsearch to check that site2 master received base..."
2054 for i in 1 2 3 4 5; do
2055 RESULT=`$LDAPSEARCH -H $URI3 \
2056 -s base -b "$BASEDN" \
2057 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2058 if test "x$RESULT" = "xOK" ; then
2062 echo "Waiting $i seconds for syncrepl to receive changes..."
2065 if test $RC != 0 ; then
2066 echo "ldapsearch failed ($RC)!"
2067 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2071 echo "Using ldapsearch to check that site2 search received base..."
2073 for i in 1 2 3 4 5; do
2074 RESULT=`$LDAPSEARCH -H $URI6 \
2075 -s base -b "$BASEDN" \
2076 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2077 if test "x$RESULT" = "xOK" ; then
2081 echo "Waiting $i seconds for syncrepl to receive changes..."
2084 if test $RC != 0 ; then
2085 echo "ldapsearch failed ($RC)!"
2086 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2092 echo "Checking contextCSN after site2 servers repopulated..."
2093 . $TESTDIR/checkcsn.sh
2095 if test $ERRORS -ne 0; then
2096 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2097 echo "Found $ERRORS errors"
2102 # Adding syncrepl of the second site1 master backend on central master
2103 # will not initialize the database unless the contextCSN attribute is
2104 # stored in the suffix of the database and not the suffix of the glue
2106 echo "Adding syncrepl of second site1 master backend on central master..."
2107 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
2108 dn: olcDatabase={4}$BACKEND,cn=config
2111 olcSyncRepl: rid=4 provider=$URI2 searchbase="ou=sm1ou2,$BASEDN"
2112 binddn="ou=sm1ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
2113 type=refreshAndPersist retry="$RETRY" timeout=1
2116 if test $RC != 0 ; then
2117 echo "ldapmodify failed to add syncrepl on central master ($RC)!"
2118 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2123 echo "Using ldapsearch to check that central master received second site1 backend..."
2125 for i in 1 2 3 4 5; do
2126 RESULT=`$LDAPSEARCH -H $URI1 \
2127 -s base -b "ou=sm1ou2,$BASEDN" \
2128 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2129 if test "x$RESULT" = "xOK" ; then
2133 echo "Waiting $i seconds for syncrepl to receive changes..."
2136 if test $RC != 0 ; then
2137 echo "ERROR: Second site1 backend not replicated to central master"
2138 ERRORS=`expr $ERRORS + 1`
2140 echo "Restarting central master slapd on TCP/IP port $PORT1..."
2143 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2146 $SLAPD -F slapd.d -h $URI1 -c rid=4,csn=0 -d $LVL $TIMING >> $LOG1 2>&1 &
2148 if test $WAIT != 0 ; then
2152 KILLPIDS="$KILLPIDS $SMC_PID"
2154 echo "Using ldapsearch to check that central master slapd is running..."
2155 for i in 1 2 3 4 5; do
2156 $LDAPSEARCH -s base -b "" -H $URI1 \
2157 'objectclass=*' > /dev/null 2>&1
2159 test $RC = 0 && break
2160 echo "Waiting $i seconds for slapd to start..."
2163 if test $RC != 0 ; then
2164 echo "ldapsearch failed ($RC)!"
2165 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2169 echo "Using ldapsearch to check that central master received second site1 backend..."
2171 for i in 1 2 3 4 5; do
2172 RESULT=`$LDAPSEARCH -H $URI1 \
2173 -s base -b "ou=sm1ou2,$BASEDN" \
2174 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2175 if test "x$RESULT" = "xOK" ; then
2179 echo "Waiting $i seconds for syncrepl to receive changes..."
2182 if test $RC != 0 ; then
2183 echo "ldapsearch failed ($RC)!"
2184 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2189 echo "Using ldapsearch to check that central search received second site1 backend..."
2191 for i in 1 2 3 4 5; do
2192 RESULT=`$LDAPSEARCH -H $URI4 \
2193 -s base -b "ou=sm1ou2,$BASEDN" \
2194 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2195 if test "x$RESULT" = "xOK" ; then
2199 echo "Waiting $i seconds for syncrepl to receive changes..."
2202 if test $RC != 0 ; then
2203 echo "ERROR: Second site1 backend not replicated to central search"
2204 ERRORS=`expr $ERRORS + 1`
2206 echo "Restarting central search slapd on TCP/IP port $PORT4..."
2209 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SSC_PID / /"`;
2212 $SLAPD -F slapd.d -h $URI4 -c rid=1,csn=0 -d $LVL $TIMING >> $LOG4 2>&1 &
2214 if test $WAIT != 0 ; then
2218 KILLPIDS="$KILLPIDS $SSC_PID"
2220 echo "Using ldapsearch to check that central search slapd is running..."
2221 for i in 1 2 3 4 5; do
2222 $LDAPSEARCH -s base -b "" -H $URI4 \
2223 'objectclass=*' > /dev/null 2>&1
2225 test $RC = 0 && break
2226 echo "Waiting $i seconds for slapd to start..."
2229 if test $RC != 0 ; then
2230 echo "ldapsearch failed ($RC)!"
2231 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2235 echo "Using ldapsearch to check that central search received second site1 backend..."
2237 for i in 1 2 3 4 5; do
2238 RESULT=`$LDAPSEARCH -H $URI4 \
2239 -s base -b "ou=sm1ou2,$BASEDN" \
2240 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2241 if test "x$RESULT" = "xOK" ; then
2245 echo "Waiting $i seconds for syncrepl to receive changes..."
2248 if test $RC != 0 ; then
2249 echo "ldapsearch failed ($RC)!"
2250 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2257 # Run race tests when more than one backend is replicated from the same
2258 # producer. This will usually fail long before 100 iterations unless
2259 # syncrepl stores the contextCSN in the suffix of its own database, and
2260 # that syncprov follows these rules before updating its own CSN when it
2261 # detects updates from syncrepl:
2262 # 1) A contextCSN value must have been stored in the suffix of all the
2263 # syncrepl configured databases within the glued syncprov database.
2264 # 2) Of all contextCSN values stored by syncrepl with the same SID,
2265 # syncprov must always select the one with the lowest csn value.
2266 test -z "$RACE_TESTS" && RACE_TESTS=10
2270 SUB_DN=ou=sub,ou=sm1ou2,dc=example,dc=com
2272 while test $RACE_ERROR -eq 0 -a $RACE_NUM -lt $RACE_TESTS ; do
2273 RACE_NUM=`expr $RACE_NUM + 1`
2274 echo "Running $RACE_NUM of $RACE_TESTS syncrepl race tests..."
2276 echo "Stopping central master..."
2279 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2281 MNUM=`expr $MNUM + 1`
2282 echo "Using ldapadd to add entry on site1 master..."
2283 $LDAPADD -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
2286 objectClass: organizationalUnit
2291 if test $RC != 0 ; then
2292 echo "ldapadd failed ($RC)!"
2293 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2297 echo "Starting central master again..."
2299 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2301 KILLPIDS="$KILLPIDS $SMC_PID"
2303 echo "Using ldapsearch to check that central master received entry..."
2304 for i in 1 2 3 4 5; do
2305 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI1 > /dev/null 2>&1
2307 test $RC = 0 && break
2310 if test $RC != 0 ; then
2311 echo "ERROR: entry not replicated to central master!"
2316 echo "Using ldapsearch to check that central search received entry..."
2317 for i in 1 2 3 4 5; do
2318 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI4 > /dev/null 2>&1
2320 test $RC = 0 && break
2323 if test $RC != 0 ; then
2324 echo "ERROR: entry not replicated to central master!"
2329 echo "Stopping central master..."
2332 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2334 echo "Using ldapdelete to delete entry on site1 master..."
2335 $LDAPDELETE -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD "$SUB_DN"
2337 if test $RC != 0 ; then
2338 echo "ldapdelete failed ($RC)!"
2339 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2343 echo "Starting central master again..."
2345 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2347 KILLPIDS="$KILLPIDS $SMC_PID"
2350 echo "Using ldapsearch to check that entry was deleted on central master..."
2352 for i in 1 2 3 4 5; do
2353 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI1 > /dev/null 2>&1
2355 if test $RC != 0; then break; fi
2359 if test $RC = 0; then
2360 echo "ERROR: Entry not removed on central master!"
2365 echo "Using ldapsearch to check that entry was deleted on central search..."
2367 for i in 1 2 3 4 5; do
2368 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI4 > /dev/null 2>&1
2370 if test $RC != 0; then break; fi
2374 if test $RC = 0; then
2375 echo "ERROR: Entry not removed on central search!"
2381 if test $RACE_ERROR != 0; then
2382 echo "Race error found after $RACE_NUM of $RACE_TESTS iterations"
2383 ERRORS=`expr $ERRORS + $RACE_ERROR`
2385 echo "No race errors found after $RACE_TESTS iterations"
2388 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2390 if test $ERRORS -ne 0; then
2391 echo "Found $ERRORS errors"
2392 echo ">>>>>> Exiting with a false success status for now"
2396 echo ">>>>> Test succeeded"