]> git.sur5r.net Git - openldap/blob - tests/scripts/test045-syncreplication-proxied
further improve test
[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-2005 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 if test x"$PROXYSYNC" = x ; then
22         echo "Test disabled; set PROXYSYNC=yes to enable"
23         exit 0
24 fi
25
26 echo "running defines.sh"
27 . $SRCDIR/scripts/defines.sh
28
29 if test $BACKLDAP = ldapno; then 
30         echo "LDAP backend not available, test skipped"
31         exit 0
32 fi 
33
34 if test $SYNCPROV = syncprovno; then 
35         echo "Syncrepl provider overlay not available, test skipped"
36         exit 0
37 fi 
38
39 if test $MONITORDB = no; then 
40         echo "Monitor backend not available, test skipped"
41         exit 0
42 fi 
43
44 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
45
46 #
47 # Test replication:
48 # - start master
49 # - start slave
50 # - populate over ldap
51 # - perform some modifies and deleted
52 # - attempt to modify the slave (referral or chain)
53 # - retrieve database over ldap and compare against expected results
54 #
55
56 echo "Starting master slapd on TCP/IP port $PORT1..."
57 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
58 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
59 MASTERPID=$!
60 if test $WAIT != 0 ; then
61     echo MASTERPID $MASTERPID
62     read foo
63 fi
64 KILLPIDS="$MASTERPID"
65
66 sleep 1
67
68 echo "Using ldapsearch to check that master slapd is running..."
69 for i in 0 1 2 3 4 5; do
70         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
71                 '(objectClass=*)' > /dev/null 2>&1
72         RC=$?
73         if test $RC = 0 ; then
74                 break
75         fi
76         echo "Waiting 5 seconds for slapd to start..."
77         sleep 5
78 done
79
80 if test $RC != 0 ; then
81         echo "ldapsearch failed ($RC)!"
82         test $KILLSERVERS != no && kill -HUP $KILLPIDS
83         exit $RC
84 fi
85
86 echo "Using ldapadd to create the context prefix entry in the master..."
87 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
88         $LDIFORDEREDCP > /dev/null 2>&1
89 RC=$?
90 if test $RC != 0 ; then
91         echo "ldapadd failed ($RC)!"
92         test $KILLSERVERS != no && kill -HUP $KILLPIDS
93         exit $RC
94 fi
95
96 echo "Starting slave slapd on TCP/IP port $PORT2..."
97 . $CONFFILTER $BACKEND $MONITORDB < $RSLAVECONF > $CONF2
98 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
99 SLAVEPID=$!
100 if test $WAIT != 0 ; then
101     echo SLAVEPID $SLAVEPID
102     read foo
103 fi
104 KILLPIDS="$MASTERPID $SLAVEPID"
105
106 sleep 1
107
108 echo "Using ldapsearch to check that slave slapd is running..."
109 for i in 0 1 2 3 4 5; do
110         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
111                 '(objectClass=*)' > /dev/null 2>&1
112         RC=$?
113         if test $RC = 0 ; then
114                 break
115         fi
116         echo "Waiting 5 seconds for slapd to start..."
117         sleep 5
118 done
119
120 if test $RC != 0 ; then
121         echo "ldapsearch failed ($RC)!"
122         test $KILLSERVERS != no && kill -HUP $KILLPIDS
123         exit $RC
124 fi
125
126 echo "Starting proxy slapd on TCP/IP port $PORT3..."
127 . $CONFFILTER $BACKEND $MONITORDB < $PLSRSLAVECONF > $CONF3
128 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
129 PROXYPID=$!
130 if test $WAIT != 0 ; then
131     echo PROXYPID $PROXYPID
132     read foo
133 fi
134 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
135
136 sleep 1
137
138 echo "Using ldapsearch to check that proxy slapd is running..."
139 for i in 0 1 2 3 4 5; do
140         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
141                 '(objectClass=*)' > /dev/null 2>&1
142         RC=$?
143         if test $RC = 0 -o $RC = 53 ; then
144                 break
145         fi
146         echo "Waiting 5 seconds for slapd to start..."
147         sleep 5
148 done
149
150 case $RC in
151 0 )
152         echo "ldapsearch should have failed ($RC)!"
153         test $KILLSERVERS != no && kill -HUP $KILLPIDS
154         exit -1
155         ;;
156 53)
157         ;;
158 *)
159         echo "ldapsearch failed ($RC)!"
160         test $KILLSERVERS != no && kill -HUP $KILLPIDS
161         exit $RC
162         ;;
163 esac
164
165 echo "Using ldapadd to populate the master directory..."
166 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
167         $LDIFORDEREDNOCP > /dev/null 2>&1
168 RC=$?
169 if test $RC != 0 ; then
170         echo "ldapadd failed ($RC)!"
171         test $KILLSERVERS != no && kill -HUP $KILLPIDS
172         exit $RC
173 fi
174
175 SLEEP=15
176 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
177 sleep $SLEEP
178
179 CHECK=1
180 #echo "Using ldapsearch to read all the entries from the master..."
181 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
182         '(objectClass=*)' > "${MASTEROUT}.1" 2>&1
183 RC=$?
184
185 if test $RC != 0 ; then
186         echo "ldapsearch failed at master ($RC)!"
187         test $KILLSERVERS != no && kill -HUP $KILLPIDS
188         exit $RC
189 fi
190
191 #echo "Using ldapsearch to read all the entries from the slave..."
192 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
193         '(objectClass=*)' > "${SLAVEOUT}.1" 2>&1
194 RC=$?
195
196 if test $RC != 0 ; then
197         echo "ldapsearch failed at slave ($RC)!"
198         test $KILLSERVERS != no && kill -HUP $KILLPIDS
199         exit $RC
200 fi
201
202 #echo "Filtering master results..."
203 . $LDIFFILTER < "${MASTEROUT}.1" > $MASTERFLT
204 #echo "Filtering slave results..."
205 . $LDIFFILTER < "${SLAVEOUT}.1" > $SLAVEFLT
206
207 echo "$CHECK - Comparing retrieved entries from master and slave..."
208 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
209
210 if test $? != 0 ; then
211         echo "test failed - master and slave databases differ"
212         test $KILLSERVERS != no && kill -HUP $KILLPIDS
213         exit 1
214 fi
215
216 SLEEP=10
217 echo "Stopping the provider, sleeping $SLEEP seconds and restarting it..."
218 kill -HUP "$MASTERPID"
219 sleep $SLEEP
220
221 echo "======================= RESTART =======================" >> $LOG1
222 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
223 MASTERPID=$!
224 if test $WAIT != 0 ; then
225     echo MASTERPID $MASTERPID
226     read foo
227 fi
228 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
229
230 sleep 1
231
232 echo "Using ldapsearch to check that master slapd is running..."
233 for i in 0 1 2 3 4 5; do
234         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
235                 '(objectClass=*)' > /dev/null 2>&1
236         RC=$?
237         if test $RC = 0 ; then
238                 break
239         fi
240         echo "Waiting 5 seconds for slapd to start..."
241         sleep 5
242 done
243
244 if test $RC != 0 ; then
245         echo "ldapsearch failed ($RC)!"
246         test $KILLSERVERS != no && kill -HUP $KILLPIDS
247         exit $RC
248 fi
249
250 echo "Using ldapmodify to modify master directory..."
251
252 #
253 # Do some modifications
254 #
255
256 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
257         $TESTOUT 2>&1 << EOMODS
258 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
259 changetype: modify
260 add: drink
261 drink: Orange Juice
262 -
263 delete: sn
264 sn: Jones
265 -
266 add: sn
267 sn: Jones
268
269 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
270 changetype: modify
271 replace: drink
272 drink: Iced Tea
273
274 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
275 changetype: modify
276 delete: uniquemember
277 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
278 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
279 -
280 add: uniquemember
281 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
282 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
283
284 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
285  =com
286 changetype: modify
287 delete: cn
288 cn: Biiff Jensen
289
290 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
291 changetype: add
292 objectclass: OpenLDAPperson
293 cn: Gern Jensen
294 sn: Jensen
295 uid: gjensen
296 title: Chief Investigator, ITD
297 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
298 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
299 drink: Coffee
300 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
301 description: Very odd
302 facsimiletelephonenumber: +1 313 555 7557
303 telephonenumber: +1 313 555 8343
304 mail: gjensen@mailgw.example.com
305 homephone: +1 313 555 8844
306
307 dn: ou=Retired, ou=People, dc=example,dc=com
308 changetype: add
309 objectclass: organizationalUnit
310 ou: Retired
311
312 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
313 changetype: add
314 objectclass: OpenLDAPperson
315 cn: Rosco P. Coltrane
316 sn: Coltrane
317 uid: rosco
318 description: Fat tycoon
319
320 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
321 changetype: modrdn
322 newrdn: cn=Rosco P. Coltrane
323 deleteoldrdn: 1
324 newsuperior: ou=Retired, ou=People, dc=example,dc=com
325
326 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
327 changetype: delete
328 EOMODS
329
330 RC=$?
331 if test $RC != 0 ; then
332         echo "ldapmodify failed ($RC)!"
333         test $KILLSERVERS != no && kill -HUP $KILLPIDS
334         exit $RC
335 fi
336
337 SLEEP=15
338 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
339 sleep $SLEEP
340
341 CHECK=`expr $CHECK + 1`
342 #echo "Using ldapsearch to read all the entries from the master..."
343 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
344         '(objectClass=*)' > "${MASTEROUT}.2" 2>&1
345 RC=$?
346
347 if test $RC != 0 ; then
348         echo "ldapsearch failed at master ($RC)!"
349         test $KILLSERVERS != no && kill -HUP $KILLPIDS
350         exit $RC
351 fi
352
353 #echo "Using ldapsearch to read all the entries from the slave..."
354 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
355         '(objectClass=*)' > "${SLAVEOUT}.2" 2>&1
356 RC=$?
357
358 if test $RC != 0 ; then
359         echo "ldapsearch failed at slave ($RC)!"
360         test $KILLSERVERS != no && kill -HUP $KILLPIDS
361         exit $RC
362 fi
363
364 #echo "Filtering master results..."
365 . $LDIFFILTER < "${MASTEROUT}.2" > $MASTERFLT
366 #echo "Filtering slave results..."
367 . $LDIFFILTER < "${SLAVEOUT}.2" > $SLAVEFLT
368
369 echo "$CHECK - Comparing retrieved entries from master and slave..."
370 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
371
372 if test $? != 0 ; then
373         echo "test failed - master and slave databases differ"
374         test $KILLSERVERS != no && kill -HUP $KILLPIDS
375         exit 1
376 fi
377
378 SLEEP=10
379 echo "Stopping proxy to test recovery; sleep for $SLEEP seconds..."
380 kill -HUP $PROXYPID
381 sleep $SLEEP
382
383 echo "Modifying more entries on the master..."
384 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
385         $TESTOUT 2>&1 << EOMODS
386 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
387 changetype: modify
388 add: description
389 description: proxy is down...
390
391 dn: cn=James T. Kirk, ou=Retired, ou=People, dc=example,dc=com
392 changetype: add
393 objectclass: OpenLDAPperson
394 sn: Kirk
395 uid: jtk
396 cn: James T. Kirk
397
398 dn: cn=Tiberius J. Hooker, ou=Retired, ou=People, dc=example,dc=com
399 changetype: add
400 objectclass: OpenLDAPperson
401 sn: Hooker
402 uid: tjh
403 cn: Tiberius J. Hooker
404
405 EOMODS
406
407 echo "Restarting proxy..."
408 echo "======================= RESTART =======================" >> $LOG3
409 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
410 PROXYPID=$!
411 if test $WAIT != 0 ; then
412     echo PROXYPID $PROXYPID
413     read foo
414 fi
415 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
416
417 SLEEP=25
418 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
419 sleep $SLEEP
420
421 CHECK=`expr $CHECK + 1`
422 #echo "Using ldapsearch to read all the entries from the master..."
423 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
424         '(objectClass=*)' > "${MASTEROUT}.3" 2>&1
425 RC=$?
426
427 if test $RC != 0 ; then
428         echo "ldapsearch failed at master ($RC)!"
429         test $KILLSERVERS != no && kill -HUP $KILLPIDS
430         exit $RC
431 fi
432
433 #echo "Using ldapsearch to read all the entries from the slave..."
434 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
435         '(objectClass=*)' > "${SLAVEOUT}.3" 2>&1
436 RC=$?
437
438 if test $RC != 0 ; then
439         echo "ldapsearch failed at slave ($RC)!"
440         test $KILLSERVERS != no && kill -HUP $KILLPIDS
441         exit $RC
442 fi
443
444 #echo "Filtering master results..."
445 . $LDIFFILTER < "${MASTEROUT}.3" > $MASTERFLT
446 #echo "Filtering slave results..."
447 . $LDIFFILTER < "${SLAVEOUT}.3" > $SLAVEFLT
448
449 echo "$CHECK - Comparing retrieved entries from master and slave..."
450 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
451
452 if test $? != 0 ; then
453         echo "test failed - master and slave databases differ"
454         test $KILLSERVERS != no && kill -HUP $KILLPIDS
455         exit 1
456 fi
457
458 if test ! $BACKLDAP = "ldapno" ; then
459         echo "Try updating the slave slapd..."
460         $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
461                 $TESTOUT 2>&1 << EOMODS
462 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
463 changetype: modify
464 add: description
465 description: This write must fail because directed to a shadow context,
466 description: unless the chain overlay is configured appropriately ;)
467
468 EOMODS
469
470         RC=$?
471         if test $RC != 0 ; then
472                 echo "ldapmodify failed ($RC)!"
473                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
474                 exit $RC
475         fi
476
477         SLEEP=15
478         echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
479         sleep $SLEEP
480
481         CHECK=`expr $CHECK + 1`
482         #echo "Using ldapsearch to read all the entries from the master..."
483         $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
484                 '(objectClass=*)' > "${MASTEROUT}.4" 2>&1
485         RC=$?
486
487         if test $RC != 0 ; then
488                 echo "ldapsearch failed at master ($RC)!"
489                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
490                 exit $RC
491         fi
492
493         #echo "Using ldapsearch to read all the entries from the slave..."
494         $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
495         '(objectClass=*)' > "${SLAVEOUT}.4" 2>&1
496         RC=$?
497
498         if test $RC != 0 ; then
499                 echo "ldapsearch failed at slave ($RC)!"
500                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
501                 exit $RC
502         fi
503
504         #echo "Filtering master results..."
505         . $LDIFFILTER < "${MASTEROUT}.4" > $MASTERFLT
506         #echo "Filtering slave results..."
507         . $LDIFFILTER < "${SLAVEOUT}.4" > $SLAVEFLT
508
509         echo "$CHECK - Comparing retrieved entries from master and slave..."
510         $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
511
512         if test $? != 0 ; then
513                 echo "test failed - master and slave databases differ"
514                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
515                 exit 1
516         fi
517 fi
518
519 SLEEP=10
520 echo "Stopping consumer to test recovery; wait $SLEEP seconds..."
521 kill -HUP $SLAVEPID
522 sleep $SLEEP
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 echo "Restarting consumer..."
535 echo "======================= RESTART =======================" >> $LOG2
536 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
537 SLAVEPID=$!
538 if test $WAIT != 0 ; then
539     echo SLAVEPID $SLAVEPID
540     read foo
541 fi
542 KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
543
544 SLEEP=25
545 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
546 sleep $SLEEP
547
548 CHECK=`expr $CHECK + 1`
549 #echo "Using ldapsearch to read all the entries from the master..."
550 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
551         '(objectClass=*)' > "${MASTEROUT}.5" 2>&1
552 RC=$?
553
554 if test $RC != 0 ; then
555         echo "ldapsearch failed at master ($RC)!"
556         test $KILLSERVERS != no && kill -HUP $KILLPIDS
557         exit $RC
558 fi
559
560 #echo "Using ldapsearch to read all the entries from the slave..."
561 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
562         '(objectClass=*)' > "${SLAVEOUT}.5" 2>&1
563 RC=$?
564
565 if test $RC != 0 ; then
566         echo "ldapsearch failed at slave ($RC)!"
567         test $KILLSERVERS != no && kill -HUP $KILLPIDS
568         exit $RC
569 fi
570
571 #echo "Filtering master results..."
572 . $LDIFFILTER < "${MASTEROUT}.5" > $MASTERFLT
573 #echo "Filtering slave results..."
574 . $LDIFFILTER < "${SLAVEOUT}.5" > $SLAVEFLT
575
576 echo "$CHECK - Comparing retrieved entries from master and slave..."
577 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
578
579 if test $? != 0 ; then
580         echo "  test failed - master and slave databases differ (ignored by now)"
581         #echo "test failed - master and slave databases differ"
582         #test $KILLSERVERS != no && kill -HUP $KILLPIDS
583         #exit 1
584
585         SLEEP=10
586         echo "  Stopping proxy to see if it auto-recovers; sleep for $SLEEP seconds..."
587         kill -HUP $PROXYPID
588         sleep $SLEEP
589
590         echo "  Restarting proxy..."
591         echo "======================= RESTART =======================" >> $LOG3
592         $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
593         PROXYPID=$!
594         if test $WAIT != 0 ; then
595                 echo PROXYPID $PROXYPID
596                 read foo
597         fi
598         KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
599
600         SLEEP=15
601         echo "  Waiting $SLEEP seconds for syncrepl to receive changes..."
602         sleep $SLEEP
603
604         #echo "Using ldapsearch to read all the entries from the slave..."
605         $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
606                 '(objectClass=*)' > "${SLAVEOUT}.5.1" 2>&1
607         RC=$?
608
609         if test $RC != 0 ; then
610                 echo "  ldapsearch failed at slave ($RC)!"
611                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
612                 exit $RC
613         fi
614
615         #echo "Filtering slave results..."
616         . $LDIFFILTER < "${SLAVEOUT}.5.1" > $SLAVEFLT
617
618         echo "  ${CHECK}.1 - Comparing retrieved entries from master and slave..."
619         $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
620
621         if test $? != 0 ; then
622                 echo "  test failed - master and slave databases differ"
623                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
624                 exit 1
625         fi
626 fi
627
628 #
629 # Modifications known to fail
630 #
631 echo "(DEVEL) Performing modifications that are known to fail..."
632 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
633         $TESTOUT 2>&1 << EOMODS
634 # First, back out previous change
635 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
636 changetype: modify
637 delete: drink
638 drink: Mad Dog 20/20
639
640 # From now on, perform modifications that are known to fail
641 dn: cn=All Staff,ou=Groups,dc=example,dc=com
642 changetype: modify
643 delete: description
644
645 EOMODS
646
647 RC=$?
648 if test $RC != 0 ; then
649         echo "ldapmodify failed ($RC)!"
650         test $KILLSERVERS != no && kill -HUP $KILLPIDS
651         exit $RC
652 fi
653
654 SLEEP=15
655 echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
656 sleep $SLEEP
657
658 CHECK=`expr $CHECK + 1`
659 #echo "Using ldapsearch to read all the entries from the master..."
660 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
661         '(objectClass=*)' > "${MASTEROUT}.6" 2>&1
662 RC=$?
663
664 if test $RC != 0 ; then
665         echo "ldapsearch failed at master ($RC)!"
666         test $KILLSERVERS != no && kill -HUP $KILLPIDS
667         exit $RC
668 fi
669
670 #echo "Using ldapsearch to read all the entries from the slave..."
671 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
672         '(objectClass=*)' > "${SLAVEOUT}.6" 2>&1
673 RC=$?
674
675 if test $RC != 0 ; then
676         echo "ldapsearch failed at slave ($RC)!"
677         test $KILLSERVERS != no && kill -HUP $KILLPIDS
678         exit $RC
679 fi
680
681 #echo "Filtering master results..."
682 . $LDIFFILTER < "${MASTEROUT}.6" > $MASTERFLT
683 #echo "Filtering slave results..."
684 . $LDIFFILTER < "${SLAVEOUT}.6" > $SLAVEFLT
685
686 echo "$CHECK - Comparing retrieved entries from master and slave..."
687 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
688
689 if test $? != 0 ; then
690         echo "test failed - master and slave databases differ (ignored by now)"
691         #echo "test failed - master and slave databases differ"
692         #test $KILLSERVERS != no && kill -HUP $KILLPIDS
693         #exit 1
694 fi
695
696 test $KILLSERVERS != no && kill -HUP $KILLPIDS
697
698 echo ">>>>> Test succeeded"
699 exit 0