3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2005 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 if test "$BACKEND" != "bdb" && test "$BACKEND" != "hdb" ; then
17 echo "Test does not support $BACKEND"
21 if test x"$PROXYSYNC" = x ; then
22 echo "Test disabled; set PROXYSYNC=yes to enable"
26 echo "running defines.sh"
27 . $SRCDIR/scripts/defines.sh
29 if test $BACKLDAP = ldapno; then
30 echo "LDAP backend not available, test skipped"
34 if test $SYNCPROV = syncprovno; then
35 echo "Syncrepl provider overlay not available, test skipped"
39 if test $MONITORDB = no; then
40 echo "Monitor backend not available, test skipped"
44 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
50 # - populate over ldap
51 # - perform some modifies and deleted
52 # - attempt to modify the slave (referral or chain)
53 # - retrieve database over ldap and compare against expected results
56 echo "Starting master slapd on TCP/IP port $PORT1..."
57 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
58 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
60 if test $WAIT != 0 ; then
61 echo MASTERPID $MASTERPID
68 echo "Using ldapsearch to check that master slapd is running..."
69 for i in 0 1 2 3 4 5; do
70 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
71 '(objectClass=*)' > /dev/null 2>&1
73 if test $RC = 0 ; then
76 echo "Waiting 5 seconds for slapd to start..."
80 if test $RC != 0 ; then
81 echo "ldapsearch failed ($RC)!"
82 test $KILLSERVERS != no && kill -HUP $KILLPIDS
86 echo "Using ldapadd to create the context prefix entry in the master..."
87 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
88 $LDIFORDEREDCP > /dev/null 2>&1
90 if test $RC != 0 ; then
91 echo "ldapadd failed ($RC)!"
92 test $KILLSERVERS != no && kill -HUP $KILLPIDS
96 echo "Starting slave slapd on TCP/IP port $PORT2..."
97 . $CONFFILTER $BACKEND $MONITORDB < $RSLAVECONF > $CONF2
98 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
100 if test $WAIT != 0 ; then
101 echo SLAVEPID $SLAVEPID
104 KILLPIDS="$MASTERPID $SLAVEPID"
108 echo "Using ldapsearch to check that slave slapd is running..."
109 for i in 0 1 2 3 4 5; do
110 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
111 '(objectClass=*)' > /dev/null 2>&1
113 if test $RC = 0 ; then
116 echo "Waiting 5 seconds for slapd to start..."
120 if test $RC != 0 ; then
121 echo "ldapsearch failed ($RC)!"
122 test $KILLSERVERS != no && kill -HUP $KILLPIDS
126 echo "Starting proxy slapd on TCP/IP port $PORT3..."
127 . $CONFFILTER $BACKEND $MONITORDB < $PLSRSLAVECONF > $CONF3
128 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
130 if test $WAIT != 0 ; then
131 echo PROXYPID $PROXYPID
134 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
138 echo "Using ldapsearch to check that proxy slapd is running..."
139 for i in 0 1 2 3 4 5; do
140 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
141 '(objectClass=*)' > /dev/null 2>&1
143 if test $RC = 0 -o $RC = 53 ; then
146 echo "Waiting 5 seconds for slapd to start..."
152 echo "ldapsearch should have failed ($RC)!"
153 test $KILLSERVERS != no && kill -HUP $KILLPIDS
159 echo "ldapsearch failed ($RC)!"
160 test $KILLSERVERS != no && kill -HUP $KILLPIDS
165 echo "Using ldapadd to populate the master directory..."
166 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
167 $LDIFORDEREDNOCP > /dev/null 2>&1
169 if test $RC != 0 ; then
170 echo "ldapadd failed ($RC)!"
171 test $KILLSERVERS != no && kill -HUP $KILLPIDS
176 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
180 #echo "Using ldapsearch to read all the entries from the master..."
181 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
182 '(objectClass=*)' > "${MASTEROUT}.1" 2>&1
185 if test $RC != 0 ; then
186 echo "ldapsearch failed at master ($RC)!"
187 test $KILLSERVERS != no && kill -HUP $KILLPIDS
191 #echo "Using ldapsearch to read all the entries from the slave..."
192 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
193 '(objectClass=*)' > "${SLAVEOUT}.1" 2>&1
196 if test $RC != 0 ; then
197 echo "ldapsearch failed at slave ($RC)!"
198 test $KILLSERVERS != no && kill -HUP $KILLPIDS
202 #echo "Filtering master results..."
203 . $LDIFFILTER < "${MASTEROUT}.1" > $MASTERFLT
204 #echo "Filtering slave results..."
205 . $LDIFFILTER < "${SLAVEOUT}.1" > $SLAVEFLT
207 echo "$CHECK - Comparing retrieved entries from master and slave..."
208 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
210 if test $? != 0 ; then
211 echo "test failed - master and slave databases differ"
212 test $KILLSERVERS != no && kill -HUP $KILLPIDS
217 echo "Stopping the provider, sleeping $SLEEP seconds and restarting it..."
218 kill -HUP "$MASTERPID"
221 echo "======================= RESTART =======================" >> $LOG1
222 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
224 if test $WAIT != 0 ; then
225 echo MASTERPID $MASTERPID
228 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
232 echo "Using ldapsearch to check that master slapd is running..."
233 for i in 0 1 2 3 4 5; do
234 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
235 '(objectClass=*)' > /dev/null 2>&1
237 if test $RC = 0 ; then
240 echo "Waiting 5 seconds for slapd to start..."
244 if test $RC != 0 ; then
245 echo "ldapsearch failed ($RC)!"
246 test $KILLSERVERS != no && kill -HUP $KILLPIDS
250 echo "Using ldapmodify to modify master directory..."
253 # Do some modifications
256 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
257 $TESTOUT 2>&1 << EOMODS
258 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
269 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
274 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
277 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
278 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
281 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
282 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
284 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
290 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
292 objectclass: OpenLDAPperson
296 title: Chief Investigator, ITD
297 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
298 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
300 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
301 description: Very odd
302 facsimiletelephonenumber: +1 313 555 7557
303 telephonenumber: +1 313 555 8343
304 mail: gjensen@mailgw.example.com
305 homephone: +1 313 555 8844
307 dn: ou=Retired, ou=People, dc=example,dc=com
309 objectclass: organizationalUnit
312 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
314 objectclass: OpenLDAPperson
315 cn: Rosco P. Coltrane
318 description: Fat tycoon
320 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
322 newrdn: cn=Rosco P. Coltrane
324 newsuperior: ou=Retired, ou=People, dc=example,dc=com
326 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
331 if test $RC != 0 ; then
332 echo "ldapmodify failed ($RC)!"
333 test $KILLSERVERS != no && kill -HUP $KILLPIDS
338 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
341 CHECK=`expr $CHECK + 1`
342 #echo "Using ldapsearch to read all the entries from the master..."
343 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
344 '(objectClass=*)' > "${MASTEROUT}.2" 2>&1
347 if test $RC != 0 ; then
348 echo "ldapsearch failed at master ($RC)!"
349 test $KILLSERVERS != no && kill -HUP $KILLPIDS
353 #echo "Using ldapsearch to read all the entries from the slave..."
354 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
355 '(objectClass=*)' > "${SLAVEOUT}.2" 2>&1
358 if test $RC != 0 ; then
359 echo "ldapsearch failed at slave ($RC)!"
360 test $KILLSERVERS != no && kill -HUP $KILLPIDS
364 #echo "Filtering master results..."
365 . $LDIFFILTER < "${MASTEROUT}.2" > $MASTERFLT
366 #echo "Filtering slave results..."
367 . $LDIFFILTER < "${SLAVEOUT}.2" > $SLAVEFLT
369 echo "$CHECK - Comparing retrieved entries from master and slave..."
370 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
372 if test $? != 0 ; then
373 echo "test failed - master and slave databases differ"
374 test $KILLSERVERS != no && kill -HUP $KILLPIDS
379 echo "Stopping proxy to test recovery; sleep for $SLEEP seconds..."
383 echo "Modifying more entries on the master..."
384 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
385 $TESTOUT 2>&1 << EOMODS
386 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
389 description: proxy is down...
391 dn: cn=James T. Kirk, ou=Retired, ou=People, dc=example,dc=com
393 objectclass: OpenLDAPperson
398 dn: cn=Tiberius J. Hooker, ou=Retired, ou=People, dc=example,dc=com
400 objectclass: OpenLDAPperson
403 cn: Tiberius J. Hooker
407 echo "Restarting proxy..."
408 echo "======================= RESTART =======================" >> $LOG3
409 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
411 if test $WAIT != 0 ; then
412 echo PROXYPID $PROXYPID
415 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
418 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
421 CHECK=`expr $CHECK + 1`
422 #echo "Using ldapsearch to read all the entries from the master..."
423 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
424 '(objectClass=*)' > "${MASTEROUT}.3" 2>&1
427 if test $RC != 0 ; then
428 echo "ldapsearch failed at master ($RC)!"
429 test $KILLSERVERS != no && kill -HUP $KILLPIDS
433 #echo "Using ldapsearch to read all the entries from the slave..."
434 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
435 '(objectClass=*)' > "${SLAVEOUT}.3" 2>&1
438 if test $RC != 0 ; then
439 echo "ldapsearch failed at slave ($RC)!"
440 test $KILLSERVERS != no && kill -HUP $KILLPIDS
444 #echo "Filtering master results..."
445 . $LDIFFILTER < "${MASTEROUT}.3" > $MASTERFLT
446 #echo "Filtering slave results..."
447 . $LDIFFILTER < "${SLAVEOUT}.3" > $SLAVEFLT
449 echo "$CHECK - Comparing retrieved entries from master and slave..."
450 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
452 if test $? != 0 ; then
453 echo "test failed - master and slave databases differ"
454 test $KILLSERVERS != no && kill -HUP $KILLPIDS
458 if test ! $BACKLDAP = "ldapno" ; then
459 echo "Try updating the slave slapd..."
460 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
461 $TESTOUT 2>&1 << EOMODS
462 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
465 description: This write must fail because directed to a shadow context,
466 description: unless the chain overlay is configured appropriately ;)
471 if test $RC != 0 ; then
472 echo "ldapmodify failed ($RC)!"
473 test $KILLSERVERS != no && kill -HUP $KILLPIDS
478 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
481 CHECK=`expr $CHECK + 1`
482 #echo "Using ldapsearch to read all the entries from the master..."
483 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
484 '(objectClass=*)' > "${MASTEROUT}.4" 2>&1
487 if test $RC != 0 ; then
488 echo "ldapsearch failed at master ($RC)!"
489 test $KILLSERVERS != no && kill -HUP $KILLPIDS
493 #echo "Using ldapsearch to read all the entries from the slave..."
494 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
495 '(objectClass=*)' > "${SLAVEOUT}.4" 2>&1
498 if test $RC != 0 ; then
499 echo "ldapsearch failed at slave ($RC)!"
500 test $KILLSERVERS != no && kill -HUP $KILLPIDS
504 #echo "Filtering master results..."
505 . $LDIFFILTER < "${MASTEROUT}.4" > $MASTERFLT
506 #echo "Filtering slave results..."
507 . $LDIFFILTER < "${SLAVEOUT}.4" > $SLAVEFLT
509 echo "$CHECK - Comparing retrieved entries from master and slave..."
510 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
512 if test $? != 0 ; then
513 echo "test failed - master and slave databases differ"
514 test $KILLSERVERS != no && kill -HUP $KILLPIDS
520 echo "Stopping consumer to test recovery; wait $SLEEP seconds..."
524 echo "Modifying more entries on the master..."
525 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
526 $TESTOUT 2>&1 << EOMODS
527 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
534 echo "Restarting consumer..."
535 echo "======================= RESTART =======================" >> $LOG2
536 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
538 if test $WAIT != 0 ; then
539 echo SLAVEPID $SLAVEPID
542 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
545 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
548 CHECK=`expr $CHECK + 1`
549 #echo "Using ldapsearch to read all the entries from the master..."
550 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
551 '(objectClass=*)' > "${MASTEROUT}.5" 2>&1
554 if test $RC != 0 ; then
555 echo "ldapsearch failed at master ($RC)!"
556 test $KILLSERVERS != no && kill -HUP $KILLPIDS
560 #echo "Using ldapsearch to read all the entries from the slave..."
561 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
562 '(objectClass=*)' > "${SLAVEOUT}.5" 2>&1
565 if test $RC != 0 ; then
566 echo "ldapsearch failed at slave ($RC)!"
567 test $KILLSERVERS != no && kill -HUP $KILLPIDS
571 #echo "Filtering master results..."
572 . $LDIFFILTER < "${MASTEROUT}.5" > $MASTERFLT
573 #echo "Filtering slave results..."
574 . $LDIFFILTER < "${SLAVEOUT}.5" > $SLAVEFLT
576 echo "$CHECK - Comparing retrieved entries from master and slave..."
577 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
579 if test $? != 0 ; then
580 echo " test failed - master and slave databases differ (ignored by now)"
581 #echo "test failed - master and slave databases differ"
582 #test $KILLSERVERS != no && kill -HUP $KILLPIDS
586 echo " Stopping proxy to see if it auto-recovers; sleep for $SLEEP seconds..."
590 echo " Restarting proxy..."
591 echo "======================= RESTART =======================" >> $LOG3
592 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
594 if test $WAIT != 0 ; then
595 echo PROXYPID $PROXYPID
598 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
601 echo " Waiting $SLEEP seconds for syncrepl to receive changes..."
604 #echo "Using ldapsearch to read all the entries from the slave..."
605 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
606 '(objectClass=*)' > "${SLAVEOUT}.5.1" 2>&1
609 if test $RC != 0 ; then
610 echo " ldapsearch failed at slave ($RC)!"
611 test $KILLSERVERS != no && kill -HUP $KILLPIDS
615 #echo "Filtering slave results..."
616 . $LDIFFILTER < "${SLAVEOUT}.5.1" > $SLAVEFLT
618 echo " ${CHECK}.1 - Comparing retrieved entries from master and slave..."
619 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
621 if test $? != 0 ; then
622 echo " test failed - master and slave databases differ"
623 test $KILLSERVERS != no && kill -HUP $KILLPIDS
629 # Modifications known to fail
631 echo "(DEVEL) Performing modifications that are known to fail..."
632 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
633 $TESTOUT 2>&1 << EOMODS
634 # First, back out previous change
635 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
640 # From now on, perform modifications that are known to fail
641 dn: cn=All Staff,ou=Groups,dc=example,dc=com
648 if test $RC != 0 ; then
649 echo "ldapmodify failed ($RC)!"
650 test $KILLSERVERS != no && kill -HUP $KILLPIDS
655 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
658 CHECK=`expr $CHECK + 1`
659 #echo "Using ldapsearch to read all the entries from the master..."
660 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
661 '(objectClass=*)' > "${MASTEROUT}.6" 2>&1
664 if test $RC != 0 ; then
665 echo "ldapsearch failed at master ($RC)!"
666 test $KILLSERVERS != no && kill -HUP $KILLPIDS
670 #echo "Using ldapsearch to read all the entries from the slave..."
671 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
672 '(objectClass=*)' > "${SLAVEOUT}.6" 2>&1
675 if test $RC != 0 ; then
676 echo "ldapsearch failed at slave ($RC)!"
677 test $KILLSERVERS != no && kill -HUP $KILLPIDS
681 #echo "Filtering master results..."
682 . $LDIFFILTER < "${MASTEROUT}.6" > $MASTERFLT
683 #echo "Filtering slave results..."
684 . $LDIFFILTER < "${SLAVEOUT}.6" > $SLAVEFLT
686 echo "$CHECK - Comparing retrieved entries from master and slave..."
687 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
689 if test $? != 0 ; then
690 echo "test failed - master and slave databases differ (ignored by now)"
691 #echo "test failed - master and slave databases differ"
692 #test $KILLSERVERS != no && kill -HUP $KILLPIDS
696 test $KILLSERVERS != no && kill -HUP $KILLPIDS
698 echo ">>>>> Test succeeded"