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 "running defines.sh"
120 . $SRCDIR/scripts/defines.sh
122 if test $SYNCPROV = syncprovno; then
123 echo "Syncrepl provider overlay not available, test skipped"
136 for dir in $SMC_DIR $SM1_DIR $SM2_DIR $SS1_DIR $SS2_DIR $SSC_DIR; do
137 mkdir -p $dir $dir/slapd.d $dir/db
140 mkdir -p $SMC_DIR/ou1 $SMC_DIR/sm1ou1 $SMC_DIR/sm1ou2
141 mkdir -p $SMC_DIR/ou2 $SMC_DIR/sm2ou1
142 mkdir -p $SM1_DIR/ou1 $SM1_DIR/sm1ou1 $SM1_DIR/sm1ou2
143 mkdir -p $SM2_DIR/ou2 $SM2_DIR/sm1ou1 $SM2_DIR/sm2ou1 $SM2_DIR/sm2ou2
149 $SLAPPASSWD -g -n >$CONFIGPWF
153 if test $WAIT != 0 ; then
159 echo "Initializing master configurations..."
160 for dir in $SMC_DIR $SM1_DIR $SM2_DIR; do
161 $SLAPADD -F $dir/slapd.d -n 0 <<EOF
163 objectClass: olcGlobal
167 dn: olcDatabase={0}config,cn=config
168 objectClass: olcDatabaseConfig
169 olcDatabase: {0}config
170 olcRootPW:< file://$CONFIGPWF
176 echo "Initializing search configurations..."
177 for dir in $SS1_DIR $SS2_DIR $SSC_DIR; do
178 $SLAPADD -F $dir/slapd.d -n 0 <<EOF
180 objectClass: olcGlobal
183 dn: olcDatabase={0}config,cn=config
184 objectClass: olcDatabaseConfig
185 olcDatabase: {0}config
186 olcRootPW:< file://$CONFIGPWF
191 echo "Starting central master slapd on TCP/IP port $PORT1..."
193 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
195 if test $WAIT != 0 ; then
199 KILLPIDS="$KILLPIDS $SMC_PID"
202 echo "Using ldapsearch to check that central master slapd is running..."
203 for i in 1 2 3 4 5; do
204 $LDAPSEARCH -s base -b "" -H $URI1 \
205 'objectclass=*' > /dev/null 2>&1
207 test $RC = 0 && break
208 echo "Waiting $i seconds for slapd to start..."
211 if test $RC != 0 ; then
212 echo "ldapsearch failed ($RC)!"
213 test $KILLSERVERS != no && kill -HUP $KILLPIDS
217 echo "Starting site1 master slapd on TCP/IP port $PORT2..."
219 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
221 if test $WAIT != 0 ; then
225 KILLPIDS="$KILLPIDS $SM1_PID"
228 echo "Using ldapsearch to check that site1 master is running..."
229 for i in 1 2 3 4 5; do
230 $LDAPSEARCH -s base -b "" -H $URI2 \
231 'objectclass=*' > /dev/null 2>&1
233 test $RC = 0 && break
234 echo "Waiting $i seconds for slapd to start..."
237 if test $RC != 0 ; then
238 echo "ldapsearch failed ($RC)!"
239 test $KILLSERVERS != no && kill -HUP $KILLPIDS
243 echo "Starting site2 master slapd on TCP/IP port $PORT3..."
245 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
247 if test $WAIT != 0 ; then
251 KILLPIDS="$KILLPIDS $SM2_PID"
254 echo "Using ldapsearch to check that site2 master is running..."
255 for i in 1 2 3 4 5; do
256 $LDAPSEARCH -s base -b "" -H $URI3 \
257 'objectclass=*' > /dev/null 2>&1
259 test $RC = 0 && break
260 echo "Waiting $i seconds for slapd to start..."
263 if test $RC != 0 ; then
264 echo "ldapsearch failed ($RC)!"
265 test $KILLSERVERS != no && kill -HUP $KILLPIDS
269 echo "Starting central search slapd on TCP/IP port $PORT4..."
271 $SLAPD -F slapd.d -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
273 if test $WAIT != 0 ; then
277 KILLPIDS="$KILLPIDS $SSC_PID"
280 echo "Using ldapsearch to check that central search slapd is running..."
281 for i in 1 2 3 4 5; do
282 $LDAPSEARCH -s base -b "" -H $URI4 \
283 'objectclass=*' > /dev/null 2>&1
285 test $RC = 0 && break
286 echo "Waiting $i seconds for slapd to start..."
289 if test $RC != 0 ; then
290 echo "ldapsearch failed ($RC)!"
291 test $KILLSERVERS != no && kill -HUP $KILLPIDS
296 echo "Starting site1 search slapd on TCP/IP port $PORT5..."
298 $SLAPD -F slapd.d -h $URI5 -d $LVL $TIMING > $LOG5 2>&1 &
300 if test $WAIT != 0 ; then
304 KILLPIDS="$KILLPIDS $SS1_PID"
307 echo "Using ldapsearch to check that site1 search slapd is running..."
308 for i in 1 2 3 4 5; do
309 $LDAPSEARCH -s base -b "" -H $URI5 \
310 'objectclass=*' > /dev/null 2>&1
312 test $RC = 0 && break
313 echo "Waiting $i seconds for slapd to start..."
316 if test $RC != 0 ; then
317 echo "ldapsearch failed ($RC)!"
318 test $KILLSERVERS != no && kill -HUP $KILLPIDS
323 echo "Starting site2 search slapd on TCP/IP port $PORT6..."
325 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING > $LOG6 2>&1 &
327 if test $WAIT != 0 ; then
331 KILLPIDS="$KILLPIDS $SS2_PID"
334 echo "Using ldapsearch to check that site2 search slapd is running..."
335 for i in 1 2 3 4 5; do
336 $LDAPSEARCH -s base -b "" -H $URI6 \
337 'objectclass=*' > /dev/null 2>&1
339 test $RC = 0 && break
340 echo "Waiting $i seconds for slapd to start..."
343 if test $RC != 0 ; then
344 echo "ldapsearch failed ($RC)!"
345 test $KILLSERVERS != no && kill -HUP $KILLPIDS
349 for uri in $URI1 $URI2 $URI3 $URI4 $URI5 $URI6; do
350 echo "Adding schema on $uri..."
351 $LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
352 include: file://$ABS_SCHEMADIR/core.ldif
354 include: file://$ABS_SCHEMADIR/cosine.ldif
356 include: file://$ABS_SCHEMADIR/inetorgperson.ldif
358 include: file://$ABS_SCHEMADIR/openldap.ldif
360 include: file://$ABS_SCHEMADIR/nis.ldif
363 if test $RC != 0 ; then
364 echo "ldapadd failed for schema config ($RC)!"
365 test $KILLSERVERS != no && kill -HUP $KILLPIDS
369 [ "$BACKENDTYPE" = mod ] || continue
371 echo "Adding backend module on $uri..."
372 $LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
373 dn: cn=module,cn=config
374 objectClass: olcModuleList
376 olcModulePath: $TESTWD/../servers/slapd/back-$BACKEND
377 olcModuleLoad: back_$BACKEND.la
380 if test $RC != 0 ; then
381 echo "ldapadd failed for backend module ($RC)!"
382 test $KILLSERVERS != no && kill -HUP $KILLPIDS
387 echo "Adding database config on central master..."
388 if [ "$SYNCPROV" = syncprovmod ]; then
389 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
390 dn: cn=module,cn=config
391 objectClass: olcModuleList
393 olcModulePath: $TESTWD/../servers/slapd/overlays
394 olcModuleLoad: syncprov.la
398 if test $RC != 0 ; then
399 echo "ldapadd failed for moduleLoad ($RC)!"
400 test $KILLSERVERS != no && kill -HUP $KILLPIDS
405 nullExclude="" nullOK="" wantNoObj=32
406 test $BACKEND = null && nullExclude="# " nullOK="OK" wantNoObj=0
408 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
409 dn: olcDatabase={1}$BACKEND,cn=config
410 objectClass: olcDatabaseConfig
411 ${nullExclude}objectClass: olc${BACKEND}Config
412 olcDatabase: {1}$BACKEND
413 ${nullExclude}olcDbDirectory: $SMC_DIR/db
415 olcRootDN: $MANAGERDN
418 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
419 objectClass: olcOverlayConfig
422 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
423 objectClass: olcOverlayConfig
424 objectClass: olcSyncProvConfig
425 olcOverlay: {1}syncprov
428 dn: olcDatabase={1}$BACKEND,cn=config
429 objectClass: olcDatabaseConfig
430 ${nullExclude}objectClass: olc${BACKEND}Config
431 olcDatabase: {1}$BACKEND
432 ${nullExclude}olcDbDirectory: $SMC_DIR/ou1
434 olcSuffix: ou=ou1,$BASEDN
435 olcRootDN: $MANAGERDN
437 dn: olcDatabase={2}$BACKEND,cn=config
438 objectClass: olcDatabaseConfig
439 ${nullExclude}objectClass: olc${BACKEND}Config
440 olcDatabase: {2}$BACKEND
441 ${nullExclude}olcDbDirectory: $SMC_DIR/ou2
443 olcSuffix: ou=ou2,$BASEDN
444 olcRootDN: $MANAGERDN
446 dn: olcDatabase={3}$BACKEND,cn=config
447 objectClass: olcDatabaseConfig
448 ${nullExclude}objectClass: olc${BACKEND}Config
449 olcDatabase: {3}$BACKEND
450 ${nullExclude}olcDbDirectory: $SMC_DIR/sm1ou1
452 olcSuffix: ou=sm1ou1,$BASEDN
455 dn: olcDatabase={4}$BACKEND,cn=config
456 objectClass: olcDatabaseConfig
457 ${nullExclude}objectClass: olc${BACKEND}Config
458 olcDatabase: {4}$BACKEND
459 ${nullExclude}olcDbDirectory: $SMC_DIR/sm1ou2
461 olcSuffix: ou=sm1ou2,$BASEDN
464 dn: olcDatabase={5}$BACKEND,cn=config
465 objectClass: olcDatabaseConfig
466 ${nullExclude}objectClass: olc${BACKEND}Config
467 olcDatabase: {5}$BACKEND
468 ${nullExclude}olcDbDirectory: $SMC_DIR/sm2ou1
470 olcSuffix: ou=sm2ou1,$BASEDN
475 if test $RC != 0 ; then
476 echo "ldapadd failed for central master database config ($RC)!"
477 test $KILLSERVERS != no && kill -HUP $KILLPIDS
481 echo "Adding database config on site1 master..."
482 if [ "$SYNCPROV" = syncprovmod ]; then
483 $LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
484 dn: cn=module,cn=config
485 objectClass: olcModuleList
487 olcModulePath: $TESTWD/../servers/slapd/overlays
488 olcModuleLoad: syncprov.la
492 if test $RC != 0 ; then
493 echo "ldapadd failed for moduleLoad ($RC)!"
494 test $KILLSERVERS != no && kill -HUP $KILLPIDS
499 $LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
500 dn: olcDatabase={1}$BACKEND,cn=config
501 objectClass: olcDatabaseConfig
502 ${nullExclude}objectClass: olc${BACKEND}Config
503 olcDatabase: {1}$BACKEND
504 ${nullExclude}olcDbDirectory: $SM1_DIR/db
508 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
509 objectClass: olcOverlayConfig
512 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
513 objectClass: olcOverlayConfig
514 objectClass: olcSyncProvConfig
515 olcOverlay: {1}syncprov
517 dn: olcDatabase={1}$BACKEND,cn=config
518 objectClass: olcDatabaseConfig
519 ${nullExclude}objectClass: olc${BACKEND}Config
520 olcDatabase: {1}$BACKEND
521 ${nullExclude}olcDbDirectory: $SM1_DIR/ou1
523 olcSuffix: ou=ou1,$BASEDN
526 dn: olcDatabase={2}$BACKEND,cn=config
527 objectClass: olcDatabaseConfig
528 ${nullExclude}objectClass: olc${BACKEND}Config
529 olcDatabase: {2}$BACKEND
530 ${nullExclude}olcDbDirectory: $SM1_DIR/sm1ou1
532 olcSuffix: ou=sm1ou1,$BASEDN
533 olcRootDN: ou=sm1ou1,$BASEDN
536 dn: olcDatabase={3}$BACKEND,cn=config
537 objectClass: olcDatabaseConfig
538 ${nullExclude}objectClass: olc${BACKEND}Config
539 olcDatabase: {3}$BACKEND
540 ${nullExclude}olcDbDirectory: $SM1_DIR/sm1ou2
542 olcSuffix: ou=sm1ou2,$BASEDN
543 olcRootDN: ou=sm1ou1,$BASEDN
548 if test $RC != 0 ; then
549 echo "ldapadd failed for site1 master database config ($RC)!"
550 test $KILLSERVERS != no && kill -HUP $KILLPIDS
554 echo "Adding database config on site2 master..."
555 if [ "$SYNCPROV" = syncprovmod ]; then
556 $LDAPADD -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
557 dn: cn=module,cn=config
558 objectClass: olcModuleList
560 olcModulePath: $TESTWD/../servers/slapd/overlays
561 olcModuleLoad: syncprov.la
565 if test $RC != 0 ; then
566 echo "ldapadd failed for moduleLoad ($RC)!"
567 test $KILLSERVERS != no && kill -HUP $KILLPIDS
572 $LDAPADD -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
573 dn: olcDatabase={1}$BACKEND,cn=config
574 objectClass: olcDatabaseConfig
575 ${nullExclude}objectClass: olc${BACKEND}Config
576 olcDatabase: {1}$BACKEND
577 ${nullExclude}olcDbDirectory: $SM2_DIR/db
581 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
582 objectClass: olcOverlayConfig
585 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
586 objectClass: olcOverlayConfig
587 objectClass: olcSyncProvConfig
588 olcOverlay: {1}syncprov
591 dn: olcDatabase={1}$BACKEND,cn=config
592 objectClass: olcDatabaseConfig
593 ${nullExclude}objectClass: olc${BACKEND}Config
594 olcDatabase: {1}$BACKEND
595 ${nullExclude}olcDbDirectory: $SM2_DIR/ou2
597 olcSuffix: ou=ou2,$BASEDN
600 dn: olcDatabase={2}$BACKEND,cn=config
601 objectClass: olcDatabaseConfig
602 ${nullExclude}objectClass: olc${BACKEND}Config
603 olcDatabase: {2}$BACKEND
604 ${nullExclude}olcDbDirectory: $SM2_DIR/sm1ou1
606 olcSuffix: ou=sm1ou1,$BASEDN
609 dn: olcDatabase={3}$BACKEND,cn=config
610 objectClass: olcDatabaseConfig
611 ${nullExclude}objectClass: olc${BACKEND}Config
612 olcDatabase: {3}$BACKEND
613 ${nullExclude}olcDbDirectory: $SM2_DIR/sm2ou1
615 olcSuffix: ou=sm2ou1,$BASEDN
616 olcRootDN: ou=sm2ou1,$BASEDN
619 dn: olcDatabase={4}$BACKEND,cn=config
620 objectClass: olcDatabaseConfig
621 ${nullExclude}objectClass: olc${BACKEND}Config
622 olcDatabase: {4}$BACKEND
623 ${nullExclude}olcDbDirectory: $SM2_DIR/sm2ou2
625 olcSuffix: ou=sm2ou2,$BASEDN
626 olcRootDN: ou=sm2ou1,$BASEDN
631 if test $RC != 0 ; then
632 echo "ldapadd failed for site2 master database config ($RC)!"
633 test $KILLSERVERS != no && kill -HUP $KILLPIDS
637 echo "Adding access rules on central master..."
638 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
639 dn: olcDatabase={-1}frontend,cn=config
642 olcAccess: to dn.exact=dc=example,dc=com
644 olcAccess: to dn.subtree=ou=ou1,dc=example,dc=com
646 olcAccess: to dn.subtree=ou=ou2,dc=example,dc=com
647 by dn.exact=ou=ou1,dc=example,dc=com none
648 by dn.exact=ou=ou2,dc=example,dc=com read
649 by dn.exact=dc=example,dc=com none
651 olcAccess: to dn.subtree=ou=sm1ou1,dc=example,dc=com
652 by dn.exact=ou=ou1,dc=example,dc=com none
653 by dn.exact=ou=ou2,dc=example,dc=com read
654 by dn.exact=dc=example,dc=com none
656 olcAccess: to dn.subtree=ou=sm1ou2,dc=example,dc=com
657 by dn.exact=ou=ou1,dc=example,dc=com none
658 by dn.exact=ou=ou2,dc=example,dc=com none
659 by dn.exact=dc=example,dc=com read
661 olcAccess: to dn.subtree=ou=sm2ou1,dc=example,dc=com
662 by dn.exact=ou=ou1,dc=example,dc=com none
663 by dn.exact=ou=ou2,dc=example,dc=com none
664 by dn.exact=dc=example,dc=com none
666 olcAccess: to * by * read
670 if test $RC != 0 ; then
671 echo "ldapmodify failed for central master access config ($RC)!"
672 test $KILLSERVERS != no && kill -HUP $KILLPIDS
676 echo "Adding access rules on site1 master..."
677 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
678 dn: olcDatabase={-1}frontend,cn=config
681 olcAccess: to dn.subtree=dc=example,dc=com
683 olcAccess: to * by * read
687 if test $RC != 0 ; then
688 echo "ldapmodify failed for site1 master access config ($RC)!"
689 test $KILLSERVERS != no && kill -HUP $KILLPIDS
693 echo "Adding access rules on site2 master..."
694 $LDAPMODIFY -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
695 dn: olcDatabase={-1}frontend,cn=config
698 olcAccess: to dn.exact=dc=example,dc=com
700 olcAccess: to dn.subtree=ou=ou2,dc=example,dc=com
702 olcAccess: to dn.subtree=ou=sm1ou1,dc=example,dc=com
705 olcAccess: to dn.subtree=ou=sm2ou1,dc=example,dc=com
707 olcAccess: to dn.subtree=ou=sm2ou2,dc=example,dc=com
708 by dn.exact=dc=example,dc=com read
711 olcAccess: to * by * read
715 if test $RC != 0 ; then
716 echo "ldapmodify failed for site2 master access config ($RC)!"
717 test $KILLSERVERS != no && kill -HUP $KILLPIDS
721 echo "Adding database config on central search..."
722 $LDAPADD -D cn=config -H $URI4 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
723 dn: olcDatabase={1}$BACKEND,cn=config
724 objectClass: olcDatabaseConfig
725 ${nullExclude}objectClass: olc${BACKEND}Config
726 olcDatabase: {1}$BACKEND
727 ${nullExclude}olcDbDirectory: $SSC_DIR/db
733 if test $RC != 0 ; then
734 echo "ldapadd failed for central search database config ($RC)!"
735 test $KILLSERVERS != no && kill -HUP $KILLPIDS
739 echo "Adding database config on site1 search..."
740 $LDAPADD -D cn=config -H $URI5 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
741 dn: olcDatabase={1}$BACKEND,cn=config
742 objectClass: olcDatabaseConfig
743 ${nullExclude}objectClass: olc${BACKEND}Config
744 olcDatabase: {1}$BACKEND
745 ${nullExclude}olcDbDirectory: $SS1_DIR/db
751 if test $RC != 0 ; then
752 echo "ldapadd failed for site1 search database config ($RC)!"
753 test $KILLSERVERS != no && kill -HUP $KILLPIDS
757 echo "Adding database config on site2 search..."
758 $LDAPADD -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
759 dn: olcDatabase={1}$BACKEND,cn=config
760 objectClass: olcDatabaseConfig
761 ${nullExclude}objectClass: olc${BACKEND}Config
762 olcDatabase: {1}$BACKEND
763 ${nullExclude}olcDbDirectory: $SS2_DIR/db
769 if test $RC != 0 ; then
770 echo "ldapadd failed for site2 search database config ($RC)!"
771 test $KILLSERVERS != no && kill -HUP $KILLPIDS
775 echo "Populating central master..."
776 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
777 dn: dc=example,dc=com
779 objectClass: organization
780 objectClass: dcObject
783 userPassword: $PASSWD
785 dn: ou=ou1,dc=example,dc=com
787 objectClass: organizationalUnit
789 userPassword: $PASSWD
791 dn: ou=ou2,dc=example,dc=com
793 objectClass: organizationalUnit
795 userPassword: $PASSWD
799 if test $RC != 0 ; then
800 echo "ldapadd failed to populate central master entry ($RC)!"
801 test $KILLSERVERS != no && kill -HUP $KILLPIDS
805 echo "Adding syncrepl on site1 master..."
806 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
807 dn: olcDatabase={4}$BACKEND,cn=config
810 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
811 binddn="ou=ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
812 type=refreshAndPersist retry="$RETRY" timeout=1
816 if test $RC != 0 ; then
817 echo "ldapmodify failed to add syncrepl on site1 master ($RC)!"
818 test $KILLSERVERS != no && kill -HUP $KILLPIDS
822 echo "Adding syncrepl on site2 master..."
823 $LDAPMODIFY -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
824 dn: olcDatabase={5}$BACKEND,cn=config
827 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
828 binddn="ou=ou2,$BASEDN" bindmethod=simple credentials=$PASSWD
829 type=refreshAndPersist retry="$RETRY" timeout=1
833 if test $RC != 0 ; then
834 echo "ldapmodify failed to add syncrepl on site2 master ($RC)!"
835 test $KILLSERVERS != no && kill -HUP $KILLPIDS
840 echo "Using ldapsearch to check that site1 master received changes..."
842 for i in 1 2 3 4 5; do
843 RESULT=`$LDAPSEARCH -H $URI2 \
844 -s base -b "ou=ou1,$BASEDN" \
845 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
846 if test "x$RESULT$nullOK" = "xOK" ; then
850 echo "Waiting $i seconds for syncrepl to receive changes..."
853 if test $RC != 0 ; then
854 echo "ldapsearch failed ($RC)!"
855 test $KILLSERVERS != no && kill -HUP $KILLPIDS
859 echo "Using ldapsearch to check that site2 master received changes..."
861 for i in 1 2 3 4 5; do
862 RESULT=`$LDAPSEARCH -H $URI3 \
863 -s base -b "ou=ou1,$BASEDN" \
864 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
865 if test "x$RESULT$nullOK" = "xOK" ; then
869 echo "Waiting $i seconds for syncrepl to receive changes..."
872 if test $RC != 0 ; then
873 echo "ldapsearch failed ($RC)!"
874 test $KILLSERVERS != no && kill -HUP $KILLPIDS
880 echo "Populating site1 master..."
881 $LDAPADD -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
882 dn: ou=sm1ou1,dc=example,dc=com
884 objectClass: organizationalUnit
887 dn: ou=sm1ou2,dc=example,dc=com
889 objectClass: organizationalUnit
894 if test $RC != 0 ; then
895 echo "ldapadd failed to populate site1 master ($RC)!"
896 test $KILLSERVERS != no && kill -HUP $KILLPIDS
902 echo "Populating site2 master..."
903 $LDAPADD -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
904 dn: ou=sm2ou1,dc=example,dc=com
906 objectClass: organizationalUnit
909 dn: ou=sm2ou2,dc=example,dc=com
911 objectClass: organizationalUnit
916 if test $RC != 0 ; then
917 echo "ldapadd failed to populate site2 master ($RC)!"
918 test $KILLSERVERS != no && kill -HUP $KILLPIDS
925 # Stop site1 master when adding syncrepl to the central master. When
926 # site1 master is started again both it and the central master will have
927 # the same number of contextCSN values, but the ones on central master
928 # will be the newest. The central master will not update its contextCSN
929 # values unless the bug in ITS#5597 have been fixed.
930 echo "Stopping site1 master..."
933 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SM1_PID / /"`;
936 echo "Adding syncrepl on central master..."
937 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
938 dn: olcDatabase={3}$BACKEND,cn=config
941 olcSyncRepl: rid=3 provider=$URI2 searchbase="ou=sm1ou1,$BASEDN"
942 binddn="ou=sm1ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
943 type=refreshAndPersist retry="$RETRY" timeout=1
945 dn: olcDatabase={5}$BACKEND,cn=config
948 olcSyncRepl: rid=5 provider=$URI3 searchbase="ou=sm2ou1,$BASEDN"
949 binddn="ou=sm2ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
950 type=refreshAndPersist retry="$RETRY" timeout=1
954 if test $RC != 0 ; then
955 echo "ldapmodify failed to add syncrepl on central master ($RC)!"
956 test $KILLSERVERS != no && kill -HUP $KILLPIDS
960 echo "Using ldapsearch to check that central master received site2 entries..."
962 for i in 1 2 3 4 5; do
963 RESULT=`$LDAPSEARCH -H $URI1 \
964 -s base -b "ou=sm2ou1,$BASEDN" \
965 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
966 if test "x$RESULT$nullOK" = "xOK" ; then
970 echo "Waiting $i seconds for syncrepl to receive changes..."
973 if test $RC != 0 ; then
974 echo "ldapsearch failed ($RC)!"
975 test $KILLSERVERS != no && kill -HUP $KILLPIDS
979 if test -z "$SM1_PID" ; then
980 echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
982 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
984 if test $WAIT != 0 ; then
988 KILLPIDS="$KILLPIDS $SM1_PID"
993 echo "Using ldapsearch to check that site1 master is running..."
994 for i in 1 2 3 4 5; do
995 $LDAPSEARCH -s base -b "" -H $URI2 \
996 'objectclass=*' > /dev/null 2>&1
998 test $RC = 0 && break
999 echo "Waiting $i seconds for slapd to start..."
1002 if test $RC != 0 ; then
1003 echo "ldapsearch failed ($RC)!"
1004 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1008 echo "Using ldapsearch to check that central master received site1 entries..."
1010 for i in 1 2 3 4 5; do
1011 RESULT=`$LDAPSEARCH -H $URI1 \
1012 -s base -b "ou=sm1ou1,$BASEDN" \
1013 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1014 if test "x$RESULT$nullOK" = "xOK" ; then
1018 echo "Waiting $i seconds for syncrepl to receive changes..."
1021 if test $RC != 0 ; then
1022 echo "ldapsearch failed ($RC)!"
1023 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1027 # Test done, now some more intialization...
1029 echo "Adding syncrepl consumer on central search..."
1030 $LDAPMODIFY -D cn=config -H $URI4 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1031 dn: olcDatabase={1}$BACKEND,cn=config
1034 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
1035 binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1036 type=refreshAndPersist retry="$RETRY" timeout=1
1040 if test $RC != 0 ; then
1041 echo "ldapmodify failed to add syncrepl on site1 search ($RC)!"
1042 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1046 echo "Adding syncrepl consumer on site1 search..."
1047 $LDAPMODIFY -D cn=config -H $URI5 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1048 dn: olcDatabase={1}$BACKEND,cn=config
1051 olcSyncRepl: rid=1 provider=$URI2 searchbase="$BASEDN"
1052 binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1053 type=refreshAndPersist retry="$RETRY" timeout=1
1057 if test $RC != 0 ; then
1058 echo "ldapmodify failed to add syncrepl on site1 search ($RC)!"
1059 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1063 echo "Adding syncrepl consumer on site2 search..."
1064 $LDAPMODIFY -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1065 dn: olcDatabase={1}$BACKEND,cn=config
1068 olcSyncRepl: rid=1 provider=$URI3 searchbase="$BASEDN"
1069 binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1070 type=refreshAndPersist retry="$RETRY" timeout=1
1074 if test $RC != 0 ; then
1075 echo "ldapmodify failed to add syncrepl on site2 search ($RC)!"
1076 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1081 echo "Using ldapsearch to check that central search received changes..."
1083 for i in 1 2 3 4 5; do
1084 RESULT=`$LDAPSEARCH -H $URI4 \
1085 -s base -b "$BASEDN" \
1086 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1087 if test "x$RESULT$nullOK" = "xOK" ; then
1091 echo "Waiting $i seconds for syncrepl to receive changes..."
1094 if test $RC != 0 ; then
1095 echo "ldapsearch failed ($RC)!"
1096 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1100 echo "Using ldapsearch to check that site1 search received changes..."
1102 for i in 1 2 3 4 5; do
1103 RESULT=`$LDAPSEARCH -H $URI5 \
1104 -s base -b "$BASEDN" \
1105 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1106 if test "x$RESULT$nullOK" = "xOK" ; then
1110 echo "Waiting $i seconds for syncrepl to receive changes..."
1113 if test $RC != 0 ; then
1114 echo "ldapsearch failed ($RC)!"
1115 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1119 echo "Using ldapsearch to check that site2 search received changes..."
1121 for i in 1 2 3 4 5; do
1122 RESULT=`$LDAPSEARCH -H $URI6 \
1123 -s base -b "$BASEDN" \
1124 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1125 if test "x$RESULT$nullOK" = "xOK" ; then
1129 echo "Waiting $i seconds for syncrepl to receive changes..."
1132 if test $RC != 0 ; then
1133 echo "ldapsearch failed ($RC)!"
1134 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1138 # Create a script that will check the contextCSN values of all servers,
1139 # and restart them to re-synchronize if it finds any errors:
1140 cat > $TESTDIR/checkcsn.sh <<'EOF'
1145 CSN1=`$LDAPSEARCH -H $URI1 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1146 CSN2=`$LDAPSEARCH -H $URI2 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1147 CSN3=`$LDAPSEARCH -H $URI3 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1148 CSN4=`$LDAPSEARCH -H $URI4 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1149 CSN5=`$LDAPSEARCH -H $URI5 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1150 CSN6=`$LDAPSEARCH -H $URI6 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1152 if test -z "$CSN1" ; then
1153 echo "ERROR: contextCSN empty on central master"
1154 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1156 nCSN=`echo "$CSN1" | wc -l`
1157 if test "$nCSN" -ne 3 ; then
1158 echo "ERROR: Wrong contextCSN count on central master, should be 3"
1159 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1160 if test -n "$CSN_VERBOSE"; then
1164 if test -z "$CSN2" -o "$CSN1" != "$CSN2" ; then
1165 echo "ERROR: contextCSN mismatch between central master and site1 master"
1166 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1167 if test -n "$CSN_VERBOSE"; then
1168 echo "contextCSN on central master:"
1170 echo "contextCSN on site1 master:"
1174 if test -z "$CSN3" -o "$CSN1" != "$CSN3" ; then
1175 echo "ERROR: contextCSN mismatch between central master and site2 master"
1176 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1177 if test -n "$CSN_VERBOSE"; then
1178 echo "contextCSN on central master:"
1180 echo "contextCSN on site2 master:"
1184 if test -z "$CSN4" -o "$CSN1" != "$CSN4" ; then
1185 echo "ERROR: contextCSN mismatch between central master and central search"
1186 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1187 if test -n "$CSN_VERBOSE"; then
1188 echo "contextCSN on central master:"
1190 echo "contextCSN on central search:"
1194 if test -z "$CSN5" -o "$CSN2" != "$CSN5" ; then
1195 echo "ERROR: contextCSN mismatch between site1 master and site1 search"
1196 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1197 if test -n "$CSN_VERBOSE"; then
1198 echo "contextCSN on site1 master:"
1200 echo "contextCSN on site1 search:"
1204 if test -z "$CSN6" -o "$CSN3" != "$CSN6" ; then
1205 echo "ERROR: contextCSN mismatch between site2 master and site2 search:"
1206 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1207 if test -n "$CSN_VERBOSE"; then
1208 echo "contextCSN on site2 master:"
1210 echo "contextCSN on site2 search:"
1215 if test $CSN_ERRORS != 0 ; then
1216 echo "Stopping all servers to synchronize contextCSN..."
1218 for pid in $KILLPIDS ; do wait $pid ; done
1221 echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
1223 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
1225 if test $WAIT != 0 ; then
1229 KILLPIDS="$KILLPIDS $SM1_PID"
1232 echo "Using ldapsearch to check that site1 master is running..."
1233 for i in 1 2 3 4 5; do
1234 $LDAPSEARCH -s base -b "" -H $URI2 \
1235 'objectclass=*' > /dev/null 2>&1
1237 test $RC = 0 && break
1238 echo "Waiting $i seconds for slapd to start..."
1241 if test $RC != 0 ; then
1242 echo "ldapsearch failed ($RC)!"
1243 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1247 echo "Restarting site2 master slapd on TCP/IP port $PORT3..."
1249 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1251 if test $WAIT != 0 ; then
1255 KILLPIDS="$KILLPIDS $SM2_PID "
1258 echo "Using ldapsearch to check that site2 master is running..."
1259 for i in 1 2 3 4 5; do
1260 $LDAPSEARCH -s base -b "" -H $URI3 \
1261 'objectclass=*' > /dev/null 2>&1
1263 test $RC = 0 && break
1264 echo "Waiting $i seconds for slapd to start..."
1267 if test $RC != 0 ; then
1268 echo "ldapsearch failed ($RC)!"
1269 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1273 echo "Restarting central master slapd on TCP/IP port $PORT1..."
1275 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
1277 if test $WAIT != 0 ; then
1281 KILLPIDS="$KILLPIDS $SMC_PID"
1284 echo "Using ldapsearch to check that central master slapd is running..."
1285 for i in 1 2 3 4 5; do
1286 $LDAPSEARCH -s base -b "" -H $URI1 \
1287 'objectclass=*' > /dev/null 2>&1
1289 test $RC = 0 && break
1290 echo "Waiting $i seconds for slapd to start..."
1293 if test $RC != 0 ; then
1294 echo "ldapsearch failed ($RC)!"
1295 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1299 echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1302 echo "Stopping site1 and site2 master..."
1303 kill -HUP $SM1_PID $SM2_PID
1304 for pid in $SM1_PID $SM2_PID ; do wait $pid ; done
1305 KILLPIDS=" $SMC_PID"
1307 echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
1309 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
1311 if test $WAIT != 0 ; then
1315 KILLPIDS="$KILLPIDS $SM1_PID"
1318 echo "Using ldapsearch to check that site1 master is running..."
1319 for i in 1 2 3 4 5; do
1320 $LDAPSEARCH -s base -b "" -H $URI2 \
1321 'objectclass=*' > /dev/null 2>&1
1323 test $RC = 0 && break
1324 echo "Waiting $i seconds for slapd to start..."
1327 if test $RC != 0 ; then
1328 echo "ldapsearch failed ($RC)!"
1329 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1333 echo "Restarting site2 master slapd on TCP/IP port $PORT3..."
1335 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1337 if test $WAIT != 0 ; then
1341 KILLPIDS="$KILLPIDS $SM2_PID"
1344 echo "Using ldapsearch to check that site2 master is running..."
1345 for i in 1 2 3 4 5; do
1346 $LDAPSEARCH -s base -b "" -H $URI3 \
1347 'objectclass=*' > /dev/null 2>&1
1349 test $RC = 0 && break
1350 echo "Waiting $i seconds for slapd to start..."
1353 if test $RC != 0 ; then
1354 echo "ldapsearch failed ($RC)!"
1355 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1359 echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1362 echo "Restarting central search slapd on TCP/IP port $PORT4..."
1364 $SLAPD -F slapd.d -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
1366 if test $WAIT != 0 ; then
1370 KILLPIDS="$KILLPIDS $SSC_PID"
1373 echo "Using ldapsearch to check that central search slapd is running..."
1374 for i in 1 2 3 4 5; do
1375 $LDAPSEARCH -s base -b "" -H $URI4 \
1376 'objectclass=*' > /dev/null 2>&1
1378 test $RC = 0 && break
1379 echo "Waiting $i seconds for slapd to start..."
1382 if test $RC != 0 ; then
1383 echo "ldapsearch failed ($RC)!"
1384 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1388 echo "Restarting site1 search slapd on TCP/IP port $PORT5..."
1390 $SLAPD -F slapd.d -h $URI5 -d $LVL $TIMING >> $LOG5 2>&1 &
1392 if test $WAIT != 0 ; then
1396 KILLPIDS="$KILLPIDS $SS1_PID"
1399 echo "Using ldapsearch to check that site1 search slapd is running..."
1400 for i in 1 2 3 4 5; do
1401 $LDAPSEARCH -s base -b "" -H $URI5 \
1402 'objectclass=*' > /dev/null 2>&1
1404 test $RC = 0 && break
1405 echo "Waiting $i seconds for slapd to start..."
1408 if test $RC != 0 ; then
1409 echo "ldapsearch failed ($RC)!"
1410 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1414 echo "Restarting site2 search slapd on TCP/IP port $PORT6..."
1416 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING >> $LOG6 2>&1 &
1418 if test $WAIT != 0 ; then
1422 KILLPIDS="$KILLPIDS $SS2_PID"
1425 echo "Using ldapsearch to check that site2 search slapd is running..."
1426 for i in 1 2 3 4 5; do
1427 $LDAPSEARCH -s base -b "" -H $URI6 \
1428 'objectclass=*' > /dev/null 2>&1
1430 test $RC = 0 && break
1431 echo "Waiting $i seconds for slapd to start..."
1434 if test $RC != 0 ; then
1435 echo "ldapsearch failed ($RC)!"
1436 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1440 echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1443 echo "Checking contextCSN after restart..."
1444 CSN1=`$LDAPSEARCH -H $URI1 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1445 CSN2=`$LDAPSEARCH -H $URI2 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1446 CSN3=`$LDAPSEARCH -H $URI3 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1447 CSN4=`$LDAPSEARCH -H $URI4 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1448 CSN5=`$LDAPSEARCH -H $URI5 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1449 CSN6=`$LDAPSEARCH -H $URI6 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1450 if test -z "$CSN1" ; then
1451 echo "ERROR: contextCSN empty on central master"
1452 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1455 if test -z "$CSN2" -o "$CSN1" != "$CSN2" ; then
1456 echo "ERROR: contextCSN mismatch between central master and site1 master"
1457 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1458 if test -n "$CSN_VERBOSE"; then
1459 echo "contextCSN on central master:"
1461 echo "contextCSN on site1 master:"
1465 if test -z "$CSN3" -o "$CSN1" != "$CSN3" ; then
1466 echo "ERROR: contextCSN mismatch between central master and site2 master"
1467 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1468 if test -n "$CSN_VERBOSE"; then
1469 echo "contextCSN on central master:"
1471 echo "contextCSN on site2 master:"
1475 if test -z "$CSN4" -o "$CSN1" != "$CSN4" ; then
1476 echo "ERROR: contextCSN mismatch between central master and central search"
1477 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1478 if test -n "$CSN_VERBOSE"; then
1479 echo "contextCSN on central master:"
1481 echo "contextCSN on central search:"
1485 if test -z "$CSN5" -o "$CSN2" != "$CSN5" ; then
1486 echo "ERROR: contextCSN mismatch between site1 master and site1 search"
1487 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1488 if test -n "$CSN_VERBOSE"; then
1489 echo "contextCSN on site1 master:"
1491 echo "contextCSN on site1 search:"
1495 if test -z "$CSN6" -o "$CSN3" != "$CSN6" ; then
1496 echo "ERROR: contextCSN mismatch between site2 master and site2 search:"
1497 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1498 if test -n "$CSN_VERBOSE"; then
1499 echo "contextCSN on site2 master:"
1501 echo "contextCSN on site2 search:"
1507 ERRORS=`expr $ERRORS + $CSN_ERRORS`
1511 test $BACKEND = null && echo : > $TESTDIR/checkcsn.sh
1513 chmod +x $TESTDIR/checkcsn.sh
1516 echo "Checking contextCSN after initial replication..."
1517 . $TESTDIR/checkcsn.sh
1522 # Test that updates to the first backend on central master, which should
1523 # be replicated to all servers actually is so, and that the contextCSN is
1524 # updated everywhere:
1525 echo "Using ldapmodify to modify first backend on central master..."
1526 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1527 dn: ou=ou1,dc=example,dc=com
1530 description: Modify$MNUM
1534 if test $RC != 0 ; then
1535 echo "ldapmodify failed ($RC)!"
1536 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1541 echo "Using ldapsearch to check replication to central search..."
1543 for i in 1 2 3 4 5; do
1544 RESULT=`$LDAPSEARCH -H $URI4 \
1545 -s base -b "ou=ou1,$BASEDN" \
1546 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1547 if test "x$RESULT$nullOK" = "xOK" ; then
1551 echo "Waiting $i seconds for syncrepl to receive changes..."
1554 if test $RC != 0 ; then
1555 echo "ldapsearch failed ($RC)!"
1556 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1560 echo "Using ldapsearch to check replication to site1 search..."
1562 for i in 1 2 3 4 5; do
1563 RESULT=`$LDAPSEARCH -H $URI5 \
1564 -s base -b "ou=ou1,$BASEDN" \
1565 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1566 if test "x$RESULT$nullOK" = "xOK" ; then
1570 echo "Waiting $i seconds for syncrepl to receive changes..."
1573 if test $RC != 0 ; then
1574 echo "ldapsearch failed ($RC)!"
1575 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1579 echo "Using ldapsearch to check replication to site2 search..."
1581 for i in 1 2 3 4 5; do
1582 RESULT=`$LDAPSEARCH -H $URI6 \
1583 -s base -b "ou=ou1,$BASEDN" \
1584 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1585 if test "x$RESULT$nullOK" = "xOK" ; then
1589 echo "Waiting $i seconds for syncrepl to receive changes..."
1592 if test $RC != 0 ; then
1593 echo "ldapsearch failed ($RC)!"
1594 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1598 echo "Checking contextCSN after modify of first backend on central master..."
1599 . $TESTDIR/checkcsn.sh
1602 # Test that updates to the second backend on central master is only
1603 # replicated to those search servers that should receive that backend.
1604 # The contextCSN should still be updated everywhere:
1605 MNUM=`expr $MNUM + 1`
1606 echo "Using ldapmodify to modify second backend on central master..."
1607 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1608 dn: ou=ou2,dc=example,dc=com
1611 description: Modify$MNUM
1615 if test $RC != 0 ; then
1616 echo "ldapmodify failed ($RC)!"
1617 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1622 echo "Using ldapsearch to check replication to site2 search..."
1624 for i in 1 2 3 4 5; do
1625 RESULT=`$LDAPSEARCH -H $URI6 \
1626 -s base -b "ou=ou2,$BASEDN" \
1627 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1628 if test "x$RESULT$nullOK" = "xOK" ; then
1632 echo "Waiting $i seconds for syncrepl to receive changes..."
1635 if test $RC != 0 ; then
1636 echo "ldapsearch failed ($RC)!"
1637 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1641 echo "Using ldapsearch to check no replication to site1 master..."
1642 for i in 1 2 3 4 5; do
1643 RESULT=`$LDAPSEARCH -H $URI2 \
1644 -s base -b "ou=ou2,$BASEDN" \
1645 "(description=Modify$NMUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1646 if test "x$RESULT" = "xNOK" ; then
1647 echo "Change was replicated to site1 search!"
1648 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1654 echo "Using ldapsearch to check no replication to central search..."
1655 for i in 1 2 3 4 5; do
1656 RESULT=`$LDAPSEARCH -H $URI4 \
1657 -s base -b "ou=ou2,$BASEDN" \
1658 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1659 if test "x$RESULT" = "xNOK" ; then
1660 echo "Change was replicated to central search!"
1661 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1667 echo "Checking contextCSN after modify of second backend on central master..."
1668 . $TESTDIR/checkcsn.sh
1671 # Test that updates to the first backend on site1 master, which should be
1672 # replicated everywhere except to central and site2 search. The contextCSN
1673 # should be updated on all servers:
1674 MNUM=`expr $MNUM + 1`
1675 echo "Using ldapmodify to modify first backend on site1 master..."
1676 $LDAPMODIFY -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1677 dn: ou=sm1ou1,dc=example,dc=com
1680 description: Modify$MNUM
1684 if test $RC != 0 ; then
1685 echo "ldapmodify failed ($RC)!"
1686 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1691 echo "Using ldapsearch to check replication to site1 search..."
1693 for i in 1 2 3 4 5; do
1694 RESULT=`$LDAPSEARCH -H $URI5 \
1695 -s base -b "ou=sm1ou1,$BASEDN" \
1696 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1697 if test "x$RESULT$nullOK" = "xOK" ; then
1701 echo "Waiting $i seconds for syncrepl to receive changes..."
1704 if test $RC != 0 ; then
1705 echo "ldapsearch failed ($RC)!"
1706 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1710 echo "Using ldapsearch to check replication to site2 master..."
1712 for i in 1 2 3 4 5; do
1713 RESULT=`$LDAPSEARCH -H $URI3 \
1714 -s base -b "ou=sm1ou1,$BASEDN" \
1715 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1716 if test "x$RESULT$nullOK" = "xOK" ; then
1720 echo "Waiting $i seconds for syncrepl to receive changes..."
1723 if test $RC != 0 ; then
1724 echo "ldapsearch failed ($RC)!"
1725 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1729 echo "Using ldapsearch to check no replication to site2 search..."
1730 for i in 1 2 3 4 5; do
1731 RESULT=`$LDAPSEARCH -H $URI6 \
1732 -s base -b "ou=sm1ou2,$BASEDN" \
1733 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1734 if test "x$RESULT" = "xNOK" ; then
1735 echo "Change was replicated to central search!"
1736 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1742 echo "Using ldapsearch to check no replication to central search..."
1743 for i in 1 2 3 4 5; do
1744 RESULT=`$LDAPSEARCH -H $URI4 \
1745 -s base -b "ou=sm1ou2,$BASEDN" \
1746 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1747 if test "x$RESULT" = "xNOK" ; then
1748 echo "Change was replicated to central search!"
1749 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1755 echo "Checking contextCSN after modify of first backend on site1 master..."
1756 . $TESTDIR/checkcsn.sh
1760 # Test updates to the second backend on site1 master, which should only be
1761 # replicated to site1 search. The contextCSN should be updated everywhere.
1762 MNUM=`expr $MNUM + 1`
1763 echo "Using ldapmodify to modify second backend on site1 master..."
1764 $LDAPMODIFY -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1765 dn: ou=sm1ou2,dc=example,dc=com
1768 description: Modify$MNUM
1772 if test $RC != 0 ; then
1773 echo "ldapmodify failed ($RC)!"
1774 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1780 echo "Using ldapsearch to check replication to site1 search..."
1782 for i in 1 2 3 4 5; do
1783 RESULT=`$LDAPSEARCH -H $URI5 \
1784 -s base -b "ou=sm1ou2,$BASEDN" \
1785 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1786 if test "x$RESULT$nullOK" = "xOK" ; then
1790 echo "Waiting $i seconds for syncrepl to receive changes..."
1793 if test $RC != 0 ; then
1794 echo "ldapsearch failed ($RC)!"
1795 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1799 echo "Using ldapsearch to check no replication to central master..."
1800 for i in 1 2 3 4 5; do
1801 RESULT=`$LDAPSEARCH -H $URI1 \
1802 -s base -b "ou=sm1ou2,$BASEDN" \
1803 "(description=Modify$NMUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1804 if test "x$RESULT" = "xNOK" ; then
1805 echo "Change was replicated to site2 search!"
1806 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1812 echo "Checking contextCSN after modify of second backend on site1 master..."
1813 . $TESTDIR/checkcsn.sh
1817 # Test updates to first backend on site2 master, which should be
1818 # replicated to the central servers, but not site1. The contextCSN
1819 # should be updated everywhere:
1820 MNUM=`expr $MNUM + 1`
1821 echo "Using ldapmodify to modify first backend on site2 master..."
1822 $LDAPMODIFY -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1823 dn: ou=sm2ou1,dc=example,dc=com
1826 description: Modify$MNUM
1830 if test $RC != 0 ; then
1831 echo "ldapmodify failed ($RC)!"
1832 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1837 echo "Using ldapsearch to check replication to central master..."
1839 for i in 1 2 3 4 5; do
1840 RESULT=`$LDAPSEARCH -H $URI1 \
1841 -s base -b "ou=sm2ou1,$BASEDN" \
1842 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1843 if test "x$RESULT$nullOK" = "xOK" ; then
1847 echo "Waiting $i seconds for syncrepl to receive changes..."
1850 if test $RC != 0 ; then
1851 echo "ldapsearch failed ($RC)!"
1852 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1856 echo "Using ldapsearch to check replication to site2 search..."
1858 for i in 1 2 3 4 5; do
1859 RESULT=`$LDAPSEARCH -H $URI6 \
1860 -s base -b "ou=sm2ou1,$BASEDN" \
1861 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1862 if test "x$RESULT$nullOK" = "xOK" ; then
1866 echo "Waiting $i seconds for syncrepl to receive changes..."
1869 if test $RC != 0 ; then
1870 echo "ldapsearch failed ($RC)!"
1871 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1875 echo "Using ldapsearch to check no replication to site1 master..."
1876 for i in 1 2 3 4 5; do
1877 RESULT=`$LDAPSEARCH -H $URI2 \
1878 -s base -b "ou=sm2ou1,$BASEDN" \
1879 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1880 if test "x$RESULT" = "xNOK" ; then
1881 echo "Change was replicated to site2 search!"
1882 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1888 echo "Using ldapsearch to check no replication to central search..."
1889 for i in 1 2 3 4 5; do
1890 RESULT=`$LDAPSEARCH -H $URI4 \
1891 -s base -b "ou=sm2ou1,$BASEDN" \
1892 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1893 if test "x$RESULT" = "xNOK" ; then
1894 echo "Change was replicated to site2 search!"
1895 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1901 echo "Checking contextCSN after modify of first backend on site2 master..."
1902 . $TESTDIR/checkcsn.sh
1906 # Test updates to the second backend on site2 master, which should only be
1907 # replicated to site2 search. As always, contextCSN should be updated
1909 MNUM=`expr $MNUM + 1`
1910 echo "Using ldapmodify to modify second backend on site2 master..."
1911 $LDAPMODIFY -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1912 dn: ou=sm2ou2,dc=example,dc=com
1915 description: Modify$MNUM
1919 if test $RC != 0 ; then
1920 echo "ldapmodify failed ($RC)!"
1921 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1926 echo "Using ldapsearch to check replication to site2 search..."
1928 for i in 1 2 3 4 5; do
1929 RESULT=`$LDAPSEARCH -H $URI6 \
1930 -s base -b "ou=sm2ou2,$BASEDN" \
1931 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1932 if test "x$RESULT$nullOK" = "xOK" ; then
1936 echo "Waiting $i seconds for syncrepl to receive changes..."
1939 if test $RC != 0 ; then
1940 echo "ldapsearch failed ($RC)!"
1941 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1945 echo "Using ldapsearch to check no replication to central master..."
1946 for i in 1 2 3 4 5; do
1947 RESULT=`$LDAPSEARCH -H $URI4 \
1948 -s base -b "ou=sm2ou2,$BASEDN" \
1949 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1950 if test "x$RESULT" = "xNOK" ; then
1951 echo "Change was replicated to central search!"
1952 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1958 echo "Checking contextCSN after modify of second backend on site2 master..."
1959 . $TESTDIR/checkcsn.sh
1962 # Test that all contextCSN values are updated on the slaves when they
1963 # starts with an empty database. Start site2 master first, then site2
1964 # search and finally central master so that the site2 search's syncrepl
1965 # connection has been set up when site2 master receives the database:
1966 echo "Stopping central master and site2 servers to test start with emtpy db..."
1967 kill -HUP $SMC_PID $SM2_PID $SS2_PID
1968 for pid in $SMC_PID $SM2_PID $SS2_PID; do wait $pid ; done
1969 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
1970 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SM2_PID / /"`;
1971 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SS2_PID / /"`;
1975 rm -rf $SM2_DIR/db/*
1976 rm -rf $SS2_DIR/db/*
1978 echo "Starting site2 master slapd on TCP/IP port $PORT3..."
1980 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1982 if test $WAIT != 0 ; then
1986 KILLPIDS="$KILLPIDS $SM2_PID"
1989 echo "Using ldapsearch to check that site2 master slapd is running..."
1990 for i in 1 2 3 4 5; do
1991 $LDAPSEARCH -s base -b "" -H $URI3 \
1992 'objectclass=*' > /dev/null 2>&1
1994 test $RC = 0 && break
1995 echo "Waiting $i seconds for slapd to start..."
1998 if test $RC != 0 ; then
1999 echo "ldapsearch failed ($RC)!"
2000 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2004 echo "Starting site2 search slapd on TCP/IP port $PORT6..."
2006 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING >> $LOG6 2>&1 &
2008 if test $WAIT != 0 ; then
2012 KILLPIDS="$KILLPIDS $SS2_PID"
2015 echo "Using ldapsearch to check that site2 search slapd is running..."
2016 for i in 1 2 3 4 5; do
2017 $LDAPSEARCH -s base -b "" -H $URI6 \
2018 'objectclass=*' > /dev/null 2>&1
2020 test $RC = 0 && break
2021 echo "Waiting $i seconds for slapd to start..."
2024 if test $RC != 0 ; then
2025 echo "ldapsearch failed ($RC)!"
2026 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2030 echo "Starting central master slapd on TCP/IP port $PORT1..."
2032 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2034 if test $WAIT != 0 ; then
2038 KILLPIDS="$KILLPIDS $SMC_PID"
2041 echo "Using ldapsearch to check that central master slapd is running..."
2042 for i in 1 2 3 4 5; do
2043 $LDAPSEARCH -s base -b "" -H $URI1 \
2044 'objectclass=*' > /dev/null 2>&1
2046 test $RC = 0 && break
2047 echo "Waiting $i seconds for slapd to start..."
2050 if test $RC != 0 ; then
2051 echo "ldapsearch failed ($RC)!"
2052 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2056 echo "Using ldapsearch to check that site2 master received base..."
2058 for i in 1 2 3 4 5; do
2059 RESULT=`$LDAPSEARCH -H $URI3 \
2060 -s base -b "$BASEDN" \
2061 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2062 if test "x$RESULT$nullOK" = "xOK" ; then
2066 echo "Waiting $i seconds for syncrepl to receive changes..."
2069 if test $RC != 0 ; then
2070 echo "ldapsearch failed ($RC)!"
2071 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2075 echo "Using ldapsearch to check that site2 search received base..."
2077 for i in 1 2 3 4 5; do
2078 RESULT=`$LDAPSEARCH -H $URI6 \
2079 -s base -b "$BASEDN" \
2080 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2081 if test "x$RESULT$nullOK" = "xOK" ; then
2085 echo "Waiting $i seconds for syncrepl to receive changes..."
2088 if test $RC != 0 ; then
2089 echo "ldapsearch failed ($RC)!"
2090 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2096 echo "Checking contextCSN after site2 servers repopulated..."
2097 . $TESTDIR/checkcsn.sh
2099 if test $ERRORS -ne 0; then
2100 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2101 echo "Found $ERRORS errors"
2106 # Adding syncrepl of the second site1 master backend on central master
2107 # will not initialize the database unless the contextCSN attribute is
2108 # stored in the suffix of the database and not the suffix of the glue
2110 echo "Adding syncrepl of second site1 master backend on central master..."
2111 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
2112 dn: olcDatabase={4}$BACKEND,cn=config
2115 olcSyncRepl: rid=4 provider=$URI2 searchbase="ou=sm1ou2,$BASEDN"
2116 binddn="ou=sm1ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
2117 type=refreshAndPersist retry="$RETRY" timeout=1
2120 if test $RC != 0 ; then
2121 echo "ldapmodify failed to add syncrepl on central master ($RC)!"
2122 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2127 echo "Using ldapsearch to check that central master received second site1 backend..."
2129 for i in 1 2 3 4 5; do
2130 RESULT=`$LDAPSEARCH -H $URI1 \
2131 -s base -b "ou=sm1ou2,$BASEDN" \
2132 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2133 if test "x$RESULT$nullOK" = "xOK" ; then
2137 echo "Waiting $i seconds for syncrepl to receive changes..."
2140 if test $RC != 0 ; then
2141 echo "ERROR: Second site1 backend not replicated to central master"
2142 ERRORS=`expr $ERRORS + 1`
2144 echo "Restarting central master slapd on TCP/IP port $PORT1..."
2147 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2150 $SLAPD -F slapd.d -h $URI1 -c rid=4,csn=0 -d $LVL $TIMING >> $LOG1 2>&1 &
2152 if test $WAIT != 0 ; then
2156 KILLPIDS="$KILLPIDS $SMC_PID"
2158 echo "Using ldapsearch to check that central master slapd is running..."
2159 for i in 1 2 3 4 5; do
2160 $LDAPSEARCH -s base -b "" -H $URI1 \
2161 'objectclass=*' > /dev/null 2>&1
2163 test $RC = 0 && break
2164 echo "Waiting $i seconds for slapd to start..."
2167 if test $RC != 0 ; then
2168 echo "ldapsearch failed ($RC)!"
2169 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2173 echo "Using ldapsearch to check that central master received second site1 backend..."
2175 for i in 1 2 3 4 5; do
2176 RESULT=`$LDAPSEARCH -H $URI1 \
2177 -s base -b "ou=sm1ou2,$BASEDN" \
2178 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2179 if test "x$RESULT$nullOK" = "xOK" ; then
2183 echo "Waiting $i seconds for syncrepl to receive changes..."
2186 if test $RC != 0 ; then
2187 echo "ldapsearch failed ($RC)!"
2188 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2193 echo "Using ldapsearch to check that central search received second site1 backend..."
2195 for i in 1 2 3 4 5; do
2196 RESULT=`$LDAPSEARCH -H $URI4 \
2197 -s base -b "ou=sm1ou2,$BASEDN" \
2198 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2199 if test "x$RESULT$nullOK" = "xOK" ; then
2203 echo "Waiting $i seconds for syncrepl to receive changes..."
2206 if test $RC != 0 ; then
2207 echo "ERROR: Second site1 backend not replicated to central search"
2208 ERRORS=`expr $ERRORS + 1`
2210 echo "Restarting central search slapd on TCP/IP port $PORT4..."
2213 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SSC_PID / /"`;
2216 $SLAPD -F slapd.d -h $URI4 -c rid=1,csn=0 -d $LVL $TIMING >> $LOG4 2>&1 &
2218 if test $WAIT != 0 ; then
2222 KILLPIDS="$KILLPIDS $SSC_PID"
2224 echo "Using ldapsearch to check that central search slapd is running..."
2225 for i in 1 2 3 4 5; do
2226 $LDAPSEARCH -s base -b "" -H $URI4 \
2227 'objectclass=*' > /dev/null 2>&1
2229 test $RC = 0 && break
2230 echo "Waiting $i seconds for slapd to start..."
2233 if test $RC != 0 ; then
2234 echo "ldapsearch failed ($RC)!"
2235 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2239 echo "Using ldapsearch to check that central search received second site1 backend..."
2241 for i in 1 2 3 4 5; do
2242 RESULT=`$LDAPSEARCH -H $URI4 \
2243 -s base -b "ou=sm1ou2,$BASEDN" \
2244 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2245 if test "x$RESULT$nullOK" = "xOK" ; then
2249 echo "Waiting $i seconds for syncrepl to receive changes..."
2252 if test $RC != 0 ; then
2253 echo "ldapsearch failed ($RC)!"
2254 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2261 # Run race tests when more than one backend is replicated from the same
2262 # provider. This will usually fail long before 100 iterations unless
2263 # syncrepl stores the contextCSN in the suffix of its own database, and
2264 # that syncprov follows these rules before updating its own CSN when it
2265 # detects updates from syncrepl:
2266 # 1) A contextCSN value must have been stored in the suffix of all the
2267 # syncrepl configured databases within the glued syncprov database.
2268 # 2) Of all contextCSN values stored by syncrepl with the same SID,
2269 # syncprov must always select the one with the lowest csn value.
2270 test -z "$RACE_TESTS" && RACE_TESTS=10
2274 SUB_DN=ou=sub,ou=sm1ou2,dc=example,dc=com
2276 while test $RACE_ERROR -eq 0 -a $RACE_NUM -lt $RACE_TESTS ; do
2277 RACE_NUM=`expr $RACE_NUM + 1`
2278 echo "Running $RACE_NUM of $RACE_TESTS syncrepl race tests..."
2280 echo "Stopping central master..."
2283 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2285 MNUM=`expr $MNUM + 1`
2286 echo "Using ldapadd to add entry on site1 master..."
2287 $LDAPADD -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
2290 objectClass: organizationalUnit
2295 if test $RC != 0 ; then
2296 echo "ldapadd failed ($RC)!"
2297 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2301 echo "Starting central master again..."
2303 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2305 KILLPIDS="$KILLPIDS $SMC_PID"
2307 echo "Using ldapsearch to check that central master received entry..."
2308 for i in 1 2 3 4 5; do
2309 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI1 > /dev/null 2>&1
2311 test $RC = 0 && break
2314 if test $RC != 0 ; then
2315 echo "ERROR: entry not replicated to central master!"
2320 echo "Using ldapsearch to check that central search received entry..."
2321 for i in 1 2 3 4 5; do
2322 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI4 > /dev/null 2>&1
2324 test $RC = 0 && break
2327 if test $RC != 0 ; then
2328 echo "ERROR: entry not replicated to central master!"
2333 echo "Stopping central master..."
2336 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2338 echo "Using ldapdelete to delete entry on site1 master..."
2339 $LDAPDELETE -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD "$SUB_DN"
2341 if test $RC != 0 ; then
2342 echo "ldapdelete failed ($RC)!"
2343 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2347 echo "Starting central master again..."
2349 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2351 KILLPIDS="$KILLPIDS $SMC_PID"
2354 echo "Using ldapsearch to check that entry was deleted on central master..."
2356 for i in 1 2 3 4 5; do
2357 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI1 > /dev/null 2>&1
2359 if test $RC = $wantNoObj; then break; fi
2363 if test $RC != $wantNoObj; then
2364 if test $RC != 0; then
2365 echo "ldapsearch failed ($RC)!"
2366 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2369 echo "ERROR: Entry not removed on central master!"
2374 echo "Using ldapsearch to check that entry was deleted on central search..."
2376 for i in 1 2 3 4 5; do
2377 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI4 > /dev/null 2>&1
2379 if test $RC != 0; then break; fi
2383 if test $RC != $wantNoObj; then
2384 echo "ERROR: Entry not removed on central search! (RC=$RC)"
2390 if test $RACE_ERROR != 0; then
2391 echo "Race error found after $RACE_NUM of $RACE_TESTS iterations"
2392 ERRORS=`expr $ERRORS + $RACE_ERROR`
2394 echo "No race errors found after $RACE_TESTS iterations"
2397 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2399 if test $ERRORS -ne 0; then
2400 echo "Found $ERRORS errors"
2401 echo ">>>>>> Exiting with a false success status for now"
2405 echo ">>>>> Test succeeded"