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