]> git.sur5r.net Git - openldap/blob - tests/scripts/test045-syncreplication-proxied
remove workaround for fixed issue
[openldap] / tests / scripts / test045-syncreplication-proxied
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2006 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.
11 ##
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>.
15
16 if test "$BACKEND" != "bdb" && test "$BACKEND" != "hdb" ; then
17         echo "Test does not support $BACKEND"
18         exit 0
19 fi
20
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
26
27 echo "running defines.sh"
28 . $SRCDIR/scripts/defines.sh
29
30 if test $BACKLDAP = ldapno; then 
31         echo "LDAP backend not available, test skipped"
32         exit 0
33 fi 
34
35 if test $SYNCPROV = syncprovno; then 
36         echo "Syncrepl provider overlay not available, test skipped"
37         exit 0
38 fi 
39
40 if test $MONITORDB = no; then 
41         echo "Monitor backend not available, test skipped"
42         exit 0
43 fi 
44
45 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
46
47 #
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
55 #
56
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
64 fi
65 KILLPIDS="$MASTERPID"
66
67 sleep 1
68
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
76         fi
77         echo "Waiting 5 seconds for slapd to start..."
78         sleep 5
79 done
80
81 if test $RC != 0 ; then
82         echo "ldapsearch failed ($RC)!"
83         test $KILLSERVERS != no && kill -HUP $KILLPIDS
84         exit $RC
85 fi
86
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
95 fi
96
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
104 fi
105 KILLPIDS="$MASTERPID $SLAVEPID"
106
107 sleep 1
108
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
116         fi
117         echo "Waiting 5 seconds for slapd to start..."
118         sleep 5
119 done
120
121 if test $RC != 0 ; then
122         echo "ldapsearch failed ($RC)!"
123         test $KILLSERVERS != no && kill -HUP $KILLPIDS
124         exit $RC
125 fi
126
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
134 fi
135 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
136
137 sleep 1
138
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 -o $RC = 53 ; then
145                 break
146         fi
147         echo "Waiting 5 seconds for slapd to start..."
148         sleep 5
149 done
150
151 case $RC in
152 0 )
153         echo "ldapsearch should have failed ($RC)!"
154         test $KILLSERVERS != no && kill -HUP $KILLPIDS
155         exit -1
156         ;;
157 53)
158         ;;
159 *)
160         echo "ldapsearch failed ($RC)!"
161         test $KILLSERVERS != no && kill -HUP $KILLPIDS
162         exit $RC
163         ;;
164 esac
165
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
169 RC=$?
170 if test $RC != 0 ; then
171         echo "ldapadd failed ($RC)!"
172         test $KILLSERVERS != no && kill -HUP $KILLPIDS
173         exit $RC
174 fi
175
176 SLEEP=15
177 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
178 sleep $SLEEP
179
180 CHECK=1
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
184 RC=$?
185
186 if test $RC != 0 ; then
187         echo "ldapsearch failed at master ($RC)!"
188         test $KILLSERVERS != no && kill -HUP $KILLPIDS
189         exit $RC
190 fi
191
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
195 RC=$?
196
197 if test $RC != 0 ; then
198         echo "ldapsearch failed at slave ($RC)!"
199         test $KILLSERVERS != no && kill -HUP $KILLPIDS
200         exit $RC
201 fi
202
203 #echo "Filtering master results..."
204 . $LDIFFILTER < "${MASTEROUT}.1" > $MASTERFLT
205 #echo "Filtering slave results..."
206 . $LDIFFILTER < "${SLAVEOUT}.1" > $SLAVEFLT
207
208 echo "$CHECK - Comparing retrieved entries from master and slave..."
209 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
210
211 if test $? != 0 ; then
212         echo "test failed - master and slave databases differ"
213         test $KILLSERVERS != no && kill -HUP $KILLPIDS
214         exit 1
215 fi
216
217 SLEEP=10
218 echo "Stopping the provider, sleeping $SLEEP seconds and restarting it..."
219 kill -HUP "$MASTERPID"
220 wait $MASTERPID
221 sleep $SLEEP
222
223 echo "======================= RESTART =======================" >> $LOG1
224 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
225 MASTERPID=$!
226 if test $WAIT != 0 ; then
227     echo MASTERPID $MASTERPID
228     read foo
229 fi
230 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
231
232 sleep 1
233
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
238         RC=$?
239         if test $RC = 0 ; then
240                 break
241         fi
242         echo "Waiting 5 seconds for slapd to start..."
243         sleep 5
244 done
245
246 if test $RC != 0 ; then
247         echo "ldapsearch failed ($RC)!"
248         test $KILLSERVERS != no && kill -HUP $KILLPIDS
249         exit $RC
250 fi
251
252 echo "Using ldapmodify to modify master directory..."
253
254 #
255 # Do some modifications
256 #
257
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
261 changetype: modify
262 add: drink
263 drink: Orange Juice
264 -
265 delete: sn
266 sn: Jones
267 -
268 add: sn
269 sn: Jones
270
271 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
272 changetype: modify
273 replace: drink
274 drink: Iced Tea
275
276 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
277 changetype: modify
278 delete: uniquemember
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
281 -
282 add: uniquemember
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
285
286 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
287  =com
288 changetype: modify
289 delete: cn
290 cn: Biiff Jensen
291
292 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
293 changetype: add
294 objectclass: OpenLDAPperson
295 cn: Gern Jensen
296 sn: Jensen
297 uid: gjensen
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
301 drink: Coffee
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
308
309 dn: ou=Retired, ou=People, dc=example,dc=com
310 changetype: add
311 objectclass: organizationalUnit
312 ou: Retired
313
314 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
315 changetype: add
316 objectclass: OpenLDAPperson
317 cn: Rosco P. Coltrane
318 sn: Coltrane
319 uid: rosco
320 description: Fat tycoon
321
322 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
323 changetype: modrdn
324 newrdn: cn=Rosco P. Coltrane
325 deleteoldrdn: 1
326 newsuperior: ou=Retired, ou=People, dc=example,dc=com
327
328 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
329 changetype: delete
330 EOMODS
331
332 RC=$?
333 if test $RC != 0 ; then
334         echo "ldapmodify failed ($RC)!"
335         test $KILLSERVERS != no && kill -HUP $KILLPIDS
336         exit $RC
337 fi
338
339 SLEEP=15
340 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
341 sleep $SLEEP
342
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
347 RC=$?
348
349 if test $RC != 0 ; then
350         echo "ldapsearch failed at master ($RC)!"
351         test $KILLSERVERS != no && kill -HUP $KILLPIDS
352         exit $RC
353 fi
354
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
358 RC=$?
359
360 if test $RC != 0 ; then
361         echo "ldapsearch failed at slave ($RC)!"
362         test $KILLSERVERS != no && kill -HUP $KILLPIDS
363         exit $RC
364 fi
365
366 #echo "Filtering master results..."
367 . $LDIFFILTER < "${MASTEROUT}.2" > $MASTERFLT
368 #echo "Filtering slave results..."
369 . $LDIFFILTER < "${SLAVEOUT}.2" > $SLAVEFLT
370
371 echo "$CHECK - Comparing retrieved entries from master and slave..."
372 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
373
374 if test $? != 0 ; then
375         echo "test failed - master and slave databases differ"
376         test $KILLSERVERS != no && kill -HUP $KILLPIDS
377         exit 1
378 fi
379
380 echo "Stopping proxy to test recovery..."
381 kill -HUP $PROXYPID
382 wait $PROXYPID
383
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
388 changetype: modify
389 add: description
390 description: proxy is down...
391
392 dn: cn=James T. Kirk, ou=Retired, ou=People, dc=example,dc=com
393 changetype: add
394 objectclass: OpenLDAPperson
395 sn: Kirk
396 uid: jtk
397 cn: James T. Kirk
398
399 dn: cn=Tiberius J. Hooker, ou=Retired, ou=People, dc=example,dc=com
400 changetype: add
401 objectclass: OpenLDAPperson
402 sn: Hooker
403 uid: tjh
404 cn: Tiberius J. Hooker
405
406 EOMODS
407
408 echo "Restarting proxy..."
409 echo "======================= RESTART =======================" >> $LOG3
410 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
411 PROXYPID=$!
412 if test $WAIT != 0 ; then
413     echo PROXYPID $PROXYPID
414     read foo
415 fi
416 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
417
418 SLEEP=25
419 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
420 sleep $SLEEP
421
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
426 RC=$?
427
428 if test $RC != 0 ; then
429         echo "ldapsearch failed at master ($RC)!"
430         test $KILLSERVERS != no && kill -HUP $KILLPIDS
431         exit $RC
432 fi
433
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
437 RC=$?
438
439 if test $RC != 0 ; then
440         echo "ldapsearch failed at slave ($RC)!"
441         test $KILLSERVERS != no && kill -HUP $KILLPIDS
442         exit $RC
443 fi
444
445 #echo "Filtering master results..."
446 . $LDIFFILTER < "${MASTEROUT}.3" > $MASTERFLT
447 #echo "Filtering slave results..."
448 . $LDIFFILTER < "${SLAVEOUT}.3" > $SLAVEFLT
449
450 echo "$CHECK - Comparing retrieved entries from master and slave..."
451 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
452
453 if test $? != 0 ; then
454         echo "test failed - master and slave databases differ"
455         test $KILLSERVERS != no && kill -HUP $KILLPIDS
456         exit 1
457 fi
458
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
464 changetype: modify
465 add: description
466 description: This write must fail because directed to a shadow context,
467 description: unless the chain overlay is configured appropriately ;)
468
469 EOMODS
470
471         RC=$?
472         if test $RC != 0 ; then
473                 echo "ldapmodify failed ($RC)!"
474                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
475                 exit $RC
476         fi
477
478         SLEEP=15
479         echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
480         sleep $SLEEP
481
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
486         RC=$?
487
488         if test $RC != 0 ; then
489                 echo "ldapsearch failed at master ($RC)!"
490                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
491                 exit $RC
492         fi
493
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
497         RC=$?
498
499         if test $RC != 0 ; then
500                 echo "ldapsearch failed at slave ($RC)!"
501                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
502                 exit $RC
503         fi
504
505         #echo "Filtering master results..."
506         . $LDIFFILTER < "${MASTEROUT}.4" > $MASTERFLT
507         #echo "Filtering slave results..."
508         . $LDIFFILTER < "${SLAVEOUT}.4" > $SLAVEFLT
509
510         echo "$CHECK - Comparing retrieved entries from master and slave..."
511         $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
512
513         if test $? != 0 ; then
514                 echo "test failed - master and slave databases differ"
515                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
516                 exit 1
517         fi
518 fi
519
520 echo "Stopping consumer to test recovery..."
521 kill -HUP $SLAVEPID
522 wait $SLAVEPID
523
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
528 changetype: modify
529 add: drink
530 drink: Mad Dog 20/20
531
532 EOMODS
533
534 SLEEP=10
535 echo "Waiting $SLEEP seconds for syncrepl to retry..."
536 sleep $SLEEP
537
538 echo "Restarting consumer..."
539 echo "======================= RESTART =======================" >> $LOG2
540 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
541 SLAVEPID=$!
542 if test $WAIT != 0 ; then
543     echo SLAVEPID $SLAVEPID
544     read foo
545 fi
546 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
547
548 SLEEP=25
549 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
550 sleep $SLEEP
551
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
556 RC=$?
557
558 if test $RC != 0 ; then
559         echo "ldapsearch failed at master ($RC)!"
560         test $KILLSERVERS != no && kill -HUP $KILLPIDS
561         exit $RC
562 fi
563
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
567 RC=$?
568
569 if test $RC != 0 ; then
570         echo "ldapsearch failed at slave ($RC)!"
571         test $KILLSERVERS != no && kill -HUP $KILLPIDS
572         exit $RC
573 fi
574
575 #echo "Filtering master results..."
576 . $LDIFFILTER < "${MASTEROUT}.5" > $MASTERFLT
577 #echo "Filtering slave results..."
578 . $LDIFFILTER < "${SLAVEOUT}.5" > $SLAVEFLT
579
580 echo "$CHECK - Comparing retrieved entries from master and slave..."
581 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
582
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
587         exit 1
588
589         # keep alive - in case we need it again
590         echo "  Stopping proxy to see if it auto-recovers..."
591         kill -HUP $PROXYPID
592         wait $PROXYPID
593
594         echo "  Restarting proxy..."
595         echo "======================= RESTART =======================" >> $LOG3
596         $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
597         PROXYPID=$!
598         if test $WAIT != 0 ; then
599                 echo PROXYPID $PROXYPID
600                 read foo
601         fi
602         KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
603
604         SLEEP=15
605         echo "  Waiting $SLEEP seconds for syncrepl to receive changes..."
606         sleep $SLEEP
607
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
611         RC=$?
612
613         if test $RC != 0 ; then
614                 echo "  ldapsearch failed at slave ($RC)!"
615                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
616                 exit $RC
617         fi
618
619         #echo "Filtering slave results..."
620         . $LDIFFILTER < "${SLAVEOUT}.5.1" > $SLAVEFLT
621
622         echo "  ${CHECK}.1 - Comparing retrieved entries from master and slave..."
623         $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
624
625         if test $? != 0 ; then
626                 echo "  test failed - master and slave databases differ"
627                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
628                 exit 1
629         fi
630 fi
631
632 #
633 # Modifications known to fail
634 #
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
640 changetype: modify
641 delete: drink
642 drink: Mad Dog 20/20
643
644 # From now on, perform modifications that are known to fail
645 dn: cn=All Staff,ou=Groups,dc=example,dc=com
646 changetype: modify
647 delete: description
648
649 EOMODS
650
651 RC=$?
652 if test $RC != 0 ; then
653         echo "ldapmodify failed ($RC)!"
654         test $KILLSERVERS != no && kill -HUP $KILLPIDS
655         exit $RC
656 fi
657
658 SLEEP=15
659 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
660 sleep $SLEEP
661
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
666 RC=$?
667
668 if test $RC != 0 ; then
669         echo "ldapsearch failed at master ($RC)!"
670         test $KILLSERVERS != no && kill -HUP $KILLPIDS
671         exit $RC
672 fi
673
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
677 RC=$?
678
679 if test $RC != 0 ; then
680         echo "ldapsearch failed at slave ($RC)!"
681         test $KILLSERVERS != no && kill -HUP $KILLPIDS
682         exit $RC
683 fi
684
685 #echo "Filtering master results..."
686 . $LDIFFILTER < "${MASTEROUT}.6" > $MASTERFLT
687 #echo "Filtering slave results..."
688 . $LDIFFILTER < "${SLAVEOUT}.6" > $SLAVEFLT
689
690 echo "$CHECK - Comparing retrieved entries from master and slave..."
691 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
692
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
697         #exit 1
698 fi
699
700 test $KILLSERVERS != no && kill -HUP $KILLPIDS
701
702 echo ">>>>> Test succeeded"
703
704 test $KILLSERVERS != no && wait
705
706 exit 0