]> git.sur5r.net Git - openldap/blob - tests/scripts/test045-syncreplication-proxied
Happy new year!
[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 sleep $SLEEP
221
222 echo "======================= RESTART =======================" >> $LOG1
223 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
224 MASTERPID=$!
225 if test $WAIT != 0 ; then
226     echo MASTERPID $MASTERPID
227     read foo
228 fi
229 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
230
231 sleep 1
232
233 echo "Using ldapsearch to check that master slapd is running..."
234 for i in 0 1 2 3 4 5; do
235         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
236                 '(objectClass=*)' > /dev/null 2>&1
237         RC=$?
238         if test $RC = 0 ; then
239                 break
240         fi
241         echo "Waiting 5 seconds for slapd to start..."
242         sleep 5
243 done
244
245 if test $RC != 0 ; then
246         echo "ldapsearch failed ($RC)!"
247         test $KILLSERVERS != no && kill -HUP $KILLPIDS
248         exit $RC
249 fi
250
251 echo "Using ldapmodify to modify master directory..."
252
253 #
254 # Do some modifications
255 #
256
257 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
258         $TESTOUT 2>&1 << EOMODS
259 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
260 changetype: modify
261 add: drink
262 drink: Orange Juice
263 -
264 delete: sn
265 sn: Jones
266 -
267 add: sn
268 sn: Jones
269
270 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
271 changetype: modify
272 replace: drink
273 drink: Iced Tea
274
275 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
276 changetype: modify
277 delete: uniquemember
278 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
279 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
280 -
281 add: uniquemember
282 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
283 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
284
285 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
286  =com
287 changetype: modify
288 delete: cn
289 cn: Biiff Jensen
290
291 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
292 changetype: add
293 objectclass: OpenLDAPperson
294 cn: Gern Jensen
295 sn: Jensen
296 uid: gjensen
297 title: Chief Investigator, ITD
298 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
299 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
300 drink: Coffee
301 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
302 description: Very odd
303 facsimiletelephonenumber: +1 313 555 7557
304 telephonenumber: +1 313 555 8343
305 mail: gjensen@mailgw.example.com
306 homephone: +1 313 555 8844
307
308 dn: ou=Retired, ou=People, dc=example,dc=com
309 changetype: add
310 objectclass: organizationalUnit
311 ou: Retired
312
313 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
314 changetype: add
315 objectclass: OpenLDAPperson
316 cn: Rosco P. Coltrane
317 sn: Coltrane
318 uid: rosco
319 description: Fat tycoon
320
321 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
322 changetype: modrdn
323 newrdn: cn=Rosco P. Coltrane
324 deleteoldrdn: 1
325 newsuperior: ou=Retired, ou=People, dc=example,dc=com
326
327 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
328 changetype: delete
329 EOMODS
330
331 RC=$?
332 if test $RC != 0 ; then
333         echo "ldapmodify failed ($RC)!"
334         test $KILLSERVERS != no && kill -HUP $KILLPIDS
335         exit $RC
336 fi
337
338 SLEEP=15
339 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
340 sleep $SLEEP
341
342 CHECK=`expr $CHECK + 1`
343 #echo "Using ldapsearch to read all the entries from the master..."
344 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
345         '(objectClass=*)' > "${MASTEROUT}.2" 2>&1
346 RC=$?
347
348 if test $RC != 0 ; then
349         echo "ldapsearch failed at master ($RC)!"
350         test $KILLSERVERS != no && kill -HUP $KILLPIDS
351         exit $RC
352 fi
353
354 #echo "Using ldapsearch to read all the entries from the slave..."
355 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
356         '(objectClass=*)' > "${SLAVEOUT}.2" 2>&1
357 RC=$?
358
359 if test $RC != 0 ; then
360         echo "ldapsearch failed at slave ($RC)!"
361         test $KILLSERVERS != no && kill -HUP $KILLPIDS
362         exit $RC
363 fi
364
365 #echo "Filtering master results..."
366 . $LDIFFILTER < "${MASTEROUT}.2" > $MASTERFLT
367 #echo "Filtering slave results..."
368 . $LDIFFILTER < "${SLAVEOUT}.2" > $SLAVEFLT
369
370 echo "$CHECK - Comparing retrieved entries from master and slave..."
371 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
372
373 if test $? != 0 ; then
374         echo "test failed - master and slave databases differ"
375         test $KILLSERVERS != no && kill -HUP $KILLPIDS
376         exit 1
377 fi
378
379 SLEEP=10
380 echo "Stopping proxy to test recovery; sleep for $SLEEP seconds..."
381 kill -HUP $PROXYPID
382 sleep $SLEEP
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 SLEEP=10
521 echo "Stopping consumer to test recovery; wait $SLEEP seconds..."
522 kill -HUP $SLAVEPID
523 sleep $SLEEP
524
525 echo "Modifying more entries on the master..."
526 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
527         $TESTOUT 2>&1 << EOMODS
528 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
529 changetype: modify
530 add: drink
531 drink: Mad Dog 20/20
532
533 EOMODS
534
535 echo "Restarting consumer..."
536 echo "======================= RESTART =======================" >> $LOG2
537 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
538 SLAVEPID=$!
539 if test $WAIT != 0 ; then
540     echo SLAVEPID $SLAVEPID
541     read foo
542 fi
543 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
544
545 SLEEP=25
546 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
547 sleep $SLEEP
548
549 CHECK=`expr $CHECK + 1`
550 #echo "Using ldapsearch to read all the entries from the master..."
551 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
552         '(objectClass=*)' > "${MASTEROUT}.5" 2>&1
553 RC=$?
554
555 if test $RC != 0 ; then
556         echo "ldapsearch failed at master ($RC)!"
557         test $KILLSERVERS != no && kill -HUP $KILLPIDS
558         exit $RC
559 fi
560
561 #echo "Using ldapsearch to read all the entries from the slave..."
562 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
563         '(objectClass=*)' > "${SLAVEOUT}.5" 2>&1
564 RC=$?
565
566 if test $RC != 0 ; then
567         echo "ldapsearch failed at slave ($RC)!"
568         test $KILLSERVERS != no && kill -HUP $KILLPIDS
569         exit $RC
570 fi
571
572 #echo "Filtering master results..."
573 . $LDIFFILTER < "${MASTEROUT}.5" > $MASTERFLT
574 #echo "Filtering slave results..."
575 . $LDIFFILTER < "${SLAVEOUT}.5" > $SLAVEFLT
576
577 echo "$CHECK - Comparing retrieved entries from master and slave..."
578 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
579
580 if test $? != 0 ; then
581         echo "  test failed - master and slave databases differ (ignored by now)"
582         #echo "test failed - master and slave databases differ"
583         #test $KILLSERVERS != no && kill -HUP $KILLPIDS
584         #exit 1
585
586         SLEEP=10
587         echo "  Stopping proxy to see if it auto-recovers; sleep for $SLEEP seconds..."
588         kill -HUP $PROXYPID
589         sleep $SLEEP
590
591         echo "  Restarting proxy..."
592         echo "======================= RESTART =======================" >> $LOG3
593         $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
594         PROXYPID=$!
595         if test $WAIT != 0 ; then
596                 echo PROXYPID $PROXYPID
597                 read foo
598         fi
599         KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
600
601         SLEEP=15
602         echo "  Waiting $SLEEP seconds for syncrepl to receive changes..."
603         sleep $SLEEP
604
605         #echo "Using ldapsearch to read all the entries from the slave..."
606         $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
607                 '(objectClass=*)' > "${SLAVEOUT}.5.1" 2>&1
608         RC=$?
609
610         if test $RC != 0 ; then
611                 echo "  ldapsearch failed at slave ($RC)!"
612                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
613                 exit $RC
614         fi
615
616         #echo "Filtering slave results..."
617         . $LDIFFILTER < "${SLAVEOUT}.5.1" > $SLAVEFLT
618
619         echo "  ${CHECK}.1 - Comparing retrieved entries from master and slave..."
620         $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
621
622         if test $? != 0 ; then
623                 echo "  test failed - master and slave databases differ"
624                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
625                 exit 1
626         fi
627 fi
628
629 #
630 # Modifications known to fail
631 #
632 echo "(DEVEL) Performing modifications that are known to fail..."
633 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
634         $TESTOUT 2>&1 << EOMODS
635 # First, back out previous change
636 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
637 changetype: modify
638 delete: drink
639 drink: Mad Dog 20/20
640
641 # From now on, perform modifications that are known to fail
642 dn: cn=All Staff,ou=Groups,dc=example,dc=com
643 changetype: modify
644 delete: description
645
646 EOMODS
647
648 RC=$?
649 if test $RC != 0 ; then
650         echo "ldapmodify failed ($RC)!"
651         test $KILLSERVERS != no && kill -HUP $KILLPIDS
652         exit $RC
653 fi
654
655 SLEEP=15
656 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
657 sleep $SLEEP
658
659 CHECK=`expr $CHECK + 1`
660 #echo "Using ldapsearch to read all the entries from the master..."
661 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
662         '(objectClass=*)' > "${MASTEROUT}.6" 2>&1
663 RC=$?
664
665 if test $RC != 0 ; then
666         echo "ldapsearch failed at master ($RC)!"
667         test $KILLSERVERS != no && kill -HUP $KILLPIDS
668         exit $RC
669 fi
670
671 #echo "Using ldapsearch to read all the entries from the slave..."
672 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
673         '(objectClass=*)' > "${SLAVEOUT}.6" 2>&1
674 RC=$?
675
676 if test $RC != 0 ; then
677         echo "ldapsearch failed at slave ($RC)!"
678         test $KILLSERVERS != no && kill -HUP $KILLPIDS
679         exit $RC
680 fi
681
682 #echo "Filtering master results..."
683 . $LDIFFILTER < "${MASTEROUT}.6" > $MASTERFLT
684 #echo "Filtering slave results..."
685 . $LDIFFILTER < "${SLAVEOUT}.6" > $SLAVEFLT
686
687 echo "$CHECK - Comparing retrieved entries from master and slave..."
688 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
689
690 if test $? != 0 ; then
691         echo "test failed - master and slave databases differ (ignored by now)"
692         #echo "test failed - master and slave databases differ"
693         #test $KILLSERVERS != no && kill -HUP $KILLPIDS
694         #exit 1
695 fi
696
697 test $KILLSERVERS != no && kill -HUP $KILLPIDS
698
699 echo ">>>>> Test succeeded"
700 exit 0