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"
223 echo "======================= RESTART =======================" >> $LOG1
224 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
226 if test $WAIT != 0 ; then
227 echo MASTERPID $MASTERPID
230 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
234 echo "Using ldapsearch to check that master slapd is running..."
235 for i in 0 1 2 3 4 5; do
236 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
237 '(objectClass=*)' > /dev/null 2>&1
239 if test $RC = 0 ; then
242 echo "Waiting 5 seconds for slapd to start..."
246 if test $RC != 0 ; then
247 echo "ldapsearch failed ($RC)!"
248 test $KILLSERVERS != no && kill -HUP $KILLPIDS
252 echo "Using ldapmodify to modify master directory..."
255 # Do some modifications
258 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
259 $TESTOUT 2>&1 << EOMODS
260 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
271 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
276 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
279 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
280 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
283 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
284 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
286 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
292 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
294 objectclass: OpenLDAPperson
298 title: Chief Investigator, ITD
299 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
300 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
302 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
303 description: Very odd
304 facsimiletelephonenumber: +1 313 555 7557
305 telephonenumber: +1 313 555 8343
306 mail: gjensen@mailgw.example.com
307 homephone: +1 313 555 8844
309 dn: ou=Retired, ou=People, dc=example,dc=com
311 objectclass: organizationalUnit
314 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
316 objectclass: OpenLDAPperson
317 cn: Rosco P. Coltrane
320 description: Fat tycoon
322 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
324 newrdn: cn=Rosco P. Coltrane
326 newsuperior: ou=Retired, ou=People, dc=example,dc=com
328 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
333 if test $RC != 0 ; then
334 echo "ldapmodify failed ($RC)!"
335 test $KILLSERVERS != no && kill -HUP $KILLPIDS
340 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
343 CHECK=`expr $CHECK + 1`
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 echo "Stopping proxy to test recovery..."
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
520 echo "Stopping consumer to test recovery..."
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
535 echo "Waiting $SLEEP seconds for syncrepl to retry..."
538 echo "Restarting consumer..."
539 echo "======================= RESTART =======================" >> $LOG2
540 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
542 if test $WAIT != 0 ; then
543 echo SLAVEPID $SLAVEPID
546 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
549 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
552 CHECK=`expr $CHECK + 1`
553 #echo "Using ldapsearch to read all the entries from the master..."
554 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
555 '(objectClass=*)' > "${MASTEROUT}.5" 2>&1
558 if test $RC != 0 ; then
559 echo "ldapsearch failed at master ($RC)!"
560 test $KILLSERVERS != no && kill -HUP $KILLPIDS
564 #echo "Using ldapsearch to read all the entries from the slave..."
565 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
566 '(objectClass=*)' > "${SLAVEOUT}.5" 2>&1
569 if test $RC != 0 ; then
570 echo "ldapsearch failed at slave ($RC)!"
571 test $KILLSERVERS != no && kill -HUP $KILLPIDS
575 #echo "Filtering master results..."
576 . $LDIFFILTER < "${MASTEROUT}.5" > $MASTERFLT
577 #echo "Filtering slave results..."
578 . $LDIFFILTER < "${SLAVEOUT}.5" > $SLAVEFLT
580 echo "$CHECK - Comparing retrieved entries from master and slave..."
581 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
583 if test $? != 0 ; then
584 #echo " test failed - master and slave databases differ (ignored by now)"
585 echo "test failed - master and slave databases differ"
586 test $KILLSERVERS != no && kill -HUP $KILLPIDS
589 # keep alive - in case we need it again
590 echo " Stopping proxy to see if it auto-recovers..."
594 echo " 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 known to fail
635 echo "(DEVEL) Performing modifications that are known to fail..."
636 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
637 $TESTOUT 2>&1 << EOMODS
638 # First, back out previous change
639 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
644 # From now on, perform modifications that are known to fail
645 dn: cn=All Staff,ou=Groups,dc=example,dc=com
652 if test $RC != 0 ; then
653 echo "ldapmodify failed ($RC)!"
654 test $KILLSERVERS != no && kill -HUP $KILLPIDS
659 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
662 CHECK=`expr $CHECK + 1`
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