2 # $OpenLDAP: pkg/ldap/tests/scripts/test048-syncrepl-multiproxy,v 1.1.2.7 2008/07/08 19:04:25 quanah Exp $
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2008 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 echo "running defines.sh"
17 .
$SRCDIR/scripts
/defines.sh
19 if test $BACKLDAP = ldapno
; then
20 echo "LDAP backend not available, test skipped"
24 if test $SYNCPROV = syncprovno
; then
25 echo "Syncrepl provider overlay not available, test skipped"
29 if test $MONITORDB = no
; then
30 echo "Monitor backend not available, test skipped"
34 if test $THREADS = threadsno
; then
35 echo "Need threads support, test skipped"
39 mkdir
-p $TESTDIR $DBDIR1 $DBDIR2 $DBDIR3
45 # - populate over ldap
46 # - perform some modifies and deleted
47 # - attempt to modify the slave (referral or chain)
48 # - retrieve database over ldap and compare against expected results
51 echo "Starting master slapd on TCP/IP port $PORT1..."
52 .
$CONFFILTER $BACKEND $MONITORDB < $PLSRMASTERCONF > $CONF1
53 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
55 if test $WAIT != 0 ; then
56 echo MASTERPID
$MASTERPID
63 echo "Using ldapsearch to check that master slapd is running..."
64 for i
in 0 1 2 3 4 5; do
65 $LDAPSEARCH -s base
-b "$MONITOR" -h $LOCALHOST -p $PORT1 \
66 '(objectClass=*)' > /dev
/null
2>&1
68 if test $RC = 0 ; then
71 echo "Waiting 5 seconds for slapd to start..."
75 if test $RC != 0 ; then
76 echo "ldapsearch failed ($RC)!"
77 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
81 echo "Using ldapadd to create the context prefix entry in the master..."
82 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
83 $LDIFORDEREDCP > /dev
/null
2>&1
85 if test $RC != 0 ; then
86 echo "ldapadd failed ($RC)!"
87 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
91 echo "Starting P1 slave slapd on TCP/IP port $PORT2..."
92 .
$CONFFILTER $BACKEND $MONITORDB < $RSLAVECONF > $CONF2
93 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
95 if test $WAIT != 0 ; then
96 echo P1SLAVEPID
$P1SLAVEPID
99 KILLPIDS
="$MASTERPID $P1SLAVEPID"
103 echo "Using ldapsearch to check that P1 slave slapd is running..."
104 for i
in 0 1 2 3 4 5; do
105 $LDAPSEARCH -s base
-b "$MONITOR" -h $LOCALHOST -p $PORT2 \
106 '(objectClass=*)' > /dev
/null
2>&1
108 if test $RC = 0 ; then
111 echo "Waiting 5 seconds for slapd to start..."
115 if test $RC != 0 ; then
116 echo "ldapsearch failed ($RC)!"
117 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
121 echo "Starting R1 slave slapd on TCP/IP port $PORT3..."
122 .
$CONFFILTER $BACKEND $MONITORDB < $RSLAVECONF |
sed -e 's;\.2\.;.3.;' > $CONF3
123 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
125 if test $WAIT != 0 ; then
126 echo R1SLAVEPID
$R1SLAVEPID
129 KILLPIDS
="$MASTERPID $P1SLAVEPID $R1SLAVEPID"
133 echo "Using ldapsearch to check that R1 slave slapd is running..."
134 for i
in 0 1 2 3 4 5; do
135 $LDAPSEARCH -s base
-b "$MONITOR" -h $LOCALHOST -p $PORT3 \
136 '(objectClass=*)' > /dev
/null
2>&1
138 if test $RC = 0; then
141 echo "Waiting 5 seconds for slapd to start..."
145 if test $RC != 0 ; then
146 echo "ldapsearch failed ($RC)!"
147 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
152 echo "$CHECK > Using ldapadd to populate the master directory..."
153 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
154 $LDIFORDEREDNOCP > /dev
/null
2>&1
156 if test $RC != 0 ; then
157 echo "ldapadd failed ($RC)!"
158 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
163 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
166 #echo "Using ldapsearch to read all the entries from the master..."
167 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
168 '(objectClass=*)' > "${MASTEROUT}.1" 2>&1
171 if test $RC != 0 ; then
172 echo "ldapsearch failed at master ($RC)!"
173 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
177 #echo "Using ldapsearch to read all the entries from the P1 slave..."
178 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
179 '(objectClass=*)' > "${SLAVEOUT}.1" 2>&1
182 if test $RC != 0 ; then
183 echo "ldapsearch failed at P1 slave ($RC)!"
184 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
188 #echo "Filtering master results..."
189 .
$LDIFFILTER < "${MASTEROUT}.1" > $MASTERFLT
190 #echo "Filtering slave results..."
191 .
$LDIFFILTER < "${SLAVEOUT}.1" > $SLAVEFLT
193 echo "$CHECK < Comparing retrieved entries from master and P1 slave..."
194 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
196 if test $?
!= 0 ; then
197 echo "test failed - master and P1 slave databases differ"
198 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
202 #echo "Using ldapsearch to read all the entries from the R1 slave..."
203 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT3 \
204 '(objectClass=*)' > "${SLAVEOUT}.1" 2>&1
207 if test $RC != 0 ; then
208 echo "ldapsearch failed at R1 slave ($RC)!"
209 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
213 #echo "Filtering slave results..."
214 .
$LDIFFILTER < "${SLAVEOUT}.1" > $SLAVEFLT
216 echo "$CHECK < Comparing retrieved entries from master and R1 slave..."
217 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
219 if test $?
!= 0 ; then
220 echo "test failed - master and R1 slave databases differ"
221 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
225 CHECK
=`expr $CHECK + 1`
227 echo "$CHECK > Stopping the provider, sleeping $SLEEP seconds and restarting it..."
228 kill -HUP "$MASTERPID"
232 echo "======================= RESTART =======================" >> $LOG1
233 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
235 if test $WAIT != 0 ; then
236 echo MASTERPID
$MASTERPID
239 KILLPIDS
="$MASTERPID $P1SLAVEPID $R1SLAVEPID"
243 echo "Using ldapsearch to check that master slapd is running..."
244 for i
in 0 1 2 3 4 5; do
245 $LDAPSEARCH -s base
-b "$MONITOR" -h $LOCALHOST -p $PORT1 \
246 '(objectClass=*)' > /dev
/null
2>&1
248 if test $RC = 0 ; then
251 echo "Waiting 5 seconds for slapd to start..."
255 if test $RC != 0 ; then
256 echo "ldapsearch failed ($RC)!"
257 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
261 echo "Using ldapmodify to modify master directory..."
264 # Do some modifications
267 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
268 $TESTOUT 2>&1 << EOMODS
269 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
280 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
285 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
288 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
289 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
292 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
293 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
295 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
301 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
303 objectclass: OpenLDAPperson
307 title: Chief Investigator, ITD
308 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
309 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
311 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
312 description: Very odd
313 facsimiletelephonenumber: +1 313 555 7557
314 telephonenumber: +1 313 555 8343
315 mail: gjensen@mailgw.example.com
316 homephone: +1 313 555 8844
318 dn: ou=Retired, ou=People, dc=example,dc=com
320 objectclass: organizationalUnit
323 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
325 objectclass: OpenLDAPperson
326 cn: Rosco P. Coltrane
329 description: Fat tycoon
331 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
333 newrdn: cn=Rosco P. Coltrane
335 newsuperior: ou=Retired, ou=People, dc=example,dc=com
337 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
342 if test $RC != 0 ; then
343 echo "ldapmodify failed ($RC)!"
344 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
349 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
352 #echo "Using ldapsearch to read all the entries from the master..."
353 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
354 '(objectClass=*)' > "${MASTEROUT}.2" 2>&1
357 if test $RC != 0 ; then
358 echo "ldapsearch failed at master ($RC)!"
359 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
363 #echo "Using ldapsearch to read all the entries from the P1 slave..."
364 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
365 '(objectClass=*)' > "${SLAVEOUT}.2" 2>&1
368 if test $RC != 0 ; then
369 echo "ldapsearch failed at P1 slave ($RC)!"
370 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
374 #echo "Filtering master results..."
375 .
$LDIFFILTER < "${MASTEROUT}.2" > $MASTERFLT
376 #echo "Filtering P1 slave results..."
377 .
$LDIFFILTER < "${SLAVEOUT}.2" > $SLAVEFLT
379 echo "$CHECK < Comparing retrieved entries from master and P1 slave..."
380 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
382 if test $?
!= 0 ; then
383 echo "test failed - master and P1 slave databases differ"
384 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
388 #echo "Using ldapsearch to read all the entries from the R1 slave..."
389 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT3 \
390 '(objectClass=*)' > "${SLAVEOUT}.2" 2>&1
393 if test $RC != 0 ; then
394 echo "ldapsearch failed at R1 slave ($RC)!"
395 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
399 #echo "Filtering slave results..."
400 .
$LDIFFILTER < "${SLAVEOUT}.2" > $SLAVEFLT
402 echo "$CHECK < Comparing retrieved entries from master and R1 slave..."
403 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
405 if test $?
!= 0 ; then
406 echo "test failed - master and R1 slave databases differ"
407 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
411 CHECK
=`expr $CHECK + 1`
412 echo "$CHECK > Stopping slaves to test recovery..."
413 kill -HUP $P1SLAVEPID $R1SLAVEPID
417 echo "Modifying more entries on the master..."
418 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
419 $TESTOUT 2>&1 << EOMODS
420 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
423 description: r1 slave is down...
425 dn: cn=James T. Kirk, ou=Retired, ou=People, dc=example,dc=com
427 objectclass: OpenLDAPperson
432 dn: cn=Tiberius J. Hooker, ou=Retired, ou=People, dc=example,dc=com
434 objectclass: OpenLDAPperson
437 cn: Tiberius J. Hooker
441 echo "Restarting P1 slave..."
442 echo "======================= RESTART =======================" >> $LOG3
443 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
445 if test $WAIT != 0 ; then
446 echo P1SLAVEPID
$P1SLAVEPID
450 echo "Restarting R1 slave..."
451 echo "======================= RESTART =======================" >> $LOG3
452 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
454 if test $WAIT != 0 ; then
455 echo R1SLAVEPID
$R1SLAVEPID
458 KILLPIDS
="$MASTERPID $P1SLAVEPID $R1SLAVEPID"
461 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
464 #echo "Using ldapsearch to read all the entries from the master..."
465 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
466 '(objectClass=*)' > "${MASTEROUT}.3" 2>&1
469 if test $RC != 0 ; then
470 echo "ldapsearch failed at master ($RC)!"
471 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
475 #echo "Using ldapsearch to read all the entries from the P1 slave..."
476 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
477 '(objectClass=*)' > "${SLAVEOUT}.3" 2>&1
480 if test $RC != 0 ; then
481 echo "ldapsearch failed at slave ($RC)!"
482 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
486 #echo "Filtering master results..."
487 .
$LDIFFILTER < "${MASTEROUT}.3" > $MASTERFLT
488 #echo "Filtering slave results..."
489 .
$LDIFFILTER < "${SLAVEOUT}.3" > $SLAVEFLT
491 echo "$CHECK < Comparing retrieved entries from master and P1 slave..."
492 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
494 if test $?
!= 0 ; then
495 echo "test failed - master and slave databases differ"
496 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
500 #echo "Using ldapsearch to read all the entries from the R1 slave..."
501 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT3 \
502 '(objectClass=*)' > "${SLAVEOUT}.3" 2>&1
505 if test $RC != 0 ; then
506 echo "ldapsearch failed at slave ($RC)!"
507 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
511 #echo "Filtering slave results..."
512 .
$LDIFFILTER < "${SLAVEOUT}.3" > $SLAVEFLT
514 echo "$CHECK < Comparing retrieved entries from master and R1 slave..."
515 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
517 if test $?
!= 0 ; then
518 echo "test failed - master and slave databases differ"
519 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
523 CHECK
=`expr $CHECK + 1`
524 echo "$CHECK > Try updating the P1 slave slapd..."
525 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
526 $TESTOUT 2>&1 << EOMODS
527 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
530 description: This write must fail because directed to a shadow context,
531 description: unless the chain overlay is configured appropriately ;)
536 if test $RC != 0 ; then
537 echo "ldapmodify failed ($RC)!"
538 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
543 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
546 #echo "Using ldapsearch to read all the entries from the master..."
547 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
548 '(objectClass=*)' > "${MASTEROUT}.4" 2>&1
551 if test $RC != 0 ; then
552 echo "ldapsearch failed at master ($RC)!"
553 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
557 #echo "Using ldapsearch to read all the entries from the P1 slave..."
558 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
559 '(objectClass=*)' > "${SLAVEOUT}.4" 2>&1
562 if test $RC != 0 ; then
563 echo "ldapsearch failed at slave ($RC)!"
564 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
568 #echo "Filtering master results..."
569 .
$LDIFFILTER < "${MASTEROUT}.4" > $MASTERFLT
570 #echo "Filtering slave results..."
571 .
$LDIFFILTER < "${SLAVEOUT}.4" > $SLAVEFLT
573 echo "$CHECK < Comparing retrieved entries from master and P1 slave..."
574 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
576 if test $?
!= 0 ; then
577 echo "test failed - master and P1 slave databases differ"
578 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
582 #echo "Using ldapsearch to read all the entries from the R1 slave..."
583 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT3 \
584 '(objectClass=*)' > "${SLAVEOUT}.4" 2>&1
587 if test $RC != 0 ; then
588 echo "ldapsearch failed at slave ($RC)!"
589 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
593 #echo "Filtering slave results..."
594 .
$LDIFFILTER < "${SLAVEOUT}.4" > $SLAVEFLT
596 echo "$CHECK < Comparing retrieved entries from master and R1 slave..."
597 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
599 if test $?
!= 0 ; then
600 echo "test failed - master and R1 slave databases differ"
601 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
605 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
607 echo ">>>>> Test succeeded"
609 test $KILLSERVERS != no
&& wait