Debian Codegraph @

tests/scripts/test045-syncreplication-proxied

raw
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2024 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
17 # test now handles known issues
18 #if test x"$PROXYSYNC" = x ; then
19 # echo "Test disabled; set PROXYSYNC=yes to enable"
20 # exit 0
21 #fi
22
23 echo "running defines.sh"
24 . $SRCDIR/scripts/defines.sh
25
26 if test $BACKLDAP = ldapno; then
27 echo "LDAP backend not available, test skipped"
28 exit 0
29 fi
30
31 if test $SYNCPROV = syncprovno; then
32 echo "Syncrepl provider overlay not available, test skipped"
33 exit 0
34 fi
35
36 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
37
38 #
39 # Test replication:
40 # - start provider
41 # - start consumer
42 # - populate over ldap
43 # - perform some modifies and deleted
44 # - attempt to modify the consumer (referral or chain)
45 # - retrieve database over ldap and compare against expected results
46 #
47
48 echo "Starting provider slapd on TCP/IP port $PORT1..."
49 . $CONFFILTER $BACKEND < $SRPROVIDERCONF > $CONF1
50 $SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 &
51 PROVIDERPID=$!
52 if test $WAIT != 0 ; then
53 echo PROVIDERPID $PROVIDERPID
54 read foo
55 fi
56 KILLPIDS="$PROVIDERPID"
57
58 sleep 1
59
60 echo "Using ldapsearch to check that provider slapd is running..."
61 for i in 0 1 2 3 4 5; do
62 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
63 '(objectClass=*)' > /dev/null 2>&1
64 RC=$?
65 if test $RC = 0 ; then
66 break
67 fi
68 echo "Waiting 5 seconds for slapd to start..."
69 sleep 5
70 done
71
72 if test $RC != 0 ; then
73 echo "ldapsearch failed ($RC)!"
74 test $KILLSERVERS != no && kill -HUP $KILLPIDS
75 exit $RC
76 fi
77
78 echo "Using ldapadd to create the context prefix entry in the provider..."
79 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD < \
80 $LDIFORDEREDCP > /dev/null 2>&1
81 RC=$?
82 if test $RC != 0 ; then
83 echo "ldapadd failed ($RC)!"
84 test $KILLSERVERS != no && kill -HUP $KILLPIDS
85 exit $RC
86 fi
87
88 echo "Starting consumer slapd on TCP/IP port $PORT2..."
89 . $CONFFILTER $BACKEND < $RCONSUMERCONF > $CONF2
90 $SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
91 CONSUMERPID=$!
92 if test $WAIT != 0 ; then
93 echo CONSUMERPID $CONSUMERPID
94 read foo
95 fi
96 KILLPIDS="$PROVIDERPID $CONSUMERPID"
97
98 sleep 1
99
100 echo "Using ldapsearch to check that consumer slapd is running..."
101 for i in 0 1 2 3 4 5; do
102 $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
103 '(objectClass=*)' > /dev/null 2>&1
104 RC=$?
105 if test $RC = 0 ; then
106 break
107 fi
108 echo "Waiting 5 seconds for slapd to start..."
109 sleep 5
110 done
111
112 if test $RC != 0 ; then
113 echo "ldapsearch failed ($RC)!"
114 test $KILLSERVERS != no && kill -HUP $KILLPIDS
115 exit $RC
116 fi
117
118 echo "Starting proxy slapd on TCP/IP port $PORT3..."
119 . $CONFFILTER $BACKEND < $PLSRCONSUMERCONF > $CONF3
120 $SLAPD -f $CONF3 -h $URI3 -d $LVL > $LOG3 2>&1 &
121 PROXYPID=$!
122 if test $WAIT != 0 ; then
123 echo PROXYPID $PROXYPID
124 read foo
125 fi
126 KILLPIDS="$PROVIDERPID $CONSUMERPID $PROXYPID"
127
128 sleep 1
129
130 echo "Using ldapsearch to check that proxy slapd is running..."
131 for i in 0 1 2 3 4 5; do
132 $LDAPSEARCH -s base -b "$MONITOR" -H $URI3 \
133 '(objectClass=*)' > /dev/null 2>&1
134 RC=$?
135 if test $RC = 0 || test $RC = 53 ; then
136 break
137 fi
138 echo "Waiting 5 seconds for slapd to start..."
139 sleep 5
140 done
141
142 case $RC in
143 0 )
144 echo "ldapsearch should have failed ($RC)!"
145 test $KILLSERVERS != no && kill -HUP $KILLPIDS
146 exit 1
147 ;;
148 53)
149 ;;
150 *)
151 echo "ldapsearch failed ($RC)!"
152 test $KILLSERVERS != no && kill -HUP $KILLPIDS
153 exit $RC
154 ;;
155 esac
156
157 CHECK=1
158 echo "$CHECK > Using ldapadd to populate the provider directory..."
159 $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD < \
160 $LDIFORDEREDNOCP > /dev/null 2>&1
161 RC=$?
162 if test $RC != 0 ; then
163 echo "ldapadd failed ($RC)!"
164 test $KILLSERVERS != no && kill -HUP $KILLPIDS
165 exit $RC
166 fi
167
168 # get provider contextCSN
169 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
170 -s base '(objectClass=*)' contextCSN > "${PROVIDEROUT}.$CHECK" 2>&1
171 RC=$?
172 if test $RC != 0 ; then
173 echo "ldapsearch failed at provider ($RC)!"
174 test $KILLSERVERS != no && kill -HUP $KILLPIDS
175 exit $RC
176 fi
177
178 # check consumer contextCSN
179 sleep 1
180 for i in 1 2 3; do
181 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
182 -s base '(objectClass=*)' contextCSN > "${CONSUMEROUT}.$CHECK" 2>&1
183 RC=$?
184
185 if test $RC != 0 ; then
186 echo "ldapsearch failed at consumer ($RC)!"
187 test $KILLSERVERS != no && kill -HUP $KILLPIDS
188 exit $RC
189 fi
190
191 $CMP ${PROVIDEROUT}.$CHECK ${CONSUMEROUT}.$CHECK > $CMPOUT
192
193 if test $? = 0 ; then
194 break
195 fi
196
197 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
198 sleep $SLEEP1
199 done
200
201 #echo "Using ldapsearch to read all the entries from the provider..."
202 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
203 '(objectClass=*)' > "${PROVIDEROUT}.$CHECK" 2>&1
204 RC=$?
205
206 if test $RC != 0 ; then
207 echo "ldapsearch failed at provider ($RC)!"
208 test $KILLSERVERS != no && kill -HUP $KILLPIDS
209 exit $RC
210 fi
211
212 #echo "Using ldapsearch to read all the entries from the consumer..."
213 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
214 '(objectClass=*)' > "${CONSUMEROUT}.$CHECK" 2>&1
215 RC=$?
216
217 if test $RC != 0 ; then
218 echo "ldapsearch failed at consumer ($RC)!"
219 test $KILLSERVERS != no && kill -HUP $KILLPIDS
220 exit $RC
221 fi
222
223 #echo "Filtering provider results..."
224 $LDIFFILTER < "${PROVIDEROUT}.$CHECK" > $PROVIDERFLT
225 #echo "Filtering consumer results..."
226 $LDIFFILTER < "${CONSUMEROUT}.$CHECK" > $CONSUMERFLT
227
228 echo "$CHECK < Comparing retrieved entries from provider and consumer..."
229 $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
230
231 if test $? != 0 ; then
232 echo "test failed - provider and consumer databases differ"
233 test $KILLSERVERS != no && kill -HUP $KILLPIDS
234 exit 1
235 fi
236
237 CHECK=`expr $CHECK + 1`
238 echo "$CHECK > Stopping the provider, sleeping $SLEEP2 seconds and restarting it..."
239 kill -HUP "$PROVIDERPID"
240 wait $PROVIDERPID
241 sleep $SLEEP2
242
243 echo "======================= RESTART =======================" >> $LOG1
244 $SLAPD -f $CONF1 -h $URI1 -d $LVL >> $LOG1 2>&1 &
245 PROVIDERPID=$!
246 if test $WAIT != 0 ; then
247 echo PROVIDERPID $PROVIDERPID
248 read foo
249 fi
250 KILLPIDS="$PROVIDERPID $CONSUMERPID $PROXYPID"
251
252 sleep 1
253
254 echo "Using ldapsearch to check that provider slapd is running..."
255 for i in 0 1 2 3 4 5; do
256 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
257 '(objectClass=*)' > /dev/null 2>&1
258 RC=$?
259 if test $RC = 0 ; then
260 break
261 fi
262 echo "Waiting 5 seconds for slapd to start..."
263 sleep 5
264 done
265
266 if test $RC != 0 ; then
267 echo "ldapsearch failed ($RC)!"
268 test $KILLSERVERS != no && kill -HUP $KILLPIDS
269 exit $RC
270 fi
271
272 echo "Using ldapmodify to modify provider directory..."
273
274 #
275 # Do some modifications
276 #
277
278 $LDAPMODIFY -v -D "$MANAGERDN" -H $URI1 -w $PASSWD > \
279 $TESTOUT 2>&1 << EOMODS
280 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
281 changetype: modify
282 add: drink
283 drink: Orange Juice
284 -
285 delete: sn
286 sn: Jones
287 -
288 add: sn
289 sn: Jones
290
291 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
292 changetype: modify
293 replace: drink
294 drink: Iced Tea
295
296 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
297 changetype: modify
298 delete: uniquemember
299 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
300 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
301 -
302 add: uniquemember
303 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
304 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
305
306 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
307 =com
308 changetype: modify
309 delete: cn
310 cn: Biiff Jensen
311
312 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
313 changetype: add
314 objectclass: OpenLDAPperson
315 cn: Gern Jensen
316 sn: Jensen
317 uid: gjensen
318 title: Chief Investigator, ITD
319 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
320 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
321 drink: Coffee
322 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
323 description: Very odd
324 facsimiletelephonenumber: +1 313 555 7557
325 telephonenumber: +1 313 555 8343
326 mail: [email protected]
327 homephone: +1 313 555 8844
328
329 dn: ou=Retired, ou=People, dc=example,dc=com
330 changetype: add
331 objectclass: organizationalUnit
332 ou: Retired
333
334 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
335 changetype: add
336 objectclass: OpenLDAPperson
337 cn: Rosco P. Coltrane
338 sn: Coltrane
339 uid: rosco
340 description: Fat tycoon
341
342 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
343 changetype: modrdn
344 newrdn: cn=Rosco P. Coltrane
345 deleteoldrdn: 1
346 newsuperior: ou=Retired, ou=People, dc=example,dc=com
347
348 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
349 changetype: delete
350 EOMODS
351
352 RC=$?
353 if test $RC != 0 ; then
354 echo "ldapmodify failed ($RC)!"
355 test $KILLSERVERS != no && kill -HUP $KILLPIDS
356 exit $RC
357 fi
358
359 # get provider contextCSN
360 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
361 -s base '(objectClass=*)' contextCSN > "${PROVIDEROUT}.$CHECK" 2>&1
362 RC=$?
363 if test $RC != 0 ; then
364 echo "ldapsearch failed at provider ($RC)!"
365 test $KILLSERVERS != no && kill -HUP $KILLPIDS
366 exit $RC
367 fi
368
369 # check consumer contextCSN
370 for i in 1 2 3; do
371 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
372 sleep $SLEEP1
373
374 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
375 -s base '(objectClass=*)' contextCSN > "${CONSUMEROUT}.$CHECK" 2>&1
376 RC=$?
377
378 if test $RC != 0 ; then
379 echo "ldapsearch failed at consumer ($RC)!"
380 test $KILLSERVERS != no && kill -HUP $KILLPIDS
381 exit $RC
382 fi
383
384 $CMP ${PROVIDEROUT}.$CHECK ${CONSUMEROUT}.$CHECK > $CMPOUT
385
386 if test $? = 0 ; then
387 break
388 fi
389 done
390
391 #echo "Using ldapsearch to read all the entries from the provider..."
392 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
393 '(objectClass=*)' > "${PROVIDEROUT}.$CHECK" 2>&1
394 RC=$?
395
396 if test $RC != 0 ; then
397 echo "ldapsearch failed at provider ($RC)!"
398 test $KILLSERVERS != no && kill -HUP $KILLPIDS
399 exit $RC
400 fi
401
402 #echo "Using ldapsearch to read all the entries from the consumer..."
403 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
404 '(objectClass=*)' > "${CONSUMEROUT}.$CHECK" 2>&1
405 RC=$?
406
407 if test $RC != 0 ; then
408 echo "ldapsearch failed at consumer ($RC)!"
409 test $KILLSERVERS != no && kill -HUP $KILLPIDS
410 exit $RC
411 fi
412
413 #echo "Filtering provider results..."
414 $LDIFFILTER < "${PROVIDEROUT}.$CHECK" > $PROVIDERFLT
415 #echo "Filtering consumer results..."
416 $LDIFFILTER < "${CONSUMEROUT}.$CHECK" > $CONSUMERFLT
417
418 echo "$CHECK < Comparing retrieved entries from provider and consumer..."
419 $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
420
421 if test $? != 0 ; then
422 echo "test failed - provider and consumer databases differ"
423 test $KILLSERVERS != no && kill -HUP $KILLPIDS
424 exit 1
425 fi
426
427 CHECK=`expr $CHECK + 1`
428 echo "$CHECK > Stopping proxy to test recovery..."
429 kill -HUP $PROXYPID
430 wait $PROXYPID
431
432 echo "Modifying more entries on the provider..."
433 $LDAPMODIFY -v -D "$MANAGERDN" -H $URI1 -w $PASSWD >> \
434 $TESTOUT 2>&1 << EOMODS
435 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
436 changetype: modify
437 add: description
438 description: proxy is down...
439
440 dn: cn=James T. Kirk, ou=Retired, ou=People, dc=example,dc=com
441 changetype: add
442 objectclass: OpenLDAPperson
443 sn: Kirk
444 uid: jtk
445 cn: James T. Kirk
446
447 dn: cn=Tiberius J. Hooker, ou=Retired, ou=People, dc=example,dc=com
448 changetype: add
449 objectclass: OpenLDAPperson
450 sn: Hooker
451 uid: tjh
452 cn: Tiberius J. Hooker
453
454 EOMODS
455
456 echo "Restarting proxy..."
457 echo "======================= RESTART =======================" >> $LOG3
458 $SLAPD -f $CONF3 -h $URI3 -d $LVL >> $LOG3 2>&1 &
459 PROXYPID=$!
460 if test $WAIT != 0 ; then
461 echo PROXYPID $PROXYPID
462 read foo
463 fi
464 KILLPIDS="$PROVIDERPID $CONSUMERPID $PROXYPID"
465
466 # get provider contextCSN
467 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
468 -s base '(objectClass=*)' contextCSN > "${PROVIDEROUT}.$CHECK" 2>&1
469 RC=$?
470 if test $RC != 0 ; then
471 echo "ldapsearch failed at provider ($RC)!"
472 test $KILLSERVERS != no && kill -HUP $KILLPIDS
473 exit $RC
474 fi
475
476 # check consumer contextCSN
477 for i in 1 2 3 4 5; do
478 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
479 sleep $SLEEP1
480
481 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
482 -s base '(objectClass=*)' contextCSN > "${CONSUMEROUT}.$CHECK" 2>&1
483 RC=$?
484
485 if test $RC != 0 ; then
486 echo "ldapsearch failed at consumer ($RC)!"
487 test $KILLSERVERS != no && kill -HUP $KILLPIDS
488 exit $RC
489 fi
490
491 $CMP ${PROVIDEROUT}.$CHECK ${CONSUMEROUT}.$CHECK > $CMPOUT
492
493 if test $? = 0 ; then
494 break
495 fi
496 done
497
498 #echo "Using ldapsearch to read all the entries from the provider..."
499 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
500 '(objectClass=*)' > "${PROVIDEROUT}.$CHECK" 2>&1
501 RC=$?
502
503 if test $RC != 0 ; then
504 echo "ldapsearch failed at provider ($RC)!"
505 test $KILLSERVERS != no && kill -HUP $KILLPIDS
506 exit $RC
507 fi
508
509 #echo "Using ldapsearch to read all the entries from the consumer..."
510 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
511 '(objectClass=*)' > "${CONSUMEROUT}.$CHECK" 2>&1
512 RC=$?
513
514 if test $RC != 0 ; then
515 echo "ldapsearch failed at consumer ($RC)!"
516 test $KILLSERVERS != no && kill -HUP $KILLPIDS
517 exit $RC
518 fi
519
520 #echo "Filtering provider results..."
521 $LDIFFILTER < "${PROVIDEROUT}.$CHECK" > $PROVIDERFLT
522 #echo "Filtering consumer results..."
523 $LDIFFILTER < "${CONSUMEROUT}.$CHECK" > $CONSUMERFLT
524
525 echo "$CHECK < Comparing retrieved entries from provider and consumer..."
526 $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
527
528 if test $? != 0 ; then
529 echo "test failed - provider and consumer databases differ"
530 test $KILLSERVERS != no && kill -HUP $KILLPIDS
531 exit 1
532 fi
533
534 CHECK=`expr $CHECK + 1`
535 echo "$CHECK > Try updating the consumer slapd..."
536 $LDAPMODIFY -v -D "$MANAGERDN" -H $URI2 -w $PASSWD > \
537 $TESTOUT 2>&1 << EOMODS
538 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
539 changetype: modify
540 add: description
541 description: This write must fail because directed to a shadow context,
542 description: unless the chain overlay is configured appropriately ;)
543
544 EOMODS
545
546 RC=$?
547 if test $RC != 0 ; then
548 echo "ldapmodify failed ($RC)!"
549 test $KILLSERVERS != no && kill -HUP $KILLPIDS
550 exit $RC
551 fi
552
553 # get provider contextCSN
554 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
555 -s base '(objectClass=*)' contextCSN > "${PROVIDEROUT}.$CHECK" 2>&1
556 RC=$?
557 if test $RC != 0 ; then
558 echo "ldapsearch failed at provider ($RC)!"
559 test $KILLSERVERS != no && kill -HUP $KILLPIDS
560 exit $RC
561 fi
562
563 # check consumer contextCSN
564 sleep 1
565
566 for i in 1 2 3; do
567 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
568 -s base '(objectClass=*)' contextCSN > "${CONSUMEROUT}.$CHECK" 2>&1
569 RC=$?
570
571 if test $RC != 0 ; then
572 echo "ldapsearch failed at consumer ($RC)!"
573 test $KILLSERVERS != no && kill -HUP $KILLPIDS
574 exit $RC
575 fi
576
577 $CMP ${PROVIDEROUT}.$CHECK ${CONSUMEROUT}.$CHECK > $CMPOUT
578
579 if test $? = 0 ; then
580 break
581 fi
582
583 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
584 sleep $SLEEP1
585 done
586
587 #echo "Using ldapsearch to read all the entries from the provider..."
588 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
589 '(objectClass=*)' > "${PROVIDEROUT}.$CHECK" 2>&1
590 RC=$?
591
592 if test $RC != 0 ; then
593 echo "ldapsearch failed at provider ($RC)!"
594 test $KILLSERVERS != no && kill -HUP $KILLPIDS
595 exit $RC
596 fi
597
598 #echo "Using ldapsearch to read all the entries from the consumer..."
599 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
600 '(objectClass=*)' > "${CONSUMEROUT}.$CHECK" 2>&1
601 RC=$?
602
603 if test $RC != 0 ; then
604 echo "ldapsearch failed at consumer ($RC)!"
605 test $KILLSERVERS != no && kill -HUP $KILLPIDS
606 exit $RC
607 fi
608
609 #echo "Filtering provider results..."
610 $LDIFFILTER < "${PROVIDEROUT}.$CHECK" > $PROVIDERFLT
611 #echo "Filtering consumer results..."
612 $LDIFFILTER < "${CONSUMEROUT}.$CHECK" > $CONSUMERFLT
613
614 echo "$CHECK < Comparing retrieved entries from provider and consumer..."
615 $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
616
617 if test $? != 0 ; then
618 echo "test failed - provider and consumer databases differ"
619 test $KILLSERVERS != no && kill -HUP $KILLPIDS
620 exit 1
621 fi
622
623 CHECK=`expr $CHECK + 1`
624 echo "$CHECK > Stopping consumer to test recovery..."
625 kill -HUP $CONSUMERPID
626 wait $CONSUMERPID
627
628 echo "Modifying more entries on the provider..."
629 $LDAPMODIFY -v -D "$MANAGERDN" -H $URI1 -w $PASSWD >> \
630 $TESTOUT 2>&1 << EOMODS
631 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
632 changetype: modify
633 add: drink
634 drink: Mad Dog 20/20
635
636 EOMODS
637
638 echo "Waiting $SLEEP2 seconds for syncrepl to retry..."
639 sleep $SLEEP2
640
641 echo "Restarting consumer..."
642 echo "======================= RESTART =======================" >> $LOG2
643 $SLAPD -f $CONF2 -h $URI2 -d $LVL >> $LOG2 2>&1 &
644 CONSUMERPID=$!
645 if test $WAIT != 0 ; then
646 echo CONSUMERPID $CONSUMERPID
647 read foo
648 fi
649 KILLPIDS="$PROVIDERPID $CONSUMERPID $PROXYPID"
650
651 # get provider contextCSN
652 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
653 -s base '(objectClass=*)' contextCSN > "${PROVIDEROUT}.$CHECK" 2>&1
654 RC=$?
655 if test $RC != 0 ; then
656 echo "ldapsearch failed at provider ($RC)!"
657 test $KILLSERVERS != no && kill -HUP $KILLPIDS
658 exit $RC
659 fi
660
661 # check consumer contextCSN
662
663 for i in 1 2 3 4 5; do
664 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
665 sleep $SLEEP1
666
667 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
668 -s base '(objectClass=*)' contextCSN > "${CONSUMEROUT}.$CHECK" 2>&1
669 RC=$?
670
671 if test $RC != 0 ; then
672 echo "ldapsearch failed at consumer ($RC)!"
673 test $KILLSERVERS != no && kill -HUP $KILLPIDS
674 exit $RC
675 fi
676
677 $CMP ${PROVIDEROUT}.$CHECK ${CONSUMEROUT}.$CHECK > $CMPOUT
678
679 if test $? = 0 ; then
680 break
681 fi
682 done
683
684 #echo "Using ldapsearch to read all the entries from the provider..."
685 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
686 '(objectClass=*)' > "${PROVIDEROUT}.$CHECK" 2>&1
687 RC=$?
688
689 if test $RC != 0 ; then
690 echo "ldapsearch failed at provider ($RC)!"
691 test $KILLSERVERS != no && kill -HUP $KILLPIDS
692 exit $RC
693 fi
694
695 #echo "Using ldapsearch to read all the entries from the consumer..."
696 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
697 '(objectClass=*)' > "${CONSUMEROUT}.$CHECK" 2>&1
698 RC=$?
699
700 if test $RC != 0 ; then
701 echo "ldapsearch failed at consumer ($RC)!"
702 test $KILLSERVERS != no && kill -HUP $KILLPIDS
703 exit $RC
704 fi
705
706 #echo "Filtering provider results..."
707 $LDIFFILTER < "${PROVIDEROUT}.$CHECK" > $PROVIDERFLT
708 #echo "Filtering consumer results..."
709 $LDIFFILTER < "${CONSUMEROUT}.$CHECK" > $CONSUMERFLT
710
711 echo "$CHECK < Comparing retrieved entries from provider and consumer..."
712 $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
713
714 if test $? != 0 ; then
715 # FIXME: keep the original workaround in place, in case we needed again
716 if test 1 = 1 ; then
717 echo "test failed - provider and consumer databases differ"
718 test $KILLSERVERS != no && kill -HUP $KILLPIDS
719 exit 1
720 fi
721
722 echo " test failed - provider and consumer databases differ (ignored by now)"
723 echo " Stopping proxy to see if it auto-recovers..."
724 kill -HUP $PROXYPID
725 wait $PROXYPID
726
727 echo " ${CHECK}.1 > Restarting proxy..."
728 echo "======================= RESTART =======================" >> $LOG3
729 $SLAPD -f $CONF3 -h $URI3 -d $LVL >> $LOG3 2>&1 &
730 PROXYPID=$!
731 if test $WAIT != 0 ; then
732 echo PROXYPID $PROXYPID
733 read foo
734 fi
735 KILLPIDS="$PROVIDERPID $CONSUMERPID $PROXYPID"
736
737 echo " Waiting $SLEEP2 seconds for syncrepl to receive changes..."
738 sleep $SLEEP2
739
740 #echo "Using ldapsearch to read all the entries from the consumer..."
741 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
742 '(objectClass=*)' > "${CONSUMEROUT}.5.1" 2>&1
743 RC=$?
744
745 if test $RC != 0 ; then
746 echo " ldapsearch failed at consumer ($RC)!"
747 test $KILLSERVERS != no && kill -HUP $KILLPIDS
748 exit $RC
749 fi
750
751 #echo "Filtering consumer results..."
752 $LDIFFILTER < "${CONSUMEROUT}.5.1" > $CONSUMERFLT
753
754 echo " ${CHECK}.1 < Comparing retrieved entries from provider and consumer..."
755 $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
756
757 if test $? != 0 ; then
758 echo " test failed - provider and consumer databases differ"
759 test $KILLSERVERS != no && kill -HUP $KILLPIDS
760 exit 1
761 fi
762 fi
763
764 #
765 # Modifications formerly known to fail
766 #
767 CHECK=`expr $CHECK + 1`
768 echo "$CHECK > Performing modifications that were formerly known to fail..."
769 $LDAPMODIFY -v -D "$MANAGERDN" -H $URI1 -w $PASSWD > \
770 $TESTOUT 2>&1 << EOMODS
771 # First, back out previous change
772 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
773 changetype: modify
774 delete: drink
775 drink: Mad Dog 20/20
776
777 # From now on, perform modifications that were formerly known to fail
778 dn: cn=All Staff,ou=Groups,dc=example,dc=com
779 changetype: modify
780 delete: description
781
782 EOMODS
783
784 RC=$?
785 if test $RC != 0 ; then
786 echo "ldapmodify failed ($RC)!"
787 test $KILLSERVERS != no && kill -HUP $KILLPIDS
788 exit $RC
789 fi
790
791 # get provider contextCSN
792 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
793 -s base '(objectClass=*)' contextCSN > "${PROVIDEROUT}.$CHECK" 2>&1
794 RC=$?
795 if test $RC != 0 ; then
796 echo "ldapsearch failed at provider ($RC)!"
797 test $KILLSERVERS != no && kill -HUP $KILLPIDS
798 exit $RC
799 fi
800
801 # check consumer contextCSN
802 sleep 1
803 for i in 1 2 3; do
804 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
805 -s base '(objectClass=*)' contextCSN > "${CONSUMEROUT}.$CHECK" 2>&1
806 RC=$?
807
808 if test $RC != 0 ; then
809 echo "ldapsearch failed at consumer ($RC)!"
810 test $KILLSERVERS != no && kill -HUP $KILLPIDS
811 exit $RC
812 fi
813
814 $CMP ${PROVIDEROUT}.$CHECK ${CONSUMEROUT}.$CHECK > $CMPOUT
815
816 if test $? = 0 ; then
817 break
818 fi
819
820 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
821 sleep $SLEEP1
822 done
823
824 #echo "Using ldapsearch to read all the entries from the provider..."
825 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
826 '(objectClass=*)' > "${PROVIDEROUT}.$CHECK" 2>&1
827 RC=$?
828
829 if test $RC != 0 ; then
830 echo "ldapsearch failed at provider ($RC)!"
831 test $KILLSERVERS != no && kill -HUP $KILLPIDS
832 exit $RC
833 fi
834
835 #echo "Using ldapsearch to read all the entries from the consumer..."
836 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
837 '(objectClass=*)' > "${CONSUMEROUT}.$CHECK" 2>&1
838 RC=$?
839
840 if test $RC != 0 ; then
841 echo "ldapsearch failed at consumer ($RC)!"
842 test $KILLSERVERS != no && kill -HUP $KILLPIDS
843 exit $RC
844 fi
845
846 #echo "Filtering provider results..."
847 $LDIFFILTER < "${PROVIDEROUT}.$CHECK" > $PROVIDERFLT
848 #echo "Filtering consumer results..."
849 $LDIFFILTER < "${CONSUMEROUT}.$CHECK" > $CONSUMERFLT
850
851 echo "$CHECK < Comparing retrieved entries from provider and consumer..."
852 $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
853
854 if test $? != 0 ; then
855 echo "test failed - provider and consumer databases differ (ignored by now)"
856 #echo "test failed - provider and consumer databases differ"
857 #test $KILLSERVERS != no && kill -HUP $KILLPIDS
858 #exit 1
859 fi
860
861 test $KILLSERVERS != no && kill -HUP $KILLPIDS
862
863 echo ">>>>> Test succeeded"
864
865 test $KILLSERVERS != no && wait
866
867 exit 0