]> git.sur5r.net Git - openldap/blob - tests/scripts/sql-test901-syncrepl
f8429c584d686cbf04771a57b912fbec25130553
[openldap] / tests / scripts / sql-test901-syncrepl
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2016 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 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 if test $BACKSQL = "sqlno" ; then 
20         echo "SQL backend not available, test skipped"
21         exit 0
22 fi 
23
24 if test $RDBMS = "rdbmsno" ; then
25         echo "SQL test not requested, test skipped"
26         exit 0
27 fi
28
29 if test "${RDBMSWRITE}" != "yes"; then
30         echo "write test disabled for ${RDBMS}; set SLAPD_USE_SQLWRITE=yes to enable"
31         exit 0
32 fi
33
34 mkdir -p $TESTDIR $DBDIR2A
35
36 echo "Starting slapd on TCP/IP port $PORT1..."
37 . $CONFFILTER $BACKEND $MONITORDB < $SQLSRMASTERCONF > $CONF1
38 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
39 PID=$!
40 if test $WAIT != 0 ; then
41     echo PID $PID
42     read foo
43 fi
44 KILLPIDS="$PID"
45
46 echo "Testing SQL backend write operations..."
47 for i in 0 1 2 3 4 5; do
48         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
49                 'objectclass=*' > /dev/null 2>&1
50         RC=$?
51         if test $RC = 0 ; then
52                 break
53         fi
54         echo "Waiting 5 seconds for slapd to start..."
55         sleep 5
56 done
57
58 if test $RC != 0 ; then
59         echo "ldapsearch failed ($RC)!"
60         test $KILLSERVERS != no && kill -HUP $KILLPIDS
61         exit $RC
62 fi
63
64 echo "Starting slave slapd on TCP/IP port $PORT2..."
65 . $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $CONF2
66 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
67 SLAVEPID=$!
68 if test $WAIT != 0 ; then
69     echo SLAVEPID $SLAVEPID
70     read foo
71 fi
72 KILLPIDS="$KILLPIDS $SLAVEPID"
73
74 echo "Using ldapsearch to check that slave slapd is running..."
75 for i in 0 1 2 3 4 5; do
76         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
77                 'objectclass=*' > /dev/null 2>&1
78         RC=$?
79         if test $RC = 0 ; then
80                 break
81         fi
82         echo "Waiting 5 seconds for slapd to start..."
83         sleep 5
84 done
85
86 if test $RC != 0 ; then
87         echo "ldapsearch failed ($RC)!"
88         test $KILLSERVERS != no && kill -HUP $KILLPIDS
89         exit $RC
90 fi
91
92 cat /dev/null > $SEARCHOUT
93
94 echo "Using ldapsearch to retrieve all the entries from the master..."
95 echo "# Using ldapsearch to retrieve all the entries from the master..." \
96         >> $SEARCHOUT
97 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
98         -D "$MANAGERDN" -w $PASSWD \
99          "(!(objectClass=referral))" >> $SEARCHOUT 2>&1
100
101 RC=$?
102 if test $RC != 0 ; then
103         echo "ldapsearch failed ($RC)!"
104         test $KILLSERVERS != no && kill -HUP $KILLPIDS
105         exit $RC
106 fi
107
108 cat /dev/null > $SEARCHOUT2
109
110 echo "Using ldapsearch to retrieve all the entries from the slave..."
111 echo "# Using ldapsearch to retrieve all the entries from the slave..." \
112         >> $SEARCHOUT2
113 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT2 -b "$BASEDN" \
114         -D "$UPDATEDN" -w $PASSWD \
115          "(objectClass=*)" >> $SEARCHOUT2 2>&1
116
117 RC=$?
118 if test $RC != 0 ; then
119         echo "ldapsearch failed ($RC)!"
120         test $KILLSERVERS != no && kill -HUP $KILLPIDS
121         exit $RC
122 fi
123
124 echo "Filtering ldapsearch results from master..."
125 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
126 echo "Filtering ldapsearch results from slave..."
127 $LDIFFILTER < $SEARCHOUT2 > $SEARCHFLT2
128 echo "Comparing filter output..."
129 $CMP $SEARCHFLT $SEARCHFLT2 > $CMPOUT
130
131 if test $? != 0 ; then
132         echo "Comparison failed"
133         test $KILLSERVERS != no && kill -HUP $KILLPIDS
134         exit 1
135 fi
136
137 cat /dev/null > $SEARCHOUT
138
139 echo "Using ldapsearch to retrieve all the entries..."
140 echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
141 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
142          "objectClass=*" >> $SEARCHOUT 2>&1
143
144 RC=$?
145 if test $RC != 0 ; then
146         echo "ldapsearch failed ($RC)!"
147         test $KILLSERVERS != no && kill -HUP $KILLPIDS
148         exit $RC
149 fi
150
151 case ${RDBMS} in
152         # list here the RDBMSes whose mapping allows writes
153 pgsql|ibmdb2)
154         MANAGERDN="cn=Manager,${BASEDN}"
155         echo "Testing add..."
156         $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
157                 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
158 version: 1
159
160 # Adding an organization...
161 dn: o=An Org,${BASEDN}
162 changetype: add
163 objectClass: organization
164 o: An Org
165
166 # Adding an organization with an "auxiliary" objectClass..
167 dn: dc=subnet,${BASEDN}
168 changetype: add
169 objectClass: organization
170 objectClass: dcObject
171 o: SubNet
172 dc: subnet
173
174 # Adding another organization with an "auxiliary" objectClass..
175 dn: dc=subnet2,${BASEDN}
176 changetype: add
177 objectClass: organization
178 objectClass: dcObject
179 o: SubNet 2
180 dc: subnet2
181
182 # Adding a person...
183 dn: cn=Lev Tolstoij,${BASEDN}
184 changetype: add
185 objectClass: inetOrgPerson
186 cn: Lev Tolstoij
187 sn: Tolstoij
188 givenName: Lev
189 telephoneNumber: +39 02 XXXX YYYY
190 telephoneNumber: +39 02 XXXX ZZZZ
191 userPassword: tanja
192
193 # Adding a person with an "auxiliary" objectClass...
194 dn: cn=Some One,${BASEDN}
195 changetype: add
196 objectClass: inetOrgPerson
197 objectClass: simpleSecurityObject
198 cn: Some One
199 sn: One
200 givenName: Some
201 telephoneNumber: +1 800 900 1234
202 telephoneNumber: +1 800 900 1235
203 userPassword: someone
204
205 # Adding a person in another subtree...
206 dn: cn=SubNet User,dc=subnet,${BASEDN}
207 changetype: add
208 objectClass: inetOrgPerson
209 cn: SubNet User
210 sn: User
211 givenName: SubNet
212
213 # Adding a document...
214 dn: documentTitle=War and Peace,${BASEDN}
215 changetype: add
216 objectClass: document
217 description: Historical novel
218 documentTitle: War and Peace
219 documentAuthor: cn=Lev Tolstoij,dc=example,dc=com
220 documentIdentifier: document 3
221 EOMODS
222
223         RC=$?
224         if test $RC != 0 ; then
225                 echo "ldapmodify failed ($RC)!"
226                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
227                 exit $RC
228         fi
229
230         echo "Using ldapsearch to retrieve all the entries..."
231         echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
232         $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
233                  "objectClass=*" >> $SEARCHOUT 2>&1
234
235         RC=$?
236         if test $RC != 0 ; then
237                 echo "ldapsearch failed ($RC)!"
238                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
239                 exit $RC
240         fi
241
242         echo "Testing modify..."
243         $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
244                 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
245 version: 1
246
247 # Deleting all telephone numbers...
248 dn: cn=Some One,${BASEDN}
249 changetype: modify
250 delete: telephoneNumber
251 -
252
253 # Adding a telephone number...
254 dn: cn=Mitya Kovalev,${BASEDN}
255 changetype: modify
256 add: telephoneNumber
257 telephoneNumber: +1 800 123 4567
258 -
259
260 # Deleting a specific telephone number and adding a new one...
261 dn: cn=Lev Tolstoij,${BASEDN}
262 changetype: modify
263 delete: telephoneNumber
264 telephoneNumber: +39 02 XXXX YYYY
265 -
266 add: telephoneNumber
267 telephoneNumber: +39 333 ZZZ 1234
268 -
269
270 # Adding an author to a document...
271 dn: documentTitle=book1,${BASEDN}
272 changetype: modify
273 add: documentAuthor
274 documentAuthor: cn=Lev Tolstoij,${BASEDN}
275 -
276
277 # Adding an author to another document...
278 dn: documentTitle=book2,${BASEDN}
279 changetype: modify
280 add: documentAuthor
281 documentAuthor: cn=Lev Tolstoij,${BASEDN}
282 -
283
284 # Adding an "auxiliary" objectClass...
285 dn: cn=Mitya Kovalev,${BASEDN}
286 changetype: modify
287 add: objectClass
288 objectClass: simpleSecurityObject
289 -
290
291 # Deleting an "auxiliary" objectClass...
292 dn: cn=Some One,${BASEDN}
293 changetype: modify
294 delete: objectClass
295 objectClass: simpleSecurityObject
296 -
297
298 # Deleting userPasswords
299 dn: cn=Lev Tolstoij,${BASEDN}
300 changetype: modify
301 delete: userPassword
302 -
303 EOMODS
304
305         RC=$?
306         if test $RC != 0 ; then
307                 echo "ldapmodify failed ($RC)!"
308                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
309                 exit $RC
310         fi
311
312         echo "Using ldapsearch to retrieve all the entries..."
313         echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
314         $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
315                  "objectClass=*" >> $SEARCHOUT 2>&1
316
317         RC=$?
318         if test $RC != 0 ; then
319                 echo "ldapsearch failed ($RC)!"
320                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
321                 exit $RC
322         fi
323
324         echo "Testing delete..."
325         $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
326                 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
327 version: 1
328
329 # Deleting a person...
330 dn: cn=Torvlobnor Puzdoy,${BASEDN}
331 changetype: delete
332
333 # Deleting a document...
334 dn: documentTitle=book1,${BASEDN}
335 changetype: delete
336
337 # Deleting an organization with an "auxiliary" objectClass...
338 dn: dc=subnet2,${BASEDN}
339 changetype: delete
340 EOMODS
341
342         RC=$?
343         if test $RC != 0 ; then
344                 echo "ldapmodify failed ($RC)!"
345                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
346                 exit $RC
347         fi
348
349         echo "Using ldapsearch to retrieve all the entries..."
350         echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
351         $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
352                  "objectClass=*" >> $SEARCHOUT 2>&1
353
354         RC=$?
355         if test $RC != 0 ; then
356                 echo "ldapsearch failed ($RC)!"
357                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
358                 exit $RC
359         fi
360
361         echo "Testing rename..."
362         $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
363                 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
364 version: 1
365
366 # Renaming an organization...
367 dn: o=An Org,${BASEDN}
368 changetype: modrdn
369 newrdn: o=Renamed Org
370 deleteoldrdn: 1
371
372 # Moving a person to another subtree...
373 dn: cn=Lev Tolstoij,${BASEDN}
374 changetype: modrdn
375 newrdn: cn=Lev Tolstoij
376 deleteoldrdn: 0
377 newsuperior: dc=subnet,${BASEDN}
378
379 # Renaming a book...
380 dn: documentTitle=book2,${BASEDN}
381 changetype: modrdn
382 newrdn: documentTitle=Renamed Book
383 deleteoldrdn: 1
384 EOMODS
385
386         RC=$?
387         if test $RC != 0 ; then
388                 echo "ldapmodify failed ($RC)!"
389                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
390                 exit $RC
391         fi
392
393         echo "Using ldapsearch to retrieve all the entries..."
394         echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
395         $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
396                  "objectClass=*" >> $SEARCHOUT 2>&1
397
398         RC=$?
399         if test $RC != 0 ; then
400                 echo "ldapsearch failed ($RC)!"
401                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
402                 exit $RC
403         fi
404
405         echo "Adding a child to a referral (should fail)..."
406         $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
407                 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
408 version: 1
409
410 dn: cn=Should Fail,ou=Referral,${BASEDN}
411 changetype: add
412 objectClass: inetOrgPerson
413 cn: Should Fail
414 sn: Fail
415 telephoneNumber: +39 02 23456789
416 EOMODS
417
418         RC=$?
419         if test $RC = 0 ; then
420                 echo "ldapmodify should have failed ($RC)!"
421                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
422                 exit 1
423         fi
424
425         echo "Modifying a referral (should fail)..."
426         $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
427                 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
428 version: 1
429
430 dn: ou=Referral,${BASEDN}
431 changetype: modify
432 replace: ref
433 ref: ldap://localhost:9009/
434 -
435 EOMODS
436
437         RC=$?
438         if test $RC = 0 ; then
439                 echo "ldapmodify should have failed ($RC)!"
440                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
441                 exit 1
442         fi
443
444         echo "Renaming a referral (should fail)..."
445         $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
446                 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
447 version: 1
448
449 dn: ou=Referral,${BASEDN}
450 changetype: modrdn
451 newrdn: ou=Renamed Referral
452 deleteoldrdn: 1
453 EOMODS
454
455         RC=$?
456         if test $RC = 0 ; then
457                 echo "ldapmodify should have failed ($RC)!"
458                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
459                 exit 1
460         fi
461
462         echo "Deleting a referral (should fail)..."
463         $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
464                 -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS
465 version: 1
466
467 dn: ou=Referral,${BASEDN}
468 changetype: delete
469 EOMODS
470
471         RC=$?
472         if test $RC = 0 ; then
473                 echo "ldapmodify should have failed ($RC)!"
474                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
475                 exit 1
476         fi
477
478         echo "Adding a referral..."
479         $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
480                 -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS
481 version: 1
482
483 dn: ou=Another Referral,${BASEDN}
484 changetype: add
485 objectClass: referral
486 objectClass: extensibleObject
487 ou: Another Referral
488 ref: ldap://localhost:9009/
489 EOMODS
490
491         RC=$?
492         if test $RC != 0 ; then
493                 echo "ldapmodify failed ($RC)!"
494                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
495                 exit $RC
496         fi
497
498         echo "Modifying a referral with manageDSAit..."
499         $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
500                 -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS
501 version: 1
502
503 dn: ou=Referral,${BASEDN}
504 changetype: modify
505 replace: ref
506 ref: ldap://localhost:9009/
507 -
508 EOMODS
509
510         RC=$?
511         if test $RC != 0 ; then
512                 echo "ldapmodify failed ($RC)!"
513                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
514                 exit $RC
515         fi
516
517         echo "Using ldapsearch to retrieve the modified entry..."
518         echo "# Using ldapsearch to retrieve the modified entry..." >> $SEARCHOUT
519         $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "ou=Referral,$BASEDN" -M \
520                  "objectClass=*" '*' ref >> $SEARCHOUT 2>&1
521
522         RC=$?
523         if test $RC != 0 ; then
524                 echo "ldapsearch failed ($RC)!"
525                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
526                 exit $RC
527         fi
528
529         echo "Renaming a referral with manageDSAit..."
530         $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
531                 -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS
532 version: 1
533
534 dn: ou=Referral,${BASEDN}
535 changetype: modrdn
536 newrdn: ou=Renamed Referral
537 deleteoldrdn: 1
538 EOMODS
539
540         RC=$?
541         if test $RC != 0 ; then
542                 echo "ldapmodify failed ($RC)!"
543                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
544                 exit $RC
545         fi
546
547         echo "Using ldapsearch to retrieve the renamed entry..."
548         echo "# Using ldapsearch to retrieve the renamed entry..." >> $SEARCHOUT
549         $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "ou=Renamed Referral,$BASEDN" -M \
550                  "objectClass=*" '*' ref >> $SEARCHOUT 2>&1
551
552         RC=$?
553         if test $RC != 0 ; then
554                 echo "ldapsearch failed ($RC)!"
555                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
556                 exit $RC
557         fi
558
559         echo "Deleting a referral with manageDSAit..."
560         $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
561                 -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS
562 version: 1
563
564 dn: ou=Renamed Referral,${BASEDN}
565 changetype: delete
566 EOMODS
567
568         RC=$?
569         if test $RC != 0 ; then
570                 echo "ldapmodify failed ($RC)!"
571                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
572                 exit $RC
573         fi
574
575         BINDDN="cn=Mitya Kovalev,${BASEDN}"
576         BINDPW="mit"
577         NEWPW="newsecret"
578         echo "Testing passwd change..."
579         $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
580                 -D "${BINDDN}" -w ${BINDPW} -s ${NEWPW} \
581                 "$BINDDN" >> $TESTOUT 2>&1
582
583         RC=$?
584         if test $RC != 0 ; then
585                 echo "ldappasswd failed ($RC)!"
586                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
587                 exit $RC
588         fi
589
590         echo -n "Testing bind with new secret... "
591         $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w $NEWPW
592         RC=$?
593         if test $RC != 0 ; then
594                 echo "ldapwhoami failed ($RC)!"
595                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
596                 exit $RC
597         fi
598
599         BINDDN="cn=Some One,${BASEDN}"
600         BINDPW="someone"
601         echo -n "Testing bind with newly added user... "
602         $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w $BINDPW
603         RC=$?
604         if test $RC != 0 ; then
605                 echo "ldapwhoami failed ($RC)!"
606                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
607                 exit $RC
608         fi
609
610         echo "Using ldapsearch to retrieve all the entries..."
611         echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
612         $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
613                  "objectClass=*" >> $SEARCHOUT 2>&1
614
615         RC=$?
616         if test $RC != 0 ; then
617                 echo "ldapsearch failed ($RC)!"
618                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
619                 exit $RC
620         fi
621
622         echo "Filtering ldapsearch results..."
623         $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
624         echo "Filtering modified ldif..."
625         $LDIFFILTER < $SQLWRITE > $LDIFFLT
626         echo "Comparing filter output..."
627         $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
628
629         if test $? != 0 ; then
630                 echo "comparison failed - SQL mods search didn't succeed"
631                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
632                 exit 1
633         fi
634
635         echo "Waiting 25 seconds for master to send changes..."
636         sleep 25
637
638         cat /dev/null > $SEARCHOUT
639
640         echo "Using ldapsearch to retrieve all the entries from the master..."
641         echo "# Using ldapsearch to retrieve all the entries from the master..." \
642                 >> $SEARCHOUT
643         $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
644                 -D "$MANAGERDN" -w $PASSWD \
645                  "(!(objectClass=referral))" >> $SEARCHOUT 2>&1
646
647         RC=$?
648         if test $RC != 0 ; then
649                 echo "ldapsearch failed ($RC)!"
650                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
651                 exit $RC
652         fi
653
654         cat /dev/null > $SEARCHOUT2
655
656         echo "Using ldapsearch to retrieve all the entries from the slave..."
657         echo "# Using ldapsearch to retrieve all the entries from the slave..." \
658                 >> $SEARCHOUT2
659         $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT2 -b "$BASEDN" \
660                 -D "$UPDATEDN" -w $PASSWD \
661                  "(objectClass=*)" >> $SEARCHOUT2 2>&1
662
663         RC=$?
664         if test $RC != 0 ; then
665                 echo "ldapsearch failed ($RC)!"
666                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
667                 exit $RC
668         fi
669
670         echo "Filtering ldapsearch results from master..."
671         $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
672         echo "Filtering ldapsearch results from slave..."
673         $LDIFFILTER < $SEARCHOUT2 > $SEARCHFLT2
674         echo "Comparing filter output..."
675         $CMP $SEARCHFLT $SEARCHFLT2 > $CMPOUT
676
677         if test $? != 0 ; then
678                 echo "Comparison failed"
679                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
680                 exit 1
681         fi
682         ;;
683
684 *)
685         echo "apparently ${RDBMS} does not support writes; skipping..."
686         ;;
687 esac
688
689 test $KILLSERVERS != no && kill -HUP $KILLPIDS
690
691 echo ">>>>> Test succeeded"
692 exit 0