1*e670fd5cSchristos#! /bin/sh 2*e670fd5cSchristos# $OpenLDAP$ 3*e670fd5cSchristos## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4*e670fd5cSchristos## 5*e670fd5cSchristos## Copyright 1998-2021 The OpenLDAP Foundation. 6*e670fd5cSchristos## All rights reserved. 7*e670fd5cSchristos## 8*e670fd5cSchristos## Redistribution and use in source and binary forms, with or without 9*e670fd5cSchristos## modification, are permitted only as authorized by the OpenLDAP 10*e670fd5cSchristos## Public License. 11*e670fd5cSchristos## 12*e670fd5cSchristos## A copy of this license is available in the file LICENSE in the 13*e670fd5cSchristos## top-level directory of the distribution or, alternatively, at 14*e670fd5cSchristos## <http://www.OpenLDAP.org/license.html>. 15*e670fd5cSchristos 16*e670fd5cSchristosecho "running defines.sh" 17*e670fd5cSchristos. $SRCDIR/scripts/defines.sh 18*e670fd5cSchristos 19*e670fd5cSchristosif test $SYNCPROV = syncprovno; then 20*e670fd5cSchristos echo "Syncrepl provider overlay not available, test skipped" 21*e670fd5cSchristos exit 0 22*e670fd5cSchristosfi 23*e670fd5cSchristosif test $ACCESSLOG = accesslogno; then 24*e670fd5cSchristos echo "Accesslog overlay not available, test skipped" 25*e670fd5cSchristos exit 0 26*e670fd5cSchristosfi 27*e670fd5cSchristos 28*e670fd5cSchristosMMR=2 29*e670fd5cSchristos 30*e670fd5cSchristosXDIR=$TESTDIR/srv 31*e670fd5cSchristosTMP=$TESTDIR/tmp 32*e670fd5cSchristos 33*e670fd5cSchristosmkdir -p $TESTDIR 34*e670fd5cSchristos 35*e670fd5cSchristos$SLAPPASSWD -g -n >$CONFIGPWF 36*e670fd5cSchristos 37*e670fd5cSchristosif test x"$SYNCMODE" = x ; then 38*e670fd5cSchristos SYNCMODE=rp 39*e670fd5cSchristosfi 40*e670fd5cSchristoscase "$SYNCMODE" in 41*e670fd5cSchristos ro) 42*e670fd5cSchristos SYNCTYPE="type=refreshOnly interval=00:00:00:03" 43*e670fd5cSchristos ;; 44*e670fd5cSchristos rp) 45*e670fd5cSchristos SYNCTYPE="type=refreshAndPersist interval=00:00:00:03" 46*e670fd5cSchristos ;; 47*e670fd5cSchristos *) 48*e670fd5cSchristos echo "unknown sync mode $SYNCMODE" 49*e670fd5cSchristos exit 1; 50*e670fd5cSchristos ;; 51*e670fd5cSchristosesac 52*e670fd5cSchristos 53*e670fd5cSchristos# 54*e670fd5cSchristos# Test delta-sync mmr 55*e670fd5cSchristos# - start servers 56*e670fd5cSchristos# - configure over ldap 57*e670fd5cSchristos# - populate over ldap 58*e670fd5cSchristos# - configure syncrepl over ldap 59*e670fd5cSchristos# - break replication 60*e670fd5cSchristos# - modify each server separately 61*e670fd5cSchristos# - restore replication 62*e670fd5cSchristos# - compare results 63*e670fd5cSchristos# 64*e670fd5cSchristos 65*e670fd5cSchristosnullExclude="" 66*e670fd5cSchristostest $BACKEND = null && nullExclude="# " 67*e670fd5cSchristos 68*e670fd5cSchristosKILLPIDS= 69*e670fd5cSchristos 70*e670fd5cSchristosecho "Initializing server configurations..." 71*e670fd5cSchristosn=1 72*e670fd5cSchristoswhile [ $n -le $MMR ]; do 73*e670fd5cSchristos 74*e670fd5cSchristosDBDIR=${XDIR}$n/db 75*e670fd5cSchristosCFDIR=${XDIR}$n/slapd.d 76*e670fd5cSchristos 77*e670fd5cSchristosmkdir -p ${XDIR}$n $DBDIR.1 $DBDIR.2 $CFDIR 78*e670fd5cSchristos 79*e670fd5cSchristoso=`expr 3 - $n` 80*e670fd5cSchristoscat > $TMP <<EOF 81*e670fd5cSchristosdn: cn=config 82*e670fd5cSchristosobjectClass: olcGlobal 83*e670fd5cSchristoscn: config 84*e670fd5cSchristosolcServerID: $n 85*e670fd5cSchristos 86*e670fd5cSchristosEOF 87*e670fd5cSchristos 88*e670fd5cSchristosif [ "$SYNCPROV" = syncprovmod -o "$ACCESSLOG" = accesslogmod ]; then 89*e670fd5cSchristos cat <<EOF >> $TMP 90*e670fd5cSchristosdn: cn=module,cn=config 91*e670fd5cSchristosobjectClass: olcModuleList 92*e670fd5cSchristoscn: module 93*e670fd5cSchristosolcModulePath: $TESTWD/../servers/slapd/overlays 94*e670fd5cSchristosEOF 95*e670fd5cSchristos if [ "$SYNCPROV" = syncprovmod ]; then 96*e670fd5cSchristos echo "olcModuleLoad: syncprov.la" >> $TMP 97*e670fd5cSchristos fi 98*e670fd5cSchristos if [ "$ACCESSLOG" = accesslogmod ]; then 99*e670fd5cSchristos echo "olcModuleLoad: accesslog.la" >> $TMP 100*e670fd5cSchristos fi 101*e670fd5cSchristos echo "" >> $TMP 102*e670fd5cSchristosfi 103*e670fd5cSchristos 104*e670fd5cSchristosif [ "$BACKENDTYPE" = mod ]; then 105*e670fd5cSchristoscat <<EOF >> $TMP 106*e670fd5cSchristosdn: cn=module,cn=config 107*e670fd5cSchristosobjectClass: olcModuleList 108*e670fd5cSchristoscn: module 109*e670fd5cSchristosolcModulePath: $TESTWD/../servers/slapd/back-$BACKEND 110*e670fd5cSchristosolcModuleLoad: back_$BACKEND.la 111*e670fd5cSchristos 112*e670fd5cSchristosEOF 113*e670fd5cSchristosfi 114*e670fd5cSchristosMYURI=`eval echo '$URI'$n` 115*e670fd5cSchristosPROVIDERURI=`eval echo '$URI'$o` 116*e670fd5cSchristosif test $INDEXDB = indexdb ; then 117*e670fd5cSchristosINDEX1="olcDbIndex: objectClass,entryCSN,reqStart,reqDN,reqResult eq" 118*e670fd5cSchristosINDEX2="olcDbIndex: objectClass,entryCSN,entryUUID eq" 119*e670fd5cSchristoselse 120*e670fd5cSchristosINDEX1= 121*e670fd5cSchristosINDEX2= 122*e670fd5cSchristosfi 123*e670fd5cSchristoscat >> $TMP <<EOF 124*e670fd5cSchristosdn: cn=schema,cn=config 125*e670fd5cSchristosobjectclass: olcSchemaconfig 126*e670fd5cSchristoscn: schema 127*e670fd5cSchristos 128*e670fd5cSchristosinclude: file://$ABS_SCHEMADIR/core.ldif 129*e670fd5cSchristos 130*e670fd5cSchristosinclude: file://$ABS_SCHEMADIR/cosine.ldif 131*e670fd5cSchristos 132*e670fd5cSchristosinclude: file://$ABS_SCHEMADIR/inetorgperson.ldif 133*e670fd5cSchristos 134*e670fd5cSchristosinclude: file://$ABS_SCHEMADIR/openldap.ldif 135*e670fd5cSchristos 136*e670fd5cSchristosinclude: file://$ABS_SCHEMADIR/nis.ldif 137*e670fd5cSchristos 138*e670fd5cSchristosdn: olcDatabase={0}config,cn=config 139*e670fd5cSchristosobjectClass: olcDatabaseConfig 140*e670fd5cSchristosolcDatabase: {0}config 141*e670fd5cSchristosolcRootPW:< file://$CONFIGPWF 142*e670fd5cSchristos 143*e670fd5cSchristosdn: olcDatabase={1}$BACKEND,cn=config 144*e670fd5cSchristosobjectClass: olcDatabaseConfig 145*e670fd5cSchristos${nullExclude}objectClass: olc${BACKEND}Config 146*e670fd5cSchristosolcDatabase: {1}$BACKEND 147*e670fd5cSchristosolcSuffix: cn=log 148*e670fd5cSchristos${nullExclude}olcDbDirectory: ${DBDIR}.1 149*e670fd5cSchristosolcRootDN: $MANAGERDN 150*e670fd5cSchristos$INDEX1 151*e670fd5cSchristos 152*e670fd5cSchristosdn: olcOverlay=syncprov,olcDatabase={1}$BACKEND,cn=config 153*e670fd5cSchristosobjectClass: olcOverlayConfig 154*e670fd5cSchristosobjectClass: olcSyncProvConfig 155*e670fd5cSchristosolcOverlay: syncprov 156*e670fd5cSchristosolcSpNoPresent: TRUE 157*e670fd5cSchristosolcSpReloadHint: TRUE 158*e670fd5cSchristos 159*e670fd5cSchristosdn: olcDatabase={2}$BACKEND,cn=config 160*e670fd5cSchristosobjectClass: olcDatabaseConfig 161*e670fd5cSchristos${nullExclude}objectClass: olc${BACKEND}Config 162*e670fd5cSchristosolcDatabase: {2}$BACKEND 163*e670fd5cSchristosolcSuffix: $BASEDN 164*e670fd5cSchristos${nullExclude}olcDbDirectory: ${DBDIR}.2 165*e670fd5cSchristosolcRootDN: $MANAGERDN 166*e670fd5cSchristosolcRootPW: $PASSWD 167*e670fd5cSchristosolcSyncRepl: rid=001 provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple 168*e670fd5cSchristos credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE retry="3 +" timeout=3 169*e670fd5cSchristosolcMirrorMode: TRUE 170*e670fd5cSchristos$INDEX2 171*e670fd5cSchristos 172*e670fd5cSchristosdn: olcOverlay=syncprov,olcDatabase={2}$BACKEND,cn=config 173*e670fd5cSchristosobjectClass: olcOverlayConfig 174*e670fd5cSchristosobjectClass: olcSyncProvConfig 175*e670fd5cSchristosolcOverlay: syncprov 176*e670fd5cSchristosolcSpSessionlogSource: cn=log 177*e670fd5cSchristos 178*e670fd5cSchristosdn: olcOverlay=accesslog,olcDatabase={2}$BACKEND,cn=config 179*e670fd5cSchristosobjectClass: olcOverlayConfig 180*e670fd5cSchristosobjectClass: olcAccessLogConfig 181*e670fd5cSchristosolcOverlay: accesslog 182*e670fd5cSchristosolcAccessLogDB: cn=log 183*e670fd5cSchristosolcAccessLogOps: writes 184*e670fd5cSchristosolcAccessLogSuccess: TRUE 185*e670fd5cSchristos 186*e670fd5cSchristosEOF 187*e670fd5cSchristos$SLAPADD -F $CFDIR -n 0 -d-1< $TMP > $TESTOUT 2>&1 188*e670fd5cSchristosPORT=`eval echo '$PORT'$n` 189*e670fd5cSchristosecho "Starting server $n on TCP/IP port $PORT..." 190*e670fd5cSchristoscd ${XDIR}${n} 191*e670fd5cSchristosLOG=`eval echo '$LOG'$n` 192*e670fd5cSchristos$SLAPD -F slapd.d -h $MYURI -d $LVL > $LOG 2>&1 & 193*e670fd5cSchristosPID=$! 194*e670fd5cSchristosif test $WAIT != 0 ; then 195*e670fd5cSchristos echo PID $PID 196*e670fd5cSchristos read foo 197*e670fd5cSchristosfi 198*e670fd5cSchristosKILLPIDS="$PID $KILLPIDS" 199*e670fd5cSchristoscd $TESTWD 200*e670fd5cSchristos 201*e670fd5cSchristosecho "Using ldapsearch to check that server $n is running..." 202*e670fd5cSchristosfor i in 0 1 2 3 4 5; do 203*e670fd5cSchristos $LDAPSEARCH -s base -b "" -H $MYURI \ 204*e670fd5cSchristos 'objectclass=*' > /dev/null 2>&1 205*e670fd5cSchristos RC=$? 206*e670fd5cSchristos if test $RC = 0 ; then 207*e670fd5cSchristos break 208*e670fd5cSchristos fi 209*e670fd5cSchristos echo "Waiting 5 seconds for slapd to start..." 210*e670fd5cSchristos sleep 5 211*e670fd5cSchristosdone 212*e670fd5cSchristos 213*e670fd5cSchristosif test $RC != 0 ; then 214*e670fd5cSchristos echo "ldapsearch failed ($RC)!" 215*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 216*e670fd5cSchristos exit $RC 217*e670fd5cSchristosfi 218*e670fd5cSchristos 219*e670fd5cSchristosif [ $n = 1 ]; then 220*e670fd5cSchristosecho "Using ldapadd for context on server 1..." 221*e670fd5cSchristos$LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDEREDCP \ 222*e670fd5cSchristos >> $TESTOUT 2>&1 223*e670fd5cSchristosRC=$? 224*e670fd5cSchristosif test $RC != 0 ; then 225*e670fd5cSchristos echo "ldapadd failed for server $n database ($RC)!" 226*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 227*e670fd5cSchristos exit $RC 228*e670fd5cSchristosfi 229*e670fd5cSchristosfi 230*e670fd5cSchristos 231*e670fd5cSchristosn=`expr $n + 1` 232*e670fd5cSchristosdone 233*e670fd5cSchristos 234*e670fd5cSchristosecho "Using ldapadd to populate server 1..." 235*e670fd5cSchristos$LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDEREDNOCP \ 236*e670fd5cSchristos >> $TESTOUT 2>&1 237*e670fd5cSchristosRC=$? 238*e670fd5cSchristosif test $RC != 0 ; then 239*e670fd5cSchristos echo "ldapadd failed for server 1 database ($RC)!" 240*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 241*e670fd5cSchristos exit $RC 242*e670fd5cSchristosfi 243*e670fd5cSchristos 244*e670fd5cSchristosecho "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 245*e670fd5cSchristossleep $SLEEP1 246*e670fd5cSchristos 247*e670fd5cSchristosn=1 248*e670fd5cSchristoswhile [ $n -le $MMR ]; do 249*e670fd5cSchristosURI=`eval echo '$URI'$n` 250*e670fd5cSchristos 251*e670fd5cSchristosecho "Using ldapsearch to read all the entries from server $n..." 252*e670fd5cSchristos$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 253*e670fd5cSchristos 'objectclass=*' > $TESTDIR/server$n.out 2>&1 254*e670fd5cSchristosRC=$? 255*e670fd5cSchristos 256*e670fd5cSchristosif test $RC != 0 ; then 257*e670fd5cSchristos echo "ldapsearch failed at server $n ($RC)!" 258*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 259*e670fd5cSchristos exit $RC 260*e670fd5cSchristosfi 261*e670fd5cSchristos$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 262*e670fd5cSchristosn=`expr $n + 1` 263*e670fd5cSchristosdone 264*e670fd5cSchristos 265*e670fd5cSchristosn=2 266*e670fd5cSchristoswhile [ $n -le $MMR ]; do 267*e670fd5cSchristosecho "Comparing retrieved entries from server 1 and server $n..." 268*e670fd5cSchristos$CMP $PROVIDERFLT $TESTDIR/server$n.flt > $CMPOUT 269*e670fd5cSchristos 270*e670fd5cSchristosif test $? != 0 ; then 271*e670fd5cSchristos echo "test failed - server 1 and server $n databases differ" 272*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 273*e670fd5cSchristos exit 1 274*e670fd5cSchristosfi 275*e670fd5cSchristosn=`expr $n + 1` 276*e670fd5cSchristosdone 277*e670fd5cSchristos 278*e670fd5cSchristosecho "Using ldapadd to populate server 2..." 279*e670fd5cSchristos$LDAPADD -D "$MANAGERDN" -H $URI2 -w $PASSWD -f $LDIFADD1 \ 280*e670fd5cSchristos >> $TESTOUT 2>&1 281*e670fd5cSchristosRC=$? 282*e670fd5cSchristosif test $RC != 0 ; then 283*e670fd5cSchristos echo "ldapadd failed for server 2 database ($RC)!" 284*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 285*e670fd5cSchristos exit $RC 286*e670fd5cSchristosfi 287*e670fd5cSchristos 288*e670fd5cSchristosTHEDN="cn=James A Jones 2,ou=Alumni Association,ou=People,dc=example,dc=com" 289*e670fd5cSchristossleep 1 290*e670fd5cSchristosfor i in 1 2 3; do 291*e670fd5cSchristos $LDAPSEARCH -S "" -b "$THEDN" -H $URI1 \ 292*e670fd5cSchristos -s base '(objectClass=*)' entryCSN > "${PROVIDEROUT}.$i" 2>&1 293*e670fd5cSchristos RC=$? 294*e670fd5cSchristos 295*e670fd5cSchristos if test $RC = 0 ; then 296*e670fd5cSchristos break 297*e670fd5cSchristos fi 298*e670fd5cSchristos 299*e670fd5cSchristos if test $RC != 32 ; then 300*e670fd5cSchristos echo "ldapsearch failed at slave ($RC)!" 301*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 302*e670fd5cSchristos exit $RC 303*e670fd5cSchristos fi 304*e670fd5cSchristos 305*e670fd5cSchristos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 306*e670fd5cSchristos sleep $SLEEP1 307*e670fd5cSchristosdone 308*e670fd5cSchristos 309*e670fd5cSchristosn=1 310*e670fd5cSchristoswhile [ $n -le $MMR ]; do 311*e670fd5cSchristosURI=`eval echo '$URI'$n` 312*e670fd5cSchristos 313*e670fd5cSchristosecho "Using ldapsearch to read all the entries from server $n..." 314*e670fd5cSchristos$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 315*e670fd5cSchristos 'objectclass=*' > $TESTDIR/server$n.out 2>&1 316*e670fd5cSchristosRC=$? 317*e670fd5cSchristos 318*e670fd5cSchristosif test $RC != 0 ; then 319*e670fd5cSchristos echo "ldapsearch failed at server $n ($RC)!" 320*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 321*e670fd5cSchristos exit $RC 322*e670fd5cSchristosfi 323*e670fd5cSchristos$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 324*e670fd5cSchristosn=`expr $n + 1` 325*e670fd5cSchristosdone 326*e670fd5cSchristos 327*e670fd5cSchristosn=2 328*e670fd5cSchristoswhile [ $n -le $MMR ]; do 329*e670fd5cSchristosecho "Comparing retrieved entries from server 1 and server $n..." 330*e670fd5cSchristos$CMP $PROVIDERFLT $TESTDIR/server$n.flt > $CMPOUT 331*e670fd5cSchristos 332*e670fd5cSchristosif test $? != 0 ; then 333*e670fd5cSchristos echo "test failed - server 1 and server $n databases differ" 334*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 335*e670fd5cSchristos exit 1 336*e670fd5cSchristosfi 337*e670fd5cSchristosn=`expr $n + 1` 338*e670fd5cSchristosdone 339*e670fd5cSchristos 340*e670fd5cSchristosecho "Retrieving syncrepl cookie..." 341*e670fd5cSchristoscookie=`$LDAPRSEARCH -b "$BASEDN" -D "$MANAGERDN" -H $URI1 -w $PASSWD \ 342*e670fd5cSchristos -E "sync=ro" 'objectclass=*' 1.1 | grep cookie | sed "s/.*cookie: //"` 343*e670fd5cSchristos 344*e670fd5cSchristosif test -z "$cookie"; then 345*e670fd5cSchristos echo "Failed to retrieve cookie from server!" 346*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 347*e670fd5cSchristos exit 1 348*e670fd5cSchristosfi 349*e670fd5cSchristos 350*e670fd5cSchristosecho "Deleting an entry from server 1..." 351*e670fd5cSchristos$LDAPDELETE -D "$MANAGERDN" -H $URI1 -w $PASSWD \ 352*e670fd5cSchristos "cn=Mark Elliot,ou=Alumni Association,ou=People,$BASEDN" \ 353*e670fd5cSchristos >> $TESTOUT 2>&1 354*e670fd5cSchristosRC=$? 355*e670fd5cSchristosif test $RC != 0 ; then 356*e670fd5cSchristos echo "ldapdelete failed for server 1 database ($RC)!" 357*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 358*e670fd5cSchristos exit $RC 359*e670fd5cSchristosfi 360*e670fd5cSchristos 361*e670fd5cSchristos 362*e670fd5cSchristosecho "Restarting servers..." 363*e670fd5cSchristoskill -HUP $KILLPIDS 364*e670fd5cSchristoswait 365*e670fd5cSchristosKILLPIDS="" 366*e670fd5cSchristosn=1 367*e670fd5cSchristoswhile [ $n -le $MMR ]; do 368*e670fd5cSchristoso=`expr 3 - $n` 369*e670fd5cSchristosMYURI=`eval echo '$URI'$n` 370*e670fd5cSchristosPROVIDERURI=`eval echo '$URI'$o` 371*e670fd5cSchristos 372*e670fd5cSchristosecho "Starting server $n again..." 373*e670fd5cSchristoscd ${XDIR}${n} 374*e670fd5cSchristosLOG=`eval echo '$LOG'$n` 375*e670fd5cSchristosecho "RESTART" >> $LOG 376*e670fd5cSchristos#if test $n = 2; then 377*e670fd5cSchristos#echo $SLAPD -F slapd.d -h $MYURI -d $LVL 378*e670fd5cSchristos#else 379*e670fd5cSchristos$SLAPD -F slapd.d -h $MYURI -d $LVL > $LOG 2>&1 & 380*e670fd5cSchristos#fi 381*e670fd5cSchristosPID=$! 382*e670fd5cSchristosif test $WAIT != 0 ; then 383*e670fd5cSchristos echo PID $PID 384*e670fd5cSchristos read foo 385*e670fd5cSchristosfi 386*e670fd5cSchristosKILLPIDS="$PID $KILLPIDS" 387*e670fd5cSchristoscd $TESTWD 388*e670fd5cSchristos 389*e670fd5cSchristosecho "Using ldapsearch to check that server $n is running..." 390*e670fd5cSchristosfor i in 0 1 2 3 4 5; do 391*e670fd5cSchristos $LDAPSEARCH -s base -b "" -H $MYURI \ 392*e670fd5cSchristos 'objectclass=*' > /dev/null 2>&1 393*e670fd5cSchristos RC=$? 394*e670fd5cSchristos if test $RC = 0 ; then 395*e670fd5cSchristos break 396*e670fd5cSchristos fi 397*e670fd5cSchristos echo "Waiting 5 seconds for slapd to start..." 398*e670fd5cSchristos sleep 5 399*e670fd5cSchristosdone 400*e670fd5cSchristos 401*e670fd5cSchristosecho "Breaking replication between server $n and $o..." 402*e670fd5cSchristos$LDAPMODIFY -D cn=config -H $MYURI -y $CONFIGPWF > $TESTOUT 2>&1 <<EOF 403*e670fd5cSchristosdn: olcDatabase={2}$BACKEND,cn=config 404*e670fd5cSchristoschangetype: modify 405*e670fd5cSchristosreplace: olcSyncRepl 406*e670fd5cSchristosolcSyncRepl: rid=001 provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple 407*e670fd5cSchristos credentials=InvalidPw searchbase="$BASEDN" $SYNCTYPE retry="3 +" timeout=3 408*e670fd5cSchristos- 409*e670fd5cSchristosreplace: olcMirrorMode 410*e670fd5cSchristosolcMirrorMode: TRUE 411*e670fd5cSchristos 412*e670fd5cSchristosEOF 413*e670fd5cSchristosRC=$? 414*e670fd5cSchristosif test $RC != 0 ; then 415*e670fd5cSchristos echo "ldapmodify failed for server $n config ($RC)!" 416*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 417*e670fd5cSchristos exit $RC 418*e670fd5cSchristosfi 419*e670fd5cSchristosn=`expr $n + 1` 420*e670fd5cSchristosdone 421*e670fd5cSchristos 422*e670fd5cSchristosecho "Using ldapmodify to force conflicts between server 1 and 2..." 423*e670fd5cSchristos$LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \ 424*e670fd5cSchristos >> $TESTOUT 2>&1 << EOF 425*e670fd5cSchristosdn: $THEDN 426*e670fd5cSchristoschangetype: modify 427*e670fd5cSchristosadd: description 428*e670fd5cSchristosdescription: Amazing 429*e670fd5cSchristos 430*e670fd5cSchristosEOF 431*e670fd5cSchristosRC=$? 432*e670fd5cSchristosif test $RC != 0 ; then 433*e670fd5cSchristos echo "ldapmodify failed for server 1 database ($RC)!" 434*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 435*e670fd5cSchristos exit $RC 436*e670fd5cSchristosfi 437*e670fd5cSchristos 438*e670fd5cSchristos$LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \ 439*e670fd5cSchristos >> $TESTOUT 2>&1 << EOF 440*e670fd5cSchristosdn: $THEDN 441*e670fd5cSchristoschangetype: modify 442*e670fd5cSchristosadd: description 443*e670fd5cSchristosdescription: Stupendous 444*e670fd5cSchristos 445*e670fd5cSchristosEOF 446*e670fd5cSchristosRC=$? 447*e670fd5cSchristosif test $RC != 0 ; then 448*e670fd5cSchristos echo "ldapmodify failed for server 2 database ($RC)!" 449*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 450*e670fd5cSchristos exit $RC 451*e670fd5cSchristosfi 452*e670fd5cSchristos 453*e670fd5cSchristos$LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \ 454*e670fd5cSchristos >> $TESTOUT 2>&1 << EOF 455*e670fd5cSchristosdn: $THEDN 456*e670fd5cSchristoschangetype: modify 457*e670fd5cSchristosdelete: description 458*e670fd5cSchristosdescription: Outstanding 459*e670fd5cSchristos- 460*e670fd5cSchristosadd: description 461*e670fd5cSchristosdescription: Mindboggling 462*e670fd5cSchristos 463*e670fd5cSchristosEOF 464*e670fd5cSchristosRC=$? 465*e670fd5cSchristosif test $RC != 0 ; then 466*e670fd5cSchristos echo "ldapmodify failed for server 1 database ($RC)!" 467*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 468*e670fd5cSchristos exit $RC 469*e670fd5cSchristosfi 470*e670fd5cSchristos 471*e670fd5cSchristos$LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \ 472*e670fd5cSchristos >> $TESTOUT 2>&1 << EOF 473*e670fd5cSchristosdn: $THEDN 474*e670fd5cSchristoschangetype: modify 475*e670fd5cSchristosdelete: description 476*e670fd5cSchristosdescription: OutStanding 477*e670fd5cSchristos- 478*e670fd5cSchristosadd: description 479*e670fd5cSchristosdescription: Bizarre 480*e670fd5cSchristos 481*e670fd5cSchristosEOF 482*e670fd5cSchristosRC=$? 483*e670fd5cSchristosif test $RC != 0 ; then 484*e670fd5cSchristos echo "ldapmodify failed for server 2 database ($RC)!" 485*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 486*e670fd5cSchristos exit $RC 487*e670fd5cSchristosfi 488*e670fd5cSchristos 489*e670fd5cSchristos$LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \ 490*e670fd5cSchristos >> $TESTOUT 2>&1 << EOF 491*e670fd5cSchristosdn: $THEDN 492*e670fd5cSchristoschangetype: modify 493*e670fd5cSchristosadd: carLicense 494*e670fd5cSchristoscarLicense: 123-XYZ 495*e670fd5cSchristos- 496*e670fd5cSchristosadd: employeeNumber 497*e670fd5cSchristosemployeeNumber: 32 498*e670fd5cSchristos 499*e670fd5cSchristosEOF 500*e670fd5cSchristosRC=$? 501*e670fd5cSchristosif test $RC != 0 ; then 502*e670fd5cSchristos echo "ldapmodify failed for server 1 database ($RC)!" 503*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 504*e670fd5cSchristos exit $RC 505*e670fd5cSchristosfi 506*e670fd5cSchristos 507*e670fd5cSchristos$LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \ 508*e670fd5cSchristos >> $TESTOUT 2>&1 << EOF 509*e670fd5cSchristosdn: $THEDN 510*e670fd5cSchristoschangetype: modify 511*e670fd5cSchristosadd: employeeType 512*e670fd5cSchristosemployeeType: deadwood 513*e670fd5cSchristos- 514*e670fd5cSchristosadd: employeeNumber 515*e670fd5cSchristosemployeeNumber: 64 516*e670fd5cSchristos 517*e670fd5cSchristosEOF 518*e670fd5cSchristosRC=$? 519*e670fd5cSchristosif test $RC != 0 ; then 520*e670fd5cSchristos echo "ldapmodify failed for server 2 database ($RC)!" 521*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 522*e670fd5cSchristos exit $RC 523*e670fd5cSchristosfi 524*e670fd5cSchristos 525*e670fd5cSchristos$LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \ 526*e670fd5cSchristos >> $TESTOUT 2>&1 << EOF 527*e670fd5cSchristosdn: $THEDN 528*e670fd5cSchristoschangetype: modify 529*e670fd5cSchristosreplace: sn 530*e670fd5cSchristossn: Replaced later 531*e670fd5cSchristos- 532*e670fd5cSchristosreplace: sn 533*e670fd5cSchristossn: Surname 534*e670fd5cSchristosEOF 535*e670fd5cSchristosRC=$? 536*e670fd5cSchristosif test $RC != 0 ; then 537*e670fd5cSchristos echo "ldapmodify failed for server 1 database ($RC)!" 538*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 539*e670fd5cSchristos exit $RC 540*e670fd5cSchristosfi 541*e670fd5cSchristos 542*e670fd5cSchristosecho "Deleting an entry from both servers..." 543*e670fd5cSchristos$LDAPDELETE -D "$MANAGERDN" -H $URI1 -w $PASSWD \ 544*e670fd5cSchristos "cn=John Doe,ou=Information Technology Division,ou=People,$BASEDN" \ 545*e670fd5cSchristos >> $TESTOUT 2>&1 546*e670fd5cSchristosRC=$? 547*e670fd5cSchristosif test $RC != 0 ; then 548*e670fd5cSchristos echo "ldapdelete failed for server 1 database ($RC)!" 549*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 550*e670fd5cSchristos exit $RC 551*e670fd5cSchristosfi 552*e670fd5cSchristos 553*e670fd5cSchristos$LDAPDELETE -D "$MANAGERDN" -H $URI2 -w $PASSWD \ 554*e670fd5cSchristos "cn=John Doe,ou=Information Technology Division,ou=People,$BASEDN" \ 555*e670fd5cSchristos >> $TESTOUT 2>&1 556*e670fd5cSchristosRC=$? 557*e670fd5cSchristosif test $RC != 0 ; then 558*e670fd5cSchristos echo "ldapdelete failed for server 2 database ($RC)!" 559*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 560*e670fd5cSchristos exit $RC 561*e670fd5cSchristosfi 562*e670fd5cSchristos 563*e670fd5cSchristosecho "Restoring replication between server 1 and 2..." 564*e670fd5cSchristosn=1 565*e670fd5cSchristoswhile [ $n -le $MMR ]; do 566*e670fd5cSchristoso=`expr 3 - $n` 567*e670fd5cSchristosMYURI=`eval echo '$URI'$n` 568*e670fd5cSchristosPROVIDERURI=`eval echo '$URI'$o` 569*e670fd5cSchristos$LDAPMODIFY -D cn=config -H $MYURI -y $CONFIGPWF > $TESTOUT 2>&1 <<EOF 570*e670fd5cSchristosdn: olcDatabase={2}$BACKEND,cn=config 571*e670fd5cSchristoschangetype: modify 572*e670fd5cSchristosreplace: olcSyncRepl 573*e670fd5cSchristosolcSyncRepl: rid=001 provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple 574*e670fd5cSchristos credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE retry="3 +" timeout=3 575*e670fd5cSchristos- 576*e670fd5cSchristosreplace: olcMirrorMode 577*e670fd5cSchristosolcMirrorMode: TRUE 578*e670fd5cSchristos 579*e670fd5cSchristosEOF 580*e670fd5cSchristosRC=$? 581*e670fd5cSchristosif test $RC != 0 ; then 582*e670fd5cSchristos echo "ldapmodify failed for server $n config ($RC)!" 583*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 584*e670fd5cSchristos exit $RC 585*e670fd5cSchristosfi 586*e670fd5cSchristosn=`expr $n + 1` 587*e670fd5cSchristosdone 588*e670fd5cSchristos 589*e670fd5cSchristosecho "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 590*e670fd5cSchristossleep $SLEEP1 591*e670fd5cSchristos 592*e670fd5cSchristosecho 2 >$TESTDIR/repl.test 593*e670fd5cSchristosecho 1 >>$TESTDIR/repl.test 594*e670fd5cSchristos 595*e670fd5cSchristosn=1 596*e670fd5cSchristoswhile [ $n -le $MMR ]; do 597*e670fd5cSchristosURI=`eval echo '$URI'$n` 598*e670fd5cSchristos 599*e670fd5cSchristosecho "Using ldapsearch to read all the entries from server $n..." 600*e670fd5cSchristos$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 601*e670fd5cSchristos 'objectclass=*' > $TESTDIR/server$n.out 2>&1 602*e670fd5cSchristosRC=$? 603*e670fd5cSchristos 604*e670fd5cSchristosif test $RC != 0 ; then 605*e670fd5cSchristos echo "ldapsearch failed at server $n ($RC)!" 606*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 607*e670fd5cSchristos exit $RC 608*e670fd5cSchristosfi 609*e670fd5cSchristos$LDIFFILTER -s a < $TESTDIR/server$n.out > $TESTDIR/server$n.flt 610*e670fd5cSchristos 611*e670fd5cSchristosecho "Checking server $n can remember which entries have been deleted even after it's been restarted..." 612*e670fd5cSchristos$LDAPRSEARCH -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 613*e670fd5cSchristos -E "sync=ro/$cookie" 'objectclass=*' 1.1 | awk '/syncUUIDs/ {count++} END {print count}' >$TESTDIR/repl.out 614*e670fd5cSchristos$LDAPRSEARCH -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD \ 615*e670fd5cSchristos -E "sync=ro/$cookie" 'objectclass=*' 1.1 | grep SyncDone | awk '/refreshDeletes=1/ {count++} END {print count}' >>$TESTDIR/repl.out 616*e670fd5cSchristos 617*e670fd5cSchristos$CMP $TESTDIR/repl.out $TESTDIR/repl.test > $CMPOUT 618*e670fd5cSchristos 619*e670fd5cSchristosif test $? != 0 ; then 620*e670fd5cSchristos echo "test failed - server did not respond with delete phase" 621*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 622*e670fd5cSchristos exit 1 623*e670fd5cSchristosfi 624*e670fd5cSchristosn=`expr $n + 1` 625*e670fd5cSchristosdone 626*e670fd5cSchristos 627*e670fd5cSchristosn=2 628*e670fd5cSchristoswhile [ $n -le $MMR ]; do 629*e670fd5cSchristosecho "Comparing retrieved entries from server 1 and server $n..." 630*e670fd5cSchristos$CMP $PROVIDERFLT $TESTDIR/server$n.flt > $CMPOUT 631*e670fd5cSchristos 632*e670fd5cSchristosif test $? != 0 ; then 633*e670fd5cSchristos echo "test failed - server 1 and server $n databases differ" 634*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 635*e670fd5cSchristos exit 1 636*e670fd5cSchristosfi 637*e670fd5cSchristosn=`expr $n + 1` 638*e670fd5cSchristosdone 639*e670fd5cSchristos 640*e670fd5cSchristostest $KILLSERVERS != no && kill -HUP $KILLPIDS 641*e670fd5cSchristos 642*e670fd5cSchristosecho ">>>>> Test succeeded" 643*e670fd5cSchristos 644*e670fd5cSchristostest $KILLSERVERS != no && wait 645*e670fd5cSchristos 646*e670fd5cSchristosexit 0 647