3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2017 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 $WITH_TLS = no ; then
20 echo "TLS support not available, test skipped"
24 if test $SYNCPROV = syncprovno; then
25 echo "Syncrepl provider overlay not available, test skipped"
28 if test $ACCESSLOG = accesslogno; then
29 echo "Accesslog overlay not available, test skipped"
39 cp -r $DATADIR/tls $TESTDIR
41 $SLAPPASSWD -g -n >$CONFIGPWF
43 if test x"$SYNCMODE" = x ; then
48 SYNCTYPE="type=refreshOnly interval=00:00:00:03"
51 SYNCTYPE="type=refreshAndPersist interval=00:00:00:03"
54 echo "unknown sync mode $SYNCMODE"
62 # - configure over ldap
63 # - populate over ldap
64 # - configure syncrepl over ldap
66 # - modify each server separately
67 # - restore replication
72 test $BACKEND = null && nullExclude="# "
76 echo "Initializing server configurations..."
78 while [ $n -le $MMR ]; do
81 CFDIR=${XDIR}$n/slapd.d
83 mkdir -p ${XDIR}$n $DBDIR.1 $DBDIR.2 $CFDIR
88 objectClass: olcGlobal
91 olcTLSCertificateFile: $TESTDIR/tls/certs/localhost.crt
92 olcTLSCertificateKeyFile: $TESTDIR/tls/private/localhost.key
96 if [ "$SYNCPROV" = syncprovmod -o "$ACCESSLOG" = accesslogmod ]; then
98 dn: cn=module,cn=config
99 objectClass: olcModuleList
101 olcModulePath: $TESTWD/../servers/slapd/overlays
103 if [ "$SYNCPROV" = syncprovmod ]; then
104 echo "olcModuleLoad: syncprov.la" >> $TMP
106 if [ "$ACCESSLOG" = accesslogmod ]; then
107 echo "olcModuleLoad: accesslog.la" >> $TMP
112 if [ "$BACKENDTYPE" = mod ]; then
114 dn: cn=module,cn=config
115 objectClass: olcModuleList
117 olcModulePath: $TESTWD/../servers/slapd/back-$BACKEND
118 olcModuleLoad: back_$BACKEND.la
122 MYURI=`eval echo '$URI'$n`
123 PROVIDERURI=`eval echo '$URIP'$o`
124 if test $INDEXDB = indexdb ; then
125 INDEX1="olcDbIndex: objectClass,entryCSN,reqStart,reqDN,reqResult eq"
126 INDEX2="olcDbIndex: objectClass,entryCSN,entryUUID eq"
132 dn: cn=schema,cn=config
133 objectclass: olcSchemaconfig
136 include: file://$ABS_SCHEMADIR/core.ldif
138 include: file://$ABS_SCHEMADIR/cosine.ldif
140 include: file://$ABS_SCHEMADIR/inetorgperson.ldif
142 include: file://$ABS_SCHEMADIR/openldap.ldif
144 include: file://$ABS_SCHEMADIR/nis.ldif
146 dn: olcDatabase={0}config,cn=config
147 objectClass: olcDatabaseConfig
148 olcDatabase: {0}config
149 olcRootPW:< file://$CONFIGPWF
151 dn: olcDatabase={1}$BACKEND,cn=config
152 objectClass: olcDatabaseConfig
153 ${nullExclude}objectClass: olc${BACKEND}Config
154 olcDatabase: {1}$BACKEND
156 ${nullExclude}olcDbDirectory: ${DBDIR}.1
157 olcRootDN: $MANAGERDN
160 dn: olcOverlay=syncprov,olcDatabase={1}$BACKEND,cn=config
161 objectClass: olcOverlayConfig
162 objectClass: olcSyncProvConfig
165 olcSpReloadHint: TRUE
167 dn: olcDatabase={2}$BACKEND,cn=config
168 objectClass: olcDatabaseConfig
169 ${nullExclude}objectClass: olc${BACKEND}Config
170 olcDatabase: {2}$BACKEND
172 ${nullExclude}olcDbDirectory: ${DBDIR}.2
173 olcRootDN: $MANAGERDN
175 olcSyncRepl: rid=001 provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple
176 credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
177 retry="3 +" timeout=3 logbase="cn=log"
178 logfilter="(&(objectclass=auditWriteObject)(reqresult=0))"
179 syncdata=accesslog tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt
184 dn: olcOverlay=syncprov,olcDatabase={2}$BACKEND,cn=config
185 objectClass: olcOverlayConfig
186 objectClass: olcSyncProvConfig
189 dn: olcOverlay=accesslog,olcDatabase={2}$BACKEND,cn=config
190 objectClass: olcOverlayConfig
191 objectClass: olcAccessLogConfig
192 olcOverlay: accesslog
193 olcAccessLogDB: cn=log
194 olcAccessLogOps: writes
195 olcAccessLogSuccess: TRUE
198 $SLAPADD -F $CFDIR -n 0 -d-1< $TMP > $TESTOUT 2>&1
199 PORT=`eval echo '$PORT'$n`
200 echo "Starting server $n on TCP/IP port $PORT..."
202 LOG=`eval echo '$LOG'$n`
203 $SLAPD -F slapd.d -h $MYURI -d $LVL $TIMING > $LOG 2>&1 &
205 if test $WAIT != 0 ; then
209 KILLPIDS="$PID $KILLPIDS"
212 echo "Using ldapsearch to check that server $n is running..."
213 for i in 0 1 2 3 4 5; do
214 $LDAPSEARCH -s base -b "" -H $MYURI \
215 'objectclass=*' > /dev/null 2>&1
217 if test $RC = 0 ; then
220 echo "Waiting 5 seconds for slapd to start..."
224 if test $RC != 0 ; then
225 echo "ldapsearch failed ($RC)!"
226 test $KILLSERVERS != no && kill -HUP $KILLPIDS
231 echo "Using ldapadd for context on server 1..."
232 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDEREDCP \
235 if test $RC != 0 ; then
236 echo "ldapadd failed for server $n database ($RC)!"
237 test $KILLSERVERS != no && kill -HUP $KILLPIDS
245 echo "Using ldapadd to populate server 1..."
246 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDEREDNOCP \
249 if test $RC != 0 ; then
250 echo "ldapadd failed for server $n database ($RC)!"
251 test $KILLSERVERS != no && kill -HUP $KILLPIDS
255 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
259 while [ $n -le $MMR ]; do
260 PORT=`expr $BASEPORT + $n`
261 URI="ldap://${LOCALHOST}:$PORT/"
263 echo "Using ldapsearch to read all the entries from server $n..."
264 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \
265 'objectclass=*' > $TESTDIR/server$n.out 2>&1
268 if test $RC != 0 ; then
269 echo "ldapsearch failed at server $n ($RC)!"
270 test $KILLSERVERS != no && kill -HUP $KILLPIDS
273 $LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt
278 while [ $n -le $MMR ]; do
279 echo "Comparing retrieved entries from server 1 and server $n..."
280 $CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT
282 if test $? != 0 ; then
283 echo "test failed - server 1 and server $n databases differ"
284 test $KILLSERVERS != no && kill -HUP $KILLPIDS
290 echo "Using ldapadd to populate server 2..."
291 $LDAPADD -D "$MANAGERDN" -H $URI2 -w $PASSWD -f $LDIFADD1 \
294 if test $RC != 0 ; then
295 echo "ldapadd failed for server 2 database ($RC)!"
296 test $KILLSERVERS != no && kill -HUP $KILLPIDS
300 THEDN="cn=James A Jones 2,ou=Alumni Association,ou=People,dc=example,dc=com"
303 $LDAPSEARCH -S "" -b "$THEDN" -H $URI1 \
304 -s base '(objectClass=*)' entryCSN > "${MASTEROUT}.$i" 2>&1
307 if test $RC = 0 ; then
311 if test $RC != 32 ; then
312 echo "ldapsearch failed at slave ($RC)!"
313 test $KILLSERVERS != no && kill -HUP $KILLPIDS
317 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
322 while [ $n -le $MMR ]; do
323 PORT=`expr $BASEPORT + $n`
324 URI="ldap://${LOCALHOST}:$PORT/"
326 echo "Using ldapsearch to read all the entries from server $n..."
327 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \
328 'objectclass=*' > $TESTDIR/server$n.out 2>&1
331 if test $RC != 0 ; then
332 echo "ldapsearch failed at server $n ($RC)!"
333 test $KILLSERVERS != no && kill -HUP $KILLPIDS
336 $LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt
341 while [ $n -le $MMR ]; do
342 echo "Comparing retrieved entries from server 1 and server $n..."
343 $CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT
345 if test $? != 0 ; then
346 echo "test failed - server 1 and server $n databases differ"
347 test $KILLSERVERS != no && kill -HUP $KILLPIDS
353 echo "Breaking replication between server 1 and 2..."
355 while [ $n -le $MMR ]; do
357 MYURI=`eval echo '$URI'$n`
358 PROVIDERURI=`eval echo '$URIP'$o`
359 $LDAPMODIFY -D cn=config -H $MYURI -y $CONFIGPWF > $TESTOUT 2>&1 <<EOF
360 dn: olcDatabase={2}$BACKEND,cn=config
363 olcSyncRepl: rid=001 provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple
364 credentials=InvalidPw searchbase="$BASEDN" $SYNCTYPE
365 retry="3 +" timeout=3 logbase="cn=log"
366 logfilter="(&(objectclass=auditWriteObject)(reqresult=0))"
367 syncdata=accesslog tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt
370 replace: olcMirrorMode
375 if test $RC != 0 ; then
376 echo "ldapmodify failed for server $n config ($RC)!"
377 test $KILLSERVERS != no && kill -HUP $KILLPIDS
383 echo "Using ldapmodify to force conflicts between server 1 and 2..."
384 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
385 >> $TESTOUT 2>&1 << EOF
393 if test $RC != 0 ; then
394 echo "ldapmodify failed for server 1 database ($RC)!"
395 test $KILLSERVERS != no && kill -HUP $KILLPIDS
399 $LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \
400 >> $TESTOUT 2>&1 << EOF
404 description: Stupendous
408 if test $RC != 0 ; then
409 echo "ldapmodify failed for server 2 database ($RC)!"
410 test $KILLSERVERS != no && kill -HUP $KILLPIDS
414 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
415 >> $TESTOUT 2>&1 << EOF
419 description: Outstanding
422 description: Mindboggling
426 if test $RC != 0 ; then
427 echo "ldapmodify failed for server 1 database ($RC)!"
428 test $KILLSERVERS != no && kill -HUP $KILLPIDS
432 $LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \
433 >> $TESTOUT 2>&1 << EOF
437 description: OutStanding
444 if test $RC != 0 ; then
445 echo "ldapmodify failed for server 2 database ($RC)!"
446 test $KILLSERVERS != no && kill -HUP $KILLPIDS
450 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
451 >> $TESTOUT 2>&1 << EOF
462 if test $RC != 0 ; then
463 echo "ldapmodify failed for server 1 database ($RC)!"
464 test $KILLSERVERS != no && kill -HUP $KILLPIDS
468 $LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \
469 >> $TESTOUT 2>&1 << EOF
473 employeeType: deadwood
480 if test $RC != 0 ; then
481 echo "ldapmodify failed for server 2 database ($RC)!"
482 test $KILLSERVERS != no && kill -HUP $KILLPIDS
486 $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
487 >> $TESTOUT 2>&1 << EOF
497 if test $RC != 0 ; then
498 echo "ldapmodify failed for server 1 database ($RC)!"
499 test $KILLSERVERS != no && kill -HUP $KILLPIDS
503 echo "Restoring replication between server 1 and 2..."
505 while [ $n -le $MMR ]; do
507 MYURI=`eval echo '$URI'$n`
508 PROVIDERURI=`eval echo '$URIP'$o`
509 $LDAPMODIFY -D cn=config -H $MYURI -y $CONFIGPWF > $TESTOUT 2>&1 <<EOF
510 dn: olcDatabase={2}$BACKEND,cn=config
513 olcSyncRepl: rid=001 provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple
514 credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
515 retry="3 +" timeout=3 logbase="cn=log"
516 logfilter="(&(objectclass=auditWriteObject)(reqresult=0))"
517 syncdata=accesslog tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt
520 replace: olcMirrorMode
525 if test $RC != 0 ; then
526 echo "ldapmodify failed for server $n config ($RC)!"
527 test $KILLSERVERS != no && kill -HUP $KILLPIDS
533 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
537 while [ $n -le $MMR ]; do
538 PORT=`expr $BASEPORT + $n`
539 URI="ldap://${LOCALHOST}:$PORT/"
541 echo "Using ldapsearch to read all the entries from server $n..."
542 $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \
543 'objectclass=*' > $TESTDIR/server$n.out 2>&1
546 if test $RC != 0 ; then
547 echo "ldapsearch failed at server $n ($RC)!"
548 test $KILLSERVERS != no && kill -HUP $KILLPIDS
551 $LDIFFILTER -s a < $TESTDIR/server$n.out > $TESTDIR/server$n.flt
556 while [ $n -le $MMR ]; do
557 echo "Comparing retrieved entries from server 1 and server $n..."
558 $CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT
560 if test $? != 0 ; then
561 echo "test failed - server 1 and server $n databases differ"
562 test $KILLSERVERS != no && kill -HUP $KILLPIDS
568 test $KILLSERVERS != no && kill -HUP $KILLPIDS
570 echo ">>>>> Test succeeded"
572 test $KILLSERVERS != no && wait