3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2006 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 # test now handles known issues
22 #if test x"$PROXYSYNC" = x ; then
23 # echo "Test disabled; set PROXYSYNC=yes to enable"
27 echo "running defines.sh"
28 . $SRCDIR/scripts/defines.sh
30 if test $BACKLDAP = ldapno; then
31 echo "LDAP backend not available, test skipped"
35 if test $SYNCPROV = syncprovno; then
36 echo "Syncrepl provider overlay not available, test skipped"
40 if test $MONITORDB = no; then
41 echo "Monitor backend not available, test skipped"
45 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
51 # - populate over ldap
52 # - perform some modifies and deleted
53 # - attempt to modify the slave (referral or chain)
54 # - retrieve database over ldap and compare against expected results
57 echo "Starting master slapd on TCP/IP port $PORT1..."
58 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
59 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
61 if test $WAIT != 0 ; then
62 echo MASTERPID $MASTERPID
69 echo "Using ldapsearch to check that master slapd is running..."
70 for i in 0 1 2 3 4 5; do
71 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
72 '(objectClass=*)' > /dev/null 2>&1
74 if test $RC = 0 ; then
77 echo "Waiting 5 seconds for slapd to start..."
81 if test $RC != 0 ; then
82 echo "ldapsearch failed ($RC)!"
83 test $KILLSERVERS != no && kill -HUP $KILLPIDS
87 echo "Using ldapadd to create the context prefix entry in the master..."
88 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
89 $LDIFORDEREDCP > /dev/null 2>&1
91 if test $RC != 0 ; then
92 echo "ldapadd failed ($RC)!"
93 test $KILLSERVERS != no && kill -HUP $KILLPIDS
97 echo "Starting slave slapd on TCP/IP port $PORT2..."
98 . $CONFFILTER $BACKEND $MONITORDB < $RSLAVECONF > $CONF2
99 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
101 if test $WAIT != 0 ; then
102 echo SLAVEPID $SLAVEPID
105 KILLPIDS="$MASTERPID $SLAVEPID"
109 echo "Using ldapsearch to check that slave slapd is running..."
110 for i in 0 1 2 3 4 5; do
111 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
112 '(objectClass=*)' > /dev/null 2>&1
114 if test $RC = 0 ; then
117 echo "Waiting 5 seconds for slapd to start..."
121 if test $RC != 0 ; then
122 echo "ldapsearch failed ($RC)!"
123 test $KILLSERVERS != no && kill -HUP $KILLPIDS
127 echo "Starting proxy slapd on TCP/IP port $PORT3..."
128 . $CONFFILTER $BACKEND $MONITORDB < $PLSRSLAVECONF > $CONF3
129 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
131 if test $WAIT != 0 ; then
132 echo PROXYPID $PROXYPID
135 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
139 echo "Using ldapsearch to check that proxy slapd is running..."
140 for i in 0 1 2 3 4 5; do
141 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
142 '(objectClass=*)' > /dev/null 2>&1
144 if test $RC = 0 -o $RC = 53 ; then
147 echo "Waiting 5 seconds for slapd to start..."
153 echo "ldapsearch should have failed ($RC)!"
154 test $KILLSERVERS != no && kill -HUP $KILLPIDS
160 echo "ldapsearch failed ($RC)!"
161 test $KILLSERVERS != no && kill -HUP $KILLPIDS
166 echo "Using ldapadd to populate the master directory..."
167 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
168 $LDIFORDEREDNOCP > /dev/null 2>&1
170 if test $RC != 0 ; then
171 echo "ldapadd failed ($RC)!"
172 test $KILLSERVERS != no && kill -HUP $KILLPIDS
177 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
181 #echo "Using ldapsearch to read all the entries from the master..."
182 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
183 '(objectClass=*)' > "${MASTEROUT}.1" 2>&1
186 if test $RC != 0 ; then
187 echo "ldapsearch failed at master ($RC)!"
188 test $KILLSERVERS != no && kill -HUP $KILLPIDS
192 #echo "Using ldapsearch to read all the entries from the slave..."
193 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
194 '(objectClass=*)' > "${SLAVEOUT}.1" 2>&1
197 if test $RC != 0 ; then
198 echo "ldapsearch failed at slave ($RC)!"
199 test $KILLSERVERS != no && kill -HUP $KILLPIDS
203 #echo "Filtering master results..."
204 . $LDIFFILTER < "${MASTEROUT}.1" > $MASTERFLT
205 #echo "Filtering slave results..."
206 . $LDIFFILTER < "${SLAVEOUT}.1" > $SLAVEFLT
208 echo "$CHECK - Comparing retrieved entries from master and slave..."
209 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
211 if test $? != 0 ; then
212 echo "test failed - master and slave databases differ"
213 test $KILLSERVERS != no && kill -HUP $KILLPIDS
218 echo "Stopping the provider, sleeping $SLEEP seconds and restarting it..."
219 kill -HUP "$MASTERPID"
222 echo "======================= RESTART =======================" >> $LOG1
223 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
225 if test $WAIT != 0 ; then
226 echo MASTERPID $MASTERPID
229 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
233 echo "Using ldapsearch to check that master slapd is running..."
234 for i in 0 1 2 3 4 5; do
235 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
236 '(objectClass=*)' > /dev/null 2>&1
238 if test $RC = 0 ; then
241 echo "Waiting 5 seconds for slapd to start..."
245 if test $RC != 0 ; then
246 echo "ldapsearch failed ($RC)!"
247 test $KILLSERVERS != no && kill -HUP $KILLPIDS
251 echo "Using ldapmodify to modify master directory..."
254 # Do some modifications
257 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
258 $TESTOUT 2>&1 << EOMODS
259 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
270 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
275 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
278 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
279 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
282 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
283 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
285 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
291 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
293 objectclass: OpenLDAPperson
297 title: Chief Investigator, ITD
298 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
299 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
301 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
302 description: Very odd
303 facsimiletelephonenumber: +1 313 555 7557
304 telephonenumber: +1 313 555 8343
305 mail: gjensen@mailgw.example.com
306 homephone: +1 313 555 8844
308 dn: ou=Retired, ou=People, dc=example,dc=com
310 objectclass: organizationalUnit
313 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
315 objectclass: OpenLDAPperson
316 cn: Rosco P. Coltrane
319 description: Fat tycoon
321 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
323 newrdn: cn=Rosco P. Coltrane
325 newsuperior: ou=Retired, ou=People, dc=example,dc=com
327 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
332 if test $RC != 0 ; then
333 echo "ldapmodify failed ($RC)!"
334 test $KILLSERVERS != no && kill -HUP $KILLPIDS
339 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
342 CHECK=`expr $CHECK + 1`
343 #echo "Using ldapsearch to read all the entries from the master..."
344 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
345 '(objectClass=*)' > "${MASTEROUT}.2" 2>&1
348 if test $RC != 0 ; then
349 echo "ldapsearch failed at master ($RC)!"
350 test $KILLSERVERS != no && kill -HUP $KILLPIDS
354 #echo "Using ldapsearch to read all the entries from the slave..."
355 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
356 '(objectClass=*)' > "${SLAVEOUT}.2" 2>&1
359 if test $RC != 0 ; then
360 echo "ldapsearch failed at slave ($RC)!"
361 test $KILLSERVERS != no && kill -HUP $KILLPIDS
365 #echo "Filtering master results..."
366 . $LDIFFILTER < "${MASTEROUT}.2" > $MASTERFLT
367 #echo "Filtering slave results..."
368 . $LDIFFILTER < "${SLAVEOUT}.2" > $SLAVEFLT
370 echo "$CHECK - Comparing retrieved entries from master and slave..."
371 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
373 if test $? != 0 ; then
374 echo "test failed - master and slave databases differ"
375 test $KILLSERVERS != no && kill -HUP $KILLPIDS
380 echo "Stopping proxy to test recovery; sleep for $SLEEP seconds..."
384 echo "Modifying more entries on the master..."
385 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
386 $TESTOUT 2>&1 << EOMODS
387 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
390 description: proxy is down...
392 dn: cn=James T. Kirk, ou=Retired, ou=People, dc=example,dc=com
394 objectclass: OpenLDAPperson
399 dn: cn=Tiberius J. Hooker, ou=Retired, ou=People, dc=example,dc=com
401 objectclass: OpenLDAPperson
404 cn: Tiberius J. Hooker
408 echo "Restarting proxy..."
409 echo "======================= RESTART =======================" >> $LOG3
410 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
412 if test $WAIT != 0 ; then
413 echo PROXYPID $PROXYPID
416 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
419 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
422 CHECK=`expr $CHECK + 1`
423 #echo "Using ldapsearch to read all the entries from the master..."
424 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
425 '(objectClass=*)' > "${MASTEROUT}.3" 2>&1
428 if test $RC != 0 ; then
429 echo "ldapsearch failed at master ($RC)!"
430 test $KILLSERVERS != no && kill -HUP $KILLPIDS
434 #echo "Using ldapsearch to read all the entries from the slave..."
435 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
436 '(objectClass=*)' > "${SLAVEOUT}.3" 2>&1
439 if test $RC != 0 ; then
440 echo "ldapsearch failed at slave ($RC)!"
441 test $KILLSERVERS != no && kill -HUP $KILLPIDS
445 #echo "Filtering master results..."
446 . $LDIFFILTER < "${MASTEROUT}.3" > $MASTERFLT
447 #echo "Filtering slave results..."
448 . $LDIFFILTER < "${SLAVEOUT}.3" > $SLAVEFLT
450 echo "$CHECK - Comparing retrieved entries from master and slave..."
451 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
453 if test $? != 0 ; then
454 echo "test failed - master and slave databases differ"
455 test $KILLSERVERS != no && kill -HUP $KILLPIDS
459 if test ! $BACKLDAP = "ldapno" ; then
460 echo "Try updating the slave slapd..."
461 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
462 $TESTOUT 2>&1 << EOMODS
463 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
466 description: This write must fail because directed to a shadow context,
467 description: unless the chain overlay is configured appropriately ;)
472 if test $RC != 0 ; then
473 echo "ldapmodify failed ($RC)!"
474 test $KILLSERVERS != no && kill -HUP $KILLPIDS
479 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
482 CHECK=`expr $CHECK + 1`
483 #echo "Using ldapsearch to read all the entries from the master..."
484 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
485 '(objectClass=*)' > "${MASTEROUT}.4" 2>&1
488 if test $RC != 0 ; then
489 echo "ldapsearch failed at master ($RC)!"
490 test $KILLSERVERS != no && kill -HUP $KILLPIDS
494 #echo "Using ldapsearch to read all the entries from the slave..."
495 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
496 '(objectClass=*)' > "${SLAVEOUT}.4" 2>&1
499 if test $RC != 0 ; then
500 echo "ldapsearch failed at slave ($RC)!"
501 test $KILLSERVERS != no && kill -HUP $KILLPIDS
505 #echo "Filtering master results..."
506 . $LDIFFILTER < "${MASTEROUT}.4" > $MASTERFLT
507 #echo "Filtering slave results..."
508 . $LDIFFILTER < "${SLAVEOUT}.4" > $SLAVEFLT
510 echo "$CHECK - Comparing retrieved entries from master and slave..."
511 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
513 if test $? != 0 ; then
514 echo "test failed - master and slave databases differ"
515 test $KILLSERVERS != no && kill -HUP $KILLPIDS
521 echo "Stopping consumer to test recovery; wait $SLEEP seconds..."
525 echo "Modifying more entries on the master..."
526 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
527 $TESTOUT 2>&1 << EOMODS
528 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
535 echo "Restarting consumer..."
536 echo "======================= RESTART =======================" >> $LOG2
537 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
539 if test $WAIT != 0 ; then
540 echo SLAVEPID $SLAVEPID
543 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
546 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
549 CHECK=`expr $CHECK + 1`
550 #echo "Using ldapsearch to read all the entries from the master..."
551 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
552 '(objectClass=*)' > "${MASTEROUT}.5" 2>&1
555 if test $RC != 0 ; then
556 echo "ldapsearch failed at master ($RC)!"
557 test $KILLSERVERS != no && kill -HUP $KILLPIDS
561 #echo "Using ldapsearch to read all the entries from the slave..."
562 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
563 '(objectClass=*)' > "${SLAVEOUT}.5" 2>&1
566 if test $RC != 0 ; then
567 echo "ldapsearch failed at slave ($RC)!"
568 test $KILLSERVERS != no && kill -HUP $KILLPIDS
572 #echo "Filtering master results..."
573 . $LDIFFILTER < "${MASTEROUT}.5" > $MASTERFLT
574 #echo "Filtering slave results..."
575 . $LDIFFILTER < "${SLAVEOUT}.5" > $SLAVEFLT
577 echo "$CHECK - Comparing retrieved entries from master and slave..."
578 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
580 if test $? != 0 ; then
581 echo " test failed - master and slave databases differ (ignored by now)"
582 #echo "test failed - master and slave databases differ"
583 #test $KILLSERVERS != no && kill -HUP $KILLPIDS
587 echo " Stopping proxy to see if it auto-recovers; sleep for $SLEEP seconds..."
591 echo " Restarting proxy..."
592 echo "======================= RESTART =======================" >> $LOG3
593 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
595 if test $WAIT != 0 ; then
596 echo PROXYPID $PROXYPID
599 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
602 echo " Waiting $SLEEP seconds for syncrepl to receive changes..."
605 #echo "Using ldapsearch to read all the entries from the slave..."
606 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
607 '(objectClass=*)' > "${SLAVEOUT}.5.1" 2>&1
610 if test $RC != 0 ; then
611 echo " ldapsearch failed at slave ($RC)!"
612 test $KILLSERVERS != no && kill -HUP $KILLPIDS
616 #echo "Filtering slave results..."
617 . $LDIFFILTER < "${SLAVEOUT}.5.1" > $SLAVEFLT
619 echo " ${CHECK}.1 - Comparing retrieved entries from master and slave..."
620 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
622 if test $? != 0 ; then
623 echo " test failed - master and slave databases differ"
624 test $KILLSERVERS != no && kill -HUP $KILLPIDS
630 # Modifications known to fail
632 echo "(DEVEL) Performing modifications that are known to fail..."
633 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
634 $TESTOUT 2>&1 << EOMODS
635 # First, back out previous change
636 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
641 # From now on, perform modifications that are known to fail
642 dn: cn=All Staff,ou=Groups,dc=example,dc=com
649 if test $RC != 0 ; then
650 echo "ldapmodify failed ($RC)!"
651 test $KILLSERVERS != no && kill -HUP $KILLPIDS
656 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
659 CHECK=`expr $CHECK + 1`
660 #echo "Using ldapsearch to read all the entries from the master..."
661 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
662 '(objectClass=*)' > "${MASTEROUT}.6" 2>&1
665 if test $RC != 0 ; then
666 echo "ldapsearch failed at master ($RC)!"
667 test $KILLSERVERS != no && kill -HUP $KILLPIDS
671 #echo "Using ldapsearch to read all the entries from the slave..."
672 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
673 '(objectClass=*)' > "${SLAVEOUT}.6" 2>&1
676 if test $RC != 0 ; then
677 echo "ldapsearch failed at slave ($RC)!"
678 test $KILLSERVERS != no && kill -HUP $KILLPIDS
682 #echo "Filtering master results..."
683 . $LDIFFILTER < "${MASTEROUT}.6" > $MASTERFLT
684 #echo "Filtering slave results..."
685 . $LDIFFILTER < "${SLAVEOUT}.6" > $SLAVEFLT
687 echo "$CHECK - Comparing retrieved entries from master and slave..."
688 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
690 if test $? != 0 ; then
691 echo "test failed - master and slave databases differ (ignored by now)"
692 #echo "test failed - master and slave databases differ"
693 #test $KILLSERVERS != no && kill -HUP $KILLPIDS
697 test $KILLSERVERS != no && kill -HUP $KILLPIDS
699 echo ">>>>> Test succeeded"