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