Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / openldap / dist / tests / scripts / test045-syncreplication-proxied
blob97a15952e240082c4972e4c377b1eea5e974f839
1 #! /bin/sh
2 # $OpenLDAP: pkg/ldap/tests/scripts/test045-syncreplication-proxied,v 1.14.2.6 2008/02/11 23:26:51 kurt Exp $
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2008 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
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"
18 exit 0
21 # test now handles known issues
22 #if test x"$PROXYSYNC" = x ; then
23 # echo "Test disabled; set PROXYSYNC=yes to enable"
24 # exit 0
25 #fi
27 echo "running defines.sh"
28 . $SRCDIR/scripts/defines.sh
30 if test $BACKLDAP = ldapno; then
31 echo "LDAP backend not available, test skipped"
32 exit 0
33 fi
35 if test $SYNCPROV = syncprovno; then
36 echo "Syncrepl provider overlay not available, test skipped"
37 exit 0
38 fi
40 if test $MONITORDB = no; then
41 echo "Monitor backend not available, test skipped"
42 exit 0
43 fi
45 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
48 # Test replication:
49 # - start master
50 # - start slave
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 &
60 MASTERPID=$!
61 if test $WAIT != 0 ; then
62 echo MASTERPID $MASTERPID
63 read foo
65 KILLPIDS="$MASTERPID"
67 sleep 1
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
73 RC=$?
74 if test $RC = 0 ; then
75 break
77 echo "Waiting 5 seconds for slapd to start..."
78 sleep 5
79 done
81 if test $RC != 0 ; then
82 echo "ldapsearch failed ($RC)!"
83 test $KILLSERVERS != no && kill -HUP $KILLPIDS
84 exit $RC
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
90 RC=$?
91 if test $RC != 0 ; then
92 echo "ldapadd failed ($RC)!"
93 test $KILLSERVERS != no && kill -HUP $KILLPIDS
94 exit $RC
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 &
100 SLAVEPID=$!
101 if test $WAIT != 0 ; then
102 echo SLAVEPID $SLAVEPID
103 read foo
105 KILLPIDS="$MASTERPID $SLAVEPID"
107 sleep 1
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
113 RC=$?
114 if test $RC = 0 ; then
115 break
117 echo "Waiting 5 seconds for slapd to start..."
118 sleep 5
119 done
121 if test $RC != 0 ; then
122 echo "ldapsearch failed ($RC)!"
123 test $KILLSERVERS != no && kill -HUP $KILLPIDS
124 exit $RC
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 &
130 PROXYPID=$!
131 if test $WAIT != 0 ; then
132 echo PROXYPID $PROXYPID
133 read foo
135 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
137 sleep 1
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
143 RC=$?
144 if test $RC = 0 || test $RC = 53 ; then
145 break
147 echo "Waiting 5 seconds for slapd to start..."
148 sleep 5
149 done
151 case $RC in
153 echo "ldapsearch should have failed ($RC)!"
154 test $KILLSERVERS != no && kill -HUP $KILLPIDS
155 exit -1
160 echo "ldapsearch failed ($RC)!"
161 test $KILLSERVERS != no && kill -HUP $KILLPIDS
162 exit $RC
164 esac
166 CHECK=1
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
170 RC=$?
171 if test $RC != 0 ; then
172 echo "ldapadd failed ($RC)!"
173 test $KILLSERVERS != no && kill -HUP $KILLPIDS
174 exit $RC
177 # get master contextCSN
178 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
179 '(objectClass=*)' -s base contextCSN > "${MASTEROUT}.$CHECK" 2>&1
180 RC=$?
181 if test $RC != 0 ; then
182 echo "ldapsearch failed at master ($RC)!"
183 test $KILLSERVERS != no && kill -HUP $KILLPIDS
184 exit $RC
187 # check slave contextCSN
188 sleep 1
189 for i in 1 2 3; do
190 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
191 '(objectClass=*)' -s base contextCSN > "${SLAVEOUT}.$CHECK" 2>&1
192 RC=$?
194 if test $RC != 0 ; then
195 echo "ldapsearch failed at slave ($RC)!"
196 test $KILLSERVERS != no && kill -HUP $KILLPIDS
197 exit $RC
200 $CMP ${MASTEROUT}.$CHECK ${SLAVEOUT}.$CHECK > $CMPOUT
202 if test $? = 0 ; then
203 break
206 SLEEP=5
207 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
208 sleep $SLEEP
209 done
211 #echo "Using ldapsearch to read all the entries from the master..."
212 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
213 '(objectClass=*)' > "${MASTEROUT}.$CHECK" 2>&1
214 RC=$?
216 if test $RC != 0 ; then
217 echo "ldapsearch failed at master ($RC)!"
218 test $KILLSERVERS != no && kill -HUP $KILLPIDS
219 exit $RC
222 #echo "Using ldapsearch to read all the entries from the slave..."
223 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
224 '(objectClass=*)' > "${SLAVEOUT}.$CHECK" 2>&1
225 RC=$?
227 if test $RC != 0 ; then
228 echo "ldapsearch failed at slave ($RC)!"
229 test $KILLSERVERS != no && kill -HUP $KILLPIDS
230 exit $RC
233 #echo "Filtering master results..."
234 . $LDIFFILTER < "${MASTEROUT}.$CHECK" > $MASTERFLT
235 #echo "Filtering slave results..."
236 . $LDIFFILTER < "${SLAVEOUT}.$CHECK" > $SLAVEFLT
238 echo "$CHECK < Comparing retrieved entries from master and slave..."
239 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
241 if test $? != 0 ; then
242 echo "test failed - master and slave databases differ"
243 test $KILLSERVERS != no && kill -HUP $KILLPIDS
244 exit 1
247 CHECK=`expr $CHECK + 1`
248 SLEEP=10
249 echo "$CHECK > Stopping the provider, sleeping $SLEEP seconds and restarting it..."
250 kill -HUP "$MASTERPID"
251 wait $MASTERPID
252 sleep $SLEEP
254 echo "======================= RESTART =======================" >> $LOG1
255 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
256 MASTERPID=$!
257 if test $WAIT != 0 ; then
258 echo MASTERPID $MASTERPID
259 read foo
261 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
263 sleep 1
265 echo "Using ldapsearch to check that master slapd is running..."
266 for i in 0 1 2 3 4 5; do
267 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
268 '(objectClass=*)' > /dev/null 2>&1
269 RC=$?
270 if test $RC = 0 ; then
271 break
273 echo "Waiting 5 seconds for slapd to start..."
274 sleep 5
275 done
277 if test $RC != 0 ; then
278 echo "ldapsearch failed ($RC)!"
279 test $KILLSERVERS != no && kill -HUP $KILLPIDS
280 exit $RC
283 echo "Using ldapmodify to modify master directory..."
286 # Do some modifications
289 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
290 $TESTOUT 2>&1 << EOMODS
291 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
292 changetype: modify
293 add: drink
294 drink: Orange Juice
296 delete: sn
297 sn: Jones
299 add: sn
300 sn: Jones
302 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
303 changetype: modify
304 replace: drink
305 drink: Iced Tea
307 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
308 changetype: modify
309 delete: uniquemember
310 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
311 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
313 add: uniquemember
314 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
315 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
317 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
318 =com
319 changetype: modify
320 delete: cn
321 cn: Biiff Jensen
323 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
324 changetype: add
325 objectclass: OpenLDAPperson
326 cn: Gern Jensen
327 sn: Jensen
328 uid: gjensen
329 title: Chief Investigator, ITD
330 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
331 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
332 drink: Coffee
333 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
334 description: Very odd
335 facsimiletelephonenumber: +1 313 555 7557
336 telephonenumber: +1 313 555 8343
337 mail: gjensen@mailgw.example.com
338 homephone: +1 313 555 8844
340 dn: ou=Retired, ou=People, dc=example,dc=com
341 changetype: add
342 objectclass: organizationalUnit
343 ou: Retired
345 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
346 changetype: add
347 objectclass: OpenLDAPperson
348 cn: Rosco P. Coltrane
349 sn: Coltrane
350 uid: rosco
351 description: Fat tycoon
353 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
354 changetype: modrdn
355 newrdn: cn=Rosco P. Coltrane
356 deleteoldrdn: 1
357 newsuperior: ou=Retired, ou=People, dc=example,dc=com
359 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
360 changetype: delete
361 EOMODS
363 RC=$?
364 if test $RC != 0 ; then
365 echo "ldapmodify failed ($RC)!"
366 test $KILLSERVERS != no && kill -HUP $KILLPIDS
367 exit $RC
370 # get master contextCSN
371 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
372 '(objectClass=*)' -s base contextCSN > "${MASTEROUT}.$CHECK" 2>&1
373 RC=$?
374 if test $RC != 0 ; then
375 echo "ldapsearch failed at master ($RC)!"
376 test $KILLSERVERS != no && kill -HUP $KILLPIDS
377 exit $RC
380 # check slave contextCSN
381 for i in 1 2 3; do
382 SLEEP=5
383 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
384 sleep $SLEEP
386 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
387 '(objectClass=*)' -s base contextCSN > "${SLAVEOUT}.$CHECK" 2>&1
388 RC=$?
390 if test $RC != 0 ; then
391 echo "ldapsearch failed at slave ($RC)!"
392 test $KILLSERVERS != no && kill -HUP $KILLPIDS
393 exit $RC
396 $CMP ${MASTEROUT}.$CHECK ${SLAVEOUT}.$CHECK > $CMPOUT
398 if test $? = 0 ; then
399 break
401 done
403 #echo "Using ldapsearch to read all the entries from the master..."
404 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
405 '(objectClass=*)' > "${MASTEROUT}.$CHECK" 2>&1
406 RC=$?
408 if test $RC != 0 ; then
409 echo "ldapsearch failed at master ($RC)!"
410 test $KILLSERVERS != no && kill -HUP $KILLPIDS
411 exit $RC
414 #echo "Using ldapsearch to read all the entries from the slave..."
415 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
416 '(objectClass=*)' > "${SLAVEOUT}.$CHECK" 2>&1
417 RC=$?
419 if test $RC != 0 ; then
420 echo "ldapsearch failed at slave ($RC)!"
421 test $KILLSERVERS != no && kill -HUP $KILLPIDS
422 exit $RC
425 #echo "Filtering master results..."
426 . $LDIFFILTER < "${MASTEROUT}.$CHECK" > $MASTERFLT
427 #echo "Filtering slave results..."
428 . $LDIFFILTER < "${SLAVEOUT}.$CHECK" > $SLAVEFLT
430 echo "$CHECK < Comparing retrieved entries from master and slave..."
431 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
433 if test $? != 0 ; then
434 echo "test failed - master and slave databases differ"
435 test $KILLSERVERS != no && kill -HUP $KILLPIDS
436 exit 1
439 CHECK=`expr $CHECK + 1`
440 echo "$CHECK > Stopping proxy to test recovery..."
441 kill -HUP $PROXYPID
442 wait $PROXYPID
444 echo "Modifying more entries on the master..."
445 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
446 $TESTOUT 2>&1 << EOMODS
447 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
448 changetype: modify
449 add: description
450 description: proxy is down...
452 dn: cn=James T. Kirk, ou=Retired, ou=People, dc=example,dc=com
453 changetype: add
454 objectclass: OpenLDAPperson
455 sn: Kirk
456 uid: jtk
457 cn: James T. Kirk
459 dn: cn=Tiberius J. Hooker, ou=Retired, ou=People, dc=example,dc=com
460 changetype: add
461 objectclass: OpenLDAPperson
462 sn: Hooker
463 uid: tjh
464 cn: Tiberius J. Hooker
466 EOMODS
468 echo "Restarting proxy..."
469 echo "======================= RESTART =======================" >> $LOG3
470 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
471 PROXYPID=$!
472 if test $WAIT != 0 ; then
473 echo PROXYPID $PROXYPID
474 read foo
476 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
478 # get master contextCSN
479 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
480 '(objectClass=*)' -s base contextCSN > "${MASTEROUT}.$CHECK" 2>&1
481 RC=$?
482 if test $RC != 0 ; then
483 echo "ldapsearch failed at master ($RC)!"
484 test $KILLSERVERS != no && kill -HUP $KILLPIDS
485 exit $RC
488 # check slave contextCSN
489 for i in 1 2 3 4 5; do
490 SLEEP=5
491 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
492 sleep $SLEEP
494 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
495 '(objectClass=*)' -s base contextCSN > "${SLAVEOUT}.$CHECK" 2>&1
496 RC=$?
498 if test $RC != 0 ; then
499 echo "ldapsearch failed at slave ($RC)!"
500 test $KILLSERVERS != no && kill -HUP $KILLPIDS
501 exit $RC
504 $CMP ${MASTEROUT}.$CHECK ${SLAVEOUT}.$CHECK > $CMPOUT
506 if test $? = 0 ; then
507 break
509 done
511 #echo "Using ldapsearch to read all the entries from the master..."
512 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
513 '(objectClass=*)' > "${MASTEROUT}.$CHECK" 2>&1
514 RC=$?
516 if test $RC != 0 ; then
517 echo "ldapsearch failed at master ($RC)!"
518 test $KILLSERVERS != no && kill -HUP $KILLPIDS
519 exit $RC
522 #echo "Using ldapsearch to read all the entries from the slave..."
523 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
524 '(objectClass=*)' > "${SLAVEOUT}.$CHECK" 2>&1
525 RC=$?
527 if test $RC != 0 ; then
528 echo "ldapsearch failed at slave ($RC)!"
529 test $KILLSERVERS != no && kill -HUP $KILLPIDS
530 exit $RC
533 #echo "Filtering master results..."
534 . $LDIFFILTER < "${MASTEROUT}.$CHECK" > $MASTERFLT
535 #echo "Filtering slave results..."
536 . $LDIFFILTER < "${SLAVEOUT}.$CHECK" > $SLAVEFLT
538 echo "$CHECK < Comparing retrieved entries from master and slave..."
539 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
541 if test $? != 0 ; then
542 echo "test failed - master and slave databases differ"
543 test $KILLSERVERS != no && kill -HUP $KILLPIDS
544 exit 1
547 CHECK=`expr $CHECK + 1`
548 echo "$CHECK > Try updating the slave slapd..."
549 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
550 $TESTOUT 2>&1 << EOMODS
551 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
552 changetype: modify
553 add: description
554 description: This write must fail because directed to a shadow context,
555 description: unless the chain overlay is configured appropriately ;)
557 EOMODS
559 RC=$?
560 if test $RC != 0 ; then
561 echo "ldapmodify failed ($RC)!"
562 test $KILLSERVERS != no && kill -HUP $KILLPIDS
563 exit $RC
566 # get master contextCSN
567 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
568 '(objectClass=*)' -s base contextCSN > "${MASTEROUT}.$CHECK" 2>&1
569 RC=$?
570 if test $RC != 0 ; then
571 echo "ldapsearch failed at master ($RC)!"
572 test $KILLSERVERS != no && kill -HUP $KILLPIDS
573 exit $RC
576 # check slave contextCSN
577 sleep 1
579 for i in 1 2 3; do
580 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
581 '(objectClass=*)' -s base contextCSN > "${SLAVEOUT}.$CHECK" 2>&1
582 RC=$?
584 if test $RC != 0 ; then
585 echo "ldapsearch failed at slave ($RC)!"
586 test $KILLSERVERS != no && kill -HUP $KILLPIDS
587 exit $RC
590 $CMP ${MASTEROUT}.$CHECK ${SLAVEOUT}.$CHECK > $CMPOUT
592 if test $? = 0 ; then
593 break
596 SLEEP=5
597 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
598 sleep $SLEEP
599 done
601 #echo "Using ldapsearch to read all the entries from the master..."
602 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
603 '(objectClass=*)' > "${MASTEROUT}.$CHECK" 2>&1
604 RC=$?
606 if test $RC != 0 ; then
607 echo "ldapsearch failed at master ($RC)!"
608 test $KILLSERVERS != no && kill -HUP $KILLPIDS
609 exit $RC
612 #echo "Using ldapsearch to read all the entries from the slave..."
613 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
614 '(objectClass=*)' > "${SLAVEOUT}.$CHECK" 2>&1
615 RC=$?
617 if test $RC != 0 ; then
618 echo "ldapsearch failed at slave ($RC)!"
619 test $KILLSERVERS != no && kill -HUP $KILLPIDS
620 exit $RC
623 #echo "Filtering master results..."
624 . $LDIFFILTER < "${MASTEROUT}.$CHECK" > $MASTERFLT
625 #echo "Filtering slave results..."
626 . $LDIFFILTER < "${SLAVEOUT}.$CHECK" > $SLAVEFLT
628 echo "$CHECK < Comparing retrieved entries from master and slave..."
629 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
631 if test $? != 0 ; then
632 echo "test failed - master and slave databases differ"
633 test $KILLSERVERS != no && kill -HUP $KILLPIDS
634 exit 1
637 CHECK=`expr $CHECK + 1`
638 echo "$CHECK > Stopping consumer to test recovery..."
639 kill -HUP $SLAVEPID
640 wait $SLAVEPID
642 echo "Modifying more entries on the master..."
643 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
644 $TESTOUT 2>&1 << EOMODS
645 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
646 changetype: modify
647 add: drink
648 drink: Mad Dog 20/20
650 EOMODS
652 SLEEP=10
653 echo "Waiting $SLEEP seconds for syncrepl to retry..."
654 sleep $SLEEP
656 echo "Restarting consumer..."
657 echo "======================= RESTART =======================" >> $LOG2
658 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
659 SLAVEPID=$!
660 if test $WAIT != 0 ; then
661 echo SLAVEPID $SLAVEPID
662 read foo
664 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
666 # get master contextCSN
667 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
668 '(objectClass=*)' -s base contextCSN > "${MASTEROUT}.$CHECK" 2>&1
669 RC=$?
670 if test $RC != 0 ; then
671 echo "ldapsearch failed at master ($RC)!"
672 test $KILLSERVERS != no && kill -HUP $KILLPIDS
673 exit $RC
676 # check slave contextCSN
678 for i in 1 2 3 4 5; do
679 SLEEP=5
680 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
681 sleep $SLEEP
683 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
684 '(objectClass=*)' -s base contextCSN > "${SLAVEOUT}.$CHECK" 2>&1
685 RC=$?
687 if test $RC != 0 ; then
688 echo "ldapsearch failed at slave ($RC)!"
689 test $KILLSERVERS != no && kill -HUP $KILLPIDS
690 exit $RC
693 $CMP ${MASTEROUT}.$CHECK ${SLAVEOUT}.$CHECK > $CMPOUT
695 if test $? = 0 ; then
696 break
698 done
700 #echo "Using ldapsearch to read all the entries from the master..."
701 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
702 '(objectClass=*)' > "${MASTEROUT}.$CHECK" 2>&1
703 RC=$?
705 if test $RC != 0 ; then
706 echo "ldapsearch failed at master ($RC)!"
707 test $KILLSERVERS != no && kill -HUP $KILLPIDS
708 exit $RC
711 #echo "Using ldapsearch to read all the entries from the slave..."
712 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
713 '(objectClass=*)' > "${SLAVEOUT}.$CHECK" 2>&1
714 RC=$?
716 if test $RC != 0 ; then
717 echo "ldapsearch failed at slave ($RC)!"
718 test $KILLSERVERS != no && kill -HUP $KILLPIDS
719 exit $RC
722 #echo "Filtering master results..."
723 . $LDIFFILTER < "${MASTEROUT}.$CHECK" > $MASTERFLT
724 #echo "Filtering slave results..."
725 . $LDIFFILTER < "${SLAVEOUT}.$CHECK" > $SLAVEFLT
727 echo "$CHECK < Comparing retrieved entries from master and slave..."
728 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
730 if test $? != 0 ; then
731 # FIXME: keep the original workaround in place, in case we needed again
732 if test 1 = 1 ; then
733 echo "test failed - master and slave databases differ"
734 test $KILLSERVERS != no && kill -HUP $KILLPIDS
735 exit 1
738 echo " test failed - master and slave databases differ (ignored by now)"
739 echo " Stopping proxy to see if it auto-recovers..."
740 kill -HUP $PROXYPID
741 wait $PROXYPID
743 echo " ${CHECK}.1 > Restarting proxy..."
744 echo "======================= RESTART =======================" >> $LOG3
745 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
746 PROXYPID=$!
747 if test $WAIT != 0 ; then
748 echo PROXYPID $PROXYPID
749 read foo
751 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
753 SLEEP=15
754 echo " Waiting $SLEEP seconds for syncrepl to receive changes..."
755 sleep $SLEEP
757 #echo "Using ldapsearch to read all the entries from the slave..."
758 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
759 '(objectClass=*)' > "${SLAVEOUT}.5.1" 2>&1
760 RC=$?
762 if test $RC != 0 ; then
763 echo " ldapsearch failed at slave ($RC)!"
764 test $KILLSERVERS != no && kill -HUP $KILLPIDS
765 exit $RC
768 #echo "Filtering slave results..."
769 . $LDIFFILTER < "${SLAVEOUT}.5.1" > $SLAVEFLT
771 echo " ${CHECK}.1 < Comparing retrieved entries from master and slave..."
772 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
774 if test $? != 0 ; then
775 echo " test failed - master and slave databases differ"
776 test $KILLSERVERS != no && kill -HUP $KILLPIDS
777 exit 1
782 # Modifications formerly known to fail
784 CHECK=`expr $CHECK + 1`
785 echo "$CHECK > Performing modifications that were formerly known to fail..."
786 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
787 $TESTOUT 2>&1 << EOMODS
788 # First, back out previous change
789 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
790 changetype: modify
791 delete: drink
792 drink: Mad Dog 20/20
794 # From now on, perform modifications that were formerly known to fail
795 dn: cn=All Staff,ou=Groups,dc=example,dc=com
796 changetype: modify
797 delete: description
799 EOMODS
801 RC=$?
802 if test $RC != 0 ; then
803 echo "ldapmodify failed ($RC)!"
804 test $KILLSERVERS != no && kill -HUP $KILLPIDS
805 exit $RC
808 # get master contextCSN
809 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
810 '(objectClass=*)' -s base contextCSN > "${MASTEROUT}.$CHECK" 2>&1
811 RC=$?
812 if test $RC != 0 ; then
813 echo "ldapsearch failed at master ($RC)!"
814 test $KILLSERVERS != no && kill -HUP $KILLPIDS
815 exit $RC
818 # check slave contextCSN
819 sleep 1
820 for i in 1 2 3; do
821 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
822 '(objectClass=*)' -s base contextCSN > "${SLAVEOUT}.$CHECK" 2>&1
823 RC=$?
825 if test $RC != 0 ; then
826 echo "ldapsearch failed at slave ($RC)!"
827 test $KILLSERVERS != no && kill -HUP $KILLPIDS
828 exit $RC
831 $CMP ${MASTEROUT}.$CHECK ${SLAVEOUT}.$CHECK > $CMPOUT
833 if test $? = 0 ; then
834 break
837 SLEEP=5
838 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
839 sleep $SLEEP
840 done
842 #echo "Using ldapsearch to read all the entries from the master..."
843 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
844 '(objectClass=*)' > "${MASTEROUT}.$CHECK" 2>&1
845 RC=$?
847 if test $RC != 0 ; then
848 echo "ldapsearch failed at master ($RC)!"
849 test $KILLSERVERS != no && kill -HUP $KILLPIDS
850 exit $RC
853 #echo "Using ldapsearch to read all the entries from the slave..."
854 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
855 '(objectClass=*)' > "${SLAVEOUT}.$CHECK" 2>&1
856 RC=$?
858 if test $RC != 0 ; then
859 echo "ldapsearch failed at slave ($RC)!"
860 test $KILLSERVERS != no && kill -HUP $KILLPIDS
861 exit $RC
864 #echo "Filtering master results..."
865 . $LDIFFILTER < "${MASTEROUT}.$CHECK" > $MASTERFLT
866 #echo "Filtering slave results..."
867 . $LDIFFILTER < "${SLAVEOUT}.$CHECK" > $SLAVEFLT
869 echo "$CHECK < Comparing retrieved entries from master and slave..."
870 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
872 if test $? != 0 ; then
873 echo "test failed - master and slave databases differ (ignored by now)"
874 #echo "test failed - master and slave databases differ"
875 #test $KILLSERVERS != no && kill -HUP $KILLPIDS
876 #exit 1
879 test $KILLSERVERS != no && kill -HUP $KILLPIDS
881 echo ">>>>> Test succeeded"
883 test $KILLSERVERS != no && wait
885 exit 0