3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2007 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
167 echo "$CHECK > Using ldapadd to populate the master directory..."
168 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
169 $LDIFORDEREDNOCP > /dev/null 2>&1
171 if test $RC != 0 ; then
172 echo "ldapadd failed ($RC)!"
173 test $KILLSERVERS != no && kill -HUP $KILLPIDS
178 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
217 CHECK=`expr $CHECK + 1`
219 echo "$CHECK > Stopping the provider, sleeping $SLEEP seconds and restarting it..."
220 kill -HUP "$MASTERPID"
224 echo "======================= RESTART =======================" >> $LOG1
225 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
227 if test $WAIT != 0 ; then
228 echo MASTERPID $MASTERPID
231 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
235 echo "Using ldapsearch to check that master slapd is running..."
236 for i in 0 1 2 3 4 5; do
237 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
238 '(objectClass=*)' > /dev/null 2>&1
240 if test $RC = 0 ; then
243 echo "Waiting 5 seconds for slapd to start..."
247 if test $RC != 0 ; then
248 echo "ldapsearch failed ($RC)!"
249 test $KILLSERVERS != no && kill -HUP $KILLPIDS
253 echo "Using ldapmodify to modify master directory..."
256 # Do some modifications
259 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
260 $TESTOUT 2>&1 << EOMODS
261 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
272 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
277 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
280 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
281 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
284 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
285 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
287 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
293 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
295 objectclass: OpenLDAPperson
299 title: Chief Investigator, ITD
300 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
301 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
303 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
304 description: Very odd
305 facsimiletelephonenumber: +1 313 555 7557
306 telephonenumber: +1 313 555 8343
307 mail: gjensen@mailgw.example.com
308 homephone: +1 313 555 8844
310 dn: ou=Retired, ou=People, dc=example,dc=com
312 objectclass: organizationalUnit
315 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
317 objectclass: OpenLDAPperson
318 cn: Rosco P. Coltrane
321 description: Fat tycoon
323 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
325 newrdn: cn=Rosco P. Coltrane
327 newsuperior: ou=Retired, ou=People, dc=example,dc=com
329 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
334 if test $RC != 0 ; then
335 echo "ldapmodify failed ($RC)!"
336 test $KILLSERVERS != no && kill -HUP $KILLPIDS
341 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
344 #echo "Using ldapsearch to read all the entries from the master..."
345 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
346 '(objectClass=*)' > "${MASTEROUT}.2" 2>&1
349 if test $RC != 0 ; then
350 echo "ldapsearch failed at master ($RC)!"
351 test $KILLSERVERS != no && kill -HUP $KILLPIDS
355 #echo "Using ldapsearch to read all the entries from the slave..."
356 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
357 '(objectClass=*)' > "${SLAVEOUT}.2" 2>&1
360 if test $RC != 0 ; then
361 echo "ldapsearch failed at slave ($RC)!"
362 test $KILLSERVERS != no && kill -HUP $KILLPIDS
366 #echo "Filtering master results..."
367 . $LDIFFILTER < "${MASTEROUT}.2" > $MASTERFLT
368 #echo "Filtering slave results..."
369 . $LDIFFILTER < "${SLAVEOUT}.2" > $SLAVEFLT
371 echo "$CHECK < Comparing retrieved entries from master and slave..."
372 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
374 if test $? != 0 ; then
375 echo "test failed - master and slave databases differ"
376 test $KILLSERVERS != no && kill -HUP $KILLPIDS
380 CHECK=`expr $CHECK + 1`
381 echo "$CHECK > Stopping proxy to test recovery..."
385 echo "Modifying more entries on the master..."
386 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
387 $TESTOUT 2>&1 << EOMODS
388 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
391 description: proxy is down...
393 dn: cn=James T. Kirk, ou=Retired, ou=People, dc=example,dc=com
395 objectclass: OpenLDAPperson
400 dn: cn=Tiberius J. Hooker, ou=Retired, ou=People, dc=example,dc=com
402 objectclass: OpenLDAPperson
405 cn: Tiberius J. Hooker
409 echo "Restarting proxy..."
410 echo "======================= RESTART =======================" >> $LOG3
411 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
413 if test $WAIT != 0 ; then
414 echo PROXYPID $PROXYPID
417 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
420 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
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 CHECK=`expr $CHECK + 1`
460 echo "$CHECK > 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 #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
518 CHECK=`expr $CHECK + 1`
519 echo "$CHECK > Stopping consumer to test recovery..."
523 echo "Modifying more entries on the master..."
524 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
525 $TESTOUT 2>&1 << EOMODS
526 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
534 echo "Waiting $SLEEP seconds for syncrepl to retry..."
537 echo "Restarting consumer..."
538 echo "======================= RESTART =======================" >> $LOG2
539 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
541 if test $WAIT != 0 ; then
542 echo SLAVEPID $SLAVEPID
545 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
548 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
551 #echo "Using ldapsearch to read all the entries from the master..."
552 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
553 '(objectClass=*)' > "${MASTEROUT}.5" 2>&1
556 if test $RC != 0 ; then
557 echo "ldapsearch failed at master ($RC)!"
558 test $KILLSERVERS != no && kill -HUP $KILLPIDS
562 #echo "Using ldapsearch to read all the entries from the slave..."
563 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
564 '(objectClass=*)' > "${SLAVEOUT}.5" 2>&1
567 if test $RC != 0 ; then
568 echo "ldapsearch failed at slave ($RC)!"
569 test $KILLSERVERS != no && kill -HUP $KILLPIDS
573 #echo "Filtering master results..."
574 . $LDIFFILTER < "${MASTEROUT}.5" > $MASTERFLT
575 #echo "Filtering slave results..."
576 . $LDIFFILTER < "${SLAVEOUT}.5" > $SLAVEFLT
578 echo "$CHECK < Comparing retrieved entries from master and slave..."
579 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
581 if test $? != 0 ; then
582 # FIXME: keep the original workaround in place, in case we needed again
584 echo "test failed - master and slave databases differ"
585 test $KILLSERVERS != no && kill -HUP $KILLPIDS
589 echo " test failed - master and slave databases differ (ignored by now)"
590 echo " Stopping proxy to see if it auto-recovers..."
594 echo " ${CHECK}.1 > Restarting proxy..."
595 echo "======================= RESTART =======================" >> $LOG3
596 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
598 if test $WAIT != 0 ; then
599 echo PROXYPID $PROXYPID
602 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
605 echo " Waiting $SLEEP seconds for syncrepl to receive changes..."
608 #echo "Using ldapsearch to read all the entries from the slave..."
609 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
610 '(objectClass=*)' > "${SLAVEOUT}.5.1" 2>&1
613 if test $RC != 0 ; then
614 echo " ldapsearch failed at slave ($RC)!"
615 test $KILLSERVERS != no && kill -HUP $KILLPIDS
619 #echo "Filtering slave results..."
620 . $LDIFFILTER < "${SLAVEOUT}.5.1" > $SLAVEFLT
622 echo " ${CHECK}.1 < Comparing retrieved entries from master and slave..."
623 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
625 if test $? != 0 ; then
626 echo " test failed - master and slave databases differ"
627 test $KILLSERVERS != no && kill -HUP $KILLPIDS
633 # Modifications formerly known to fail
635 CHECK=`expr $CHECK + 1`
636 echo "$CHECK > Performing modifications that were formerly known to fail..."
637 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
638 $TESTOUT 2>&1 << EOMODS
639 # First, back out previous change
640 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
645 # From now on, perform modifications that were formerly known to fail
646 dn: cn=All Staff,ou=Groups,dc=example,dc=com
653 if test $RC != 0 ; then
654 echo "ldapmodify failed ($RC)!"
655 test $KILLSERVERS != no && kill -HUP $KILLPIDS
660 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
663 #echo "Using ldapsearch to read all the entries from the master..."
664 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
665 '(objectClass=*)' > "${MASTEROUT}.6" 2>&1
668 if test $RC != 0 ; then
669 echo "ldapsearch failed at master ($RC)!"
670 test $KILLSERVERS != no && kill -HUP $KILLPIDS
674 #echo "Using ldapsearch to read all the entries from the slave..."
675 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
676 '(objectClass=*)' > "${SLAVEOUT}.6" 2>&1
679 if test $RC != 0 ; then
680 echo "ldapsearch failed at slave ($RC)!"
681 test $KILLSERVERS != no && kill -HUP $KILLPIDS
685 #echo "Filtering master results..."
686 . $LDIFFILTER < "${MASTEROUT}.6" > $MASTERFLT
687 #echo "Filtering slave results..."
688 . $LDIFFILTER < "${SLAVEOUT}.6" > $SLAVEFLT
690 echo "$CHECK < Comparing retrieved entries from master and slave..."
691 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
693 if test $? != 0 ; then
694 echo "test failed - master and slave databases differ (ignored by now)"
695 #echo "test failed - master and slave databases differ"
696 #test $KILLSERVERS != no && kill -HUP $KILLPIDS
700 test $KILLSERVERS != no && kill -HUP $KILLPIDS
702 echo ">>>>> Test succeeded"
704 test $KILLSERVERS != no && wait