]> git.sur5r.net Git - openldap/blob - tests/scripts/test058-syncrepl-asymmetric
Disable test058 until it someone can track down what's wrong with it
[openldap] / tests / scripts / test058-syncrepl-asymmetric
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2011 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
11 ##
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>.
15
16 # This script tests a configuration scenario as described in these URLs:
17 #
18 # http://www.openldap.org/lists/openldap-devel/200806/msg00041.html
19 # http://www.openldap.org/lists/openldap-devel/200806/msg00054.html
20 #
21 # Search for "TEST:" to find each major test this script performs.
22
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".
26
27 # The following notations are used in variable names below to identify
28 # these servers, the first number defines the $URL# and $PORT# variable
29 # that server uses:
30 #
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
37
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.
44
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.
49
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).
55
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.
60
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...
69
70 #               glue    ou1             ou2             sm1ou1  sm1ou2  sm2ou1  sm2ou2
71 # smc   M               M               M               S               S               S               -
72 # sm1   S               S               -               M               M               -               -
73 # sm2   S               S               S               S               -               M               M
74 # ssc   S               S               -               -               S               -               -
75 # ss1   S               S               -               S               S               -               -
76 # ss2   S               S               S               -               -               S               S
77
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).
83 #
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.
88
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.
102
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
107 # configurations!
108
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.
113
114 if test "$BACKEND" = ldif ; then
115         echo "$BACKEND backend does not support access controls, test skipped"
116         exit 0
117 fi
118
119 echo "Test 058 is currently disabled"
120 exit 0
121
122 echo "running defines.sh"
123 . $SRCDIR/scripts/defines.sh
124
125 if test $SYNCPROV = syncprovno; then
126         echo "Syncrepl provider overlay not available, test skipped"
127         exit 0
128 fi
129
130 SMC_DIR=$TESTDIR/smc
131 SM1_DIR=$TESTDIR/sm1
132 SM2_DIR=$TESTDIR/sm2
133 SS1_DIR=$TESTDIR/ss1
134 SS2_DIR=$TESTDIR/ss2
135 SSC_DIR=$TESTDIR/ssc
136
137 mkdir -p $TESTDIR
138
139 for dir in $SMC_DIR $SM1_DIR $SM2_DIR $SS1_DIR $SS2_DIR $SSC_DIR; do
140         mkdir -p $dir $dir/slapd.d $dir/db
141 done
142
143 mkdir -p $SMC_DIR/ou1 $SMC_DIR/sm1ou1 $SMC_DIR/sm1ou2
144 mkdir -p $SMC_DIR/ou2 $SMC_DIR/sm2ou1
145 mkdir -p $SM1_DIR/ou1 $SM1_DIR/sm1ou1 $SM1_DIR/sm1ou2
146 mkdir -p $SM2_DIR/ou2 $SM2_DIR/sm1ou1 $SM2_DIR/sm2ou1 $SM2_DIR/sm2ou2
147
148 cd $TESTDIR
149
150 KILLPIDS=
151
152 $SLAPPASSWD -g -n >$CONFIGPWF
153
154 ID=1
155
156 if test $WAIT != 0 ; then
157         RETRY="1 60"
158 else
159         RETRY="1 10"
160 fi
161
162 echo "Initializing master configurations..."
163 for dir in $SMC_DIR $SM1_DIR $SM2_DIR; do
164         $SLAPADD -F $dir/slapd.d -n 0 <<EOF
165 dn: cn=config
166 objectClass: olcGlobal
167 cn: config
168 olcServerID: $ID
169
170 dn: olcDatabase={0}config,cn=config
171 objectClass: olcDatabaseConfig
172 olcDatabase: {0}config
173 olcRootPW:< file://$CONFIGPWF
174
175 EOF
176         ID=`expr $ID + 1`
177 done
178
179 echo "Initializing search configurations..."
180 for dir in $SS1_DIR $SS2_DIR $SSC_DIR; do
181         $SLAPADD -F $dir/slapd.d -n 0 <<EOF
182 dn: cn=config
183 objectClass: olcGlobal
184 cn: config
185
186 dn: olcDatabase={0}config,cn=config
187 objectClass: olcDatabaseConfig
188 olcDatabase: {0}config
189 olcRootPW:< file://$CONFIGPWF
190
191 EOF
192 done
193
194 echo "Starting central master slapd on TCP/IP port $PORT1..."
195 cd $SMC_DIR
196 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
197 SMC_PID=$!
198 if test $WAIT != 0 ; then
199         echo PID $SMC_PID
200         read foo
201 fi
202 KILLPIDS="$KILLPIDS $SMC_PID"
203 cd $TESTWD
204 sleep 1
205 echo "Using ldapsearch to check that central master slapd is running..."
206 for i in 1 2 3 4 5; do
207         $LDAPSEARCH -s base -b "" -H $URI1 \
208                 'objectclass=*' > /dev/null 2>&1
209         RC=$?
210         test $RC = 0 && break
211         echo "Waiting $i seconds for slapd to start..."
212         sleep $i
213 done
214 if test $RC != 0 ; then
215         echo "ldapsearch failed ($RC)!"
216         test $KILLSERVERS != no && kill -HUP $KILLPIDS
217         exit $RC
218 fi
219
220 echo "Starting site1 master slapd on TCP/IP port $PORT2..."
221 cd $SM1_DIR
222 $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
223 SM1_PID=$!
224 if test $WAIT != 0 ; then
225         echo PID $SM1_PID
226         read foo
227 fi
228 KILLPIDS="$KILLPIDS $SM1_PID"
229 cd $TESTWD
230 sleep 1
231 echo "Using ldapsearch to check that site1 master is running..."
232 for i in 1 2 3 4 5; do
233         $LDAPSEARCH -s base -b "" -H $URI2 \
234                 'objectclass=*' > /dev/null 2>&1
235         RC=$?
236         test $RC = 0 && break
237         echo "Waiting $i seconds for slapd to start..."
238         sleep $i
239 done
240 if test $RC != 0 ; then
241         echo "ldapsearch failed ($RC)!"
242         test $KILLSERVERS != no && kill -HUP $KILLPIDS
243         exit $RC
244 fi
245
246 echo "Starting site2 master slapd on TCP/IP port $PORT3..."
247 cd $SM2_DIR
248 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
249 SM2_PID=$!
250 if test $WAIT != 0 ; then
251         echo PID $SM2_PID
252         read foo
253 fi
254 KILLPIDS="$KILLPIDS $SM2_PID"
255 cd $TESTWD
256 sleep 1
257 echo "Using ldapsearch to check that site2 master is running..."
258 for i in 1 2 3 4 5; do
259         $LDAPSEARCH -s base -b "" -H $URI3 \
260                 'objectclass=*' > /dev/null 2>&1
261         RC=$?
262         test $RC = 0 && break
263         echo "Waiting $i seconds for slapd to start..."
264         sleep $i
265 done
266 if test $RC != 0 ; then
267         echo "ldapsearch failed ($RC)!"
268         test $KILLSERVERS != no && kill -HUP $KILLPIDS
269         exit $RC
270 fi
271
272 echo "Starting central search slapd on TCP/IP port $PORT4..."
273 cd $SSC_DIR
274 $SLAPD -F slapd.d -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
275 SSC_PID=$!
276 if test $WAIT != 0 ; then
277         echo PID $SSC_PID
278         read foo
279 fi
280 KILLPIDS="$KILLPIDS $SSC_PID"
281 cd $TESTWD
282 sleep 1
283 echo "Using ldapsearch to check that central search slapd is running..."
284 for i in 1 2 3 4 5; do
285         $LDAPSEARCH -s base -b "" -H $URI4 \
286                 'objectclass=*' > /dev/null 2>&1
287         RC=$?
288         test $RC = 0 && break
289         echo "Waiting $i seconds for slapd to start..."
290         sleep $i
291 done
292 if test $RC != 0 ; then
293         echo "ldapsearch failed ($RC)!"
294         test $KILLSERVERS != no && kill -HUP $KILLPIDS
295         exit $RC
296 fi
297
298
299 echo "Starting site1 search slapd on TCP/IP port $PORT5..."
300 cd $SS1_DIR
301 $SLAPD -F slapd.d -h $URI5 -d $LVL $TIMING > $LOG5 2>&1 &
302 SS1_PID=$!
303 if test $WAIT != 0 ; then
304         echo PID $SS1_PID
305         read foo
306 fi
307 KILLPIDS="$KILLPIDS $SS1_PID"
308 cd $TESTWD
309 sleep 1
310 echo "Using ldapsearch to check that site1 search slapd is running..."
311 for i in 1 2 3 4 5; do
312         $LDAPSEARCH -s base -b "" -H $URI5 \
313                 'objectclass=*' > /dev/null 2>&1
314         RC=$?
315         test $RC = 0 && break
316         echo "Waiting $i seconds for slapd to start..."
317         sleep $i
318 done
319 if test $RC != 0 ; then
320         echo "ldapsearch failed ($RC)!"
321         test $KILLSERVERS != no && kill -HUP $KILLPIDS
322         exit $RC
323 fi
324
325
326 echo "Starting site2 search slapd on TCP/IP port $PORT6..."
327 cd $SS2_DIR
328 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING > $LOG6 2>&1 &
329 SS2_PID=$!
330 if test $WAIT != 0 ; then
331         echo PID $SS2_PID
332         read foo
333 fi
334 KILLPIDS="$KILLPIDS $SS2_PID"
335 cd $TESTWD
336 sleep 1
337 echo "Using ldapsearch to check that site2 search slapd is running..."
338 for i in 1 2 3 4 5; do
339         $LDAPSEARCH -s base -b "" -H $URI6 \
340                 'objectclass=*' > /dev/null 2>&1
341         RC=$?
342         test $RC = 0 && break
343         echo "Waiting $i seconds for slapd to start..."
344         sleep $i
345 done
346 if test $RC != 0 ; then
347         echo "ldapsearch failed ($RC)!"
348         test $KILLSERVERS != no && kill -HUP $KILLPIDS
349         exit $RC
350 fi
351
352 for uri in $URI1 $URI2 $URI3 $URI4 $URI5 $URI6; do
353         echo "Adding schema on $uri..."
354         $LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
355 include: file://$ABS_SCHEMADIR/core.ldif
356
357 include: file://$ABS_SCHEMADIR/cosine.ldif
358
359 include: file://$ABS_SCHEMADIR/inetorgperson.ldif
360
361 include: file://$ABS_SCHEMADIR/openldap.ldif
362
363 include: file://$ABS_SCHEMADIR/nis.ldif
364 EOF
365         RC=$?
366         if test $RC != 0 ; then
367                 echo "ldapadd failed for schema config ($RC)!"
368                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
369                 exit $RC
370         fi
371
372         [ "$BACKENDTYPE" = mod ] || continue
373
374         echo "Adding backend module on $uri..."
375         $LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
376 dn: cn=module,cn=config
377 objectClass: olcModuleList
378 cn: module
379 olcModulePath: $TESTWD/../servers/slapd/back-$BACKEND
380 olcModuleLoad: back_$BACKEND.la
381 EOF
382         RC=$?
383         if test $RC != 0 ; then
384                 echo "ldapadd failed for backend module ($RC)!"
385                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
386                 exit $RC
387         fi
388 done
389
390 echo "Adding database config on central master..."
391 if [ "$SYNCPROV" = syncprovmod ]; then
392         $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
393 dn: cn=module,cn=config
394 objectClass: olcModuleList
395 cn: module
396 olcModulePath: $TESTWD/../servers/slapd/overlays
397 olcModuleLoad: syncprov.la
398
399 EOF
400         RC=$?
401         if test $RC != 0 ; then
402                 echo "ldapadd failed for moduleLoad ($RC)!"
403                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
404                 exit $RC
405         fi
406 fi
407
408 nullExclude="" nullOK="" wantNoObj=32
409 test $BACKEND = null && nullExclude="# " nullOK="OK" wantNoObj=0
410
411 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
412 dn: olcDatabase={1}$BACKEND,cn=config
413 objectClass: olcDatabaseConfig
414 ${nullExclude}objectClass: olc${BACKEND}Config
415 olcDatabase: {1}$BACKEND
416 ${nullExclude}olcDbDirectory: $SMC_DIR/db
417 olcSuffix: $BASEDN
418 olcRootDN: $MANAGERDN
419 olcRootPW: $PASSWD
420
421 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
422 objectClass: olcOverlayConfig
423 olcOverlay: {0}glue
424
425 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
426 objectClass: olcOverlayConfig
427 objectClass: olcSyncProvConfig
428 olcOverlay: {1}syncprov
429 olcSpCheckpoint: 3 1
430
431 dn: olcDatabase={1}$BACKEND,cn=config
432 objectClass: olcDatabaseConfig
433 ${nullExclude}objectClass: olc${BACKEND}Config
434 olcDatabase: {1}$BACKEND
435 ${nullExclude}olcDbDirectory: $SMC_DIR/ou1
436 olcSubordinate: TRUE
437 olcSuffix: ou=ou1,$BASEDN
438 olcRootDN: $MANAGERDN
439
440 dn: olcDatabase={2}$BACKEND,cn=config
441 objectClass: olcDatabaseConfig
442 ${nullExclude}objectClass: olc${BACKEND}Config
443 olcDatabase: {2}$BACKEND
444 ${nullExclude}olcDbDirectory: $SMC_DIR/ou2
445 olcSubordinate: TRUE
446 olcSuffix: ou=ou2,$BASEDN
447 olcRootDN: $MANAGERDN
448
449 dn: olcDatabase={3}$BACKEND,cn=config
450 objectClass: olcDatabaseConfig
451 ${nullExclude}objectClass: olc${BACKEND}Config
452 olcDatabase: {3}$BACKEND
453 ${nullExclude}olcDbDirectory: $SMC_DIR/sm1ou1
454 olcSubordinate: TRUE
455 olcSuffix: ou=sm1ou1,$BASEDN
456 olcRootDN: $UPDATEDN
457
458 dn: olcDatabase={4}$BACKEND,cn=config
459 objectClass: olcDatabaseConfig
460 ${nullExclude}objectClass: olc${BACKEND}Config
461 olcDatabase: {4}$BACKEND
462 ${nullExclude}olcDbDirectory: $SMC_DIR/sm1ou2
463 olcSubordinate: TRUE
464 olcSuffix: ou=sm1ou2,$BASEDN
465 olcRootDN: $UPDATEDN
466
467 dn: olcDatabase={5}$BACKEND,cn=config
468 objectClass: olcDatabaseConfig
469 ${nullExclude}objectClass: olc${BACKEND}Config
470 olcDatabase: {5}$BACKEND
471 ${nullExclude}olcDbDirectory: $SMC_DIR/sm2ou1
472 olcSubordinate: TRUE
473 olcSuffix: ou=sm2ou1,$BASEDN
474 olcRootDN: $UPDATEDN
475
476 EOF
477 RC=$?
478 if test $RC != 0 ; then
479         echo "ldapadd failed for central master database config ($RC)!"
480         test $KILLSERVERS != no && kill -HUP $KILLPIDS
481         exit $RC
482 fi
483
484 echo "Adding database config on site1 master..."
485 if [ "$SYNCPROV" = syncprovmod ]; then
486         $LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
487 dn: cn=module,cn=config
488 objectClass: olcModuleList
489 cn: module
490 olcModulePath: $TESTWD/../servers/slapd/overlays
491 olcModuleLoad: syncprov.la
492
493 EOF
494         RC=$?
495         if test $RC != 0 ; then
496                 echo "ldapadd failed for moduleLoad ($RC)!"
497                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
498                 exit $RC
499         fi
500 fi
501
502 $LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
503 dn: olcDatabase={1}$BACKEND,cn=config
504 objectClass: olcDatabaseConfig
505 ${nullExclude}objectClass: olc${BACKEND}Config
506 olcDatabase: {1}$BACKEND
507 ${nullExclude}olcDbDirectory: $SM1_DIR/db
508 olcSuffix: $BASEDN
509 olcRootDN: $UPDATEDN
510
511 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
512 objectClass: olcOverlayConfig
513 olcOverlay: {0}glue
514
515 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
516 objectClass: olcOverlayConfig
517 objectClass: olcSyncProvConfig
518 olcOverlay: {1}syncprov
519
520 dn: olcDatabase={1}$BACKEND,cn=config
521 objectClass: olcDatabaseConfig
522 ${nullExclude}objectClass: olc${BACKEND}Config
523 olcDatabase: {1}$BACKEND
524 ${nullExclude}olcDbDirectory: $SM1_DIR/ou1
525 olcSubordinate: TRUE
526 olcSuffix: ou=ou1,$BASEDN
527 olcRootDN: $UPDATEDN
528
529 dn: olcDatabase={2}$BACKEND,cn=config
530 objectClass: olcDatabaseConfig
531 ${nullExclude}objectClass: olc${BACKEND}Config
532 olcDatabase: {2}$BACKEND
533 ${nullExclude}olcDbDirectory: $SM1_DIR/sm1ou1
534 olcSubordinate: TRUE
535 olcSuffix: ou=sm1ou1,$BASEDN
536 olcRootDN: ou=sm1ou1,$BASEDN
537 olcRootPW: $PASSWD
538
539 dn: olcDatabase={3}$BACKEND,cn=config
540 objectClass: olcDatabaseConfig
541 ${nullExclude}objectClass: olc${BACKEND}Config
542 olcDatabase: {3}$BACKEND
543 ${nullExclude}olcDbDirectory: $SM1_DIR/sm1ou2
544 olcSubordinate: TRUE
545 olcSuffix: ou=sm1ou2,$BASEDN
546 olcRootDN: ou=sm1ou1,$BASEDN
547
548 EOF
549
550 RC=$?
551 if test $RC != 0 ; then
552         echo "ldapadd failed for site1 master database config ($RC)!"
553         test $KILLSERVERS != no && kill -HUP $KILLPIDS
554         exit $RC
555 fi
556
557 echo "Adding database config on site2 master..."
558 if [ "$SYNCPROV" = syncprovmod ]; then
559         $LDAPADD -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
560 dn: cn=module,cn=config
561 objectClass: olcModuleList
562 cn: module
563 olcModulePath: $TESTWD/../servers/slapd/overlays
564 olcModuleLoad: syncprov.la
565
566 EOF
567         RC=$?
568         if test $RC != 0 ; then
569                 echo "ldapadd failed for moduleLoad ($RC)!"
570                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
571                 exit $RC
572         fi
573 fi
574
575 $LDAPADD -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
576 dn: olcDatabase={1}$BACKEND,cn=config
577 objectClass: olcDatabaseConfig
578 ${nullExclude}objectClass: olc${BACKEND}Config
579 olcDatabase: {1}$BACKEND
580 ${nullExclude}olcDbDirectory: $SM2_DIR/db
581 olcSuffix: $BASEDN
582 olcRootDN: $UPDATEDN
583
584 dn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
585 objectClass: olcOverlayConfig
586 olcOverlay: {0}glue
587
588 dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
589 objectClass: olcOverlayConfig
590 objectClass: olcSyncProvConfig
591 olcOverlay: {1}syncprov
592 olcSpCheckpoint: 1 1
593
594 dn: olcDatabase={1}$BACKEND,cn=config
595 objectClass: olcDatabaseConfig
596 ${nullExclude}objectClass: olc${BACKEND}Config
597 olcDatabase: {1}$BACKEND
598 ${nullExclude}olcDbDirectory: $SM2_DIR/ou2
599 olcSubordinate: TRUE
600 olcSuffix: ou=ou2,$BASEDN
601 olcRootDN: $UPDATEDN
602
603 dn: olcDatabase={2}$BACKEND,cn=config
604 objectClass: olcDatabaseConfig
605 ${nullExclude}objectClass: olc${BACKEND}Config
606 olcDatabase: {2}$BACKEND
607 ${nullExclude}olcDbDirectory: $SM2_DIR/sm1ou1
608 olcSubordinate: TRUE
609 olcSuffix: ou=sm1ou1,$BASEDN
610 olcRootDN: $UPDATEDN
611
612 dn: olcDatabase={3}$BACKEND,cn=config
613 objectClass: olcDatabaseConfig
614 ${nullExclude}objectClass: olc${BACKEND}Config
615 olcDatabase: {3}$BACKEND
616 ${nullExclude}olcDbDirectory: $SM2_DIR/sm2ou1
617 olcSubordinate: TRUE
618 olcSuffix: ou=sm2ou1,$BASEDN
619 olcRootDN: ou=sm2ou1,$BASEDN
620 olcRootPW: $PASSWD
621
622 dn: olcDatabase={4}$BACKEND,cn=config
623 objectClass: olcDatabaseConfig
624 ${nullExclude}objectClass: olc${BACKEND}Config
625 olcDatabase: {4}$BACKEND
626 ${nullExclude}olcDbDirectory: $SM2_DIR/sm2ou2
627 olcSubordinate: TRUE
628 olcSuffix: ou=sm2ou2,$BASEDN
629 olcRootDN: ou=sm2ou1,$BASEDN
630
631 EOF
632
633 RC=$?
634 if test $RC != 0 ; then
635         echo "ldapadd failed for site2 master database config ($RC)!"
636         test $KILLSERVERS != no && kill -HUP $KILLPIDS
637         exit $RC
638 fi
639
640 echo "Adding access rules on central master..."
641 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
642 dn: olcDatabase={-1}frontend,cn=config
643 changetype: modify
644 add: olcAccess
645 olcAccess: to dn.exact=dc=example,dc=com
646   by * read
647 olcAccess: to dn.subtree=ou=ou1,dc=example,dc=com
648   by * read
649 olcAccess: to dn.subtree=ou=ou2,dc=example,dc=com
650   by dn.exact=ou=ou1,dc=example,dc=com none
651   by dn.exact=ou=ou2,dc=example,dc=com read
652   by dn.exact=dc=example,dc=com none
653   by * read
654 olcAccess: to dn.subtree=ou=sm1ou1,dc=example,dc=com
655   by dn.exact=ou=ou1,dc=example,dc=com none
656   by dn.exact=ou=ou2,dc=example,dc=com read
657   by dn.exact=dc=example,dc=com none
658   by * read
659 olcAccess: to dn.subtree=ou=sm1ou2,dc=example,dc=com
660   by dn.exact=ou=ou1,dc=example,dc=com none
661   by dn.exact=ou=ou2,dc=example,dc=com none
662   by dn.exact=dc=example,dc=com read
663   by * read
664 olcAccess: to dn.subtree=ou=sm2ou1,dc=example,dc=com
665   by dn.exact=ou=ou1,dc=example,dc=com none
666   by dn.exact=ou=ou2,dc=example,dc=com none
667   by dn.exact=dc=example,dc=com none
668   by * read
669 olcAccess: to * by * read
670
671 EOF
672 RC=$?
673 if test $RC != 0 ; then
674         echo "ldapmodify failed for central master access config ($RC)!"
675         test $KILLSERVERS != no && kill -HUP $KILLPIDS
676         exit $RC
677 fi
678
679 echo "Adding access rules on site1 master..."
680 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
681 dn: olcDatabase={-1}frontend,cn=config
682 changetype: modify
683 add: olcAccess
684 olcAccess: to dn.subtree=dc=example,dc=com
685   by * read
686 olcAccess: to * by * read
687
688 EOF
689 RC=$?
690 if test $RC != 0 ; then
691         echo "ldapmodify failed for site1 master access config ($RC)!"
692         test $KILLSERVERS != no && kill -HUP $KILLPIDS
693         exit $RC
694 fi
695
696 echo "Adding access rules on site2 master..."
697 $LDAPMODIFY -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
698 dn: olcDatabase={-1}frontend,cn=config
699 changetype: modify
700 add: olcAccess
701 olcAccess: to dn.exact=dc=example,dc=com
702   by * read
703 olcAccess: to dn.subtree=ou=ou2,dc=example,dc=com
704   by * read
705 olcAccess: to dn.subtree=ou=sm1ou1,dc=example,dc=com
706   by users none
707   by * read
708 olcAccess: to dn.subtree=ou=sm2ou1,dc=example,dc=com
709   by * read
710 olcAccess: to dn.subtree=ou=sm2ou2,dc=example,dc=com
711   by dn.exact=dc=example,dc=com read
712   by users none
713   by * read
714 olcAccess: to * by * read
715
716 EOF
717 RC=$?
718 if test $RC != 0 ; then
719         echo "ldapmodify failed for site2 master access config ($RC)!"
720         test $KILLSERVERS != no && kill -HUP $KILLPIDS
721         exit $RC
722 fi
723
724 echo "Adding database config on central search..."
725 $LDAPADD -D cn=config -H $URI4 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
726 dn: olcDatabase={1}$BACKEND,cn=config
727 objectClass: olcDatabaseConfig
728 ${nullExclude}objectClass: olc${BACKEND}Config
729 olcDatabase: {1}$BACKEND
730 ${nullExclude}olcDbDirectory: $SSC_DIR/db
731 olcSuffix: $BASEDN
732 olcRootDN: $UPDATEDN
733
734 EOF
735 RC=$?
736 if test $RC != 0 ; then
737         echo "ldapadd failed for central search database config ($RC)!"
738         test $KILLSERVERS != no && kill -HUP $KILLPIDS
739         exit $RC
740 fi
741
742 echo "Adding database config on site1 search..."
743 $LDAPADD -D cn=config -H $URI5 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
744 dn: olcDatabase={1}$BACKEND,cn=config
745 objectClass: olcDatabaseConfig
746 ${nullExclude}objectClass: olc${BACKEND}Config
747 olcDatabase: {1}$BACKEND
748 ${nullExclude}olcDbDirectory: $SS1_DIR/db
749 olcSuffix: $BASEDN
750 olcRootDN: $UPDATEDN
751
752 EOF
753 RC=$?
754 if test $RC != 0 ; then
755         echo "ldapadd failed for site1 search database config ($RC)!"
756         test $KILLSERVERS != no && kill -HUP $KILLPIDS
757         exit $RC
758 fi
759
760 echo "Adding database config on site2 search..."
761 $LDAPADD -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
762 dn: olcDatabase={1}$BACKEND,cn=config
763 objectClass: olcDatabaseConfig
764 ${nullExclude}objectClass: olc${BACKEND}Config
765 olcDatabase: {1}$BACKEND
766 ${nullExclude}olcDbDirectory: $SS2_DIR/db
767 olcSuffix: $BASEDN
768 olcRootDN: $UPDATEDN
769
770 EOF
771 RC=$?
772 if test $RC != 0 ; then
773         echo "ldapadd failed for site2 search database config ($RC)!"
774         test $KILLSERVERS != no && kill -HUP $KILLPIDS
775         exit $RC
776 fi
777
778 echo "Populating central master..."
779 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
780 dn: dc=example,dc=com
781 objectClass: top
782 objectClass: organization
783 objectClass: dcObject
784 dc: example
785 o: Example, Inc
786 userPassword: $PASSWD
787
788 dn: ou=ou1,dc=example,dc=com
789 objectClass: top
790 objectClass: organizationalUnit
791 ou: ou1
792 userPassword: $PASSWD
793
794 dn: ou=ou2,dc=example,dc=com
795 objectClass: top
796 objectClass: organizationalUnit
797 ou: ou2
798 userPassword: $PASSWD
799
800 EOF
801 RC=$?
802 if test $RC != 0 ; then
803         echo "ldapadd failed to populate central master entry ($RC)!"
804         test $KILLSERVERS != no && kill -HUP $KILLPIDS
805         exit $RC
806 fi
807
808 echo "Adding syncrepl on site1 master..."
809 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
810 dn: olcDatabase={4}$BACKEND,cn=config
811 changetype: modify
812 add: olcSyncRepl
813 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
814   binddn="ou=ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
815   type=refreshAndPersist retry="$RETRY" timeout=1
816
817 EOF
818 RC=$?
819 if test $RC != 0 ; then
820         echo "ldapmodify failed to add syncrepl on site1 master ($RC)!"
821         test $KILLSERVERS != no && kill -HUP $KILLPIDS
822         exit $RC
823 fi
824
825 echo "Adding syncrepl on site2 master..."
826 $LDAPMODIFY -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
827 dn: olcDatabase={5}$BACKEND,cn=config
828 changetype: modify
829 add: olcSyncRepl
830 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
831   binddn="ou=ou2,$BASEDN" bindmethod=simple credentials=$PASSWD
832   type=refreshAndPersist retry="$RETRY" timeout=1
833
834 EOF
835 RC=$?
836 if test $RC != 0 ; then
837         echo "ldapmodify failed to add syncrepl on site2 master ($RC)!"
838         test $KILLSERVERS != no && kill -HUP $KILLPIDS
839         exit $RC
840 fi
841 sleep 1
842
843 echo "Using ldapsearch to check that site1 master received changes..."
844 RC=32
845 for i in 1 2 3 4 5; do
846         RESULT=`$LDAPSEARCH -H $URI2 \
847                 -s base -b "ou=ou1,$BASEDN" \
848                 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
849         if test "x$RESULT$nullOK" = "xOK" ; then
850                 RC=0
851                 break
852         fi
853         echo "Waiting $i seconds for syncrepl to receive changes..."
854         sleep $i
855 done
856 if test $RC != 0 ; then
857         echo "ldapsearch failed ($RC)!"
858         test $KILLSERVERS != no && kill -HUP $KILLPIDS
859         exit $RC
860 fi
861
862 echo "Using ldapsearch to check that site2 master received changes..."
863 RC=32
864 for i in 1 2 3 4 5; do
865         RESULT=`$LDAPSEARCH -H $URI3 \
866                 -s base -b "ou=ou1,$BASEDN" \
867                 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
868         if test "x$RESULT$nullOK" = "xOK" ; then
869                 RC=0
870                 break
871         fi
872         echo "Waiting $i seconds for syncrepl to receive changes..."
873         sleep $i
874 done
875 if test $RC != 0 ; then
876         echo "ldapsearch failed ($RC)!"
877         test $KILLSERVERS != no && kill -HUP $KILLPIDS
878         exit $RC
879 fi
880
881 sleep 1
882
883 echo "Populating site1 master..."
884 $LDAPADD -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
885 dn: ou=sm1ou1,dc=example,dc=com
886 objectClass: top
887 objectClass: organizationalUnit
888 ou: sm1ou1
889
890 dn: ou=sm1ou2,dc=example,dc=com
891 objectClass: top
892 objectClass: organizationalUnit
893 ou: sm1ou2
894
895 EOF
896 RC=$?
897 if test $RC != 0 ; then
898         echo "ldapadd failed to populate site1 master ($RC)!"
899         test $KILLSERVERS != no && kill -HUP $KILLPIDS
900         exit $RC
901 fi
902
903 sleep 1
904
905 echo "Populating site2 master..."
906 $LDAPADD -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
907 dn: ou=sm2ou1,dc=example,dc=com
908 objectClass: top
909 objectClass: organizationalUnit
910 ou: sm2ou1
911
912 dn: ou=sm2ou2,dc=example,dc=com
913 objectClass: top
914 objectClass: organizationalUnit
915 ou: sm2ou2
916
917 EOF
918 RC=$?
919 if test $RC != 0 ; then
920         echo "ldapadd failed to populate site2 master ($RC)!"
921         test $KILLSERVERS != no && kill -HUP $KILLPIDS
922         exit $RC
923 fi
924
925 ERRORS=0
926
927 # TEST:
928 # Stop site1 master when adding syncrepl to the central master.  When
929 # site1 master is started again both it and the central master will have
930 # the same number of contextCSN values, but the ones on central master
931 # will be the newest.  The central master will not update its contextCSN
932 # values unless the bug in ITS#5597 have been fixed.
933 echo "Stopping site1 master..."
934 kill -HUP "$SM1_PID"
935 wait "$SM1_PID"
936 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SM1_PID / /"`;
937 SM1_PID=
938
939 echo "Adding syncrepl on central master..."
940 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
941 dn: olcDatabase={3}$BACKEND,cn=config
942 changetype: modify
943 add: olcSyncRepl
944 olcSyncRepl: rid=3 provider=$URI2 searchbase="ou=sm1ou1,$BASEDN"
945   binddn="ou=sm1ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
946   type=refreshAndPersist retry="$RETRY" timeout=1
947
948 dn: olcDatabase={5}$BACKEND,cn=config
949 changetype: modify
950 add: olcSyncRepl
951 olcSyncRepl: rid=5 provider=$URI3 searchbase="ou=sm2ou1,$BASEDN"
952   binddn="ou=sm2ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
953   type=refreshAndPersist retry="$RETRY" timeout=1
954
955 EOF
956 RC=$?
957 if test $RC != 0 ; then
958         echo "ldapmodify failed to add syncrepl on central master ($RC)!"
959         test $KILLSERVERS != no && kill -HUP $KILLPIDS
960         exit $RC
961 fi
962 sleep 1
963 echo "Using ldapsearch to check that central master received site2 entries..."
964 RC=32
965 for i in 1 2 3 4 5; do
966         RESULT=`$LDAPSEARCH -H $URI1 \
967                 -s base -b "ou=sm2ou1,$BASEDN" \
968                 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
969         if test "x$RESULT$nullOK" = "xOK" ; then
970                 RC=0
971                 break
972         fi
973         echo "Waiting $i seconds for syncrepl to receive changes..."
974         sleep $i
975 done
976 if test $RC != 0 ; then
977         echo "ldapsearch failed ($RC)!"
978         test $KILLSERVERS != no && kill -HUP $KILLPIDS
979         exit $RC
980 fi
981
982 if test -z "$SM1_PID" ; then
983         echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
984         cd $SM1_DIR
985         $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
986         SM1_PID=$!
987         if test $WAIT != 0 ; then
988             echo PID $SM1_PID
989             read foo
990         fi
991         KILLPIDS="$KILLPIDS $SM1_PID"
992         cd $TESTWD
993         sleep 1
994 fi
995 sleep 1
996 echo "Using ldapsearch to check that site1 master is running..."
997 for i in 1 2 3 4 5; do
998         $LDAPSEARCH -s base -b "" -H $URI2 \
999                 'objectclass=*' > /dev/null 2>&1
1000         RC=$?
1001         test $RC = 0 && break
1002         echo "Waiting $i seconds for slapd to start..."
1003         sleep $i
1004 done
1005 if test $RC != 0 ; then
1006         echo "ldapsearch failed ($RC)!"
1007         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1008         exit $RC
1009 fi
1010
1011 echo "Using ldapsearch to check that central master received site1 entries..."
1012 RC=32
1013 for i in 1 2 3 4 5; do
1014         RESULT=`$LDAPSEARCH -H $URI1 \
1015                 -s base -b "ou=sm1ou1,$BASEDN" \
1016                 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1017         if test "x$RESULT$nullOK" = "xOK" ; then
1018                 RC=0
1019                 break
1020         fi
1021         echo "Waiting $i seconds for syncrepl to receive changes..."
1022         sleep $i
1023 done
1024 if test $RC != 0 ; then
1025         echo "ldapsearch failed ($RC)!"
1026         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1027         exit $RC
1028 fi
1029
1030 # Test done, now some more intialization...
1031
1032 echo "Adding syncrepl consumer on central search..."
1033 $LDAPMODIFY -D cn=config -H $URI4 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1034 dn: olcDatabase={1}$BACKEND,cn=config
1035 changetype: modify
1036 add: olcSyncRepl
1037 olcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
1038   binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1039   type=refreshAndPersist retry="$RETRY" timeout=1
1040
1041 EOF
1042 RC=$?
1043 if test $RC != 0 ; then
1044         echo "ldapmodify failed to add syncrepl on site1 search ($RC)!"
1045         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1046         exit $RC
1047 fi
1048
1049 echo "Adding syncrepl consumer on site1 search..."
1050 $LDAPMODIFY -D cn=config -H $URI5 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1051 dn: olcDatabase={1}$BACKEND,cn=config
1052 changetype: modify
1053 add: olcSyncRepl
1054 olcSyncRepl: rid=1 provider=$URI2 searchbase="$BASEDN"
1055   binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1056   type=refreshAndPersist retry="$RETRY" timeout=1
1057
1058 EOF
1059 RC=$?
1060 if test $RC != 0 ; then
1061         echo "ldapmodify failed to add syncrepl on site1 search ($RC)!"
1062         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1063         exit $RC
1064 fi
1065
1066 echo "Adding syncrepl consumer on site2 search..."
1067 $LDAPMODIFY -D cn=config -H $URI6 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
1068 dn: olcDatabase={1}$BACKEND,cn=config
1069 changetype: modify
1070 add: olcSyncRepl
1071 olcSyncRepl: rid=1 provider=$URI3 searchbase="$BASEDN"
1072   binddn="$BASEDN" bindmethod=simple credentials=$PASSWD
1073   type=refreshAndPersist retry="$RETRY" timeout=1
1074
1075 EOF
1076 RC=$?
1077 if test $RC != 0 ; then
1078         echo "ldapmodify failed to add syncrepl on site2 search ($RC)!"
1079         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1080         exit $RC
1081 fi
1082 sleep 1
1083
1084 echo "Using ldapsearch to check that central search received changes..."
1085 RC=32
1086 for i in 1 2 3 4 5; do
1087         RESULT=`$LDAPSEARCH -H $URI4 \
1088                 -s base -b "$BASEDN" \
1089                 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1090         if test "x$RESULT$nullOK" = "xOK" ; then
1091                 RC=0
1092                 break
1093         fi
1094         echo "Waiting $i seconds for syncrepl to receive changes..."
1095         sleep $i
1096 done
1097 if test $RC != 0 ; then
1098         echo "ldapsearch failed ($RC)!"
1099         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1100         exit $RC
1101 fi
1102
1103 echo "Using ldapsearch to check that site1 search received changes..."
1104 RC=32
1105 for i in 1 2 3 4 5; do
1106         RESULT=`$LDAPSEARCH -H $URI5 \
1107                 -s base -b "$BASEDN" \
1108                 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1109         if test "x$RESULT$nullOK" = "xOK" ; then
1110                 RC=0
1111                 break
1112         fi
1113         echo "Waiting $i seconds for syncrepl to receive changes..."
1114         sleep $i
1115 done
1116 if test $RC != 0 ; then
1117         echo "ldapsearch failed ($RC)!"
1118         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1119         exit $RC
1120 fi
1121
1122 echo "Using ldapsearch to check that site2 search received changes..."
1123 RC=32
1124 for i in 1 2 3 4 5; do
1125         RESULT=`$LDAPSEARCH -H $URI6 \
1126                 -s base -b "$BASEDN" \
1127                 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
1128         if test "x$RESULT$nullOK" = "xOK" ; then
1129                 RC=0
1130                 break
1131         fi
1132         echo "Waiting $i seconds for syncrepl to receive changes..."
1133         sleep $i
1134 done
1135 if test $RC != 0 ; then
1136         echo "ldapsearch failed ($RC)!"
1137         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1138         exit $RC
1139 fi
1140
1141 # Create a script that will check the contextCSN values of all servers,
1142 # and restart them to re-synchronize if it finds any errors:
1143 cat > $TESTDIR/checkcsn.sh <<'EOF'
1144 #!/bin/sh
1145
1146 CSN_ERRORS=0
1147
1148 CSN1=`$LDAPSEARCH -H $URI1 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1149 CSN2=`$LDAPSEARCH -H $URI2 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1150 CSN3=`$LDAPSEARCH -H $URI3 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1151 CSN4=`$LDAPSEARCH -H $URI4 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1152 CSN5=`$LDAPSEARCH -H $URI5 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1153 CSN6=`$LDAPSEARCH -H $URI6 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1154
1155 if test -z "$CSN1" ; then
1156         echo "ERROR: contextCSN empty on central master"
1157         CSN_ERRORS=`expr $CSN_ERRORS + 1`
1158 fi
1159 nCSN=`echo "$CSN1" | wc -l`
1160 if test "$nCSN" -ne 3 ; then
1161         echo "ERROR: Wrong contextCSN count on central master, should be 3"
1162         CSN_ERRORS=`expr $CSN_ERRORS + 1`
1163         if test -n "$CSN_VERBOSE"; then
1164                 echo "$CSN1"
1165         fi
1166 fi
1167 if  test -z "$CSN2" -o "$CSN1" != "$CSN2" ; then
1168         echo "ERROR: contextCSN mismatch between central master and site1 master"
1169         CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1170         if test -n "$CSN_VERBOSE"; then
1171                 echo "contextCSN on central master:"
1172                 echo "$CSN1"
1173                 echo "contextCSN on site1 master:"
1174                 echo "$CSN2"
1175         fi
1176 fi
1177 if  test -z "$CSN3" -o "$CSN1" != "$CSN3" ; then
1178         echo "ERROR: contextCSN mismatch between central master and site2 master"
1179         CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1180         if test -n "$CSN_VERBOSE"; then
1181                 echo "contextCSN on central master:"
1182                 echo "$CSN1"
1183                 echo "contextCSN on site2 master:"
1184                 echo "$CSN3"
1185         fi
1186 fi
1187 if  test -z "$CSN4" -o "$CSN1" != "$CSN4" ; then
1188         echo "ERROR: contextCSN mismatch between central master and central search"
1189         CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1190         if test -n "$CSN_VERBOSE"; then
1191                 echo "contextCSN on central master:"
1192                 echo "$CSN1"
1193                 echo "contextCSN on central search:"
1194                 echo "$CSN4"
1195         fi
1196 fi
1197 if  test -z "$CSN5" -o "$CSN2" != "$CSN5" ; then
1198         echo "ERROR: contextCSN mismatch between site1 master and site1 search"
1199         CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1200         if test -n "$CSN_VERBOSE"; then
1201                 echo "contextCSN on site1 master:"
1202                 echo "$CSN2"
1203                 echo "contextCSN on site1 search:"
1204                 echo "$CSN5"
1205         fi
1206 fi
1207 if  test -z "$CSN6" -o "$CSN3" != "$CSN6" ; then
1208         echo "ERROR: contextCSN mismatch between site2 master and site2 search:"
1209         CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1210         if test -n "$CSN_VERBOSE"; then
1211                 echo "contextCSN on site2 master:"
1212                 echo "$CSN3"
1213                 echo "contextCSN on site2 search:"
1214                 echo "$CSN6"
1215         fi
1216 fi
1217
1218 if test $CSN_ERRORS != 0 ; then
1219         echo "Stopping all servers to synchronize contextCSN..."
1220         kill -HUP  $KILLPIDS
1221         for pid in $KILLPIDS ; do wait $pid ; done
1222         KILLPIDS=
1223
1224         echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
1225         cd $SM1_DIR
1226         $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
1227         SM1_PID=$!
1228         if test $WAIT != 0 ; then
1229                 echo PID $SM1_PID
1230                 read foo
1231         fi
1232         KILLPIDS="$KILLPIDS $SM1_PID"
1233         cd $TESTWD
1234         sleep 1
1235         echo "Using ldapsearch to check that site1 master is running..."
1236         for i in 1 2 3 4 5; do
1237                 $LDAPSEARCH -s base -b "" -H $URI2 \
1238                         'objectclass=*' > /dev/null 2>&1
1239                 RC=$?
1240                 test $RC = 0 && break
1241                 echo "Waiting $i seconds for slapd to start..."
1242                 sleep $i
1243         done
1244         if test $RC != 0 ; then
1245                 echo "ldapsearch failed ($RC)!"
1246                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1247                 exit $RC
1248         fi
1249
1250         echo "Restarting site2 master slapd on TCP/IP port $PORT3..."
1251         cd $SM2_DIR
1252         $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1253         SM2_PID=$!
1254         if test $WAIT != 0 ; then
1255                 echo PID $SM2_PID
1256                 read foo
1257         fi
1258         KILLPIDS="$KILLPIDS $SM2_PID "
1259         cd $TESTWD
1260         sleep 1
1261         echo "Using ldapsearch to check that site2 master is running..."
1262         for i in 1 2 3 4 5; do
1263                 $LDAPSEARCH -s base -b "" -H $URI3 \
1264                         'objectclass=*' > /dev/null 2>&1
1265                 RC=$?
1266                 test $RC = 0 && break
1267                 echo "Waiting $i seconds for slapd to start..."
1268                 sleep $i
1269         done
1270         if test $RC != 0 ; then
1271                 echo "ldapsearch failed ($RC)!"
1272                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1273                 exit $RC
1274         fi
1275
1276         echo "Restarting central master slapd on TCP/IP port $PORT1..."
1277         cd $SMC_DIR
1278         $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
1279         SMC_PID=$!
1280         if test $WAIT != 0 ; then
1281                 echo PID $SMC_PID
1282                 read foo
1283         fi
1284         KILLPIDS="$KILLPIDS $SMC_PID"
1285         cd $TESTWD
1286         sleep 1
1287         echo "Using ldapsearch to check that central master slapd is running..."
1288         for i in 1 2 3 4 5; do
1289                 $LDAPSEARCH -s base -b "" -H $URI1 \
1290                         'objectclass=*' > /dev/null 2>&1
1291                 RC=$?
1292                 test $RC = 0 && break
1293                 echo "Waiting $i seconds for slapd to start..."
1294                 sleep $i
1295         done
1296         if test $RC != 0 ; then
1297                 echo "ldapsearch failed ($RC)!"
1298                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1299                 exit $RC
1300         fi
1301
1302         echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1303         sleep 5
1304
1305         echo "Stopping site1 and site2 master..."
1306         kill -HUP  $SM1_PID $SM2_PID
1307         for pid in $SM1_PID $SM2_PID ; do wait $pid ; done
1308         KILLPIDS=" $SMC_PID"
1309
1310         echo "Restarting site1 master slapd on TCP/IP port $PORT2..."
1311         cd $SM1_DIR
1312         $SLAPD -F slapd.d -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
1313         SM1_PID=$!
1314         if test $WAIT != 0 ; then
1315                 echo PID $SM1_PID
1316                 read foo
1317         fi
1318         KILLPIDS="$KILLPIDS $SM1_PID"
1319         cd $TESTWD
1320         sleep 1
1321         echo "Using ldapsearch to check that site1 master is running..."
1322         for i in 1 2 3 4 5; do
1323                 $LDAPSEARCH -s base -b "" -H $URI2 \
1324                         'objectclass=*' > /dev/null 2>&1
1325                 RC=$?
1326                 test $RC = 0 && break
1327                 echo "Waiting $i seconds for slapd to start..."
1328                 sleep $i
1329         done
1330         if test $RC != 0 ; then
1331                 echo "ldapsearch failed ($RC)!"
1332                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1333                 exit $RC
1334         fi
1335
1336         echo "Restarting site2 master slapd on TCP/IP port $PORT3..."
1337         cd $SM2_DIR
1338         $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1339         SM2_PID=$!
1340         if test $WAIT != 0 ; then
1341                 echo PID $SM2_PID
1342                 read foo
1343         fi
1344         KILLPIDS="$KILLPIDS $SM2_PID"
1345         cd $TESTWD
1346         sleep 1
1347         echo "Using ldapsearch to check that site2 master is running..."
1348         for i in 1 2 3 4 5; do
1349                 $LDAPSEARCH -s base -b "" -H $URI3 \
1350                         'objectclass=*' > /dev/null 2>&1
1351                 RC=$?
1352                 test $RC = 0 && break
1353                 echo "Waiting $i seconds for slapd to start..."
1354                 sleep $i
1355         done
1356         if test $RC != 0 ; then
1357                 echo "ldapsearch failed ($RC)!"
1358                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1359                 exit $RC
1360         fi
1361
1362         echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1363         sleep 5
1364
1365         echo "Restarting central search slapd on TCP/IP port $PORT4..."
1366         cd $SSC_DIR
1367         $SLAPD -F slapd.d -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
1368         SSC_PID=$!
1369         if test $WAIT != 0 ; then
1370                 echo PID $SSC_PID
1371                 read foo
1372         fi
1373         KILLPIDS="$KILLPIDS $SSC_PID"
1374         cd $TESTWD
1375         sleep 1
1376         echo "Using ldapsearch to check that central search slapd is running..."
1377         for i in 1 2 3 4 5; do
1378                 $LDAPSEARCH -s base -b "" -H $URI4 \
1379                         'objectclass=*' > /dev/null 2>&1
1380                 RC=$?
1381                 test $RC = 0 && break
1382                 echo "Waiting $i seconds for slapd to start..."
1383                 sleep $i
1384         done
1385         if test $RC != 0 ; then
1386                 echo "ldapsearch failed ($RC)!"
1387                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1388                 exit $RC
1389         fi
1390
1391         echo "Restarting site1 search slapd on TCP/IP port $PORT5..."
1392         cd $SS1_DIR
1393         $SLAPD -F slapd.d -h $URI5 -d $LVL $TIMING >> $LOG5 2>&1 &
1394         SS1_PID=$!
1395         if test $WAIT != 0 ; then
1396                 echo PID $SS1_PID
1397                 read foo
1398         fi
1399         KILLPIDS="$KILLPIDS $SS1_PID"
1400         cd $TESTWD
1401         sleep 1
1402         echo "Using ldapsearch to check that site1 search slapd is running..."
1403         for i in 1 2 3 4 5; do
1404                 $LDAPSEARCH -s base -b "" -H $URI5 \
1405                         'objectclass=*' > /dev/null 2>&1
1406                 RC=$?
1407                 test $RC = 0 && break
1408                 echo "Waiting $i seconds for slapd to start..."
1409                 sleep $i
1410         done
1411         if test $RC != 0 ; then
1412                 echo "ldapsearch failed ($RC)!"
1413                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1414                 exit $RC
1415         fi
1416
1417         echo "Restarting site2 search slapd on TCP/IP port $PORT6..."
1418         cd $SS2_DIR
1419         $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING >> $LOG6 2>&1 &
1420         SS2_PID=$!
1421         if test $WAIT != 0 ; then
1422                 echo PID $SS2_PID
1423                 read foo
1424         fi
1425         KILLPIDS="$KILLPIDS $SS2_PID"
1426         cd $TESTWD
1427         sleep 1
1428         echo "Using ldapsearch to check that site2 search slapd is running..."
1429         for i in 1 2 3 4 5; do
1430                 $LDAPSEARCH -s base -b "" -H $URI6 \
1431                         'objectclass=*' > /dev/null 2>&1
1432                 RC=$?
1433                 test $RC = 0 && break
1434                 echo "Waiting $i seconds for slapd to start..."
1435                 sleep $i
1436         done
1437         if test $RC != 0 ; then
1438                 echo "ldapsearch failed ($RC)!"
1439                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1440                 exit $RC
1441         fi
1442
1443         echo "Sleeping 5 seconds to allow contextCSN to synchronize..."
1444         sleep 5
1445
1446         echo "Checking contextCSN after restart..."
1447         CSN1=`$LDAPSEARCH -H $URI1 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1448         CSN2=`$LDAPSEARCH -H $URI2 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1449         CSN3=`$LDAPSEARCH -H $URI3 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1450         CSN4=`$LDAPSEARCH -H $URI4 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1451         CSN5=`$LDAPSEARCH -H $URI5 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1452         CSN6=`$LDAPSEARCH -H $URI6 -b $BASEDN -s base contextCSN | grep contextCSN | sort`
1453         if test -z "$CSN1" ; then
1454                 echo "ERROR: contextCSN empty on central master"
1455                 CSN_ERRORS=`expr $CSN_ERRORS + 1`
1456         fi
1457
1458         if  test -z "$CSN2" -o "$CSN1" != "$CSN2" ; then
1459                 echo "ERROR: contextCSN mismatch between central master and site1 master"
1460                 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1461                 if test -n "$CSN_VERBOSE"; then
1462                         echo "contextCSN on central master:"
1463                         echo "$CSN1"
1464                         echo "contextCSN on site1 master:"
1465                         echo "$CSN2"
1466                 fi
1467         fi
1468         if  test -z "$CSN3" -o "$CSN1" != "$CSN3" ; then
1469                 echo "ERROR: contextCSN mismatch between central master and site2 master"
1470                 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1471                 if test -n "$CSN_VERBOSE"; then
1472                         echo "contextCSN on central master:"
1473                         echo "$CSN1"
1474                         echo "contextCSN on site2 master:"
1475                         echo "$CSN3"
1476                 fi
1477         fi
1478         if  test -z "$CSN4" -o "$CSN1" != "$CSN4" ; then
1479                 echo "ERROR: contextCSN mismatch between central master and central search"
1480                 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1481                 if test -n "$CSN_VERBOSE"; then
1482                         echo "contextCSN on central master:"
1483                         echo "$CSN1"
1484                         echo "contextCSN on central search:"
1485                         echo "$CSN4"
1486                 fi
1487         fi
1488         if  test -z "$CSN5" -o "$CSN2" != "$CSN5" ; then
1489                 echo "ERROR: contextCSN mismatch between site1 master and site1 search"
1490                 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1491                 if test -n "$CSN_VERBOSE"; then
1492                         echo "contextCSN on site1 master:"
1493                         echo "$CSN2"
1494                         echo "contextCSN on site1 search:"
1495                         echo "$CSN5"
1496                 fi
1497         fi
1498         if  test -z "$CSN6" -o "$CSN3" != "$CSN6" ; then
1499                 echo "ERROR: contextCSN mismatch between site2 master and site2 search:"
1500                 CSN_ERRORS=`expr $CSN_ERRORS + 1`;
1501                 if test -n "$CSN_VERBOSE"; then
1502                         echo "contextCSN on site2 master:"
1503                         echo "$CSN3"
1504                         echo "contextCSN on site2 search:"
1505                         echo "$CSN6"
1506                 fi
1507         fi
1508 fi
1509
1510 ERRORS=`expr $ERRORS + $CSN_ERRORS`
1511
1512 EOF
1513
1514 test $BACKEND = null && echo : > $TESTDIR/checkcsn.sh
1515
1516 chmod +x $TESTDIR/checkcsn.sh
1517
1518
1519 echo "Checking contextCSN after initial replication..."
1520 . $TESTDIR/checkcsn.sh
1521
1522 MNUM=1
1523
1524 # TEST:
1525 # Test that updates to the first backend on central master, which should
1526 # be replicated to all servers actually is so, and that the contextCSN is
1527 # updated everywhere:
1528 echo "Using ldapmodify to modify first backend on central master..."
1529 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1530 dn: ou=ou1,dc=example,dc=com
1531 changetype: modify
1532 add: description
1533 description: Modify$MNUM
1534
1535 EOF
1536 RC=$?
1537 if test $RC != 0 ; then
1538         echo "ldapmodify failed ($RC)!"
1539         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1540         exit $RC
1541 fi
1542 sleep 1
1543
1544 echo "Using ldapsearch to check replication to central search..."
1545 RC=32
1546 for i in 1 2 3 4 5; do
1547         RESULT=`$LDAPSEARCH -H $URI4 \
1548                 -s base -b "ou=ou1,$BASEDN" \
1549                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1550         if test "x$RESULT$nullOK" = "xOK" ; then
1551                 RC=0
1552                 break
1553         fi
1554         echo "Waiting $i seconds for syncrepl to receive changes..."
1555         sleep $i
1556 done
1557 if test $RC != 0 ; then
1558         echo "ldapsearch failed ($RC)!"
1559         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1560         exit $RC
1561 fi
1562
1563 echo "Using ldapsearch to check replication to site1 search..."
1564 RC=32
1565 for i in 1 2 3 4 5; do
1566         RESULT=`$LDAPSEARCH -H $URI5 \
1567                 -s base -b "ou=ou1,$BASEDN" \
1568                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1569         if test "x$RESULT$nullOK" = "xOK" ; then
1570                 RC=0
1571                 break
1572         fi
1573         echo "Waiting $i seconds for syncrepl to receive changes..."
1574         sleep $i
1575 done
1576 if test $RC != 0 ; then
1577         echo "ldapsearch failed ($RC)!"
1578         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1579         exit $RC
1580 fi
1581
1582 echo "Using ldapsearch to check replication to site2 search..."
1583 RC=32
1584 for i in 1 2 3 4 5; do
1585         RESULT=`$LDAPSEARCH -H $URI6 \
1586                 -s base -b "ou=ou1,$BASEDN" \
1587                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1588         if test "x$RESULT$nullOK" = "xOK" ; then
1589                 RC=0
1590                 break
1591         fi
1592         echo "Waiting $i seconds for syncrepl to receive changes..."
1593         sleep $i
1594 done
1595 if test $RC != 0 ; then
1596         echo "ldapsearch failed ($RC)!"
1597         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1598         exit $RC
1599 fi
1600
1601 echo "Checking contextCSN after modify of first backend on central master..."
1602 . $TESTDIR/checkcsn.sh
1603
1604 # TEST:
1605 # Test that updates to the second backend on central master is only
1606 # replicated to those search servers that should receive that backend.
1607 # The contextCSN should still be updated everywhere:
1608 MNUM=`expr $MNUM + 1`
1609 echo "Using ldapmodify to modify second backend on central master..."
1610 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1611 dn: ou=ou2,dc=example,dc=com
1612 changetype: modify
1613 add: description
1614 description: Modify$MNUM
1615
1616 EOF
1617 RC=$?
1618 if test $RC != 0 ; then
1619         echo "ldapmodify failed ($RC)!"
1620         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1621         exit $RC
1622 fi
1623 sleep 1
1624
1625 echo "Using ldapsearch to check replication to site2 search..."
1626 RC=32
1627 for i in 1 2 3 4 5; do
1628         RESULT=`$LDAPSEARCH -H $URI6 \
1629                 -s base -b "ou=ou2,$BASEDN" \
1630                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1631         if test "x$RESULT$nullOK" = "xOK" ; then
1632                 RC=0
1633                 break
1634         fi
1635         echo "Waiting $i seconds for syncrepl to receive changes..."
1636         sleep $i
1637 done
1638 if test $RC != 0 ; then
1639         echo "ldapsearch failed ($RC)!"
1640         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1641         exit $RC
1642 fi
1643
1644 echo "Using ldapsearch to check no replication to site1 master..."
1645 for i in 1 2 3 4 5; do
1646         RESULT=`$LDAPSEARCH -H $URI2 \
1647                 -s base -b "ou=ou2,$BASEDN" \
1648                 "(description=Modify$NMUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1649         if test "x$RESULT" = "xNOK" ; then
1650                 echo "Change was replicated to site1 search!"
1651                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1652                 exit 1
1653         fi
1654         sleep 1
1655 done
1656
1657 echo "Using ldapsearch to check no replication to central search..."
1658 for i in 1 2 3 4 5; do
1659         RESULT=`$LDAPSEARCH -H $URI4 \
1660                 -s base -b "ou=ou2,$BASEDN" \
1661                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1662         if test "x$RESULT" = "xNOK" ; then
1663                 echo "Change was replicated to central search!"
1664                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1665                 exit 1
1666         fi
1667         sleep 1
1668 done
1669
1670 echo "Checking contextCSN after modify of second backend on central master..."
1671 . $TESTDIR/checkcsn.sh
1672
1673 # TEST:
1674 # Test that updates to the first backend on site1 master, which should be
1675 # replicated everywhere except to central and site2 search.  The contextCSN
1676 # should be updated on all servers:
1677 MNUM=`expr $MNUM + 1`
1678 echo "Using ldapmodify to modify first backend on site1 master..."
1679 $LDAPMODIFY -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1680 dn: ou=sm1ou1,dc=example,dc=com
1681 changetype: modify
1682 add: description
1683 description: Modify$MNUM
1684
1685 EOF
1686 RC=$?
1687 if test $RC != 0 ; then
1688         echo "ldapmodify failed ($RC)!"
1689         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1690         exit $RC
1691 fi
1692 sleep 1
1693
1694 echo "Using ldapsearch to check replication to site1 search..."
1695 RC=32
1696 for i in 1 2 3 4 5; do
1697         RESULT=`$LDAPSEARCH -H $URI5 \
1698                 -s base -b "ou=sm1ou1,$BASEDN" \
1699                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1700         if test "x$RESULT$nullOK" = "xOK" ; then
1701                 RC=0
1702                 break
1703         fi
1704         echo "Waiting $i seconds for syncrepl to receive changes..."
1705         sleep $i
1706 done
1707 if test $RC != 0 ; then
1708         echo "ldapsearch failed ($RC)!"
1709         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1710         exit $RC
1711 fi
1712
1713 echo "Using ldapsearch to check replication to site2 master..."
1714 RC=32
1715 for i in 1 2 3 4 5; do
1716         RESULT=`$LDAPSEARCH -H $URI3 \
1717                 -s base -b "ou=sm1ou1,$BASEDN" \
1718                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1719         if test "x$RESULT$nullOK" = "xOK" ; then
1720                 RC=0
1721                 break
1722         fi
1723         echo "Waiting $i seconds for syncrepl to receive changes..."
1724         sleep $i
1725 done
1726 if test $RC != 0 ; then
1727         echo "ldapsearch failed ($RC)!"
1728         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1729         exit $RC
1730 fi
1731
1732 echo "Using ldapsearch to check no replication to site2 search..."
1733 for i in 1 2 3 4 5; do
1734         RESULT=`$LDAPSEARCH -H $URI6 \
1735                 -s base -b "ou=sm1ou2,$BASEDN" \
1736                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1737         if test "x$RESULT" = "xNOK" ; then
1738                 echo "Change was replicated to central search!"
1739                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1740                 exit 1
1741         fi
1742         sleep 1
1743 done
1744
1745 echo "Using ldapsearch to check no replication to central search..."
1746 for i in 1 2 3 4 5; do
1747         RESULT=`$LDAPSEARCH -H $URI4 \
1748                 -s base -b "ou=sm1ou2,$BASEDN" \
1749                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1750         if test "x$RESULT" = "xNOK" ; then
1751                 echo "Change was replicated to central search!"
1752                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1753                 exit 1
1754         fi
1755         sleep 1
1756 done
1757
1758 echo "Checking contextCSN after modify of first backend on site1 master..."
1759 . $TESTDIR/checkcsn.sh
1760
1761
1762 # TEST:
1763 # Test updates to the second backend on site1 master, which should only be
1764 # replicated to site1 search.  The contextCSN should be updated everywhere.
1765 MNUM=`expr $MNUM + 1`
1766 echo "Using ldapmodify to modify second backend on site1 master..."
1767 $LDAPMODIFY -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1768 dn: ou=sm1ou2,dc=example,dc=com
1769 changetype: modify
1770 add: description
1771 description: Modify$MNUM
1772
1773 EOF
1774 RC=$?
1775 if test $RC != 0 ; then
1776         echo "ldapmodify failed ($RC)!"
1777         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1778         exit $RC
1779 fi
1780 sleep 1
1781
1782
1783 echo "Using ldapsearch to check replication to site1 search..."
1784 RC=32
1785 for i in 1 2 3 4 5; do
1786         RESULT=`$LDAPSEARCH -H $URI5 \
1787                 -s base -b "ou=sm1ou2,$BASEDN" \
1788                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1789         if test "x$RESULT$nullOK" = "xOK" ; then
1790                 RC=0
1791                 break
1792         fi
1793         echo "Waiting $i seconds for syncrepl to receive changes..."
1794         sleep $i
1795 done
1796 if test $RC != 0 ; then
1797         echo "ldapsearch failed ($RC)!"
1798         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1799         exit $RC
1800 fi
1801
1802 echo "Using ldapsearch to check no replication to central master..."
1803 for i in 1 2 3 4 5; do
1804         RESULT=`$LDAPSEARCH -H $URI1 \
1805                 -s base -b "ou=sm1ou2,$BASEDN" \
1806                 "(description=Modify$NMUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1807         if test "x$RESULT" = "xNOK" ; then
1808                 echo "Change was replicated to site2 search!"
1809                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1810                 exit 1
1811         fi
1812         sleep 1
1813 done
1814
1815 echo "Checking contextCSN after modify of second backend on site1 master..."
1816 . $TESTDIR/checkcsn.sh
1817
1818
1819 # TEST:
1820 # Test updates to first backend on site2 master, which should be
1821 # replicated to the central servers, but not site1.  The contextCSN
1822 # should be updated everywhere:
1823 MNUM=`expr $MNUM + 1`
1824 echo "Using ldapmodify to modify first backend on site2 master..."
1825 $LDAPMODIFY -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1826 dn: ou=sm2ou1,dc=example,dc=com
1827 changetype: modify
1828 add: description
1829 description: Modify$MNUM
1830
1831 EOF
1832 RC=$?
1833 if test $RC != 0 ; then
1834         echo "ldapmodify failed ($RC)!"
1835         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1836         exit $RC
1837 fi
1838 sleep 1
1839
1840 echo "Using ldapsearch to check replication to central master..."
1841 RC=32
1842 for i in 1 2 3 4 5; do
1843         RESULT=`$LDAPSEARCH -H $URI1 \
1844                 -s base -b "ou=sm2ou1,$BASEDN" \
1845                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1846         if test "x$RESULT$nullOK" = "xOK" ; then
1847                 RC=0
1848                 break
1849         fi
1850         echo "Waiting $i seconds for syncrepl to receive changes..."
1851         sleep $i
1852 done
1853 if test $RC != 0 ; then
1854         echo "ldapsearch failed ($RC)!"
1855         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1856         exit $RC
1857 fi
1858
1859 echo "Using ldapsearch to check replication to site2 search..."
1860 RC=32
1861 for i in 1 2 3 4 5; do
1862         RESULT=`$LDAPSEARCH -H $URI6 \
1863                 -s base -b "ou=sm2ou1,$BASEDN" \
1864                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1865         if test "x$RESULT$nullOK" = "xOK" ; then
1866                 RC=0
1867                 break
1868         fi
1869         echo "Waiting $i seconds for syncrepl to receive changes..."
1870         sleep $i
1871 done
1872 if test $RC != 0 ; then
1873         echo "ldapsearch failed ($RC)!"
1874         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1875         exit $RC
1876 fi
1877
1878 echo "Using ldapsearch to check no replication to site1 master..."
1879 for i in 1 2 3 4 5; do
1880         RESULT=`$LDAPSEARCH -H $URI2 \
1881                 -s base -b "ou=sm2ou1,$BASEDN" \
1882                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1883         if test "x$RESULT" = "xNOK" ; then
1884                 echo "Change was replicated to site2 search!"
1885                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1886                 exit 1
1887         fi
1888         sleep 1
1889 done
1890
1891 echo "Using ldapsearch to check no replication to central search..."
1892 for i in 1 2 3 4 5; do
1893         RESULT=`$LDAPSEARCH -H $URI4 \
1894                 -s base -b "ou=sm2ou1,$BASEDN" \
1895                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1896         if test "x$RESULT" = "xNOK" ; then
1897                 echo "Change was replicated to site2 search!"
1898                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1899                 exit 1
1900         fi
1901         sleep 1
1902 done
1903
1904 echo "Checking contextCSN after modify of first backend on site2 master..."
1905 . $TESTDIR/checkcsn.sh
1906
1907
1908 # TEST:
1909 # Test updates to the second backend on site2 master, which should only be
1910 # replicated to site2 search.  As always, contextCSN should be updated
1911 # everywhere:
1912 MNUM=`expr $MNUM + 1`
1913 echo "Using ldapmodify to modify second backend on site2 master..."
1914 $LDAPMODIFY -D "ou=sm2ou1,$BASEDN" -H $URI3 -w $PASSWD <<EOF >> $TESTOUT 2>&1
1915 dn: ou=sm2ou2,dc=example,dc=com
1916 changetype: modify
1917 add: description
1918 description: Modify$MNUM
1919
1920 EOF
1921 RC=$?
1922 if test $RC != 0 ; then
1923         echo "ldapmodify failed ($RC)!"
1924         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1925         exit $RC
1926 fi
1927 sleep 1
1928
1929 echo "Using ldapsearch to check replication to site2 search..."
1930 RC=32
1931 for i in 1 2 3 4 5; do
1932         RESULT=`$LDAPSEARCH -H $URI6 \
1933                 -s base -b "ou=sm2ou2,$BASEDN" \
1934                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "OK"}'`
1935         if test "x$RESULT$nullOK" = "xOK" ; then
1936                 RC=0
1937                 break
1938         fi
1939         echo "Waiting $i seconds for syncrepl to receive changes..."
1940         sleep $i
1941 done
1942 if test $RC != 0 ; then
1943         echo "ldapsearch failed ($RC)!"
1944         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1945         exit $RC
1946 fi
1947
1948 echo "Using ldapsearch to check no replication to central master..."
1949 for i in 1 2 3 4 5; do
1950         RESULT=`$LDAPSEARCH -H $URI4 \
1951                 -s base -b "ou=sm2ou2,$BASEDN" \
1952                 "(description=Modify$MNUM)" 2>&1 | awk '/^dn:/ {print "NOK"}'`
1953         if test "x$RESULT" = "xNOK" ; then
1954                 echo "Change was replicated to central search!"
1955                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1956                 exit 1
1957         fi
1958         sleep 1
1959 done
1960
1961 echo "Checking contextCSN after modify of second backend on site2 master..."
1962 . $TESTDIR/checkcsn.sh
1963
1964 # TEST:
1965 # Test that all contextCSN values are updated on the slaves when they
1966 # starts with an empty database.  Start site2 master first, then site2
1967 # search and finally central master so that the site2 search's syncrepl
1968 # connection has been set up when site2 master receives the database:
1969 echo "Stopping central master and site2 servers to test start with emtpy db..."
1970 kill -HUP  $SMC_PID $SM2_PID $SS2_PID
1971 for pid in $SMC_PID $SM2_PID $SS2_PID; do wait $pid ; done
1972 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
1973 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SM2_PID / /"`;
1974 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SS2_PID / /"`;
1975 SMC_PID=
1976 SM2_PID=
1977 SS2_PID=
1978 rm -rf $SM2_DIR/db/*
1979 rm -rf $SS2_DIR/db/*
1980
1981 echo "Starting site2 master slapd on TCP/IP port $PORT3..."
1982 cd $SM2_DIR
1983 $SLAPD -F slapd.d -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
1984 SM2_PID=$!
1985 if test $WAIT != 0 ; then
1986         echo PID $SM2_PID
1987         read foo
1988 fi
1989 KILLPIDS="$KILLPIDS $SM2_PID"
1990 cd $TESTWD
1991 sleep 1
1992 echo "Using ldapsearch to check that site2 master slapd is running..."
1993 for i in 1 2 3 4 5; do
1994         $LDAPSEARCH -s base -b "" -H $URI3 \
1995                 'objectclass=*' > /dev/null 2>&1
1996         RC=$?
1997         test $RC = 0 && break
1998         echo "Waiting $i seconds for slapd to start..."
1999         sleep $i
2000 done
2001 if test $RC != 0 ; then
2002         echo "ldapsearch failed ($RC)!"
2003         test $KILLSERVERS != no && kill -HUP $KILLPIDS
2004         exit $RC
2005 fi
2006
2007 echo "Starting site2 search slapd on TCP/IP port $PORT6..."
2008 cd $SS2_DIR
2009 $SLAPD -F slapd.d -h $URI6 -d $LVL $TIMING >> $LOG6 2>&1 &
2010 SS2_PID=$!
2011 if test $WAIT != 0 ; then
2012         echo PID $SS2_PID
2013         read foo
2014 fi
2015 KILLPIDS="$KILLPIDS $SS2_PID"
2016 cd $TESTWD
2017 sleep 1
2018 echo "Using ldapsearch to check that site2 search slapd is running..."
2019 for i in 1 2 3 4 5; do
2020         $LDAPSEARCH -s base -b "" -H $URI6 \
2021                 'objectclass=*' > /dev/null 2>&1
2022         RC=$?
2023         test $RC = 0 && break
2024         echo "Waiting $i seconds for slapd to start..."
2025         sleep $i
2026 done
2027 if test $RC != 0 ; then
2028         echo "ldapsearch failed ($RC)!"
2029         test $KILLSERVERS != no && kill -HUP $KILLPIDS
2030         exit $RC
2031 fi
2032
2033 echo "Starting central master slapd on TCP/IP port $PORT1..."
2034 cd $SMC_DIR
2035 $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2036 SMC_PID=$!
2037 if test $WAIT != 0 ; then
2038         echo PID $SMC_PID
2039         read foo
2040 fi
2041 KILLPIDS="$KILLPIDS $SMC_PID"
2042 cd $TESTWD
2043 sleep 1
2044 echo "Using ldapsearch to check that central master slapd is running..."
2045 for i in 1 2 3 4 5; do
2046         $LDAPSEARCH -s base -b "" -H $URI1 \
2047                 'objectclass=*' > /dev/null 2>&1
2048         RC=$?
2049         test $RC = 0 && break
2050         echo "Waiting $i seconds for slapd to start..."
2051         sleep $i
2052 done
2053 if test $RC != 0 ; then
2054         echo "ldapsearch failed ($RC)!"
2055         test $KILLSERVERS != no && kill -HUP $KILLPIDS
2056         exit $RC
2057 fi
2058
2059 echo "Using ldapsearch to check that site2 master received base..."
2060 RC=32
2061 for i in 1 2 3 4 5; do
2062         RESULT=`$LDAPSEARCH -H $URI3 \
2063                 -s base -b "$BASEDN" \
2064                 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2065         if test "x$RESULT$nullOK" = "xOK" ; then
2066                 RC=0
2067                 break
2068         fi
2069         echo "Waiting $i seconds for syncrepl to receive changes..."
2070         sleep $i
2071 done
2072 if test $RC != 0 ; then
2073         echo "ldapsearch failed ($RC)!"
2074         test $KILLSERVERS != no && kill -HUP $KILLPIDS
2075         exit $RC
2076 fi
2077
2078 echo "Using ldapsearch to check that site2 search received base..."
2079 RC=32
2080 for i in 1 2 3 4 5; do
2081         RESULT=`$LDAPSEARCH -H $URI6 \
2082                 -s base -b "$BASEDN" \
2083                 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2084         if test "x$RESULT$nullOK" = "xOK" ; then
2085                 RC=0
2086                 break
2087         fi
2088         echo "Waiting $i seconds for syncrepl to receive changes..."
2089         sleep $i
2090 done
2091 if test $RC != 0 ; then
2092         echo "ldapsearch failed ($RC)!"
2093         test $KILLSERVERS != no && kill -HUP $KILLPIDS
2094         exit $RC
2095 fi
2096
2097 sleep $SLEEP1
2098
2099 echo "Checking contextCSN after site2 servers repopulated..."
2100 . $TESTDIR/checkcsn.sh
2101
2102 if test $ERRORS -ne 0; then
2103         test $KILLSERVERS != no && kill -HUP $KILLPIDS
2104         echo "Found $ERRORS errors"
2105         exit $ERRORS
2106 fi
2107
2108 # TEST:
2109 # Adding syncrepl of the second site1 master backend on central master
2110 # will not initialize the database unless the contextCSN attribute is
2111 # stored in the suffix of the database and not the suffix of the glue
2112 # database:
2113 echo "Adding syncrepl of second site1 master backend on central master..."
2114 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
2115 dn: olcDatabase={4}$BACKEND,cn=config
2116 changetype: modify
2117 add: olcSyncRepl
2118 olcSyncRepl: rid=4 provider=$URI2 searchbase="ou=sm1ou2,$BASEDN"
2119   binddn="ou=sm1ou1,$BASEDN" bindmethod=simple credentials=$PASSWD
2120   type=refreshAndPersist retry="$RETRY" timeout=1
2121 EOF
2122 RC=$?
2123 if test $RC != 0 ; then
2124         echo "ldapmodify failed to add syncrepl on central master ($RC)!"
2125         test $KILLSERVERS != no && kill -HUP $KILLPIDS
2126         exit $RC
2127 fi
2128 sleep 1
2129
2130 echo "Using ldapsearch to check that central master received second site1 backend..."
2131 RC=32
2132 for i in 1 2 3 4 5; do
2133         RESULT=`$LDAPSEARCH -H $URI1 \
2134                 -s base -b "ou=sm1ou2,$BASEDN" \
2135                 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2136         if test "x$RESULT$nullOK" = "xOK" ; then
2137                 RC=0
2138                 break
2139         fi
2140         echo "Waiting $i seconds for syncrepl to receive changes..."
2141         sleep $i
2142 done
2143 if test $RC != 0 ; then
2144         echo "ERROR: Second site1 backend not replicated to central master"
2145         ERRORS=`expr $ERRORS + 1`
2146
2147         echo "Restarting central master slapd on TCP/IP port $PORT1..."
2148         kill -HUP $SMC_PID
2149         wait $SMC_PID
2150         KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2151
2152         cd $SMC_DIR
2153         $SLAPD -F slapd.d -h $URI1 -c rid=4,csn=0 -d $LVL $TIMING >> $LOG1 2>&1 &
2154         SMC_PID=$!
2155         if test $WAIT != 0 ; then
2156                 echo PID $SMC_PID
2157                 read foo
2158         fi
2159         KILLPIDS="$KILLPIDS $SMC_PID"
2160         cd $TESTWD
2161         echo "Using ldapsearch to check that central master slapd is running..."
2162         for i in 1 2 3 4 5; do
2163                 $LDAPSEARCH -s base -b "" -H $URI1 \
2164                         'objectclass=*' > /dev/null 2>&1
2165                 RC=$?
2166                 test $RC = 0 && break
2167                 echo "Waiting $i seconds for slapd to start..."
2168                 sleep $i
2169         done
2170         if test $RC != 0 ; then
2171                 echo "ldapsearch failed ($RC)!"
2172                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2173                 exit $RC
2174         fi
2175
2176         echo "Using ldapsearch to check that central master received second site1 backend..."
2177         RC=32
2178         for i in 1 2 3 4 5; do
2179                 RESULT=`$LDAPSEARCH -H $URI1 \
2180                         -s base -b "ou=sm1ou2,$BASEDN" \
2181                         '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2182                 if test "x$RESULT$nullOK" = "xOK" ; then
2183                         RC=0
2184                         break
2185                 fi
2186                 echo "Waiting $i seconds for syncrepl to receive changes..."
2187                 sleep $i
2188         done
2189         if test $RC != 0 ; then
2190                 echo "ldapsearch failed ($RC)!"
2191                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2192                 exit $RC
2193         fi
2194 fi
2195
2196 echo "Using ldapsearch to check that central search received second site1 backend..."
2197 RC=32
2198 for i in 1 2 3 4 5; do
2199         RESULT=`$LDAPSEARCH -H $URI4 \
2200                 -s base -b "ou=sm1ou2,$BASEDN" \
2201                 '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2202         if test "x$RESULT$nullOK" = "xOK" ; then
2203                 RC=0
2204                 break
2205         fi
2206         echo "Waiting $i seconds for syncrepl to receive changes..."
2207         sleep $i
2208 done
2209 if test $RC != 0 ; then
2210         echo "ERROR: Second site1 backend not replicated to central search"
2211         ERRORS=`expr $ERRORS + 1`
2212
2213         echo "Restarting central search slapd on TCP/IP port $PORT4..."
2214         kill -HUP $SSC_PID
2215         wait $SSC_PID
2216         KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SSC_PID / /"`;
2217
2218         cd $SSC_DIR
2219         $SLAPD -F slapd.d -h $URI4 -c rid=1,csn=0 -d $LVL $TIMING >> $LOG4 2>&1 &
2220         SSC_PID=$!
2221         if test $WAIT != 0 ; then
2222                 echo PID $SSC_PID
2223                 read foo
2224         fi
2225         KILLPIDS="$KILLPIDS $SSC_PID"
2226         cd $TESTWD
2227         echo "Using ldapsearch to check that central search slapd is running..."
2228         for i in 1 2 3 4 5; do
2229                 $LDAPSEARCH -s base -b "" -H $URI4 \
2230                         'objectclass=*' > /dev/null 2>&1
2231                 RC=$?
2232                 test $RC = 0 && break
2233                 echo "Waiting $i seconds for slapd to start..."
2234                 sleep $i
2235         done
2236         if test $RC != 0 ; then
2237                 echo "ldapsearch failed ($RC)!"
2238                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2239                 exit $RC
2240         fi
2241
2242         echo "Using ldapsearch to check that central search received second site1 backend..."
2243         RC=32
2244         for i in 1 2 3 4 5; do
2245                 RESULT=`$LDAPSEARCH -H $URI4 \
2246                         -s base -b "ou=sm1ou2,$BASEDN" \
2247                         '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
2248                 if test "x$RESULT$nullOK" = "xOK" ; then
2249                         RC=0
2250                         break
2251                 fi
2252                 echo "Waiting $i seconds for syncrepl to receive changes..."
2253                 sleep $i
2254         done
2255         if test $RC != 0 ; then
2256                 echo "ldapsearch failed ($RC)!"
2257                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2258                 exit $RC
2259         fi
2260 fi
2261
2262
2263 # TEST:
2264 # Run race tests when more than one backend is replicated from the same
2265 # provider.  This will usually fail long before 100 iterations unless
2266 # syncrepl stores the contextCSN in the suffix of its own database, and
2267 # that syncprov follows these rules before updating its own CSN when it
2268 # detects updates from syncrepl:
2269 # 1) A contextCSN value must have been stored in the suffix of all the
2270 #        syncrepl configured databases within the glued syncprov database.
2271 # 2) Of all contextCSN values stored by syncrepl with the same SID,
2272 #        syncprov must always select the one with the lowest csn value.
2273 test -z "$RACE_TESTS" && RACE_TESTS=10
2274 RACE_NUM=0
2275 RACE_ERROR=0
2276
2277 SUB_DN=ou=sub,ou=sm1ou2,dc=example,dc=com
2278
2279 while test $RACE_ERROR -eq 0 -a $RACE_NUM -lt $RACE_TESTS ; do
2280         RACE_NUM=`expr $RACE_NUM + 1`
2281         echo "Running $RACE_NUM of $RACE_TESTS syncrepl race tests..."
2282
2283         echo "Stopping central master..."
2284         kill -HUP $SMC_PID
2285         wait $SMC_PID
2286         KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2287
2288         MNUM=`expr $MNUM + 1`
2289         echo "Using ldapadd to add entry on site1 master..."
2290         $LDAPADD -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
2291 dn: $SUB_DN
2292 objectClass: top
2293 objectClass: organizationalUnit
2294 ou: sub
2295
2296 EOF
2297         RC=$?
2298         if test $RC != 0 ; then
2299                 echo "ldapadd failed ($RC)!"
2300                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2301                 exit $RC
2302         fi
2303
2304         echo "Starting central master again..."
2305         cd $SMC_DIR
2306         $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2307         SMC_PID=$!
2308         KILLPIDS="$KILLPIDS $SMC_PID"
2309         cd $TESTWD
2310         echo "Using ldapsearch to check that central master received entry..."
2311         for i in 1 2 3 4 5; do
2312                 $LDAPSEARCH -s base -b "$SUB_DN"  -H $URI1 > /dev/null 2>&1
2313                 RC=$?
2314                 test $RC = 0 && break
2315                 sleep $i
2316         done
2317         if test $RC != 0 ; then
2318                 echo "ERROR: entry not replicated to central master!"
2319                 RACE_ERROR=1
2320                 break
2321         fi
2322
2323         echo "Using ldapsearch to check that central search received entry..."
2324         for i in 1 2 3 4 5; do
2325                 $LDAPSEARCH -s base -b "$SUB_DN"  -H $URI4 > /dev/null 2>&1
2326                 RC=$?
2327                 test $RC = 0 && break
2328                 sleep $i
2329         done
2330         if test $RC != 0 ; then
2331                 echo "ERROR: entry not replicated to central master!"
2332                 RACE_ERROR=1
2333                 break
2334         fi
2335
2336         echo "Stopping central master..."
2337         kill -HUP $SMC_PID
2338         wait $SMC_PID
2339         KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $SMC_PID / /"`;
2340
2341         echo "Using ldapdelete to delete entry on site1 master..."
2342         $LDAPDELETE -D "ou=sm1ou1,$BASEDN" -H $URI2 -w $PASSWD "$SUB_DN"
2343         RC=$?
2344         if test $RC != 0 ; then
2345                 echo "ldapdelete failed ($RC)!"
2346                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2347                 exit $RC
2348         fi
2349
2350         echo "Starting central master again..."
2351         cd $SMC_DIR
2352         $SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
2353         SMC_PID=$!
2354         KILLPIDS="$KILLPIDS $SMC_PID"
2355         cd $TESTWD
2356
2357         echo "Using ldapsearch to check that entry was deleted on central master..."
2358         RC=0
2359         for i in 1 2 3 4 5; do
2360                 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI1 > /dev/null 2>&1
2361                 RC=$?
2362                 if test $RC = $wantNoObj; then break; fi
2363                 sleep $i
2364         done
2365
2366         if test $RC != $wantNoObj; then
2367                 if test $RC != 0; then
2368                         echo "ldapsearch failed ($RC)!"
2369                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
2370                         exit $RC
2371                 fi
2372                 echo "ERROR: Entry not removed on central master!"
2373                 RACE_ERROR=1
2374                 break
2375         fi
2376
2377         echo "Using ldapsearch to check that entry was deleted on central search..."
2378         RC=0
2379         for i in 1 2 3 4 5; do
2380                 $LDAPSEARCH -s base -b "$SUB_DN" -H $URI4 > /dev/null 2>&1
2381                 RC=$?
2382                 if test $RC != 0; then break; fi
2383                 sleep $i
2384         done
2385
2386         if test $RC != $wantNoObj; then
2387                 echo "ERROR: Entry not removed on central search! (RC=$RC)"
2388                 RACE_ERROR=1
2389                 break
2390         fi
2391 done
2392
2393 if test $RACE_ERROR != 0; then
2394         echo "Race error found after $RACE_NUM of $RACE_TESTS iterations"
2395         ERRORS=`expr $ERRORS + $RACE_ERROR`
2396 else
2397         echo "No race errors found after $RACE_TESTS iterations"
2398 fi
2399
2400 test $KILLSERVERS != no && kill -HUP $KILLPIDS
2401
2402 if test $ERRORS -ne 0; then
2403         echo "Found $ERRORS errors"
2404         echo ">>>>>> Exiting with a false success status for now"
2405         exit 0
2406 fi
2407
2408 echo ">>>>> Test succeeded"
2409
2410 exit 0