3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2013 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 # This script tests a configuration scenario as described in these URLs:
18 # http://www.openldap.org/lists/openldap-devel/200806/msg00041.html
19 # http://www.openldap.org/lists/openldap-devel/200806/msg00054.html
21 # Search for "TEST:" to find each major test this script performs.
23 # The configuration here consist of 3 "sites", each with a "master" and
24 # a "search" server. One of the sites is the "central", the other two
25 # are called "site1" and "site2".
27 # The following notations are used in variable names below to identify
28 # these servers, the first number defines the $URL# and $PORT# variable
31 # 1: SMC_* Site Master Central
32 # 2: SM1_* Site Master 1
33 # 3: SM2_* Site Master 2
34 # 4: SSC_* Search Site Central
35 # 5: SS1_* Search Site 1
36 # 6: SS2_* Search Site 2
38 # The master servers all have a set of subordinate databases glued below
39 # the same suffix database. Each of the masters are the master for at
40 # least one of these subordinate databases, but there are never more
41 # than one master for any single database. I.e, this is neither a
42 # traditional single-master configuration, nor what most people think
43 # of as multi-master, but more what can be called multiple masters.
45 # The central master replicates to the two other masters, and receives
46 # updates from them of the backends they are the master for. There is
47 # no direct connection between the other two master servers. All of the
48 # masters have the syncprov overlay configured on the glue database.
50 # The search servers replicates from the master server at their site.
51 # They all have a single database with the glue suffix, but their
52 # database configuration doesn't matter much in this test. (This
53 # database layout was originally created before gluing was introduced
54 # in OpenLDAP, which is why the search servers doesn't use it).
56 # The primary objective for gluing the backend databases is not to make
57 # them look like one huge database but to create a common search suffix
58 # for the clients. Searching is mostly done on the search servers, only
59 # updates are done on the masters.
61 # It varies which backends that are replicated to which server (hence
62 # the name asymmetric in this test). Access control rules on the
63 # masters are used to control what their consumers receives. The table
64 # below gives an overview of which backend (the columns) that are
65 # replicated to which server (the rows). A "M" defines the master for
66 # the backend, a "S" is a slave, and "-" means it is not replicated
67 # there. Oh, the table probably looks wrong without the 4-position
68 # tab-stops OpenLDAP uses...
70 # glue ou1 ou2 sm1ou1 sm1ou2 sm2ou1 sm2ou2
78 # On the central master syncrepl is configured on the subordinate
79 # databases, as it varies which backends that exists on its providers.
80 # Had it been used on the glue database then syncrepl would have removed
81 # the backends replicated from site1 but not present on site2 when it
82 # synchronizes with site2 (and vice versa).
84 # All the other servers uses syncrepl on the glue database, since
85 # replicating more than one subordinate database from the same master
86 # creates (as of the writing of this test script) race conditions that
87 # causes the replication to fail, as the race tests at the end shows.
89 # The databases controlled by syncrepl all have $UPDATEDN as their
90 # RootDN, while the master servers has other RootDN values for the
91 # backends they are the backend for them self. This violates the current
92 # guidelines for gluing databases, which states that the same rootdn
93 # should be used on all of them. Unfortunately, this cannot be done on
94 # site masters 1 and 2. The backends they manage locally are either not
95 # present on the central master, or when so they are not replicated back
96 # to their source, which causes syncrepl to try to remove the content of
97 # these backends when it synchronizes with the central master. The
98 # differing rootdn values used on the backends controlled by syncrepl
99 # and those managed locally prevents it from succeeding in this. As
100 # noted above, moving syncrepl to the subordinate databases is currently
101 # not an option since that creates race conditions.
103 # The binddn values used in the syncrepl configurations are chosen to
104 # make the configuration and access control rules easiest to set up. It
105 # occasionally uses a DN that is also used as a RootDN. This is not a
106 # good practice and should not be taken as an example for real
109 # This script will print the content of any invalid contextCSN values it
110 # detects if the environment variable CSN_VERBOSE is non-empty. The
111 # environment variable RACE_TESTS can be set to the number of race test
112 # iterations the script should perform.
114 if test "$BACKEND" = ldif ; then
115 echo "$BACKEND backend does not support access controls, test skipped"
119 #echo "Test 058 is currently disabled"
122 echo "running defines.sh"
123 . $SRCDIR/scripts/defines.sh
125 if test $SYNCPROV = syncprovno; then
126 echo "Syncrepl provider overlay not available, test skipped"
141 for dir in $SMC_DIR $SM1_DIR $SM2_DIR $SS1_DIR $SS2_DIR $SSC_DIR; do
142 mkdir -p $dir $dir/slapd.d $dir/db
145 mkdir -p $SMC_DIR/ou1 $SMC_DIR/sm1ou1 $SMC_DIR/sm1ou2
146 mkdir -p $SMC_DIR/ou2 $SMC_DIR/sm2ou1
147 mkdir -p $SM1_DIR/ou1 $SM1_DIR/sm1ou1 $SM1_DIR/sm1ou2
148 mkdir -p $SM2_DIR/ou2 $SM2_DIR/sm1ou1 $SM2_DIR/sm2ou1 $SM2_DIR/sm2ou2
154 $SLAPPASSWD -g -n >$CONFIGPWF
158 if test $WAIT != 0 ; then
164 echo "Initializing master configurations..."
165 for dir in $SMC_DIR $SM1_DIR $SM2_DIR; do
166 $SLAPADD -F $dir/slapd.d -n 0 <<EOF
168 objectClass: olcGlobal
172 dn: olcDatabase={0}config,cn=config
173 objectClass: olcDatabaseConfig
174 olcDatabase: {0}config
175 olcRootPW:< file://$CONFIGPWF
181 echo "Initializing search configurations..."
182 for dir in $SS1_DIR $SS2_DIR $SSC_DIR; do
183 $SLAPADD -F $dir/slapd.d -n 0 <<EOF
185 objectClass: olcGlobal
188 dn: olcDatabase={0}config,cn=config
189 objectClass: olcDatabaseConfig
190 olcDatabase: {0}config
191 olcRootPW:< file://$CONFIGPWF
196 echo "Starting central master slapd on TCP/IP port $PORT1..."
198 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
200 if test $WAIT != 0 ; then
204 KILLPIDS="$KILLPIDS $SMC_PID"
207 echo "Using ldapsearch to check that central master slapd is running..."
208 for i in 1 2 3 4 5; do
209 $LDAPSEARCH -s base -b "" -H $URI1 \
210 'objectclass=*' > /dev/null 2>&1
212 test $RC = 0 && break
213 echo "Waiting $i seconds for slapd to start..."
216 if test $RC != 0 ; then
217 echo "ldapsearch failed ($RC)!"
218 test $KILLSERVERS != no && kill -HUP $KILLPIDS
222 echo "Starting site1 master slapd on TCP/IP port $PORT2..."
224 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
226 if test $WAIT != 0 ; then
230 KILLPIDS="$KILLPIDS $SM1_PID"
233 echo "Using ldapsearch to check that site1 master is running..."
234 for i in 1 2 3 4 5; do
235 $LDAPSEARCH -s base -b "" -H $URI2 \
236 'objectclass=*' > /dev/null 2>&1
238 test $RC = 0 && break
239 echo "Waiting $i seconds for slapd to start..."
242 if test $RC != 0 ; then
243 echo "ldapsearch failed ($RC)!"
244 test $KILLSERVERS != no && kill -HUP $KILLPIDS
248 echo "Starting site2 master slapd on TCP/IP port $PORT3..."
250 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
252 if test $WAIT != 0 ; then
256 KILLPIDS="$KILLPIDS $SM2_PID"
259 echo "Using ldapsearch to check that site2 master is running..."
260 for i in 1 2 3 4 5; do
261 $LDAPSEARCH -s base -b "" -H $URI3 \
262 'objectclass=*' > /dev/null 2>&1
264 test $RC = 0 && break
265 echo "Waiting $i seconds for slapd to start..."
268 if test $RC != 0 ; then
269 echo "ldapsearch failed ($RC)!"
270 test $KILLSERVERS != no && kill -HUP $KILLPIDS
274 echo "Starting central search slapd on TCP/IP port $PORT4..."
276 $SLAPD -F slapd.d -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
278 if test $WAIT != 0 ; then
282 KILLPIDS="$KILLPIDS $SSC_PID"
285 echo "Using ldapsearch to check that central search slapd is running..."
286 for i in 1 2 3 4 5; do
287 $LDAPSEARCH -s base -b "" -H $URI4 \
288 'objectclass=*' > /dev/null 2>&1
290 test $RC = 0 && break
291 echo "Waiting $i seconds for slapd to start..."
294 if test $RC != 0 ; then
295 echo "ldapsearch failed ($RC)!"
296 test $KILLSERVERS != no && kill -HUP $KILLPIDS
301 echo "Starting site1 search slapd on TCP/IP port $PORT5..."
303 $SLAPD -F slapd.d -h $URI5 -d $LVL $TIMING > $LOG5 2>&1 &
305 if test $WAIT != 0 ; then
309 KILLPIDS="$KILLPIDS $SS1_PID"
312 echo "Using ldapsearch to check that site1 search slapd is running..."
313 for i in 1 2 3 4 5; do
314 $LDAPSEARCH -s base -b "" -H $URI5 \
315 'objectclass=*' > /dev/null 2>&1
317 test $RC = 0 && break
318 echo "Waiting $i seconds for slapd to start..."
321 if test $RC != 0 ; then
322 echo "ldapsearch failed ($RC)!"
323 test $KILLSERVERS != no && kill -HUP $KILLPIDS
328 echo "Starting site2 search slapd on TCP/IP port $PORT6..."
330 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING > $LOG6 2>&1 &
332 if test $WAIT != 0 ; then
336 KILLPIDS="$KILLPIDS $SS2_PID"
339 echo "Using ldapsearch to check that site2 search slapd is running..."
340 for i in 1 2 3 4 5; do
341 $LDAPSEARCH -s base -b "" -H $URI6 \
342 'objectclass=*' > /dev/null 2>&1
344 test $RC = 0 && break
345 echo "Waiting $i seconds for slapd to start..."
348 if test $RC != 0 ; then
349 echo "ldapsearch failed ($RC)!"
350 test $KILLSERVERS != no && kill -HUP $KILLPIDS
354 for uri in $URI1 $URI2 $URI3 $URI4 $URI5 $URI6; do
355 echo "Adding schema on $uri..."
356 $LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
357 include: file://$ABS_SCHEMADIR/core.ldif
359 include: file://$ABS_SCHEMADIR/cosine.ldif
361 include: file://$ABS_SCHEMADIR/inetorgperson.ldif
363 include: file://$ABS_SCHEMADIR/openldap.ldif
365 include: file://$ABS_SCHEMADIR/nis.ldif
368 if test $RC != 0 ; then
369 echo "ldapadd failed for schema config ($RC)!"
370 test $KILLSERVERS != no && kill -HUP $KILLPIDS
374 [ "$BACKENDTYPE" = mod ] || continue
376 echo "Adding backend module on $uri..."
377 $LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
378 dn: cn=module,cn=config
379 objectClass: olcModuleList
381 olcModulePath: $TESTWD/../servers/slapd/back-$BACKEND
382 olcModuleLoad: back_$BACKEND.la
385 if test $RC != 0 ; then
386 echo "ldapadd failed for backend module ($RC)!"
387 test $KILLSERVERS != no && kill -HUP $KILLPIDS
392 echo "Adding database config on central master..."
393 if [ "$SYNCPROV" = syncprovmod ]; then
394 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
395 dn: cn=module,cn=config
396 objectClass: olcModuleList
398 olcModulePath: $TESTWD/../servers/slapd/overlays
399 olcModuleLoad: syncprov.la
403 if test $RC != 0 ; then
404 echo "ldapadd failed for moduleLoad ($RC)!"
405 test $KILLSERVERS != no && kill -HUP $KILLPIDS
410 nullExclude="" nullOK="" wantNoObj=32
411 test $BACKEND = null && nullExclude="# " nullOK="OK" wantNoObj=0
413 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
414 dn: olcDatabase={1}$BACKEND,cn=config
415 objectClass: olcDatabaseConfig
416 ${nullExclude}objectClass: olc${BACKEND}Config
417 olcDatabase: {1}$BACKEND
418 ${nullExclude}olcDbDirectory: $SMC_DIR/db
420 olcRootDN: $MANAGERDN
423 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
424 objectClass: olcOverlayConfig
427 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
428 objectClass: olcOverlayConfig
429 objectClass: olcSyncProvConfig
430 olcOverlay: {1}syncprov
433 dn: olcDatabase={1}$BACKEND,cn=config
434 objectClass: olcDatabaseConfig
435 ${nullExclude}objectClass: olc${BACKEND}Config
436 olcDatabase: {1}$BACKEND
437 ${nullExclude}olcDbDirectory: $SMC_DIR/ou1
439 olcSuffix: ou=ou1,$BASEDN
440 olcRootDN: $MANAGERDN
442 dn: olcDatabase={2}$BACKEND,cn=config
443 objectClass: olcDatabaseConfig
444 ${nullExclude}objectClass: olc${BACKEND}Config
445 olcDatabase: {2}$BACKEND
446 ${nullExclude}olcDbDirectory: $SMC_DIR/ou2
448 olcSuffix: ou=ou2,$BASEDN
449 olcRootDN: $MANAGERDN
451 dn: olcDatabase={3}$BACKEND,cn=config
452 objectClass: olcDatabaseConfig
453 ${nullExclude}objectClass: olc${BACKEND}Config
454 olcDatabase: {3}$BACKEND
455 ${nullExclude}olcDbDirectory: $SMC_DIR/sm1ou1
457 olcSuffix: ou=sm1ou1,$BASEDN
460 dn: olcDatabase={4}$BACKEND,cn=config
461 objectClass: olcDatabaseConfig
462 ${nullExclude}objectClass: olc${BACKEND}Config
463 olcDatabase: {4}$BACKEND
464 ${nullExclude}olcDbDirectory: $SMC_DIR/sm1ou2
466 olcSuffix: ou=sm1ou2,$BASEDN
469 dn: olcDatabase={5}$BACKEND,cn=config
470 objectClass: olcDatabaseConfig
471 ${nullExclude}objectClass: olc${BACKEND}Config
472 olcDatabase: {5}$BACKEND
473 ${nullExclude}olcDbDirectory: $SMC_DIR/sm2ou1
475 olcSuffix: ou=sm2ou1,$BASEDN
480 if test $RC != 0 ; then
481 echo "ldapadd failed for central master database config ($RC)!"
482 test $KILLSERVERS != no && kill -HUP $KILLPIDS
486 echo "Adding database config on site1 master..."
487 if [ "$SYNCPROV" = syncprovmod ]; then
488 $LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
489 dn: cn=module,cn=config
490 objectClass: olcModuleList
492 olcModulePath: $TESTWD/../servers/slapd/overlays
493 olcModuleLoad: syncprov.la
497 if test $RC != 0 ; then
498 echo "ldapadd failed for moduleLoad ($RC)!"
499 test $KILLSERVERS != no && kill -HUP $KILLPIDS
504 $LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
505 dn: olcDatabase={1}$BACKEND,cn=config
506 objectClass: olcDatabaseConfig
507 ${nullExclude}objectClass: olc${BACKEND}Config
508 olcDatabase: {1}$BACKEND
509 ${nullExclude}olcDbDirectory: $SM1_DIR/db
513 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
514 objectClass: olcOverlayConfig
517 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
518 objectClass: olcOverlayConfig
519 objectClass: olcSyncProvConfig
520 olcOverlay: {1}syncprov
522 dn: olcDatabase={1}$BACKEND,cn=config
523 objectClass: olcDatabaseConfig
524 ${nullExclude}objectClass: olc${BACKEND}Config
525 olcDatabase: {1}$BACKEND
526 ${nullExclude}olcDbDirectory: $SM1_DIR/ou1
528 olcSuffix: ou=ou1,$BASEDN
531 dn: olcDatabase={2}$BACKEND,cn=config
532 objectClass: olcDatabaseConfig
533 ${nullExclude}objectClass: olc${BACKEND}Config
534 olcDatabase: {2}$BACKEND
535 ${nullExclude}olcDbDirectory: $SM1_DIR/sm1ou1
537 olcSuffix: ou=sm1ou1,$BASEDN
538 olcRootDN: ou=sm1ou1,$BASEDN
541 dn: olcDatabase={3}$BACKEND,cn=config
542 objectClass: olcDatabaseConfig
543 ${nullExclude}objectClass: olc${BACKEND}Config
544 olcDatabase: {3}$BACKEND
545 ${nullExclude}olcDbDirectory: $SM1_DIR/sm1ou2
547 olcSuffix: ou=sm1ou2,$BASEDN
548 olcRootDN: ou=sm1ou1,$BASEDN
553 if test $RC != 0 ; then
554 echo "ldapadd failed for site1 master database config ($RC)!"
555 test $KILLSERVERS != no && kill -HUP $KILLPIDS
559 echo "Adding database config on site2 master..."
560 if [ "$SYNCPROV" = syncprovmod ]; then
561 $LDAPADD -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
562 dn: cn=module,cn=config
563 objectClass: olcModuleList
565 olcModulePath: $TESTWD/../servers/slapd/overlays
566 olcModuleLoad: syncprov.la
570 if test $RC != 0 ; then
571 echo "ldapadd failed for moduleLoad ($RC)!"
572 test $KILLSERVERS != no && kill -HUP $KILLPIDS
577 $LDAPADD -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
578 dn: olcDatabase={1}$BACKEND,cn=config
579 objectClass: olcDatabaseConfig
580 ${nullExclude}objectClass: olc${BACKEND}Config
581 olcDatabase: {1}$BACKEND
582 ${nullExclude}olcDbDirectory: $SM2_DIR/db
586 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
587 objectClass: olcOverlayConfig
590 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
591 objectClass: olcOverlayConfig
592 objectClass: olcSyncProvConfig
593 olcOverlay: {1}syncprov
596 dn: olcDatabase={1}$BACKEND,cn=config
597 objectClass: olcDatabaseConfig
598 ${nullExclude}objectClass: olc${BACKEND}Config
599 olcDatabase: {1}$BACKEND
600 ${nullExclude}olcDbDirectory: $SM2_DIR/ou2
602 olcSuffix: ou=ou2,$BASEDN
605 dn: olcDatabase={2}$BACKEND,cn=config
606 objectClass: olcDatabaseConfig
607 ${nullExclude}objectClass: olc${BACKEND}Config
608 olcDatabase: {2}$BACKEND
609 ${nullExclude}olcDbDirectory: $SM2_DIR/sm1ou1
611 olcSuffix: ou=sm1ou1,$BASEDN
614 dn: olcDatabase={3}$BACKEND,cn=config
615 objectClass: olcDatabaseConfig
616 ${nullExclude}objectClass: olc${BACKEND}Config
617 olcDatabase: {3}$BACKEND
618 ${nullExclude}olcDbDirectory: $SM2_DIR/sm2ou1
620 olcSuffix: ou=sm2ou1,$BASEDN
621 olcRootDN: ou=sm2ou1,$BASEDN
624 dn: olcDatabase={4}$BACKEND,cn=config
625 objectClass: olcDatabaseConfig
626 ${nullExclude}objectClass: olc${BACKEND}Config
627 olcDatabase: {4}$BACKEND
628 ${nullExclude}olcDbDirectory: $SM2_DIR/sm2ou2
630 olcSuffix: ou=sm2ou2,$BASEDN
631 olcRootDN: ou=sm2ou1,$BASEDN
636 if test $RC != 0 ; then
637 echo "ldapadd failed for site2 master database config ($RC)!"
638 test $KILLSERVERS != no && kill -HUP $KILLPIDS
642 echo "Adding access rules on central master..."
643 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
644 dn: olcDatabase={-1}frontend,cn=config
647 olcAccess: to dn.exact=dc=example,dc=com
649 olcAccess: to dn.subtree=ou=ou1,dc=example,dc=com
651 olcAccess: to dn.subtree=ou=ou2,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=sm1ou1,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 read
659 by dn.exact=dc=example,dc=com none
661 olcAccess: to dn.subtree=ou=sm1ou2,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 read
666 olcAccess: to dn.subtree=ou=sm2ou1,dc=example,dc=com
667 by dn.exact=ou=ou1,dc=example,dc=com none
668 by dn.exact=ou=ou2,dc=example,dc=com none
669 by dn.exact=dc=example,dc=com none
671 olcAccess: to * by * read
675 if test $RC != 0 ; then
676 echo "ldapmodify failed for central master access config ($RC)!"
677 test $KILLSERVERS != no && kill -HUP $KILLPIDS
681 echo "Adding access rules on site1 master..."
682 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
683 dn: olcDatabase={-1}frontend,cn=config
686 olcAccess: to dn.subtree=dc=example,dc=com
688 olcAccess: to * by * read
692 if test $RC != 0 ; then
693 echo "ldapmodify failed for site1 master access config ($RC)!"
694 test $KILLSERVERS != no && kill -HUP $KILLPIDS
698 echo "Adding access rules on site2 master..."
699 $LDAPMODIFY -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
700 dn: olcDatabase={-1}frontend,cn=config
703 olcAccess: to dn.exact=dc=example,dc=com
705 olcAccess: to dn.subtree=ou=ou2,dc=example,dc=com
707 olcAccess: to dn.subtree=ou=sm1ou1,dc=example,dc=com
710 olcAccess: to dn.subtree=ou=sm2ou1,dc=example,dc=com
712 olcAccess: to dn.subtree=ou=sm2ou2,dc=example,dc=com
713 by dn.exact=dc=example,dc=com read
716 olcAccess: to * by * read
720 if test $RC != 0 ; then
721 echo "ldapmodify failed for site2 master access config ($RC)!"
722 test $KILLSERVERS != no && kill -HUP $KILLPIDS
726 echo "Adding database config on central search..."
727 $LDAPADD -D cn=config -H $URI4 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
728 dn: olcDatabase={1}$BACKEND,cn=config
729 objectClass: olcDatabaseConfig
730 ${nullExclude}objectClass: olc${BACKEND}Config
731 olcDatabase: {1}$BACKEND
732 ${nullExclude}olcDbDirectory: $SSC_DIR/db
738 if test $RC != 0 ; then
739 echo "ldapadd failed for central search database config ($RC)!"
740 test $KILLSERVERS != no && kill -HUP $KILLPIDS
744 echo "Adding database config on site1 search..."
745 $LDAPADD -D cn=config -H $URI5 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
746 dn: olcDatabase={1}$BACKEND,cn=config
747 objectClass: olcDatabaseConfig
748 ${nullExclude}objectClass: olc${BACKEND}Config
749 olcDatabase: {1}$BACKEND
750 ${nullExclude}olcDbDirectory: $SS1_DIR/db
756 if test $RC != 0 ; then
757 echo "ldapadd failed for site1 search database config ($RC)!"
758 test $KILLSERVERS != no && kill -HUP $KILLPIDS
762 echo "Adding database config on site2 search..."
763 $LDAPADD -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
764 dn: olcDatabase={1}$BACKEND,cn=config
765 objectClass: olcDatabaseConfig
766 ${nullExclude}objectClass: olc${BACKEND}Config
767 olcDatabase: {1}$BACKEND
768 ${nullExclude}olcDbDirectory: $SS2_DIR/db
774 if test $RC != 0 ; then
775 echo "ldapadd failed for site2 search database config ($RC)!"
776 test $KILLSERVERS != no && kill -HUP $KILLPIDS
780 echo "Populating central master..."
781 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
782 dn: dc=example,dc=com
784 objectClass: organization
785 objectClass: dcObject
788 userPassword: $PASSWD
790 dn: ou=ou1,dc=example,dc=com
792 objectClass: organizationalUnit
794 userPassword: $PASSWD
796 dn: ou=ou2,dc=example,dc=com
798 objectClass: organizationalUnit
800 userPassword: $PASSWD
804 if test $RC != 0 ; then
805 echo "ldapadd failed to populate central master entry ($RC)!"
806 test $KILLSERVERS != no && kill -HUP $KILLPIDS
810 echo "Adding syncrepl on site1 master..."
811 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
812 dn: olcDatabase={4}$BACKEND,cn=config
815 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
816 binddn="ou=ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
817 type=refreshAndPersist retry="$RETRY" timeout=1
821 if test $RC != 0 ; then
822 echo "ldapmodify failed to add syncrepl on site1 master ($RC)!"
823 test $KILLSERVERS != no && kill -HUP $KILLPIDS
827 echo "Adding syncrepl on site2 master..."
828 $LDAPMODIFY -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
829 dn: olcDatabase={5}$BACKEND,cn=config
832 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
833 binddn="ou=ou2,$BASEDN" bindmethod=simple credentials=$PASSWD
834 type=refreshAndPersist retry="$RETRY" timeout=1
838 if test $RC != 0 ; then
839 echo "ldapmodify failed to add syncrepl on site2 master ($RC)!"
840 test $KILLSERVERS != no && kill -HUP $KILLPIDS
845 echo "Using ldapsearch to check that site1 master received changes..."
847 for i in 1 2 3 4 5; do
848 RESULT=`$LDAPSEARCH -H $URI2 \
849 -s base -b "ou=ou1,$BASEDN" \
850 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
851 if test "x$RESULT$nullOK" = "xOK" ; then
855 echo "Waiting $i seconds for syncrepl to receive changes..."
858 if test $RC != 0 ; then
859 echo "ldapsearch failed ($RC)!"
860 test $KILLSERVERS != no && kill -HUP $KILLPIDS
864 echo "Using ldapsearch to check that site2 master received changes..."
866 for i in 1 2 3 4 5; do
867 RESULT=`$LDAPSEARCH -H $URI3 \
868 -s base -b "ou=ou1,$BASEDN" \
869 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
870 if test "x$RESULT$nullOK" = "xOK" ; then
874 echo "Waiting $i seconds for syncrepl to receive changes..."
877 if test $RC != 0 ; then
878 echo "ldapsearch failed ($RC)!"
879 test $KILLSERVERS != no && kill -HUP $KILLPIDS
885 echo "Populating site1 master..."
886 $LDAPADD -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
887 dn: ou=sm1ou1,dc=example,dc=com
889 objectClass: organizationalUnit
892 dn: ou=sm1ou2,dc=example,dc=com
894 objectClass: organizationalUnit
899 if test $RC != 0 ; then
900 echo "ldapadd failed to populate site1 master ($RC)!"
901 test $KILLSERVERS != no && kill -HUP $KILLPIDS
907 echo "Populating site2 master..."
908 $LDAPADD -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
909 dn: ou=sm2ou1,dc=example,dc=com
911 objectClass: organizationalUnit
914 dn: ou=sm2ou2,dc=example,dc=com
916 objectClass: organizationalUnit
921 if test $RC != 0 ; then
922 echo "ldapadd failed to populate site2 master ($RC)!"
923 test $KILLSERVERS != no && kill -HUP $KILLPIDS
930 # Stop site1 master when adding syncrepl to the central master. When
931 # site1 master is started again both it and the central master will have
932 # the same number of contextCSN values, but the ones on central master
933 # will be the newest. The central master will not update its contextCSN
934 # values unless the bug in ITS#5597 have been fixed.
935 echo "Stopping site1 master..."
938 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SM1_PID / /"`;
941 echo "Adding syncrepl on central master..."
942 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
943 dn: olcDatabase={3}$BACKEND,cn=config
946 olcSyncRepl: rid=3 provider=$URI2 searchbase="ou=sm1ou1,$BASEDN"
947 binddn="ou=sm1ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
948 type=refreshAndPersist retry="$RETRY" timeout=1
950 dn: olcDatabase={5}$BACKEND,cn=config
953 olcSyncRepl: rid=5 provider=$URI3 searchbase="ou=sm2ou1,$BASEDN"
954 binddn="ou=sm2ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
955 type=refreshAndPersist retry="$RETRY" timeout=1
959 if test $RC != 0 ; then
960 echo "ldapmodify failed to add syncrepl on central master ($RC)!"
961 test $KILLSERVERS != no && kill -HUP $KILLPIDS
965 echo "Using ldapsearch to check that central master received site2 entries..."
967 for i in 1 2 3 4 5; do
968 RESULT=`$LDAPSEARCH -H $URI1 \
969 -s base -b "ou=sm2ou1,$BASEDN" \
970 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
971 if test "x$RESULT$nullOK" = "xOK" ; then
975 echo "Waiting $i seconds for syncrepl to receive changes..."
978 if test $RC != 0 ; then
979 echo "ldapsearch failed ($RC)!"
980 test $KILLSERVERS != no && kill -HUP $KILLPIDS
984 # Test for ITS#6716, modify on central master to ensure that the CSN
985 # order is "sid2 < sid3 < sid1". When site1 master starts it is likely
986 # to sync with central master before it syncs with site1 master. When
987 # central master syncs with site1 master they will share the sid1 and
988 # sid3 CSNs, the additonal sid2 CSN hold by site1 master will be the
989 # oldest. Central master will not receive the changes made on site1
990 # master unless it completely ignores the CSNs presented by central
992 echo "Using ldapmodify to modify central master..."
993 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
994 dn: dc=example,dc=com
997 description: Modify$MNUM
1001 if test $RC != 0 ; then
1002 echo "ldapmodify failed ($RC)!"
1003 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1007 if test -z "$SM1_PID" ; then
1008 echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
1010 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
1012 if test $WAIT != 0 ; then
1016 KILLPIDS="$KILLPIDS $SM1_PID"
1021 echo "Using ldapsearch to check that site1 master is running..."
1022 for i in 1 2 3 4 5; do
1023 $LDAPSEARCH -s base -b "" -H $URI2 \
1024 'objectclass=*' > /dev/null 2>&1
1026 test $RC = 0 && break
1027 echo "Waiting $i seconds for slapd to start..."
1030 if test $RC != 0 ; then
1031 echo "ldapsearch failed ($RC)!"
1032 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1036 echo "Using ldapsearch to check that central master received site1 entries..."
1038 for i in 1 2 3 4 5; do
1039 RESULT=`$LDAPSEARCH -H $URI1 \
1040 -s base -b "ou=sm1ou1,$BASEDN" \
1041 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1042 if test "x$RESULT$nullOK" = "xOK" ; then
1046 echo "Waiting $i seconds for syncrepl to receive changes..."
1049 if test $RC != 0 ; then
1050 echo "ldapsearch failed ($RC)!"
1051 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1055 echo "Using ldapsearch to check that site1 master received central master update..."
1057 for i in 1 2 3 4 5; do
1058 RESULT=`$LDAPSEARCH -H $URI2 \
1059 -s base -b "$BASEDN" \
1060 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1061 if test "x$RESULT$nullOK" = "xOK" ; then
1065 echo "Waiting $i seconds for syncrepl to receive changes..."
1068 if test $RC != 0 ; then
1069 echo "ldapsearch failed ($RC)!"
1070 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1074 echo "Using ldapsearch to check that site2 master received central master update..."
1076 for i in 1 2 3 4 5; do
1077 RESULT=`$LDAPSEARCH -H $URI3 \
1078 -s base -b "$BASEDN" \
1079 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1080 if test "x$RESULT$nullOK" = "xOK" ; then
1084 echo "Waiting $i seconds for syncrepl to receive changes..."
1087 if test $RC != 0 ; then
1088 echo "ldapsearch failed ($RC)!"
1089 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1093 # Test done, now some more intialization...
1095 echo "Adding syncrepl consumer on central search..."
1096 $LDAPMODIFY -D cn=config -H $URI4 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1097 dn: olcDatabase={1}$BACKEND,cn=config
1100 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
1101 binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1102 type=refreshAndPersist retry="$RETRY" timeout=1
1106 if test $RC != 0 ; then
1107 echo "ldapmodify failed to add syncrepl on site1 search ($RC)!"
1108 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1112 echo "Adding syncrepl consumer on site1 search..."
1113 $LDAPMODIFY -D cn=config -H $URI5 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1114 dn: olcDatabase={1}$BACKEND,cn=config
1117 olcSyncRepl: rid=1 provider=$URI2 searchbase="$BASEDN"
1118 binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1119 type=refreshAndPersist retry="$RETRY" timeout=1
1123 if test $RC != 0 ; then
1124 echo "ldapmodify failed to add syncrepl on site1 search ($RC)!"
1125 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1129 echo "Adding syncrepl consumer on site2 search..."
1130 $LDAPMODIFY -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1131 dn: olcDatabase={1}$BACKEND,cn=config
1134 olcSyncRepl: rid=1 provider=$URI3 searchbase="$BASEDN"
1135 binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1136 type=refreshAndPersist retry="$RETRY" timeout=1
1140 if test $RC != 0 ; then
1141 echo "ldapmodify failed to add syncrepl on site2 search ($RC)!"
1142 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1147 echo "Using ldapsearch to check that central search received changes..."
1149 for i in 1 2 3 4 5; do
1150 RESULT=`$LDAPSEARCH -H $URI4 \
1151 -s base -b "$BASEDN" \
1152 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1153 if test "x$RESULT$nullOK" = "xOK" ; then
1157 echo "Waiting $i seconds for syncrepl to receive changes..."
1160 if test $RC != 0 ; then
1161 echo "ldapsearch failed ($RC)!"
1162 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1166 echo "Using ldapsearch to check that site1 search received changes..."
1168 for i in 1 2 3 4 5; do
1169 RESULT=`$LDAPSEARCH -H $URI5 \
1170 -s base -b "$BASEDN" \
1171 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1172 if test "x$RESULT$nullOK" = "xOK" ; then
1176 echo "Waiting $i seconds for syncrepl to receive changes..."
1179 if test $RC != 0 ; then
1180 echo "ldapsearch failed ($RC)!"
1181 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1185 echo "Using ldapsearch to check that site2 search received changes..."
1187 for i in 1 2 3 4 5; do
1188 RESULT=`$LDAPSEARCH -H $URI6 \
1189 -s base -b "$BASEDN" \
1190 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1191 if test "x$RESULT$nullOK" = "xOK" ; then
1195 echo "Waiting $i seconds for syncrepl to receive changes..."
1198 if test $RC != 0 ; then
1199 echo "ldapsearch failed ($RC)!"
1200 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1204 # Create a script that will check the contextCSN values of all servers,
1205 # and restart them to re-synchronize if it finds any errors:
1206 cat > $TESTDIR/checkcsn.sh <<'EOF'
1211 CSN1=`$LDAPSEARCH -H $URI1 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1212 CSN2=`$LDAPSEARCH -H $URI2 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1213 CSN3=`$LDAPSEARCH -H $URI3 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1214 CSN4=`$LDAPSEARCH -H $URI4 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1215 CSN5=`$LDAPSEARCH -H $URI5 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1216 CSN6=`$LDAPSEARCH -H $URI6 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1218 if test -z "$CSN1" ; then
1219 echo "ERROR: contextCSN empty on central master"
1220 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1222 nCSN=`echo "$CSN1" | wc -l`
1223 if test "$nCSN" -ne 3 ; then
1224 echo "ERROR: Wrong contextCSN count on central master, should be 3"
1225 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1226 if test -n "$CSN_VERBOSE"; then
1230 if test -z "$CSN2" -o "$CSN1" != "$CSN2" ; then
1231 echo "ERROR: contextCSN mismatch between central master and site1 master"
1232 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1233 if test -n "$CSN_VERBOSE"; then
1234 echo "contextCSN on central master:"
1236 echo "contextCSN on site1 master:"
1240 if test -z "$CSN3" -o "$CSN1" != "$CSN3" ; then
1241 echo "ERROR: contextCSN mismatch between central master and site2 master"
1242 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1243 if test -n "$CSN_VERBOSE"; then
1244 echo "contextCSN on central master:"
1246 echo "contextCSN on site2 master:"
1250 if test -z "$CSN4" -o "$CSN1" != "$CSN4" ; then
1251 echo "ERROR: contextCSN mismatch between central master and central search"
1252 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1253 if test -n "$CSN_VERBOSE"; then
1254 echo "contextCSN on central master:"
1256 echo "contextCSN on central search:"
1260 if test -z "$CSN5" -o "$CSN2" != "$CSN5" ; then
1261 echo "ERROR: contextCSN mismatch between site1 master and site1 search"
1262 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1263 if test -n "$CSN_VERBOSE"; then
1264 echo "contextCSN on site1 master:"
1266 echo "contextCSN on site1 search:"
1270 if test -z "$CSN6" -o "$CSN3" != "$CSN6" ; then
1271 echo "ERROR: contextCSN mismatch between site2 master and site2 search:"
1272 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1273 if test -n "$CSN_VERBOSE"; then
1274 echo "contextCSN on site2 master:"
1276 echo "contextCSN on site2 search:"
1281 if test $CSN_ERRORS != 0 ; then
1282 echo "Stopping all servers to synchronize contextCSN..."
1284 for pid in $KILLPIDS ; do wait $pid ; done
1287 echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
1289 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
1291 if test $WAIT != 0 ; then
1295 KILLPIDS="$KILLPIDS $SM1_PID"
1298 echo "Using ldapsearch to check that site1 master is running..."
1299 for i in 1 2 3 4 5; do
1300 $LDAPSEARCH -s base -b "" -H $URI2 \
1301 'objectclass=*' > /dev/null 2>&1
1303 test $RC = 0 && break
1304 echo "Waiting $i seconds for slapd to start..."
1307 if test $RC != 0 ; then
1308 echo "ldapsearch failed ($RC)!"
1309 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1313 echo "Restarting site2 master slapd on TCP/IP port $PORT3..."
1315 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1317 if test $WAIT != 0 ; then
1321 KILLPIDS="$KILLPIDS $SM2_PID "
1324 echo "Using ldapsearch to check that site2 master is running..."
1325 for i in 1 2 3 4 5; do
1326 $LDAPSEARCH -s base -b "" -H $URI3 \
1327 'objectclass=*' > /dev/null 2>&1
1329 test $RC = 0 && break
1330 echo "Waiting $i seconds for slapd to start..."
1333 if test $RC != 0 ; then
1334 echo "ldapsearch failed ($RC)!"
1335 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1339 echo "Restarting central master slapd on TCP/IP port $PORT1..."
1341 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
1343 if test $WAIT != 0 ; then
1347 KILLPIDS="$KILLPIDS $SMC_PID"
1350 echo "Using ldapsearch to check that central master slapd is running..."
1351 for i in 1 2 3 4 5; do
1352 $LDAPSEARCH -s base -b "" -H $URI1 \
1353 'objectclass=*' > /dev/null 2>&1
1355 test $RC = 0 && break
1356 echo "Waiting $i seconds for slapd to start..."
1359 if test $RC != 0 ; then
1360 echo "ldapsearch failed ($RC)!"
1361 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1365 echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1368 echo "Stopping site1 and site2 master..."
1369 kill -HUP $SM1_PID $SM2_PID
1370 for pid in $SM1_PID $SM2_PID ; do wait $pid ; done
1371 KILLPIDS=" $SMC_PID"
1373 echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
1375 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
1377 if test $WAIT != 0 ; then
1381 KILLPIDS="$KILLPIDS $SM1_PID"
1384 echo "Using ldapsearch to check that site1 master is running..."
1385 for i in 1 2 3 4 5; do
1386 $LDAPSEARCH -s base -b "" -H $URI2 \
1387 'objectclass=*' > /dev/null 2>&1
1389 test $RC = 0 && break
1390 echo "Waiting $i seconds for slapd to start..."
1393 if test $RC != 0 ; then
1394 echo "ldapsearch failed ($RC)!"
1395 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1399 echo "Restarting site2 master slapd on TCP/IP port $PORT3..."
1401 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1403 if test $WAIT != 0 ; then
1407 KILLPIDS="$KILLPIDS $SM2_PID"
1410 echo "Using ldapsearch to check that site2 master is running..."
1411 for i in 1 2 3 4 5; do
1412 $LDAPSEARCH -s base -b "" -H $URI3 \
1413 'objectclass=*' > /dev/null 2>&1
1415 test $RC = 0 && break
1416 echo "Waiting $i seconds for slapd to start..."
1419 if test $RC != 0 ; then
1420 echo "ldapsearch failed ($RC)!"
1421 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1425 echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1428 echo "Restarting central search slapd on TCP/IP port $PORT4..."
1430 $SLAPD -F slapd.d -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
1432 if test $WAIT != 0 ; then
1436 KILLPIDS="$KILLPIDS $SSC_PID"
1439 echo "Using ldapsearch to check that central search slapd is running..."
1440 for i in 1 2 3 4 5; do
1441 $LDAPSEARCH -s base -b "" -H $URI4 \
1442 'objectclass=*' > /dev/null 2>&1
1444 test $RC = 0 && break
1445 echo "Waiting $i seconds for slapd to start..."
1448 if test $RC != 0 ; then
1449 echo "ldapsearch failed ($RC)!"
1450 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1454 echo "Restarting site1 search slapd on TCP/IP port $PORT5..."
1456 $SLAPD -F slapd.d -h $URI5 -d $LVL $TIMING >> $LOG5 2>&1 &
1458 if test $WAIT != 0 ; then
1462 KILLPIDS="$KILLPIDS $SS1_PID"
1465 echo "Using ldapsearch to check that site1 search slapd is running..."
1466 for i in 1 2 3 4 5; do
1467 $LDAPSEARCH -s base -b "" -H $URI5 \
1468 'objectclass=*' > /dev/null 2>&1
1470 test $RC = 0 && break
1471 echo "Waiting $i seconds for slapd to start..."
1474 if test $RC != 0 ; then
1475 echo "ldapsearch failed ($RC)!"
1476 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1480 echo "Restarting site2 search slapd on TCP/IP port $PORT6..."
1482 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING >> $LOG6 2>&1 &
1484 if test $WAIT != 0 ; then
1488 KILLPIDS="$KILLPIDS $SS2_PID"
1491 echo "Using ldapsearch to check that site2 search slapd is running..."
1492 for i in 1 2 3 4 5; do
1493 $LDAPSEARCH -s base -b "" -H $URI6 \
1494 'objectclass=*' > /dev/null 2>&1
1496 test $RC = 0 && break
1497 echo "Waiting $i seconds for slapd to start..."
1500 if test $RC != 0 ; then
1501 echo "ldapsearch failed ($RC)!"
1502 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1506 echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1509 echo "Checking contextCSN after restart..."
1510 CSN1=`$LDAPSEARCH -H $URI1 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1511 CSN2=`$LDAPSEARCH -H $URI2 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1512 CSN3=`$LDAPSEARCH -H $URI3 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1513 CSN4=`$LDAPSEARCH -H $URI4 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1514 CSN5=`$LDAPSEARCH -H $URI5 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1515 CSN6=`$LDAPSEARCH -H $URI6 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1516 if test -z "$CSN1" ; then
1517 echo "ERROR: contextCSN empty on central master"
1518 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1521 if test -z "$CSN2" -o "$CSN1" != "$CSN2" ; then
1522 echo "ERROR: contextCSN mismatch between central master and site1 master"
1523 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1524 if test -n "$CSN_VERBOSE"; then
1525 echo "contextCSN on central master:"
1527 echo "contextCSN on site1 master:"
1531 if test -z "$CSN3" -o "$CSN1" != "$CSN3" ; then
1532 echo "ERROR: contextCSN mismatch between central master and site2 master"
1533 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1534 if test -n "$CSN_VERBOSE"; then
1535 echo "contextCSN on central master:"
1537 echo "contextCSN on site2 master:"
1541 if test -z "$CSN4" -o "$CSN1" != "$CSN4" ; then
1542 echo "ERROR: contextCSN mismatch between central master and central search"
1543 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1544 if test -n "$CSN_VERBOSE"; then
1545 echo "contextCSN on central master:"
1547 echo "contextCSN on central search:"
1551 if test -z "$CSN5" -o "$CSN2" != "$CSN5" ; then
1552 echo "ERROR: contextCSN mismatch between site1 master and site1 search"
1553 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1554 if test -n "$CSN_VERBOSE"; then
1555 echo "contextCSN on site1 master:"
1557 echo "contextCSN on site1 search:"
1561 if test -z "$CSN6" -o "$CSN3" != "$CSN6" ; then
1562 echo "ERROR: contextCSN mismatch between site2 master and site2 search:"
1563 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1564 if test -n "$CSN_VERBOSE"; then
1565 echo "contextCSN on site2 master:"
1567 echo "contextCSN on site2 search:"
1573 ERRORS=`expr $ERRORS + $CSN_ERRORS`
1577 test $BACKEND = null && echo : > $TESTDIR/checkcsn.sh
1579 chmod +x $TESTDIR/checkcsn.sh
1582 echo "Checking contextCSN after initial replication..."
1583 . $TESTDIR/checkcsn.sh
1586 # Test that updates to the first backend on central master, which should
1587 # be replicated to all servers actually is so, and that the contextCSN is
1588 # updated everywhere:
1589 echo "Using ldapmodify to modify first backend on central master..."
1590 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1591 dn: ou=ou1,dc=example,dc=com
1594 description: Modify$MNUM
1598 if test $RC != 0 ; then
1599 echo "ldapmodify failed ($RC)!"
1600 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1605 echo "Using ldapsearch to check replication to central search..."
1607 for i in 1 2 3 4 5; do
1608 RESULT=`$LDAPSEARCH -H $URI4 \
1609 -s base -b "ou=ou1,$BASEDN" \
1610 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1611 if test "x$RESULT$nullOK" = "xOK" ; then
1615 echo "Waiting $i seconds for syncrepl to receive changes..."
1618 if test $RC != 0 ; then
1619 echo "ldapsearch failed ($RC)!"
1620 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1624 echo "Using ldapsearch to check replication to site1 search..."
1626 for i in 1 2 3 4 5; do
1627 RESULT=`$LDAPSEARCH -H $URI5 \
1628 -s base -b "ou=ou1,$BASEDN" \
1629 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1630 if test "x$RESULT$nullOK" = "xOK" ; then
1634 echo "Waiting $i seconds for syncrepl to receive changes..."
1637 if test $RC != 0 ; then
1638 echo "ldapsearch failed ($RC)!"
1639 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1643 echo "Using ldapsearch to check replication to site2 search..."
1645 for i in 1 2 3 4 5; do
1646 RESULT=`$LDAPSEARCH -H $URI6 \
1647 -s base -b "ou=ou1,$BASEDN" \
1648 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1649 if test "x$RESULT$nullOK" = "xOK" ; then
1653 echo "Waiting $i seconds for syncrepl to receive changes..."
1656 if test $RC != 0 ; then
1657 echo "ldapsearch failed ($RC)!"
1658 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1662 echo "Checking contextCSN after modify of first backend on central master..."
1663 . $TESTDIR/checkcsn.sh
1666 # Test that updates to the second backend on central master is only
1667 # replicated to those search servers that should receive that backend.
1668 # The contextCSN should still be updated everywhere:
1669 MNUM=`expr $MNUM + 1`
1670 echo "Using ldapmodify to modify second backend on central master..."
1671 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1672 dn: ou=ou2,dc=example,dc=com
1675 description: Modify$MNUM
1679 if test $RC != 0 ; then
1680 echo "ldapmodify failed ($RC)!"
1681 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1686 echo "Using ldapsearch to check replication to site2 search..."
1688 for i in 1 2 3 4 5; do
1689 RESULT=`$LDAPSEARCH -H $URI6 \
1690 -s base -b "ou=ou2,$BASEDN" \
1691 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1692 if test "x$RESULT$nullOK" = "xOK" ; then
1696 echo "Waiting $i seconds for syncrepl to receive changes..."
1699 if test $RC != 0 ; then
1700 echo "ldapsearch failed ($RC)!"
1701 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1705 echo "Using ldapsearch to check no replication to site1 master..."
1706 for i in 1 2 3 4 5; do
1707 RESULT=`$LDAPSEARCH -H $URI2 \
1708 -s base -b "ou=ou2,$BASEDN" \
1709 "(description=Modify$NMUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1710 if test "x$RESULT" = "xNOK" ; then
1711 echo "Change was replicated to site1 search!"
1712 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1718 echo "Using ldapsearch to check no replication to central search..."
1719 for i in 1 2 3 4 5; do
1720 RESULT=`$LDAPSEARCH -H $URI4 \
1721 -s base -b "ou=ou2,$BASEDN" \
1722 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1723 if test "x$RESULT" = "xNOK" ; then
1724 echo "Change was replicated to central search!"
1725 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1731 echo "Checking contextCSN after modify of second backend on central master..."
1732 . $TESTDIR/checkcsn.sh
1735 # Test that updates to the first backend on site1 master, which should be
1736 # replicated everywhere except to central and site2 search. The contextCSN
1737 # should be updated on all servers:
1738 MNUM=`expr $MNUM + 1`
1739 echo "Using ldapmodify to modify first backend on site1 master..."
1740 $LDAPMODIFY -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1741 dn: ou=sm1ou1,dc=example,dc=com
1744 description: Modify$MNUM
1748 if test $RC != 0 ; then
1749 echo "ldapmodify failed ($RC)!"
1750 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1755 echo "Using ldapsearch to check replication to site1 search..."
1757 for i in 1 2 3 4 5; do
1758 RESULT=`$LDAPSEARCH -H $URI5 \
1759 -s base -b "ou=sm1ou1,$BASEDN" \
1760 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1761 if test "x$RESULT$nullOK" = "xOK" ; then
1765 echo "Waiting $i seconds for syncrepl to receive changes..."
1768 if test $RC != 0 ; then
1769 echo "ldapsearch failed ($RC)!"
1770 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1774 echo "Using ldapsearch to check replication to site2 master..."
1776 for i in 1 2 3 4 5; do
1777 RESULT=`$LDAPSEARCH -H $URI3 \
1778 -s base -b "ou=sm1ou1,$BASEDN" \
1779 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1780 if test "x$RESULT$nullOK" = "xOK" ; then
1784 echo "Waiting $i seconds for syncrepl to receive changes..."
1787 if test $RC != 0 ; then
1788 echo "ldapsearch failed ($RC)!"
1789 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1793 echo "Using ldapsearch to check no replication to site2 search..."
1794 for i in 1 2 3 4 5; do
1795 RESULT=`$LDAPSEARCH -H $URI6 \
1796 -s base -b "ou=sm1ou2,$BASEDN" \
1797 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1798 if test "x$RESULT" = "xNOK" ; then
1799 echo "Change was replicated to central search!"
1800 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1806 echo "Using ldapsearch to check no replication to central search..."
1807 for i in 1 2 3 4 5; do
1808 RESULT=`$LDAPSEARCH -H $URI4 \
1809 -s base -b "ou=sm1ou2,$BASEDN" \
1810 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1811 if test "x$RESULT" = "xNOK" ; then
1812 echo "Change was replicated to central search!"
1813 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1819 echo "Checking contextCSN after modify of first backend on site1 master..."
1820 . $TESTDIR/checkcsn.sh
1824 # Test updates to the second backend on site1 master, which should only be
1825 # replicated to site1 search. The contextCSN should be updated everywhere.
1826 MNUM=`expr $MNUM + 1`
1827 echo "Using ldapmodify to modify second backend on site1 master..."
1828 $LDAPMODIFY -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1829 dn: ou=sm1ou2,dc=example,dc=com
1832 description: Modify$MNUM
1836 if test $RC != 0 ; then
1837 echo "ldapmodify failed ($RC)!"
1838 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1844 echo "Using ldapsearch to check replication to site1 search..."
1846 for i in 1 2 3 4 5; do
1847 RESULT=`$LDAPSEARCH -H $URI5 \
1848 -s base -b "ou=sm1ou2,$BASEDN" \
1849 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1850 if test "x$RESULT$nullOK" = "xOK" ; then
1854 echo "Waiting $i seconds for syncrepl to receive changes..."
1857 if test $RC != 0 ; then
1858 echo "ldapsearch failed ($RC)!"
1859 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1863 echo "Using ldapsearch to check no replication to central master..."
1864 for i in 1 2 3 4 5; do
1865 RESULT=`$LDAPSEARCH -H $URI1 \
1866 -s base -b "ou=sm1ou2,$BASEDN" \
1867 "(description=Modify$NMUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1868 if test "x$RESULT" = "xNOK" ; then
1869 echo "Change was replicated to site2 search!"
1870 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1876 echo "Checking contextCSN after modify of second backend on site1 master..."
1877 . $TESTDIR/checkcsn.sh
1881 # Test updates to first backend on site2 master, which should be
1882 # replicated to the central servers, but not site1. The contextCSN
1883 # should be updated everywhere:
1884 MNUM=`expr $MNUM + 1`
1885 echo "Using ldapmodify to modify first backend on site2 master..."
1886 $LDAPMODIFY -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1887 dn: ou=sm2ou1,dc=example,dc=com
1890 description: Modify$MNUM
1894 if test $RC != 0 ; then
1895 echo "ldapmodify failed ($RC)!"
1896 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1901 echo "Using ldapsearch to check replication to central master..."
1903 for i in 1 2 3 4 5; do
1904 RESULT=`$LDAPSEARCH -H $URI1 \
1905 -s base -b "ou=sm2ou1,$BASEDN" \
1906 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1907 if test "x$RESULT$nullOK" = "xOK" ; then
1911 echo "Waiting $i seconds for syncrepl to receive changes..."
1914 if test $RC != 0 ; then
1915 echo "ldapsearch failed ($RC)!"
1916 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1920 echo "Using ldapsearch to check replication to site2 search..."
1922 for i in 1 2 3 4 5; do
1923 RESULT=`$LDAPSEARCH -H $URI6 \
1924 -s base -b "ou=sm2ou1,$BASEDN" \
1925 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1926 if test "x$RESULT$nullOK" = "xOK" ; then
1930 echo "Waiting $i seconds for syncrepl to receive changes..."
1933 if test $RC != 0 ; then
1934 echo "ldapsearch failed ($RC)!"
1935 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1939 echo "Using ldapsearch to check no replication to site1 master..."
1940 for i in 1 2 3 4 5; do
1941 RESULT=`$LDAPSEARCH -H $URI2 \
1942 -s base -b "ou=sm2ou1,$BASEDN" \
1943 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1944 if test "x$RESULT" = "xNOK" ; then
1945 echo "Change was replicated to site2 search!"
1946 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1952 echo "Using ldapsearch to check no replication to central search..."
1953 for i in 1 2 3 4 5; do
1954 RESULT=`$LDAPSEARCH -H $URI4 \
1955 -s base -b "ou=sm2ou1,$BASEDN" \
1956 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1957 if test "x$RESULT" = "xNOK" ; then
1958 echo "Change was replicated to site2 search!"
1959 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1965 echo "Checking contextCSN after modify of first backend on site2 master..."
1966 . $TESTDIR/checkcsn.sh
1970 # Test updates to the second backend on site2 master, which should only be
1971 # replicated to site2 search. As always, contextCSN should be updated
1973 MNUM=`expr $MNUM + 1`
1974 echo "Using ldapmodify to modify second backend on site2 master..."
1975 $LDAPMODIFY -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1976 dn: ou=sm2ou2,dc=example,dc=com
1979 description: Modify$MNUM
1983 if test $RC != 0 ; then
1984 echo "ldapmodify failed ($RC)!"
1985 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1990 echo "Using ldapsearch to check replication to site2 search..."
1992 for i in 1 2 3 4 5; do
1993 RESULT=`$LDAPSEARCH -H $URI6 \
1994 -s base -b "ou=sm2ou2,$BASEDN" \
1995 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1996 if test "x$RESULT$nullOK" = "xOK" ; then
2000 echo "Waiting $i seconds for syncrepl to receive changes..."
2003 if test $RC != 0 ; then
2004 echo "ldapsearch failed ($RC)!"
2005 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2009 echo "Using ldapsearch to check no replication to central master..."
2010 for i in 1 2 3 4 5; do
2011 RESULT=`$LDAPSEARCH -H $URI4 \
2012 -s base -b "ou=sm2ou2,$BASEDN" \
2013 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
2014 if test "x$RESULT" = "xNOK" ; then
2015 echo "Change was replicated to central search!"
2016 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2022 echo "Checking contextCSN after modify of second backend on site2 master..."
2023 . $TESTDIR/checkcsn.sh
2026 # Test that all contextCSN values are updated on the slaves when they
2027 # starts with an empty database. Start site2 master first, then site2
2028 # search and finally central master so that the site2 search's syncrepl
2029 # connection has been set up when site2 master receives the database:
2030 echo "Stopping central master and site2 servers to test start with emtpy db..."
2031 kill -HUP $SMC_PID $SM2_PID $SS2_PID
2032 for pid in $SMC_PID $SM2_PID $SS2_PID; do wait $pid ; done
2033 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2034 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SM2_PID / /"`;
2035 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SS2_PID / /"`;
2039 rm -rf $SM2_DIR/db/*
2040 rm -rf $SS2_DIR/db/*
2042 echo "Starting site2 master slapd on TCP/IP port $PORT3..."
2044 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
2046 if test $WAIT != 0 ; then
2050 KILLPIDS="$KILLPIDS $SM2_PID"
2053 echo "Using ldapsearch to check that site2 master slapd is running..."
2054 for i in 1 2 3 4 5; do
2055 $LDAPSEARCH -s base -b "" -H $URI3 \
2056 'objectclass=*' > /dev/null 2>&1
2058 test $RC = 0 && break
2059 echo "Waiting $i seconds for slapd to start..."
2062 if test $RC != 0 ; then
2063 echo "ldapsearch failed ($RC)!"
2064 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2068 echo "Starting site2 search slapd on TCP/IP port $PORT6..."
2070 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING >> $LOG6 2>&1 &
2072 if test $WAIT != 0 ; then
2076 KILLPIDS="$KILLPIDS $SS2_PID"
2079 echo "Using ldapsearch to check that site2 search slapd is running..."
2080 for i in 1 2 3 4 5; do
2081 $LDAPSEARCH -s base -b "" -H $URI6 \
2082 'objectclass=*' > /dev/null 2>&1
2084 test $RC = 0 && break
2085 echo "Waiting $i seconds for slapd to start..."
2088 if test $RC != 0 ; then
2089 echo "ldapsearch failed ($RC)!"
2090 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2094 echo "Starting central master slapd on TCP/IP port $PORT1..."
2096 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2098 if test $WAIT != 0 ; then
2102 KILLPIDS="$KILLPIDS $SMC_PID"
2105 echo "Using ldapsearch to check that central master slapd is running..."
2106 for i in 1 2 3 4 5; do
2107 $LDAPSEARCH -s base -b "" -H $URI1 \
2108 'objectclass=*' > /dev/null 2>&1
2110 test $RC = 0 && break
2111 echo "Waiting $i seconds for slapd to start..."
2114 if test $RC != 0 ; then
2115 echo "ldapsearch failed ($RC)!"
2116 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2120 echo "Using ldapsearch to check that site2 master received base..."
2122 for i in 1 2 3 4 5; do
2123 RESULT=`$LDAPSEARCH -H $URI3 \
2124 -s base -b "$BASEDN" \
2125 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2126 if test "x$RESULT$nullOK" = "xOK" ; then
2130 echo "Waiting $i seconds for syncrepl to receive changes..."
2133 if test $RC != 0 ; then
2134 echo "ldapsearch failed ($RC)!"
2135 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2139 echo "Using ldapsearch to check that site2 search received base..."
2141 for i in 1 2 3 4 5; do
2142 RESULT=`$LDAPSEARCH -H $URI6 \
2143 -s base -b "$BASEDN" \
2144 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2145 if test "x$RESULT$nullOK" = "xOK" ; then
2149 echo "Waiting $i seconds for syncrepl to receive changes..."
2152 if test $RC != 0 ; then
2153 echo "ldapsearch failed ($RC)!"
2154 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2160 echo "Checking contextCSN after site2 servers repopulated..."
2161 . $TESTDIR/checkcsn.sh
2163 if test $ERRORS -ne 0; then
2164 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2165 echo "Found $ERRORS errors"
2170 # Adding syncrepl of the second site1 master backend on central master
2171 # will not initialize the database unless the contextCSN attribute is
2172 # stored in the suffix of the database and not the suffix of the glue
2174 echo "Adding syncrepl of second site1 master backend on central master..."
2175 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
2176 dn: olcDatabase={4}$BACKEND,cn=config
2179 olcSyncRepl: rid=4 provider=$URI2 searchbase="ou=sm1ou2,$BASEDN"
2180 binddn="ou=sm1ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
2181 type=refreshAndPersist retry="$RETRY" timeout=1
2184 if test $RC != 0 ; then
2185 echo "ldapmodify failed to add syncrepl on central master ($RC)!"
2186 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2191 echo "Using ldapsearch to check that central master received second site1 backend..."
2193 for i in 1 2 3 4 5; do
2194 RESULT=`$LDAPSEARCH -H $URI1 \
2195 -s base -b "ou=sm1ou2,$BASEDN" \
2196 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2197 if test "x$RESULT$nullOK" = "xOK" ; then
2201 echo "Waiting $i seconds for syncrepl to receive changes..."
2204 if test $RC != 0 ; then
2205 echo "ERROR: Second site1 backend not replicated to central master"
2206 ERRORS=`expr $ERRORS + 1`
2208 echo "Restarting central master slapd on TCP/IP port $PORT1..."
2211 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2214 $SLAPD -F slapd.d -h $URI1 -c rid=4,csn=0 -d $LVL $TIMING >> $LOG1 2>&1 &
2216 if test $WAIT != 0 ; then
2220 KILLPIDS="$KILLPIDS $SMC_PID"
2222 echo "Using ldapsearch to check that central master slapd is running..."
2223 for i in 1 2 3 4 5; do
2224 $LDAPSEARCH -s base -b "" -H $URI1 \
2225 'objectclass=*' > /dev/null 2>&1
2227 test $RC = 0 && break
2228 echo "Waiting $i seconds for slapd to start..."
2231 if test $RC != 0 ; then
2232 echo "ldapsearch failed ($RC)!"
2233 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2237 echo "Using ldapsearch to check that central master received second site1 backend..."
2239 for i in 1 2 3 4 5; do
2240 RESULT=`$LDAPSEARCH -H $URI1 \
2241 -s base -b "ou=sm1ou2,$BASEDN" \
2242 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2243 if test "x$RESULT$nullOK" = "xOK" ; then
2247 echo "Waiting $i seconds for syncrepl to receive changes..."
2250 if test $RC != 0 ; then
2251 echo "ldapsearch failed ($RC)!"
2252 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2257 echo "Using ldapsearch to check that central search received second site1 backend..."
2259 for i in 1 2 3 4 5; do
2260 RESULT=`$LDAPSEARCH -H $URI4 \
2261 -s base -b "ou=sm1ou2,$BASEDN" \
2262 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2263 if test "x$RESULT$nullOK" = "xOK" ; then
2267 echo "Waiting $i seconds for syncrepl to receive changes..."
2270 if test $RC != 0 ; then
2271 echo "ERROR: Second site1 backend not replicated to central search"
2272 ERRORS=`expr $ERRORS + 1`
2274 echo "Restarting central search slapd on TCP/IP port $PORT4..."
2277 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SSC_PID / /"`;
2280 $SLAPD -F slapd.d -h $URI4 -c rid=1,csn=0 -d $LVL $TIMING >> $LOG4 2>&1 &
2282 if test $WAIT != 0 ; then
2286 KILLPIDS="$KILLPIDS $SSC_PID"
2288 echo "Using ldapsearch to check that central search slapd is running..."
2289 for i in 1 2 3 4 5; do
2290 $LDAPSEARCH -s base -b "" -H $URI4 \
2291 'objectclass=*' > /dev/null 2>&1
2293 test $RC = 0 && break
2294 echo "Waiting $i seconds for slapd to start..."
2297 if test $RC != 0 ; then
2298 echo "ldapsearch failed ($RC)!"
2299 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2303 echo "Using ldapsearch to check that central search received second site1 backend..."
2305 for i in 1 2 3 4 5; do
2306 RESULT=`$LDAPSEARCH -H $URI4 \
2307 -s base -b "ou=sm1ou2,$BASEDN" \
2308 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2309 if test "x$RESULT$nullOK" = "xOK" ; then
2313 echo "Waiting $i seconds for syncrepl to receive changes..."
2316 if test $RC != 0 ; then
2317 echo "ldapsearch failed ($RC)!"
2318 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2325 # Run race tests when more than one backend is replicated from the same
2326 # provider. This will usually fail long before 100 iterations unless
2327 # syncrepl stores the contextCSN in the suffix of its own database, and
2328 # that syncprov follows these rules before updating its own CSN when it
2329 # detects updates from syncrepl:
2330 # 1) A contextCSN value must have been stored in the suffix of all the
2331 # syncrepl configured databases within the glued syncprov database.
2332 # 2) Of all contextCSN values stored by syncrepl with the same SID,
2333 # syncprov must always select the one with the lowest csn value.
2334 test -z "$RACE_TESTS" && RACE_TESTS=10
2338 SUB_DN=ou=sub,ou=sm1ou2,dc=example,dc=com
2340 while test $RACE_ERROR -eq 0 -a $RACE_NUM -lt $RACE_TESTS ; do
2341 RACE_NUM=`expr $RACE_NUM + 1`
2342 echo "Running $RACE_NUM of $RACE_TESTS syncrepl race tests..."
2344 echo "Stopping central master..."
2347 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2349 MNUM=`expr $MNUM + 1`
2350 echo "Using ldapadd to add entry on site1 master..."
2351 $LDAPADD -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
2354 objectClass: organizationalUnit
2359 if test $RC != 0 ; then
2360 echo "ldapadd failed ($RC)!"
2361 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2365 echo "Starting central master again..."
2367 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2369 KILLPIDS="$KILLPIDS $SMC_PID"
2371 echo "Using ldapsearch to check that central master received entry..."
2372 for i in 1 2 3 4 5; do
2373 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI1 > /dev/null 2>&1
2375 test $RC = 0 && break
2378 if test $RC != 0 ; then
2379 echo "ERROR: entry not replicated to central master!"
2384 echo "Using ldapsearch to check that central search received entry..."
2385 for i in 1 2 3 4 5; do
2386 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI4 > /dev/null 2>&1
2388 test $RC = 0 && break
2391 if test $RC != 0 ; then
2392 echo "ERROR: entry not replicated to central master!"
2397 echo "Stopping central master..."
2400 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2402 echo "Using ldapdelete to delete entry on site1 master..."
2403 $LDAPDELETE -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD "$SUB_DN"
2405 if test $RC != 0 ; then
2406 echo "ldapdelete failed ($RC)!"
2407 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2411 echo "Starting central master again..."
2413 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2415 KILLPIDS="$KILLPIDS $SMC_PID"
2418 echo "Using ldapsearch to check that entry was deleted on central master..."
2420 for i in 1 2 3 4 5; do
2421 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI1 > /dev/null 2>&1
2423 if test $RC = $wantNoObj; then break; fi
2427 if test $RC != $wantNoObj; then
2428 if test $RC != 0; then
2429 echo "ldapsearch failed ($RC)!"
2430 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2433 echo "ERROR: Entry not removed on central master!"
2438 echo "Using ldapsearch to check that entry was deleted on central search..."
2440 for i in 1 2 3 4 5; do
2441 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI4 > /dev/null 2>&1
2443 if test $RC != 0; then break; fi
2447 if test $RC != $wantNoObj; then
2448 echo "ERROR: Entry not removed on central search! (RC=$RC)"
2454 if test $RACE_ERROR != 0; then
2455 echo "Race error found after $RACE_NUM of $RACE_TESTS iterations"
2456 ERRORS=`expr $ERRORS + $RACE_ERROR`
2458 echo "No race errors found after $RACE_TESTS iterations"
2461 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2463 if test $ERRORS -ne 0; then
2464 echo "Found $ERRORS errors"
2465 echo ">>>>>> Exiting with a false success status for now"
2469 echo ">>>>> Test succeeded"