1#! /bin/sh 2# $OpenLDAP$ 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 1998-2011 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: $TESTWD/../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: $TESTWD/../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 314if test $INDEXDB = indexdb ; then 315 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1 316dn: olcDatabase={1}$BACKEND,cn=config 317changetype: modify 318add: olcDbIndex 319olcDbIndex: objectClass,entryUUID,entryCSN eq 320olcDbIndex: cn,uid pres,eq,sub 321EOF 322 RC=$? 323 if test $RC != 0 ; then 324 echo "ldapadd modify for database config ($RC)!" 325 test $KILLSERVERS != no && kill -HUP $KILLPIDS 326 exit $RC 327 fi 328fi 329 330echo "Using ldapadd to populate server 1..." 331$LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDERED \ 332 >> $TESTOUT 2>&1 333RC=$? 334if test $RC != 0 ; then 335 echo "ldapadd failed for server 1 database ($RC)!" 336 test $KILLSERVERS != no && kill -HUP $KILLPIDS 337 exit $RC 338fi 339 340echo "Waiting $SLEEP2 seconds for syncrepl to receive changes..." 341sleep $SLEEP2 342 343n=1 344while [ $n -le $MMR ]; do 345PORT=`expr $BASEPORT + $n` 346URI="ldap://${LOCALHOST}:$PORT/" 347 348echo "Using ldapsearch to read config from server $n..." 349$LDAPSEARCH -b cn=config -D cn=config -H $URI -y $CONFIGPWF \ 350 'objectclass=*' > $TESTDIR/server$n.out 2>&1 351RC=$? 352 353if test $RC != 0 ; then 354 echo "ldapsearch failed at server $n ($RC)!" 355 test $KILLSERVERS != no && kill -HUP $KILLPIDS 356 exit $RC 357fi 358 359$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 360 361n=`expr $n + 1` 362done 363 364n=2 365while [ $n -le $MMR ]; do 366echo "Comparing retrieved configs from server 1 and server $n..." 367$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT 368 369if test $? != 0 ; then 370 echo "test failed - server 1 and server $n configs differ" 371 test $KILLSERVERS != no && kill -HUP $KILLPIDS 372 exit 1 373fi 374n=`expr $n + 1` 375done 376 377n=1 378while [ $n -le $MMR ]; do 379PORT=`expr $BASEPORT + $n` 380URI="ldap://${LOCALHOST}:$PORT/" 381 382echo "Using ldapsearch to read all the entries from server $n..." 383$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 384 'objectclass=*' > $TESTDIR/server$n.out 2>&1 385RC=$? 386 387if test $RC != 0 ; then 388 echo "ldapsearch failed at server $n ($RC)!" 389 test $KILLSERVERS != no && kill -HUP $KILLPIDS 390 exit $RC 391fi 392$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 393n=`expr $n + 1` 394done 395 396n=2 397while [ $n -le $MMR ]; do 398echo "Comparing retrieved entries from server 1 and server $n..." 399$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT 400 401if test $? != 0 ; then 402 echo "test failed - server 1 and server $n databases differ" 403 test $KILLSERVERS != no && kill -HUP $KILLPIDS 404 exit 1 405fi 406n=`expr $n + 1` 407done 408 409echo "Using ldapadd to populate server 2..." 410$LDAPADD -D "$MANAGERDN" -H $URI2 -w $PASSWD -f $LDIFADD1 \ 411 >> $TESTOUT 2>&1 412RC=$? 413if test $RC != 0 ; then 414 echo "ldapadd failed for server 2 database ($RC)!" 415 test $KILLSERVERS != no && kill -HUP $KILLPIDS 416 exit $RC 417fi 418 419echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 420sleep $SLEEP1 421 422n=1 423while [ $n -le $MMR ]; do 424PORT=`expr $BASEPORT + $n` 425URI="ldap://${LOCALHOST}:$PORT/" 426 427echo "Using ldapsearch to read all the entries from server $n..." 428$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 429 'objectclass=*' > $TESTDIR/server$n.out 2>&1 430RC=$? 431 432if test $RC != 0 ; then 433 echo "ldapsearch failed at server $n ($RC)!" 434 test $KILLSERVERS != no && kill -HUP $KILLPIDS 435 exit $RC 436fi 437$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 438n=`expr $n + 1` 439done 440 441n=2 442while [ $n -le $MMR ]; do 443echo "Comparing retrieved entries from server 1 and server $n..." 444$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT 445 446if test $? != 0 ; then 447 echo "test failed - server 1 and server $n databases differ" 448 test $KILLSERVERS != no && kill -HUP $KILLPIDS 449 exit 1 450fi 451n=`expr $n + 1` 452done 453 454echo "Using ldapadd to populate server 3..." 455$LDAPADD -D "$MANAGERDN" -H $URI3 -w $PASSWD \ 456 << EOMODS >> $TESTOUT 2>&1 457dn: cn=Server 3 Test,dc=example,dc=com 458changetype: add 459objectClass: device 460cn: Server 3 Test 461EOMODS 462RC=$? 463if test $RC != 0 ; then 464 echo "ldapadd failed for server 3 database ($RC)!" 465 test $KILLSERVERS != no && kill -HUP $KILLPIDS 466 exit $RC 467fi 468 469echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 470sleep $SLEEP1 471 472n=1 473while [ $n -le $MMR ]; do 474PORT=`expr $BASEPORT + $n` 475URI="ldap://${LOCALHOST}:$PORT/" 476 477echo "Using ldapsearch to read all the entries from server $n..." 478$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 479 'objectclass=*' > $TESTDIR/server$n.out 2>&1 480RC=$? 481 482if test $RC != 0 ; then 483 echo "ldapsearch failed at server $n ($RC)!" 484 test $KILLSERVERS != no && kill -HUP $KILLPIDS 485 exit $RC 486fi 487$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 488n=`expr $n + 1` 489done 490 491n=2 492while [ $n -le $MMR ]; do 493echo "Comparing retrieved entries from server 1 and server $n..." 494$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT 495 496if test $? != 0 ; then 497 echo "test failed - server 1 and server $n databases differ" 498 test $KILLSERVERS != no && kill -HUP $KILLPIDS 499 exit 1 500fi 501n=`expr $n + 1` 502done 503 504echo "Using ldapmodify to add to server 1 entries that will be deleted..." 505$LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \ 506 >> $TESTOUT 2>&1 << EOADDS 507dn: cn=To be deleted by server 1,dc=example,dc=com 508changetype: add 509objectClass: device 510# no distinguished values, will be added by DSA 511 512dn: cn=To be deleted by server 2,dc=example,dc=com 513changetype: add 514objectClass: device 515# no distinguished values, will be added by DSA 516 517dn: cn=To be deleted by server 3,dc=example,dc=com 518changetype: add 519objectClass: device 520# no distinguished values, will be added by DSA 521 522dn: cn=To be deleted by server 1,dc=example,dc=com 523changetype: delete 524EOADDS 525RC=$? 526if test $RC != 0 ; then 527 echo "ldapmodify failed for server 1 database ($RC)!" 528 test $KILLSERVERS != no && kill -HUP $KILLPIDS 529 exit $RC 530fi 531 532echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 533sleep $SLEEP1 534 535n=1 536while [ $n -le $MMR ]; do 537PORT=`expr $BASEPORT + $n` 538URI="ldap://${LOCALHOST}:$PORT/" 539 540echo "Using ldapsearch to read all the entries from server $n..." 541$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 542 'objectclass=*' > $TESTDIR/server$n.out 2>&1 543RC=$? 544 545if test $RC != 0 ; then 546 echo "ldapsearch failed at server $n ($RC)!" 547 test $KILLSERVERS != no && kill -HUP $KILLPIDS 548 exit $RC 549fi 550$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 551n=`expr $n + 1` 552done 553 554n=2 555while [ $n -le $MMR ]; do 556echo "Comparing retrieved entries from server 1 and server $n..." 557$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT 558 559if test $? != 0 ; then 560 echo "test failed - server 1 and server $n databases differ" 561 test $KILLSERVERS != no && kill -HUP $KILLPIDS 562 exit 1 563fi 564n=`expr $n + 1` 565done 566 567echo "Using ldapmodify to delete entries from server 2..." 568$LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \ 569 >> $TESTOUT 2>&1 << EOADDS 570dn: cn=To be deleted by server 2,dc=example,dc=com 571changetype: delete 572EOADDS 573RC=$? 574if test $RC != 0 ; then 575 echo "ldapmodify failed for server 2 database ($RC)!" 576 test $KILLSERVERS != no && kill -HUP $KILLPIDS 577 exit $RC 578fi 579 580echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 581sleep $SLEEP1 582 583echo "Using ldapmodify to delete entries from server 3..." 584$LDAPMODIFY -D "$MANAGERDN" -H $URI3 -w $PASSWD \ 585 >> $TESTOUT 2>&1 << EOADDS 586dn: cn=To be deleted by server 3,dc=example,dc=com 587changetype: delete 588EOADDS 589RC=$? 590if test $RC != 0 ; then 591 echo "ldapmodify failed for server 3 database ($RC)!" 592 test $KILLSERVERS != no && kill -HUP $KILLPIDS 593 exit $RC 594fi 595 596echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 597sleep $SLEEP1 598 599n=1 600while [ $n -le $MMR ]; do 601PORT=`expr $BASEPORT + $n` 602URI="ldap://${LOCALHOST}:$PORT/" 603 604echo "Using ldapsearch to read all the entries from server $n..." 605$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 606 'objectclass=*' > $TESTDIR/server$n.out 2>&1 607RC=$? 608 609if test $RC != 0 ; then 610 echo "ldapsearch failed at server $n ($RC)!" 611 test $KILLSERVERS != no && kill -HUP $KILLPIDS 612 exit $RC 613fi 614$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 615n=`expr $n + 1` 616done 617 618n=2 619while [ $n -le $MMR ]; do 620echo "Comparing retrieved entries from server 1 and server $n..." 621$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT 622 623if test $? != 0 ; then 624 echo "test failed - server 1 and server $n databases differ" 625 test $KILLSERVERS != no && kill -HUP $KILLPIDS 626 exit 1 627fi 628n=`expr $n + 1` 629done 630 631# kill! 632# test $KILLSERVERS != no && kill -HUP $KILLPIDS 633kill -HUP $KILLPIDS 634 635# kill! 636# test $KILLSERVERS != no && wait 637wait 638 639echo "Restarting servers..." 640KILLPIDS="" 641 642echo "Starting server 1 on TCP/IP port $PORT1..." 643echo "======================= RESTART =======================" >> $LOG1 644cd ${XDIR}1 645$SLAPD -F slapd.d -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 & 646PID=$! 647if test $WAIT != 0 ; then 648 echo PID $PID 649 read foo 650fi 651KILLPIDS="$PID" 652cd $TESTWD 653 654sleep 1 655 656echo "Using ldapsearch to check that server 1 is running..." 657for i in 0 1 2 3 4 5; do 658 $LDAPSEARCH -s base -b "" -H $URI1 \ 659 'objectclass=*' > /dev/null 2>&1 660 RC=$? 661 if test $RC = 0 ; then 662 break 663 fi 664 echo "Waiting 5 seconds for slapd to start..." 665 sleep 5 666done 667 668if test $RC != 0 ; then 669 echo "ldapsearch failed ($RC)!" 670 test $KILLSERVERS != no && kill -HUP $KILLPIDS 671 exit $RC 672fi 673 674n=2 675while [ $n -le $MMR ]; do 676PORT=`expr $BASEPORT + $n` 677URI="ldap://${LOCALHOST}:$PORT/" 678LOG=$TESTDIR/slapd.$n.log 679echo "Starting server $n on TCP/IP port $PORT..." 680cd ${XDIR}$n 681echo "======================= RESTART =======================" >> $LOG 682$SLAPD -F ./slapd.d -h $URI -d $LVL $TIMING >> $LOG 2>&1 & 683PID=$! 684if test $WAIT != 0 ; then 685 echo PID $PID 686 read foo 687fi 688KILLPIDS="$KILLPIDS $PID" 689cd $TESTWD 690n=`expr $n + 1` 691done 692 693n=2 694while [ $n -le $MMR ]; do 695PORT=`expr $BASEPORT + $n` 696URI="ldap://${LOCALHOST}:$PORT/" 697echo "Using ldapsearch to check that server $n is running..." 698for i in 0 1 2 3 4 5; do 699 $LDAPSEARCH -s base -b "" -H $URI \ 700 'objectclass=*' > /dev/null 2>&1 701 RC=$? 702 if test $RC = 0 ; then 703 break 704 fi 705 echo "Waiting 5 seconds for slapd to start..." 706 sleep 5 707done 708 709if test $RC != 0 ; then 710 echo "ldapsearch failed ($RC)!" 711 test $KILLSERVERS != no && kill -HUP $KILLPIDS 712 exit $RC 713fi 714n=`expr $n + 1` 715done 716 717# Insert modifications and more tests here. 718echo "Waiting $SLEEP1 seconds for servers to resync..." 719sleep $SLEEP1 720 721echo "Using ldapmodify to add/modify/delete entries from server 1..." 722for i in 1 2 3 4 5 6 7 8 9 10; do 723echo " iteration $i" 724$LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \ 725 >> $TESTOUT 2>&1 << EOMODS 726dn: cn=Add-Mod-Del,dc=example,dc=com 727changetype: add 728cn: Add-Mod-Del 729objectclass: organizationalRole 730 731dn: cn=Add-Mod-Del,dc=example,dc=com 732changetype: modify 733replace: description 734description: guinea pig 735- 736 737dn: cn=Add-Mod-Del,dc=example,dc=com 738changetype: delete 739EOMODS 740RC=$? 741if test $RC != 0 ; then 742 echo "ldapmodify failed for server 1 database ($RC)!" 743 test $KILLSERVERS != no && kill -HUP $KILLPIDS 744 exit $RC 745fi 746done 747 748echo "Waiting $SLEEP1 seconds for servers to resync..." 749sleep $SLEEP1 750 751n=1 752while [ $n -le $MMR ]; do 753PORT=`expr $BASEPORT + $n` 754URI="ldap://${LOCALHOST}:$PORT/" 755 756echo "Using ldapsearch to read all the entries from server $n..." 757$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 758 'objectclass=*' > $TESTDIR/server$n.out 2>&1 759RC=$? 760 761if test $RC != 0 ; then 762 echo "ldapsearch failed at server $n ($RC)!" 763 test $KILLSERVERS != no && kill -HUP $KILLPIDS 764 exit $RC 765fi 766$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 767n=`expr $n + 1` 768done 769 770n=2 771while [ $n -le $MMR ]; do 772echo "Comparing retrieved entries from server 1 and server $n..." 773$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT 774 775if test $? != 0 ; then 776 echo "test failed - server 1 and server $n databases differ" 777 test $KILLSERVERS != no && kill -HUP $KILLPIDS 778 exit 1 779fi 780n=`expr $n + 1` 781done 782 783test $KILLSERVERS != no && kill -HUP $KILLPIDS 784 785echo ">>>>> Test succeeded" 786 787test $KILLSERVERS != no && wait 788 789exit 0 790