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 # test now handles known issues
17 if test x"$PROXYSYNC" = x ; then
18 echo "Test disabled; set PROXYSYNC=yes to enable"
22 echo "running defines.sh"
23 . $SRCDIR/scripts/defines.sh
25 if test $BACKLDAP = ldapno; then
26 echo "LDAP backend not available, test skipped"
30 if test $SYNCPROV = syncprovno; then
31 echo "Syncrepl provider overlay not available, test skipped"
35 if test $MONITORDB = no; then
36 echo "Monitor backend not available, test skipped"
40 mkdir -p $TESTDIR $DBDIR1 $DBDIR2 $DBDIR3
46 # - populate over ldap
47 # - perform some modifies and deleted
48 # - attempt to modify the slave (referral or chain)
49 # - retrieve database over ldap and compare against expected results
52 echo "Starting master slapd on TCP/IP port $PORT1..."
53 . $CONFFILTER $BACKEND $MONITORDB < $PLSRMASTERCONF > $CONF1
54 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
56 if test $WAIT != 0 ; then
57 echo MASTERPID $MASTERPID
64 echo "Using ldapsearch to check that master slapd is running..."
65 for i in 0 1 2 3 4 5; do
66 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
67 '(objectClass=*)' > /dev/null 2>&1
69 if test $RC = 0 ; then
72 echo "Waiting 5 seconds for slapd to start..."
76 if test $RC != 0 ; then
77 echo "ldapsearch failed ($RC)!"
78 test $KILLSERVERS != no && kill -HUP $KILLPIDS
82 echo "Using ldapadd to create the context prefix entry in the master..."
83 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
84 $LDIFORDEREDCP > /dev/null 2>&1
86 if test $RC != 0 ; then
87 echo "ldapadd failed ($RC)!"
88 test $KILLSERVERS != no && kill -HUP $KILLPIDS
92 echo "Starting P1 slave slapd on TCP/IP port $PORT2..."
93 . $CONFFILTER $BACKEND $MONITORDB < $RSLAVECONF > $CONF2
94 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
96 if test $WAIT != 0 ; then
97 echo P1SLAVEPID $P1SLAVEPID
100 KILLPIDS="$MASTERPID $P1SLAVEPID"
104 echo "Using ldapsearch to check that P1 slave slapd is running..."
105 for i in 0 1 2 3 4 5; do
106 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
107 '(objectClass=*)' > /dev/null 2>&1
109 if test $RC = 0 ; then
112 echo "Waiting 5 seconds for slapd to start..."
116 if test $RC != 0 ; then
117 echo "ldapsearch failed ($RC)!"
118 test $KILLSERVERS != no && kill -HUP $KILLPIDS
122 echo "Starting R1 slave slapd on TCP/IP port $PORT3..."
123 . $CONFFILTER $BACKEND $MONITORDB < $RSLAVECONF | sed -e 's;\.2\.;.3.;' > $CONF3
124 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
126 if test $WAIT != 0 ; then
127 echo R1SLAVEPID $R1SLAVEPID
130 KILLPIDS="$MASTERPID $P1SLAVEPID $R1SLAVEPID"
134 echo "Using ldapsearch to check that R1 slave slapd is running..."
135 for i in 0 1 2 3 4 5; do
136 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
137 '(objectClass=*)' > /dev/null 2>&1
139 if test $RC = 0; then
142 echo "Waiting 5 seconds for slapd to start..."
146 if test $RC != 0 ; then
147 echo "ldapsearch failed ($RC)!"
148 test $KILLSERVERS != no && kill -HUP $KILLPIDS
153 echo "$CHECK > Using ldapadd to populate the master directory..."
154 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
155 $LDIFORDEREDNOCP > /dev/null 2>&1
157 if test $RC != 0 ; then
158 echo "ldapadd failed ($RC)!"
159 test $KILLSERVERS != no && kill -HUP $KILLPIDS
164 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
167 #echo "Using ldapsearch to read all the entries from the master..."
168 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
169 '(objectClass=*)' > "${MASTEROUT}.1" 2>&1
172 if test $RC != 0 ; then
173 echo "ldapsearch failed at master ($RC)!"
174 test $KILLSERVERS != no && kill -HUP $KILLPIDS
178 #echo "Using ldapsearch to read all the entries from the P1 slave..."
179 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
180 '(objectClass=*)' > "${SLAVEOUT}.1" 2>&1
183 if test $RC != 0 ; then
184 echo "ldapsearch failed at P1 slave ($RC)!"
185 test $KILLSERVERS != no && kill -HUP $KILLPIDS
189 #echo "Filtering master results..."
190 . $LDIFFILTER < "${MASTEROUT}.1" > $MASTERFLT
191 #echo "Filtering slave results..."
192 . $LDIFFILTER < "${SLAVEOUT}.1" > $SLAVEFLT
194 echo "$CHECK < Comparing retrieved entries from master and P1 slave..."
195 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
197 if test $? != 0 ; then
198 echo "test failed - master and P1 slave databases differ"
199 test $KILLSERVERS != no && kill -HUP $KILLPIDS
203 #echo "Using ldapsearch to read all the entries from the R1 slave..."
204 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT3 \
205 '(objectClass=*)' > "${SLAVEOUT}.1" 2>&1
208 if test $RC != 0 ; then
209 echo "ldapsearch failed at R1 slave ($RC)!"
210 test $KILLSERVERS != no && kill -HUP $KILLPIDS
214 #echo "Filtering slave results..."
215 . $LDIFFILTER < "${SLAVEOUT}.1" > $SLAVEFLT
217 echo "$CHECK < Comparing retrieved entries from master and R1 slave..."
218 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
220 if test $? != 0 ; then
221 echo "test failed - master and R1 slave databases differ"
222 test $KILLSERVERS != no && kill -HUP $KILLPIDS
226 CHECK=`expr $CHECK + 1`
228 echo "$CHECK > Stopping the provider, sleeping $SLEEP seconds and restarting it..."
229 kill -HUP "$MASTERPID"
233 echo "======================= RESTART =======================" >> $LOG1
234 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
236 if test $WAIT != 0 ; then
237 echo MASTERPID $MASTERPID
240 KILLPIDS="$MASTERPID $P1SLAVEPID $R1SLAVEPID"
244 echo "Using ldapsearch to check that master slapd is running..."
245 for i in 0 1 2 3 4 5; do
246 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
247 '(objectClass=*)' > /dev/null 2>&1
249 if test $RC = 0 ; then
252 echo "Waiting 5 seconds for slapd to start..."
256 if test $RC != 0 ; then
257 echo "ldapsearch failed ($RC)!"
258 test $KILLSERVERS != no && kill -HUP $KILLPIDS
262 echo "Using ldapmodify to modify master directory..."
265 # Do some modifications
268 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
269 $TESTOUT 2>&1 << EOMODS
270 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
281 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
286 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
289 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
290 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
293 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
294 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
296 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
302 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
304 objectclass: OpenLDAPperson
308 title: Chief Investigator, ITD
309 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
310 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
312 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
313 description: Very odd
314 facsimiletelephonenumber: +1 313 555 7557
315 telephonenumber: +1 313 555 8343
316 mail: gjensen@mailgw.example.com
317 homephone: +1 313 555 8844
319 dn: ou=Retired, ou=People, dc=example,dc=com
321 objectclass: organizationalUnit
324 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
326 objectclass: OpenLDAPperson
327 cn: Rosco P. Coltrane
330 description: Fat tycoon
332 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
334 newrdn: cn=Rosco P. Coltrane
336 newsuperior: ou=Retired, ou=People, dc=example,dc=com
338 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
343 if test $RC != 0 ; then
344 echo "ldapmodify failed ($RC)!"
345 test $KILLSERVERS != no && kill -HUP $KILLPIDS
350 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
353 #echo "Using ldapsearch to read all the entries from the master..."
354 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
355 '(objectClass=*)' > "${MASTEROUT}.2" 2>&1
358 if test $RC != 0 ; then
359 echo "ldapsearch failed at master ($RC)!"
360 test $KILLSERVERS != no && kill -HUP $KILLPIDS
364 #echo "Using ldapsearch to read all the entries from the P1 slave..."
365 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
366 '(objectClass=*)' > "${SLAVEOUT}.2" 2>&1
369 if test $RC != 0 ; then
370 echo "ldapsearch failed at P1 slave ($RC)!"
371 test $KILLSERVERS != no && kill -HUP $KILLPIDS
375 #echo "Filtering master results..."
376 . $LDIFFILTER < "${MASTEROUT}.2" > $MASTERFLT
377 #echo "Filtering P1 slave results..."
378 . $LDIFFILTER < "${SLAVEOUT}.2" > $SLAVEFLT
380 echo "$CHECK < Comparing retrieved entries from master and P1 slave..."
381 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
383 if test $? != 0 ; then
384 echo "test failed - master and P1 slave databases differ"
385 test $KILLSERVERS != no && kill -HUP $KILLPIDS
389 #echo "Using ldapsearch to read all the entries from the R1 slave..."
390 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT3 \
391 '(objectClass=*)' > "${SLAVEOUT}.2" 2>&1
394 if test $RC != 0 ; then
395 echo "ldapsearch failed at R1 slave ($RC)!"
396 test $KILLSERVERS != no && kill -HUP $KILLPIDS
400 #echo "Filtering slave results..."
401 . $LDIFFILTER < "${SLAVEOUT}.2" > $SLAVEFLT
403 echo "$CHECK < Comparing retrieved entries from master and R1 slave..."
404 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
406 if test $? != 0 ; then
407 echo "test failed - master and R1 slave databases differ"
408 test $KILLSERVERS != no && kill -HUP $KILLPIDS
412 CHECK=`expr $CHECK + 1`
413 echo "$CHECK > Stopping slaves to test recovery..."
414 kill -HUP $P1SLAVEPID $R1SLAVEPID
418 echo "Modifying more entries on the master..."
419 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
420 $TESTOUT 2>&1 << EOMODS
421 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
424 description: r1 slave is down...
426 dn: cn=James T. Kirk, ou=Retired, ou=People, dc=example,dc=com
428 objectclass: OpenLDAPperson
433 dn: cn=Tiberius J. Hooker, ou=Retired, ou=People, dc=example,dc=com
435 objectclass: OpenLDAPperson
438 cn: Tiberius J. Hooker
442 echo "Restarting P1 slave..."
443 echo "======================= RESTART =======================" >> $LOG3
444 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
446 if test $WAIT != 0 ; then
447 echo P1SLAVEPID $P1SLAVEPID
451 echo "Restarting R1 slave..."
452 echo "======================= RESTART =======================" >> $LOG3
453 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
455 if test $WAIT != 0 ; then
456 echo R1SLAVEPID $R1SLAVEPID
459 KILLPIDS="$MASTERPID $P1SLAVEPID $R1SLAVEPID"
462 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
465 #echo "Using ldapsearch to read all the entries from the master..."
466 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
467 '(objectClass=*)' > "${MASTEROUT}.3" 2>&1
470 if test $RC != 0 ; then
471 echo "ldapsearch failed at master ($RC)!"
472 test $KILLSERVERS != no && kill -HUP $KILLPIDS
476 #echo "Using ldapsearch to read all the entries from the P1 slave..."
477 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
478 '(objectClass=*)' > "${SLAVEOUT}.3" 2>&1
481 if test $RC != 0 ; then
482 echo "ldapsearch failed at slave ($RC)!"
483 test $KILLSERVERS != no && kill -HUP $KILLPIDS
487 #echo "Filtering master results..."
488 . $LDIFFILTER < "${MASTEROUT}.3" > $MASTERFLT
489 #echo "Filtering slave results..."
490 . $LDIFFILTER < "${SLAVEOUT}.3" > $SLAVEFLT
492 echo "$CHECK < Comparing retrieved entries from master and P1 slave..."
493 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
495 if test $? != 0 ; then
496 echo "test failed - master and slave databases differ"
497 test $KILLSERVERS != no && kill -HUP $KILLPIDS
501 #echo "Using ldapsearch to read all the entries from the R1 slave..."
502 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT3 \
503 '(objectClass=*)' > "${SLAVEOUT}.3" 2>&1
506 if test $RC != 0 ; then
507 echo "ldapsearch failed at slave ($RC)!"
508 test $KILLSERVERS != no && kill -HUP $KILLPIDS
512 #echo "Filtering slave results..."
513 . $LDIFFILTER < "${SLAVEOUT}.3" > $SLAVEFLT
515 echo "$CHECK < Comparing retrieved entries from master and R1 slave..."
516 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
518 if test $? != 0 ; then
519 echo "test failed - master and slave databases differ"
520 test $KILLSERVERS != no && kill -HUP $KILLPIDS
524 CHECK=`expr $CHECK + 1`
525 echo "$CHECK > Try updating the P1 slave slapd..."
526 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
527 $TESTOUT 2>&1 << EOMODS
528 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
531 description: This write must fail because directed to a shadow context,
532 description: unless the chain overlay is configured appropriately ;)
537 if test $RC != 0 ; then
538 echo "ldapmodify failed ($RC)!"
539 test $KILLSERVERS != no && kill -HUP $KILLPIDS
544 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
547 #echo "Using ldapsearch to read all the entries from the master..."
548 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
549 '(objectClass=*)' > "${MASTEROUT}.4" 2>&1
552 if test $RC != 0 ; then
553 echo "ldapsearch failed at master ($RC)!"
554 test $KILLSERVERS != no && kill -HUP $KILLPIDS
558 #echo "Using ldapsearch to read all the entries from the P1 slave..."
559 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
560 '(objectClass=*)' > "${SLAVEOUT}.4" 2>&1
563 if test $RC != 0 ; then
564 echo "ldapsearch failed at slave ($RC)!"
565 test $KILLSERVERS != no && kill -HUP $KILLPIDS
569 #echo "Filtering master results..."
570 . $LDIFFILTER < "${MASTEROUT}.4" > $MASTERFLT
571 #echo "Filtering slave results..."
572 . $LDIFFILTER < "${SLAVEOUT}.4" > $SLAVEFLT
574 echo "$CHECK < Comparing retrieved entries from master and P1 slave..."
575 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
577 if test $? != 0 ; then
578 echo "test failed - master and P1 slave databases differ"
579 test $KILLSERVERS != no && kill -HUP $KILLPIDS
583 #echo "Using ldapsearch to read all the entries from the R1 slave..."
584 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT3 \
585 '(objectClass=*)' > "${SLAVEOUT}.4" 2>&1
588 if test $RC != 0 ; then
589 echo "ldapsearch failed at slave ($RC)!"
590 test $KILLSERVERS != no && kill -HUP $KILLPIDS
594 #echo "Filtering slave results..."
595 . $LDIFFILTER < "${SLAVEOUT}.4" > $SLAVEFLT
597 echo "$CHECK < Comparing retrieved entries from master and R1 slave..."
598 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
600 if test $? != 0 ; then
601 echo "test failed - master and R1 slave databases differ"
602 test $KILLSERVERS != no && kill -HUP $KILLPIDS
606 test $KILLSERVERS != no && kill -HUP $KILLPIDS
608 echo ">>>>> Test succeeded"
610 test $KILLSERVERS != no && wait