1#! /bin/sh 2# OpenLDAP: pkg/ldap/tests/scripts/test050-syncrepl-multimaster,v 1.3.2.21 2010/04/19 19:14:36 quanah Exp 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 1998-2010 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 16echo "running defines.sh" 17. $SRCDIR/scripts/defines.sh 18 19if test $SYNCPROV = syncprovno; then 20 echo "Syncrepl provider overlay not available, test skipped" 21 exit 0 22fi 23 24MMR=${MMR-4} 25 26if [ $MMR -gt 9 ]; then 27MMR=9 28fi 29 30XDIR=$TESTDIR/srv 31TMP=$TESTDIR/tmp 32 33mkdir -p $TESTDIR 34 35$SLAPPASSWD -g -n >$CONFIGPWF 36 37if test x"$SYNCMODE" = x ; then 38 SYNCMODE=rp 39fi 40case "$SYNCMODE" in 41 ro) 42 SYNCTYPE="type=refreshOnly interval=00:00:00:03" 43 ;; 44 rp) 45 SYNCTYPE="type=refreshAndPersist" 46 ;; 47 *) 48 echo "unknown sync mode $SYNCMODE" 49 exit 1; 50 ;; 51esac 52 53# 54# Test replication of dynamic config: 55# - start servers 56# - configure over ldap 57# - populate over ldap 58# - configure syncrepl over ldap 59# - retrieve database over ldap and compare against expected results 60# 61 62echo "Initializing server configurations..." 63n=1 64while [ $n -le $MMR ]; do 65 66DBDIR=${XDIR}$n/db 67CFDIR=${XDIR}$n/slapd.d 68 69mkdir -p ${XDIR}$n $DBDIR $CFDIR 70 71$SLAPADD -F $CFDIR -n 0 <<EOF 72dn: cn=config 73objectClass: olcGlobal 74cn: config 75olcServerID: $n 76 77dn: olcDatabase={0}config,cn=config 78objectClass: olcDatabaseConfig 79olcDatabase: {0}config 80olcRootPW:< file://$CONFIGPWF 81EOF 82 83n=`expr $n + 1` 84done 85 86echo "Starting server 1 on TCP/IP port $PORT1..." 87cd ${XDIR}1 88$SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & 89PID=$! 90if test $WAIT != 0 ; then 91 echo PID $PID 92 read foo 93fi 94KILLPIDS="$PID" 95cd $TESTWD 96 97sleep 1 98 99echo "Using ldapsearch to check that server 1 is running..." 100for i in 0 1 2 3 4 5; do 101 $LDAPSEARCH -s base -b "" -H $URI1 \ 102 'objectclass=*' > /dev/null 2>&1 103 RC=$? 104 if test $RC = 0 ; then 105 break 106 fi 107 echo "Waiting 5 seconds for slapd to start..." 108 sleep 5 109done 110 111if test $RC != 0 ; then 112 echo "ldapsearch failed ($RC)!" 113 test $KILLSERVERS != no && kill -HUP $KILLPIDS 114 exit $RC 115fi 116 117echo "Inserting syncprov overlay on server 1..." 118echo "" > $TMP 119if [ "$SYNCPROV" = syncprovmod ]; then 120cat <<EOF >> $TMP 121dn: cn=module,cn=config 122changetype: add 123objectClass: olcModuleList 124cn: module 125olcModulePath: ../../../servers/slapd/overlays 126olcModuleLoad: syncprov.la 127 128EOF 129fi 130# 131# Note that we configure a timeout here; it's possible for both 132# servers to attempt to bind to each other while a modify to 133# cn=config is in progress. When the modify pauses the thread pool 134# neither server will progress. The timeout will drop the syncrepl 135# attempt and allow the modifies to complete. 136# 137read CONFIGPW < $CONFIGPWF 138echo "dn: cn=config" >> $TMP 139echo "changetype: modify" >> $TMP 140echo "replace: olcServerID" >> $TMP 141n=1 142while [ $n -le $MMR ]; do 143PORT=`expr $BASEPORT + $n` 144URI="ldap://${LOCALHOST}:$PORT/" 145echo "olcServerID: $n $URI" >> $TMP 146n=`expr $n + 1` 147done 148 149cat <<EOF >> $TMP 150 151dn: olcOverlay=syncprov,olcDatabase={0}config,cn=config 152changetype: add 153objectClass: olcOverlayConfig 154objectClass: olcSyncProvConfig 155olcOverlay: syncprov 156 157dn: olcDatabase={0}config,cn=config 158changetype: modify 159add: olcSyncRepl 160EOF 161 162n=1 163while [ $n -le $MMR ]; do 164PORT=`expr $BASEPORT + $n` 165URI="ldap://${LOCALHOST}:$PORT/" 166echo "olcSyncRepl: rid=00$n provider=$URI binddn=\"cn=config\" bindmethod=simple" >> $TMP 167echo " credentials=$CONFIGPW searchbase=\"cn=config\" type=refreshAndPersist" >> $TMP 168echo " retry=\"3 10 300 5\" timeout=3" >> $TMP 169n=`expr $n + 1` 170done 171echo "-" >> $TMP 172echo "add: olcMirrorMode" >> $TMP 173echo "olcMirrorMode: TRUE" >> $TMP 174$LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF < $TMP >> $TESTOUT 2>&1 175RC=$? 176if test $RC != 0 ; then 177 echo "ldapmodify failed for syncrepl config ($RC)!" 178 test $KILLSERVERS != no && kill -HUP $KILLPIDS 179 exit $RC 180fi 181 182n=2 183while [ $n -le $MMR ]; do 184PORT=`expr $BASEPORT + $n` 185URI="ldap://${LOCALHOST}:$PORT/" 186LOG=$TESTDIR/slapd.$n.log 187echo "Starting server $n on TCP/IP port $PORT..." 188cd ${XDIR}$n 189$SLAPD -F ./slapd.d -h $URI -d $LVL $TIMING > $LOG 2>&1 & 190SLAVEPID=$! 191if test $WAIT != 0 ; then 192 echo SLAVEPID $SLAVEPID 193 read foo 194fi 195KILLPIDS="$KILLPIDS $SLAVEPID" 196cd $TESTWD 197 198sleep 1 199 200echo "Using ldapsearch to check that server $n is running..." 201for i in 0 1 2 3 4 5; do 202 $LDAPSEARCH -s base -b "" -H $URI \ 203 'objectclass=*' > /dev/null 2>&1 204 RC=$? 205 if test $RC = 0 ; then 206 break 207 fi 208 echo "Waiting 5 seconds for slapd to start..." 209 sleep 5 210done 211 212if test $RC != 0 ; then 213 echo "ldapsearch failed ($RC)!" 214 test $KILLSERVERS != no && kill -HUP $KILLPIDS 215 exit $RC 216fi 217 218echo "Configuring syncrepl on server $n..." 219cat <<EOF > $TMP 220dn: olcDatabase={0}config,cn=config 221changetype: modify 222add: olcSyncRepl 223EOF 224j=1 225while [ $j -le $MMR ]; do 226P2=`expr $BASEPORT + $j` 227U2="ldap://${LOCALHOST}:$P2/" 228echo "olcSyncRepl: rid=00$j provider=$U2 binddn=\"cn=config\" bindmethod=simple" >> $TMP 229echo " credentials=$CONFIGPW searchbase=\"cn=config\" type=refreshAndPersist" >> $TMP 230echo " retry=\"3 10 300 5\" timeout=3" >> $TMP 231j=`expr $j + 1` 232done 233cat <<EOF >> $TMP 234- 235add: olcMirrorMode 236olcMirrorMode: TRUE 237EOF 238$LDAPMODIFY -D cn=config -H $URI -y $CONFIGPWF < $TMP >>$TESTOUT 2>&1 239n=`expr $n + 1` 240done 241 242echo "Adding schema and databases on server 1..." 243$LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1 244include: file://$ABS_SCHEMADIR/core.ldif 245 246include: file://$ABS_SCHEMADIR/cosine.ldif 247 248include: file://$ABS_SCHEMADIR/inetorgperson.ldif 249 250include: file://$ABS_SCHEMADIR/openldap.ldif 251 252include: file://$ABS_SCHEMADIR/nis.ldif 253EOF 254RC=$? 255if test $RC != 0 ; then 256 echo "ldapadd failed for schema config ($RC)!" 257 test $KILLSERVERS != no && kill -HUP $KILLPIDS 258 exit $RC 259fi 260 261nullExclude="" 262test $BACKEND = null && nullExclude="# " 263 264echo "" > $TMP 265if [ "$BACKENDTYPE" = mod ]; then 266cat <<EOF >> $TMP 267dn: cn=module,cn=config 268objectClass: olcModuleList 269cn: module 270olcModulePath: ../../../servers/slapd/back-$BACKEND 271olcModuleLoad: back_$BACKEND.la 272 273EOF 274fi 275 276cat <<EOF >> $TMP 277dn: olcDatabase={1}$BACKEND,cn=config 278objectClass: olcDatabaseConfig 279${nullExclude}objectClass: olc${BACKEND}Config 280olcDatabase: {1}$BACKEND 281olcSuffix: $BASEDN 282${nullExclude}olcDbDirectory: ./db 283olcRootDN: $MANAGERDN 284olcRootPW: $PASSWD 285EOF 286 287n=1 288while [ $n -le $MMR ]; do 289PORT=`expr $BASEPORT + $n` 290URI="ldap://${LOCALHOST}:$PORT/" 291 292echo "olcSyncRepl: rid=01$n provider=$URI binddn=\"$MANAGERDN\" bindmethod=simple" >> $TMP 293echo " credentials=$PASSWD searchbase=\"$BASEDN\" $SYNCTYPE" >> $TMP 294echo " retry=\"3 10 300 5\" timeout=3" >> $TMP 295n=`expr $n + 1` 296done 297 298cat <<EOF >> $TMP 299olcMirrorMode: TRUE 300 301dn: olcOverlay=syncprov,olcDatabase={1}${BACKEND},cn=config 302objectClass: olcOverlayConfig 303objectClass: olcSyncProvConfig 304olcOverlay: syncprov 305EOF 306$LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF < $TMP >>$TESTOUT 2>&1 307RC=$? 308if test $RC != 0 ; then 309 echo "ldapadd failed for database config ($RC)!" 310 test $KILLSERVERS != no && kill -HUP $KILLPIDS 311 exit $RC 312fi 313 314case $BACKEND in 315bdb | hdb) 316 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1 317dn: olcDatabase={1}$BACKEND,cn=config 318changetype: modify 319add: olcDbIndex 320olcDbIndex: objectClass,entryUUID,entryCSN eq 321olcDbIndex: cn,uid pres,eq,sub 322EOF 323 RC=$? 324 if test $RC != 0 ; then 325 echo "ldapadd modify for database config ($RC)!" 326 test $KILLSERVERS != no && kill -HUP $KILLPIDS 327 exit $RC 328 fi 329 ;; 330esac 331 332echo "Using ldapadd to populate server 1..." 333$LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDERED \ 334 >> $TESTOUT 2>&1 335RC=$? 336if test $RC != 0 ; then 337 echo "ldapadd failed for server 1 database ($RC)!" 338 test $KILLSERVERS != no && kill -HUP $KILLPIDS 339 exit $RC 340fi 341 342echo "Waiting $SLEEP2 seconds for syncrepl to receive changes..." 343sleep $SLEEP2 344 345n=1 346while [ $n -le $MMR ]; do 347PORT=`expr $BASEPORT + $n` 348URI="ldap://${LOCALHOST}:$PORT/" 349 350echo "Using ldapsearch to read config from server $n..." 351$LDAPSEARCH -b cn=config -D cn=config -H $URI -y $CONFIGPWF \ 352 'objectclass=*' > $TESTDIR/server$n.out 2>&1 353RC=$? 354 355if test $RC != 0 ; then 356 echo "ldapsearch failed at server $n ($RC)!" 357 test $KILLSERVERS != no && kill -HUP $KILLPIDS 358 exit $RC 359fi 360 361$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 362 363n=`expr $n + 1` 364done 365 366n=2 367while [ $n -le $MMR ]; do 368echo "Comparing retrieved configs from server 1 and server $n..." 369$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT 370 371if test $? != 0 ; then 372 echo "test failed - server 1 and server $n configs differ" 373 test $KILLSERVERS != no && kill -HUP $KILLPIDS 374 exit 1 375fi 376n=`expr $n + 1` 377done 378 379n=1 380while [ $n -le $MMR ]; do 381PORT=`expr $BASEPORT + $n` 382URI="ldap://${LOCALHOST}:$PORT/" 383 384echo "Using ldapsearch to read all the entries from server $n..." 385$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 386 'objectclass=*' > $TESTDIR/server$n.out 2>&1 387RC=$? 388 389if test $RC != 0 ; then 390 echo "ldapsearch failed at server $n ($RC)!" 391 test $KILLSERVERS != no && kill -HUP $KILLPIDS 392 exit $RC 393fi 394$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 395n=`expr $n + 1` 396done 397 398n=2 399while [ $n -le $MMR ]; do 400echo "Comparing retrieved entries from server 1 and server $n..." 401$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT 402 403if test $? != 0 ; then 404 echo "test failed - server 1 and server $n databases differ" 405 test $KILLSERVERS != no && kill -HUP $KILLPIDS 406 exit 1 407fi 408n=`expr $n + 1` 409done 410 411echo "Using ldapadd to populate server 2..." 412$LDAPADD -D "$MANAGERDN" -H $URI2 -w $PASSWD -f $LDIFADD1 \ 413 >> $TESTOUT 2>&1 414RC=$? 415if test $RC != 0 ; then 416 echo "ldapadd failed for server 2 database ($RC)!" 417 test $KILLSERVERS != no && kill -HUP $KILLPIDS 418 exit $RC 419fi 420 421echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 422sleep $SLEEP1 423 424n=1 425while [ $n -le $MMR ]; do 426PORT=`expr $BASEPORT + $n` 427URI="ldap://${LOCALHOST}:$PORT/" 428 429echo "Using ldapsearch to read all the entries from server $n..." 430$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 431 'objectclass=*' > $TESTDIR/server$n.out 2>&1 432RC=$? 433 434if test $RC != 0 ; then 435 echo "ldapsearch failed at server $n ($RC)!" 436 test $KILLSERVERS != no && kill -HUP $KILLPIDS 437 exit $RC 438fi 439$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 440n=`expr $n + 1` 441done 442 443n=2 444while [ $n -le $MMR ]; do 445echo "Comparing retrieved entries from server 1 and server $n..." 446$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT 447 448if test $? != 0 ; then 449 echo "test failed - server 1 and server $n databases differ" 450 test $KILLSERVERS != no && kill -HUP $KILLPIDS 451 exit 1 452fi 453n=`expr $n + 1` 454done 455 456echo "Using ldapadd to populate server 3..." 457$LDAPADD -D "$MANAGERDN" -H $URI3 -w $PASSWD \ 458 << EOMODS >> $TESTOUT 2>&1 459dn: cn=Server 3 Test,dc=example,dc=com 460changetype: add 461objectClass: device 462cn: Server 3 Test 463EOMODS 464RC=$? 465if test $RC != 0 ; then 466 echo "ldapadd failed for server 3 database ($RC)!" 467 test $KILLSERVERS != no && kill -HUP $KILLPIDS 468 exit $RC 469fi 470 471echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 472sleep $SLEEP1 473 474n=1 475while [ $n -le $MMR ]; do 476PORT=`expr $BASEPORT + $n` 477URI="ldap://${LOCALHOST}:$PORT/" 478 479echo "Using ldapsearch to read all the entries from server $n..." 480$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 481 'objectclass=*' > $TESTDIR/server$n.out 2>&1 482RC=$? 483 484if test $RC != 0 ; then 485 echo "ldapsearch failed at server $n ($RC)!" 486 test $KILLSERVERS != no && kill -HUP $KILLPIDS 487 exit $RC 488fi 489$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 490n=`expr $n + 1` 491done 492 493n=2 494while [ $n -le $MMR ]; do 495echo "Comparing retrieved entries from server 1 and server $n..." 496$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT 497 498if test $? != 0 ; then 499 echo "test failed - server 1 and server $n databases differ" 500 test $KILLSERVERS != no && kill -HUP $KILLPIDS 501 exit 1 502fi 503n=`expr $n + 1` 504done 505 506echo "Using ldapmodify to add to server 1 entries that will be deleted..." 507$LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \ 508 >> $TESTOUT 2>&1 << EOADDS 509dn: cn=To be deleted by server 1,dc=example,dc=com 510changetype: add 511objectClass: device 512# no distinguished values, will be added by DSA 513 514dn: cn=To be deleted by server 2,dc=example,dc=com 515changetype: add 516objectClass: device 517# no distinguished values, will be added by DSA 518 519dn: cn=To be deleted by server 3,dc=example,dc=com 520changetype: add 521objectClass: device 522# no distinguished values, will be added by DSA 523 524dn: cn=To be deleted by server 1,dc=example,dc=com 525changetype: delete 526EOADDS 527RC=$? 528if test $RC != 0 ; then 529 echo "ldapmodify failed for server 1 database ($RC)!" 530 test $KILLSERVERS != no && kill -HUP $KILLPIDS 531 exit $RC 532fi 533 534echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 535sleep $SLEEP1 536 537n=1 538while [ $n -le $MMR ]; do 539PORT=`expr $BASEPORT + $n` 540URI="ldap://${LOCALHOST}:$PORT/" 541 542echo "Using ldapsearch to read all the entries from server $n..." 543$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 544 'objectclass=*' > $TESTDIR/server$n.out 2>&1 545RC=$? 546 547if test $RC != 0 ; then 548 echo "ldapsearch failed at server $n ($RC)!" 549 test $KILLSERVERS != no && kill -HUP $KILLPIDS 550 exit $RC 551fi 552$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 553n=`expr $n + 1` 554done 555 556n=2 557while [ $n -le $MMR ]; do 558echo "Comparing retrieved entries from server 1 and server $n..." 559$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT 560 561if test $? != 0 ; then 562 echo "test failed - server 1 and server $n databases differ" 563 test $KILLSERVERS != no && kill -HUP $KILLPIDS 564 exit 1 565fi 566n=`expr $n + 1` 567done 568 569echo "Using ldapmodify to delete entries from server 2..." 570$LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \ 571 >> $TESTOUT 2>&1 << EOADDS 572dn: cn=To be deleted by server 2,dc=example,dc=com 573changetype: delete 574EOADDS 575RC=$? 576if test $RC != 0 ; then 577 echo "ldapmodify failed for server 2 database ($RC)!" 578 test $KILLSERVERS != no && kill -HUP $KILLPIDS 579 exit $RC 580fi 581 582echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 583sleep $SLEEP1 584 585echo "Using ldapmodify to delete entries from server 3..." 586$LDAPMODIFY -D "$MANAGERDN" -H $URI3 -w $PASSWD \ 587 >> $TESTOUT 2>&1 << EOADDS 588dn: cn=To be deleted by server 3,dc=example,dc=com 589changetype: delete 590EOADDS 591RC=$? 592if test $RC != 0 ; then 593 echo "ldapmodify failed for server 3 database ($RC)!" 594 test $KILLSERVERS != no && kill -HUP $KILLPIDS 595 exit $RC 596fi 597 598echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 599sleep $SLEEP1 600 601n=1 602while [ $n -le $MMR ]; do 603PORT=`expr $BASEPORT + $n` 604URI="ldap://${LOCALHOST}:$PORT/" 605 606echo "Using ldapsearch to read all the entries from server $n..." 607$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 608 'objectclass=*' > $TESTDIR/server$n.out 2>&1 609RC=$? 610 611if test $RC != 0 ; then 612 echo "ldapsearch failed at server $n ($RC)!" 613 test $KILLSERVERS != no && kill -HUP $KILLPIDS 614 exit $RC 615fi 616$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 617n=`expr $n + 1` 618done 619 620n=2 621while [ $n -le $MMR ]; do 622echo "Comparing retrieved entries from server 1 and server $n..." 623$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT 624 625if test $? != 0 ; then 626 echo "test failed - server 1 and server $n databases differ" 627 test $KILLSERVERS != no && kill -HUP $KILLPIDS 628 exit 1 629fi 630n=`expr $n + 1` 631done 632 633# kill! 634# test $KILLSERVERS != no && kill -HUP $KILLPIDS 635kill -HUP $KILLPIDS 636 637# kill! 638# test $KILLSERVERS != no && wait 639wait 640 641echo "Restarting servers..." 642KILLPIDS="" 643 644echo "Starting server 1 on TCP/IP port $PORT1..." 645echo "======================= RESTART =======================" >> $LOG1 646cd ${XDIR}1 647$SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 & 648PID=$! 649if test $WAIT != 0 ; then 650 echo PID $PID 651 read foo 652fi 653KILLPIDS="$PID" 654cd $TESTWD 655 656sleep 1 657 658echo "Using ldapsearch to check that server 1 is running..." 659for i in 0 1 2 3 4 5; do 660 $LDAPSEARCH -s base -b "" -H $URI1 \ 661 'objectclass=*' > /dev/null 2>&1 662 RC=$? 663 if test $RC = 0 ; then 664 break 665 fi 666 echo "Waiting 5 seconds for slapd to start..." 667 sleep 5 668done 669 670if test $RC != 0 ; then 671 echo "ldapsearch failed ($RC)!" 672 test $KILLSERVERS != no && kill -HUP $KILLPIDS 673 exit $RC 674fi 675 676n=2 677while [ $n -le $MMR ]; do 678PORT=`expr $BASEPORT + $n` 679URI="ldap://${LOCALHOST}:$PORT/" 680LOG=$TESTDIR/slapd.$n.log 681echo "Starting server $n on TCP/IP port $PORT..." 682cd ${XDIR}$n 683echo "======================= RESTART =======================" >> $LOG 684$SLAPD -F ./slapd.d -h $URI -d $LVL $TIMING >> $LOG 2>&1 & 685PID=$! 686if test $WAIT != 0 ; then 687 echo PID $PID 688 read foo 689fi 690KILLPIDS="$KILLPIDS $PID" 691cd $TESTWD 692n=`expr $n + 1` 693done 694 695n=2 696while [ $n -le $MMR ]; do 697PORT=`expr $BASEPORT + $n` 698URI="ldap://${LOCALHOST}:$PORT/" 699echo "Using ldapsearch to check that server $n is running..." 700for i in 0 1 2 3 4 5; do 701 $LDAPSEARCH -s base -b "" -H $URI \ 702 'objectclass=*' > /dev/null 2>&1 703 RC=$? 704 if test $RC = 0 ; then 705 break 706 fi 707 echo "Waiting 5 seconds for slapd to start..." 708 sleep 5 709done 710 711if test $RC != 0 ; then 712 echo "ldapsearch failed ($RC)!" 713 test $KILLSERVERS != no && kill -HUP $KILLPIDS 714 exit $RC 715fi 716n=`expr $n + 1` 717done 718 719# Insert modifications and more tests here. 720echo "Waiting $SLEEP1 seconds for servers to resync..." 721sleep $SLEEP1 722 723echo "Using ldapmodify to add/modify/delete entries from server 1..." 724for i in 1 2 3 4 5 6 7 8 9 10; do 725echo " iteration $i" 726$LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \ 727 >> $TESTOUT 2>&1 << EOMODS 728dn: cn=Add-Mod-Del,dc=example,dc=com 729changetype: add 730cn: Add-Mod-Del 731objectclass: organizationalRole 732 733dn: cn=Add-Mod-Del,dc=example,dc=com 734changetype: modify 735replace: description 736description: guinea pig 737- 738 739dn: cn=Add-Mod-Del,dc=example,dc=com 740changetype: delete 741EOMODS 742RC=$? 743if test $RC != 0 ; then 744 echo "ldapmodify failed for server 1 database ($RC)!" 745 test $KILLSERVERS != no && kill -HUP $KILLPIDS 746 exit $RC 747fi 748done 749 750echo "Waiting $SLEEP1 seconds for servers to resync..." 751sleep $SLEEP1 752 753n=1 754while [ $n -le $MMR ]; do 755PORT=`expr $BASEPORT + $n` 756URI="ldap://${LOCALHOST}:$PORT/" 757 758echo "Using ldapsearch to read all the entries from server $n..." 759$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 760 'objectclass=*' > $TESTDIR/server$n.out 2>&1 761RC=$? 762 763if test $RC != 0 ; then 764 echo "ldapsearch failed at server $n ($RC)!" 765 test $KILLSERVERS != no && kill -HUP $KILLPIDS 766 exit $RC 767fi 768$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 769n=`expr $n + 1` 770done 771 772n=2 773while [ $n -le $MMR ]; do 774echo "Comparing retrieved entries from server 1 and server $n..." 775$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT 776 777if test $? != 0 ; then 778 echo "test failed - server 1 and server $n databases differ" 779 test $KILLSERVERS != no && kill -HUP $KILLPIDS 780 exit 1 781fi 782n=`expr $n + 1` 783done 784 785test $KILLSERVERS != no && kill -HUP $KILLPIDS 786 787echo ">>>>> Test succeeded" 788 789test $KILLSERVERS != no && wait 790 791exit 0 792