3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2012 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 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test $SYNCPROV = syncprovno; then
20 echo "Syncrepl provider overlay not available, test skipped"
23 if test $ACCESSLOG = accesslogno; then
24 echo "Accesslog overlay not available, test skipped"
35 $SLAPPASSWD -g -n >$CONFIGPWF
37 if test x"$SYNCMODE" = x ; then
42 SYNCTYPE="type=refreshOnly interval=00:00:00:03"
45 SYNCTYPE="type=refreshAndPersist interval=00:00:00:03"
48 echo "unknown sync mode $SYNCMODE"
56 # - configure over ldap
57 # - populate over ldap
58 # - configure syncrepl over ldap
60 # - modify each server separately
61 # - restore replication
66 test $BACKEND = null && nullExclude="# "
70 echo "Initializing server configurations..."
72 while [ $n -le $MMR ]; do
75 CFDIR=${XDIR}$n/slapd.d
77 mkdir -p ${XDIR}$n $DBDIR.1 $DBDIR.2 $CFDIR
82 objectClass: olcGlobal
88 if [ "$SYNCPROV" = syncprovmod -o "$ACCESSLOG" = accesslogmod ]; then
90 dn: cn=module,cn=config
91 objectClass: olcModuleList
93 olcModulePath: $TESTWD/../servers/slapd/overlays
95 if [ "$SYNCPROV" = syncprovmod ]; then
96 echo "olcModuleLoad: syncprov.la" >> $TMP
98 if [ "$ACCESSLOG" = accesslogmod ]; then
99 echo "olcModuleLoad: accesslog.la" >> $TMP
104 if [ "$BACKENDTYPE" = mod ]; then
106 dn: cn=module,cn=config
107 objectClass: olcModuleList
109 olcModulePath: $TESTWD/../servers/slapd/back-$BACKEND
110 olcModuleLoad: back_$BACKEND.la
114 MYURI=`eval echo '$URI'$n`
115 PROVIDERURI=`eval echo '$URI'$o`
116 if test $INDEXDB = indexdb ; then
117 INDEX1="olcDbIndex: objectClass,entryCSN,reqStart,reqDN eq"
118 INDEX2="olcDbIndex: objectClass,entryCSN,entryUUID eq"
124 dn: cn=schema,cn=config
125 objectclass: olcSchemaconfig
128 include: file://$ABS_SCHEMADIR/core.ldif
130 include: file://$ABS_SCHEMADIR/cosine.ldif
132 include: file://$ABS_SCHEMADIR/inetorgperson.ldif
134 include: file://$ABS_SCHEMADIR/openldap.ldif
136 include: file://$ABS_SCHEMADIR/nis.ldif
138 dn: olcDatabase={0}config,cn=config
139 objectClass: olcDatabaseConfig
140 olcDatabase: {0}config
141 olcRootPW:< file://$CONFIGPWF
143 dn: olcDatabase={1}$BACKEND,cn=config
144 objectClass: olcDatabaseConfig
145 ${nullExclude}objectClass: olc${BACKEND}Config
146 olcDatabase: {1}$BACKEND
148 ${nullExclude}olcDbDirectory: ${DBDIR}.1
149 olcRootDN: $MANAGERDN
152 dn: olcOverlay=syncprov,olcDatabase={1}$BACKEND,cn=config
153 objectClass: olcOverlayConfig
154 objectClass: olcSyncProvConfig
157 olcSpReloadHint: TRUE
159 dn: olcDatabase={2}$BACKEND,cn=config
160 objectClass: olcDatabaseConfig
161 ${nullExclude}objectClass: olc${BACKEND}Config
162 olcDatabase: {2}$BACKEND
164 ${nullExclude}olcDbDirectory: ${DBDIR}.2
165 olcRootDN: $MANAGERDN
167 olcSyncRepl: rid=001 provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple
168 credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
169 retry="3 +" timeout=3 logbase="cn=log"
170 logfilter="(&(objectclass=auditWriteObject)(reqresult=0))"
175 dn: olcOverlay=syncprov,olcDatabase={2}$BACKEND,cn=config
176 objectClass: olcOverlayConfig
177 objectClass: olcSyncProvConfig
180 dn: olcOverlay=accesslog,olcDatabase={2}$BACKEND,cn=config
181 objectClass: olcOverlayConfig
182 objectClass: olcAccessLogConfig
183 olcOverlay: accesslog
184 olcAccessLogDB: cn=log
185 olcAccessLogOps: writes
186 olcAccessLogSuccess: TRUE
189 $SLAPADD -F $CFDIR -n 0 -d-1< $TMP > $TESTOUT 2>&1
190 PORT=`eval echo '$PORT'$n`
191 echo "Starting server $n on TCP/IP port $PORT..."
193 LOG=`eval echo '$LOG'$n`
194 $SLAPD -F slapd.d -h $MYURI -d $LVL $TIMING > $LOG 2>&1 &
196 if test $WAIT != 0 ; then
200 KILLPIDS="$PID $KILLPIDS"
203 echo "Using ldapsearch to check that server $n is running..."
204 for i in 0 1 2 3 4 5; do
205 $LDAPSEARCH -s base -b "" -H $MYURI \
206 'objectclass=*' > /dev/null 2>&1
208 if test $RC = 0 ; then
211 echo "Waiting 5 seconds for slapd to start..."
215 if test $RC != 0 ; then
216 echo "ldapsearch failed ($RC)!"
217 test $KILLSERVERS != no && kill -HUP $KILLPIDS
222 echo "Using ldapadd for context on server 1..."
223 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDEREDCP \
226 if test $RC != 0 ; then
227 echo "ldapadd failed for server $n database ($RC)!"
228 test $KILLSERVERS != no && kill -HUP $KILLPIDS
236 echo "Using ldapadd to populate server 1..."
237 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDEREDNOCP \
240 if test $RC != 0 ; then
241 echo "ldapadd failed for server $n database ($RC)!"
242 test $KILLSERVERS != no && kill -HUP $KILLPIDS
246 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
250 while [ $n -le $MMR ]; do
251 PORT=`expr $BASEPORT + $n`
252 URI="ldap://${LOCALHOST}:$PORT/"
254 echo "Using ldapsearch to read all the entries from server $n..."
255 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \
256 'objectclass=*' > $TESTDIR/server$n.out 2>&1
259 if test $RC != 0 ; then
260 echo "ldapsearch failed at server $n ($RC)!"
261 test $KILLSERVERS != no && kill -HUP $KILLPIDS
264 $LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt
269 while [ $n -le $MMR ]; do
270 echo "Comparing retrieved entries from server 1 and server $n..."
271 $CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT
273 if test $? != 0 ; then
274 echo "test failed - server 1 and server $n databases differ"
275 test $KILLSERVERS != no && kill -HUP $KILLPIDS
281 echo "Using ldapadd to populate server 2..."
282 $LDAPADD -D "$MANAGERDN" -H $URI2 -w $PASSWD -f $LDIFADD1 \
285 if test $RC != 0 ; then
286 echo "ldapadd failed for server 2 database ($RC)!"
287 test $KILLSERVERS != no && kill -HUP $KILLPIDS
291 THEDN="cn=James A Jones 2,ou=Alumni Association,ou=People,dc=example,dc=com"
294 $LDAPSEARCH -S "" -b "$THEDN" -H $URI1 \
295 -s base '(objectClass=*)' entryCSN > "${MASTEROUT}.$i" 2>&1
298 if test $RC = 0 ; then
302 if test $RC != 32 ; then
303 echo "ldapsearch failed at slave ($RC)!"
304 test $KILLSERVERS != no && kill -HUP $KILLPIDS
308 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
313 while [ $n -le $MMR ]; do
314 PORT=`expr $BASEPORT + $n`
315 URI="ldap://${LOCALHOST}:$PORT/"
317 echo "Using ldapsearch to read all the entries from server $n..."
318 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \
319 'objectclass=*' > $TESTDIR/server$n.out 2>&1
322 if test $RC != 0 ; then
323 echo "ldapsearch failed at server $n ($RC)!"
324 test $KILLSERVERS != no && kill -HUP $KILLPIDS
327 $LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt
332 while [ $n -le $MMR ]; do
333 echo "Comparing retrieved entries from server 1 and server $n..."
334 $CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT
336 if test $? != 0 ; then
337 echo "test failed - server 1 and server $n databases differ"
338 test $KILLSERVERS != no && kill -HUP $KILLPIDS
344 echo "Breaking replication between server 1 and 2..."
346 while [ $n -le $MMR ]; do
348 MYURI=`eval echo '$URI'$n`
349 PROVIDERURI=`eval echo '$URI'$o`
350 $LDAPMODIFY -D cn=config -H $MYURI -y $CONFIGPWF > $TESTOUT 2>&1 <<EOF
351 dn: olcDatabase={2}$BACKEND,cn=config
354 olcSyncRepl: rid=001 provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple
355 credentials=InvalidPw searchbase="$BASEDN" $SYNCTYPE
356 retry="3 +" timeout=3 logbase="cn=log"
357 logfilter="(&(objectclass=auditWriteObject)(reqresult=0))"
360 replace: olcMirrorMode
365 if test $RC != 0 ; then
366 echo "ldapmodify failed for server $n config ($RC)!"
367 test $KILLSERVERS != no && kill -HUP $KILLPIDS
373 echo "Using ldapmodify to force conflicts between server 1 and 2..."
374 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
375 >> $TESTOUT 2>&1 << EOF
383 if test $RC != 0 ; then
384 echo "ldapmodify failed for server 1 database ($RC)!"
385 test $KILLSERVERS != no && kill -HUP $KILLPIDS
389 $LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \
390 >> $TESTOUT 2>&1 << EOF
394 description: Stupendous
398 if test $RC != 0 ; then
399 echo "ldapmodify failed for server 2 database ($RC)!"
400 test $KILLSERVERS != no && kill -HUP $KILLPIDS
404 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
405 >> $TESTOUT 2>&1 << EOF
409 description: Outstanding
412 description: Mindboggling
416 if test $RC != 0 ; then
417 echo "ldapmodify failed for server 1 database ($RC)!"
418 test $KILLSERVERS != no && kill -HUP $KILLPIDS
422 $LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \
423 >> $TESTOUT 2>&1 << EOF
427 description: OutStanding
434 if test $RC != 0 ; then
435 echo "ldapmodify failed for server 2 database ($RC)!"
436 test $KILLSERVERS != no && kill -HUP $KILLPIDS
440 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
441 >> $TESTOUT 2>&1 << EOF
452 if test $RC != 0 ; then
453 echo "ldapmodify failed for server 1 database ($RC)!"
454 test $KILLSERVERS != no && kill -HUP $KILLPIDS
458 $LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \
459 >> $TESTOUT 2>&1 << EOF
463 employeeType: deadwood
470 if test $RC != 0 ; then
471 echo "ldapmodify failed for server 2 database ($RC)!"
472 test $KILLSERVERS != no && kill -HUP $KILLPIDS
476 echo "Restoring replication between server 1 and 2..."
478 while [ $n -le $MMR ]; do
480 MYURI=`eval echo '$URI'$n`
481 PROVIDERURI=`eval echo '$URI'$o`
482 $LDAPMODIFY -D cn=config -H $MYURI -y $CONFIGPWF > $TESTOUT 2>&1 <<EOF
483 dn: olcDatabase={2}$BACKEND,cn=config
486 olcSyncRepl: rid=001 provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple
487 credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
488 retry="3 +" timeout=3 logbase="cn=log"
489 logfilter="(&(objectclass=auditWriteObject)(reqresult=0))"
492 replace: olcMirrorMode
497 if test $RC != 0 ; then
498 echo "ldapmodify failed for server $n config ($RC)!"
499 test $KILLSERVERS != no && kill -HUP $KILLPIDS
505 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
509 while [ $n -le $MMR ]; do
510 PORT=`expr $BASEPORT + $n`
511 URI="ldap://${LOCALHOST}:$PORT/"
513 echo "Using ldapsearch to read all the entries from server $n..."
514 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \
515 'objectclass=*' > $TESTDIR/server$n.out 2>&1
518 if test $RC != 0 ; then
519 echo "ldapsearch failed at server $n ($RC)!"
520 test $KILLSERVERS != no && kill -HUP $KILLPIDS
523 $LDIFFILTER -s $BACKEND=a < $TESTDIR/server$n.out > $TESTDIR/server$n.flt
528 while [ $n -le $MMR ]; do
529 echo "Comparing retrieved entries from server 1 and server $n..."
530 $CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT
532 if test $? != 0 ; then
533 echo "test failed - server 1 and server $n databases differ"
534 test $KILLSERVERS != no && kill -HUP $KILLPIDS
540 test $KILLSERVERS != no && kill -HUP $KILLPIDS
542 echo ">>>>> Test succeeded"
544 test $KILLSERVERS != no && wait