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 if test $ACCESSLOG = accesslogno; then 24 1.1 christos echo "Accesslog overlay not available, test skipped" 25 1.1 christos exit 0 26 1.1 christos fi 27 1.1 christos 28 1.1 christos CFPRO=$TESTDIR/cfpro.d 29 1.1 christos CFCON=$TESTDIR/cfcon.d 30 1.1 christos 31 1.1 christos mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C $DBDIR1D $DBDIR2A $CFPRO $CFCON 32 1.1 christos 33 1.1 christos $SLAPPASSWD -g -n >$CONFIGPWF 34 1.1 christos 35 1.1 christos if test x"$SYNCMODE" = x ; then 36 1.1 christos SYNCMODE=rp 37 1.1 christos fi 38 1.1 christos case "$SYNCMODE" in 39 1.1 christos ro) 40 1.1 christos SYNCTYPE="type=refreshOnly interval=00:00:00:03" 41 1.1 christos ;; 42 1.1 christos rp) 43 1.1 christos SYNCTYPE="type=refreshAndPersist" 44 1.1 christos ;; 45 1.1 christos *) 46 1.1 christos echo "unknown sync mode $SYNCMODE" 47 1.1 christos exit 1; 48 1.1 christos ;; 49 1.1 christos esac 50 1.1 christos 51 1.1 christos # 52 1.1 christos # Test replication of dynamic config with alternate consumer config: 53 1.1 christos # - start provider 54 1.1 christos # - start consumer 55 1.1 christos # - configure over ldap 56 1.1 christos # - populate over ldap 57 1.1 christos # - configure syncrepl over ldap 58 1.1 christos # - retrieve database over ldap and compare against expected results 59 1.1 christos # 60 1.1 christos 61 1.1 christos echo "Starting provider slapd on TCP/IP port $PORT1..." 62 1.1 christos . $CONFFILTER $BACKEND < $DYNAMICCONF > $CONFLDIF 63 1.1 christos $SLAPADD -F $CFPRO -n 0 -l $CONFLDIF 64 1.1.1.2 christos RC=$? 65 1.1.1.2 christos if test $RC != 0 ; then 66 1.1.1.2 christos echo "slapadd failed ($RC)!" 67 1.1.1.2 christos exit $RC 68 1.1.1.2 christos fi 69 1.1.1.2 christos 70 1.1 christos $SLAPD -F $CFPRO -h $URI1 -d $LVL > $LOG1 2>&1 & 71 1.1 christos PID=$! 72 1.1 christos if test $WAIT != 0 ; then 73 1.1 christos echo PID $PID 74 1.1 christos read foo 75 1.1 christos fi 76 1.1 christos KILLPIDS="$PID" 77 1.1 christos 78 1.1 christos sleep 1 79 1.1 christos 80 1.1 christos echo "Using ldapsearch to check that provider slapd is running..." 81 1.1 christos for i in 0 1 2 3 4 5; do 82 1.1 christos $LDAPSEARCH -s base -b "" -H $URI1 \ 83 1.1 christos 'objectclass=*' > /dev/null 2>&1 84 1.1 christos RC=$? 85 1.1 christos if test $RC = 0 ; then 86 1.1 christos break 87 1.1 christos fi 88 1.1 christos echo "Waiting 5 seconds for slapd to start..." 89 1.1 christos sleep 5 90 1.1 christos done 91 1.1 christos 92 1.1 christos if test $RC != 0 ; then 93 1.1 christos echo "ldapsearch failed ($RC)!" 94 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 95 1.1 christos exit $RC 96 1.1 christos fi 97 1.1 christos 98 1.1 christos echo "Inserting syncprov and accesslog overlays on provider..." 99 1.1 christos if [ "$SYNCPROV" = syncprovmod -a "$ACCESSLOG" = accesslogmod ]; then 100 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1 101 1.1 christos dn: cn=module,cn=config 102 1.1 christos objectClass: olcModuleList 103 1.1 christos cn: module 104 1.1 christos olcModulePath: ../servers/slapd/overlays 105 1.1 christos olcModuleLoad: syncprov.la 106 1.1 christos olcModuleLoad: accesslog.la 107 1.1 christos EOF 108 1.1 christos RC=$? 109 1.1 christos if test $RC != 0 ; then 110 1.1 christos echo "ldapadd failed for moduleLoad of syncprov and accesslog ($RC)!" 111 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 112 1.1 christos exit $RC 113 1.1 christos fi 114 1.1 christos elif [ "$SYNCPROV" = syncprovmod ]; then 115 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1 116 1.1 christos dn: cn=module,cn=config 117 1.1 christos objectClass: olcModuleList 118 1.1 christos cn: module 119 1.1 christos olcModulePath: ../servers/slapd/overlays 120 1.1 christos olcModuleLoad: syncprov.la 121 1.1 christos EOF 122 1.1 christos RC=$? 123 1.1 christos if test $RC != 0 ; then 124 1.1 christos echo "ldapadd failed for moduleLoad of syncprov ($RC)!" 125 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 126 1.1 christos exit $RC 127 1.1 christos fi 128 1.1 christos elif [ "$ACCESSLOG" = accesslogmod ]; then 129 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1 130 1.1 christos dn: cn=module,cn=config 131 1.1 christos objectClass: olcModuleList 132 1.1 christos cn: module 133 1.1 christos olcModulePath: ../servers/slapd/overlays 134 1.1 christos olcModuleLoad: accesslog.la 135 1.1 christos EOF 136 1.1 christos RC=$? 137 1.1 christos if test $RC != 0 ; then 138 1.1 christos echo "ldapadd failed for moduleLoad of accesslog ($RC)!" 139 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 140 1.1 christos exit $RC 141 1.1 christos fi 142 1.1 christos fi 143 1.1 christos 144 1.1 christos echo "Adding backend accesslog databases using $BACKEND..." 145 1.1 christos if [ "$BACKENDTYPE" = mod ]; then 146 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1 147 1.1 christos dn: cn=module,cn=config 148 1.1 christos objectClass: olcModuleList 149 1.1 christos cn: module 150 1.1 christos olcModulePath: $TESTWD/../servers/slapd/back-$BACKEND 151 1.1 christos olcModuleLoad: back_$BACKEND.la 152 1.1 christos EOF 153 1.1 christos RC=$? 154 1.1 christos if test $RC != 0 ; then 155 1.1 christos echo "ldapadd failed for moduleLoad of $BACKEND ($RC)!" 156 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 157 1.1 christos exit $RC 158 1.1 christos fi 159 1.1 christos fi 160 1.1 christos 161 1.1 christos read CONFIGPW < $CONFIGPWF 162 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1 163 1.1 christos dn: olcDatabase={1}$BACKEND,cn=config 164 1.1 christos objectClass: olcDatabaseConfig 165 1.1 christos objectClass: olc${BACKEND}Config 166 1.1 christos olcDatabase: {1}$BACKEND 167 1.1 christos olcSuffix: cn=accesslog 168 1.1 christos ${nullExclude}olcDbDirectory: $DBDIR1C 169 1.1 christos olcRootDN: cn=config 170 1.1 christos olcSizeLimit: unlimited 171 1.1 christos olcTimeLimit: unlimited 172 1.1 christos olcDbIndex: default eq 173 1.1 christos olcDbIndex: entryCSN,objectClass,reqEnd,reqResult,reqStart,reqDN 174 1.1 christos 175 1.1 christos dn: olcOverlay=syncprov,olcDatabase={1}${BACKEND},cn=config 176 1.1 christos changetype: add 177 1.1 christos objectClass: olcOverlayConfig 178 1.1 christos objectClass: olcSyncProvConfig 179 1.1 christos olcOverlay: syncprov 180 1.1 christos olcSpNoPresent: TRUE 181 1.1 christos olcSpReloadHint: TRUE 182 1.1 christos 183 1.1 christos dn: olcDatabase={2}$BACKEND,cn=config 184 1.1 christos objectClass: olcDatabaseConfig 185 1.1 christos objectClass: olc${BACKEND}Config 186 1.1 christos olcDatabase: {2}$BACKEND 187 1.1 christos olcSuffix: cn=consumer-accesslog 188 1.1 christos ${nullExclude}olcDbDirectory: $DBDIR1D 189 1.1 christos olcRootDN: cn=consumer,cn=config 190 1.1 christos olcSizeLimit: unlimited 191 1.1 christos olcTimeLimit: unlimited 192 1.1 christos olcDbIndex: default eq 193 1.1 christos olcDbIndex: entryCSN,objectClass,reqEnd,reqResult,reqStart,reqDN 194 1.1 christos 195 1.1 christos dn: olcOverlay=syncprov,olcDatabase={2}${BACKEND},cn=config 196 1.1 christos changetype: add 197 1.1 christos objectClass: olcOverlayConfig 198 1.1 christos objectClass: olcSyncProvConfig 199 1.1 christos olcOverlay: syncprov 200 1.1 christos olcSpNoPresent: TRUE 201 1.1 christos olcSpReloadHint: TRUE 202 1.1 christos EOF 203 1.1 christos 204 1.1 christos RC=$? 205 1.1 christos if test $RC != 0 ; then 206 1.1 christos echo "ldapadd failed for accesslog databases using $BACKEND ($RC)!" 207 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 208 1.1 christos exit $RC 209 1.1 christos fi 210 1.1 christos 211 1.1 christos $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1 212 1.1 christos dn: olcOverlay=syncprov,olcDatabase={0}config,cn=config 213 1.1 christos changetype: add 214 1.1 christos objectClass: olcOverlayConfig 215 1.1 christos objectClass: olcSyncProvConfig 216 1.1 christos olcOverlay: syncprov 217 1.1 christos 218 1.1 christos dn: olcOverlay=accesslog,olcDatabase={0}config,cn=config 219 1.1 christos changetype: add 220 1.1 christos objectClass: olcOverlayConfig 221 1.1 christos objectClass: olcAccessLogConfig 222 1.1 christos olcOverlay: accesslog 223 1.1 christos olcAccessLogDB: cn=accesslog 224 1.1 christos olcAccessLogOps: writes 225 1.1 christos olcAccessLogPurge: 07+00:00 01+00:00 226 1.1 christos olcAccessLogSuccess: TRUE 227 1.1 christos EOF 228 1.1 christos 229 1.1 christos RC=$? 230 1.1 christos if test $RC != 0 ; then 231 1.1 christos echo "ldapmodify failed for syncprov and accesslog overlay config ($RC)!" 232 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 233 1.1 christos exit $RC 234 1.1 christos fi 235 1.1 christos 236 1.1 christos # Consumers will not replicate the provider's actual cn=config. 237 1.1 christos # Instead, they will use an alternate DB so that they may be 238 1.1 christos # configured differently from the provider. This alternate DB 239 1.1 christos # will also be a consumer for the real cn=schema,cn=config tree. 240 1.1 christos # It has multi-provider enabled so that it can be written directly 241 1.1 christos # while being a consumer of the main schema. 242 1.1.1.2 christos echo "Configuring accesslog config DB on provider..." 243 1.1 christos $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1 244 1.1 christos dn: cn=config 245 1.1 christos changetype: modify 246 1.1 christos add: olcServerID 247 1.1 christos olcServerID: 1 248 1.1 christos 249 1.1 christos dn: olcDatabase={1}ldif,cn=config 250 1.1 christos changetype: add 251 1.1 christos objectClass: olcDatabaseConfig 252 1.1 christos objectClass: olcLdifConfig 253 1.1 christos olcDatabase: {1}ldif 254 1.1 christos olcDbDirectory: $DBDIR1A 255 1.1 christos olcSuffix: cn=config,cn=consumer 256 1.1 christos olcRootDN: cn=config,cn=consumer 257 1.1 christos olcRootPW: repsecret 258 1.1 christos olcAccess: to * by dn.base="cn=config" write 259 1.1 christos 260 1.1 christos dn: olcOverlay=syncprov,olcDatabase={1}ldif,cn=config 261 1.1 christos changetype: add 262 1.1 christos objectClass: olcOverlayConfig 263 1.1 christos objectClass: olcSyncProvConfig 264 1.1 christos olcOverlay: syncprov 265 1.1 christos 266 1.1 christos dn: olcOverlay=accesslog,olcDatabase={1}ldif,cn=config 267 1.1 christos changetype: add 268 1.1 christos objectClass: olcOverlayConfig 269 1.1 christos objectClass: olcAccessLogConfig 270 1.1 christos olcOverlay: accesslog 271 1.1 christos olcAccessLogDB: cn=consumer-accesslog 272 1.1 christos olcAccessLogOps: writes 273 1.1 christos olcAccessLogPurge: 07+00:00 01+00:00 274 1.1 christos olcAccessLogSuccess: TRUE 275 1.1.1.2 christos EOF 276 1.1.1.2 christos 277 1.1.1.2 christos RC=$? 278 1.1.1.2 christos if test $RC != 0 ; then 279 1.1.1.2 christos echo "ldapmodify failed for consumer DB config ($RC)!" 280 1.1.1.2 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 281 1.1.1.2 christos exit $RC 282 1.1.1.2 christos fi 283 1.1 christos 284 1.1.1.2 christos echo "Waiting 3 seconds for syncrepl to make root accesslog entry..." 285 1.1.1.2 christos sleep 3 286 1.1.1.2 christos 287 1.1.1.2 christos echo "Configuring consumer config DB on provider..." 288 1.1.1.2 christos $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1 289 1.1 christos dn: cn=config,cn=consumer 290 1.1 christos changetype: add 291 1.1 christos objectClass: olcGlobal 292 1.1 christos cn: consumerconfig 293 1.1 christos 294 1.1 christos dn: olcDatabase={0}config,cn=config,cn=consumer 295 1.1 christos changetype: add 296 1.1 christos objectClass: olcDatabaseConfig 297 1.1 christos olcDatabase: {0}config 298 1.1 christos olcRootPW: topsecret 299 1.1 christos olcSyncrepl: {0}rid=001 provider=$URI1 binddn="cn=config,cn=consumer" 300 1.1 christos bindmethod=simple credentials=repsecret searchbase="cn=config,cn=consumer" 301 1.1 christos $SYNCTYPE retry="3 5 300 5" timeout=3 suffixmassage="cn=config" 302 1.1 christos olcUpdateRef: $URI1 303 1.1 christos 304 1.1 christos dn: olcDatabase={1}ldif,cn=config 305 1.1 christos changetype: modify 306 1.1 christos add: olcSyncrepl 307 1.1 christos olcSyncrepl: {0}rid=001 provider=$URI1 binddn="cn=config" 308 1.1 christos bindmethod=simple credentials=$CONFIGPW searchbase="cn=schema,cn=config" 309 1.1 christos $SYNCTYPE retry="3 5 300 5" timeout=3 310 1.1 christos suffixmassage="cn=schema,cn=config,cn=consumer" 311 1.1.1.2 christos # a dummy stanza we add to the beginning and remove again 312 1.1.1.2 christos olcSyncrepl: {0}rid=006 provider=$URI6 binddn="cn=config" 313 1.1.1.2 christos bindmethod=simple credentials=$CONFIGPW searchbase="cn=schema,cn=config" 314 1.1.1.2 christos $SYNCTYPE retry="3 5 300 5" timeout=3 315 1.1.1.2 christos suffixmassage="cn=schema,cn=config,cn=consumer" 316 1.1.1.2 christos - 317 1.1.1.2 christos delete: olcSyncrepl 318 1.1.1.2 christos olcSyncrepl: {0} 319 1.1 christos - 320 1.1 christos add: olcMultiProvider 321 1.1 christos olcMultiProvider: TRUE 322 1.1 christos 323 1.1 christos EOF 324 1.1 christos RC=$? 325 1.1 christos if test $RC != 0 ; then 326 1.1 christos echo "ldapmodify failed for consumer DB config ($RC)!" 327 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 328 1.1 christos exit $RC 329 1.1 christos fi 330 1.1 christos 331 1.1 christos echo "Starting consumer slapd on TCP/IP port $PORT2..." 332 1.1 christos $SLAPADD -F $CFCON -n 0 -l $CONFLDIF 333 1.1.1.2 christos RC=$? 334 1.1.1.2 christos if test $RC != 0 ; then 335 1.1.1.2 christos echo "slapadd failed ($RC)!" 336 1.1.1.2 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 337 1.1.1.2 christos exit $RC 338 1.1.1.2 christos fi 339 1.1.1.2 christos 340 1.1 christos $SLAPD -F $CFCON -h $URI2 -d $LVL > $LOG2 2>&1 & 341 1.1 christos CONSUMERPID=$! 342 1.1 christos if test $WAIT != 0 ; then 343 1.1 christos echo CONSUMERPID $CONSUMERPID 344 1.1 christos read foo 345 1.1 christos fi 346 1.1 christos KILLPIDS="$KILLPIDS $CONSUMERPID" 347 1.1 christos 348 1.1 christos sleep 1 349 1.1 christos 350 1.1 christos echo "Using ldapsearch to check that consumer slapd is running..." 351 1.1 christos for i in 0 1 2 3 4 5; do 352 1.1 christos $LDAPSEARCH -s base -b "" -H $URI2 \ 353 1.1 christos 'objectclass=*' > /dev/null 2>&1 354 1.1 christos RC=$? 355 1.1 christos if test $RC = 0 ; then 356 1.1 christos break 357 1.1 christos fi 358 1.1 christos echo "Waiting 5 seconds for slapd to start..." 359 1.1 christos sleep 5 360 1.1 christos done 361 1.1 christos 362 1.1 christos if test $RC != 0 ; then 363 1.1 christos echo "ldapsearch failed ($RC)!" 364 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 365 1.1 christos exit $RC 366 1.1 christos fi 367 1.1 christos 368 1.1 christos echo "Configuring syncrepl on consumer..." 369 1.1 christos $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1 370 1.1 christos dn: olcDatabase={0}config,cn=config 371 1.1 christos changetype: modify 372 1.1 christos add: olcSyncRepl 373 1.1 christos olcSyncRepl: rid=001 provider=$URI1 binddn="cn=config,cn=consumer" 374 1.1 christos bindmethod=simple credentials=repsecret searchbase="cn=config,cn=consumer" 375 1.1 christos $SYNCTYPE retry="3 5 300 5" timeout=3 logbase="cn=consumer-accesslog" 376 1.1 christos logfilter="(&(objectclass=auditWriteObject)(reqresult=0))" 377 1.1 christos syncdata=accesslog suffixmassage="cn=config" 378 1.1 christos - 379 1.1 christos add: olcUpdateRef 380 1.1 christos olcUpdateRef: $URI1 381 1.1 christos EOF 382 1.1 christos 383 1.1 christos sleep 1 384 1.1 christos 385 1.1 christos echo "Using ldapsearch to check that syncrepl received config changes..." 386 1.1 christos RC=32 387 1.1 christos for i in 0 1 2 3 4 5; do 388 1.1 christos RESULT=`$LDAPSEARCH -H $URI2 -D cn=config -y $CONFIGPWF \ 389 1.1 christos -s base -b "olcDatabase={0}config,cn=config" \ 390 1.1 christos '(olcUpdateRef=*)' 2>&1 | awk '/^dn:/ {print "OK"}'` 391 1.1 christos if test "x$RESULT" = "xOK" ; then 392 1.1 christos RC=0 393 1.1 christos break 394 1.1 christos fi 395 1.1 christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 396 1.1 christos sleep $SLEEP1 397 1.1 christos done 398 1.1 christos 399 1.1 christos if test $RC != 0 ; then 400 1.1 christos echo "ldapsearch failed ($RC)!" 401 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 402 1.1 christos exit $RC 403 1.1 christos fi 404 1.1 christos 405 1.1 christos echo "Adding schema and databases on provider..." 406 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1 407 1.1 christos include: file://$ABS_SCHEMADIR/core.ldif 408 1.1 christos 409 1.1 christos include: file://$ABS_SCHEMADIR/cosine.ldif 410 1.1 christos 411 1.1 christos include: file://$ABS_SCHEMADIR/inetorgperson.ldif 412 1.1 christos 413 1.1 christos include: file://$ABS_SCHEMADIR/openldap.ldif 414 1.1 christos 415 1.1 christos include: file://$ABS_SCHEMADIR/nis.ldif 416 1.1 christos EOF 417 1.1 christos RC=$? 418 1.1 christos if test $RC != 0 ; then 419 1.1 christos echo "ldapadd failed for schema config ($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 "Using ldapsearch to check that syncrepl received the schema changes..." 425 1.1 christos RC=32 426 1.1 christos for i in 0 1 2 3 4 5; do 427 1.1 christos RESULT=`$LDAPSEARCH -H $URI2 -D cn=config -y $CONFIGPWF \ 428 1.1 christos -s sub -b "cn=schema,cn=config" \ 429 1.1 christos '(cn=*openldap)' 2>&1 | awk '/^dn:/ {print "OK"}'` 430 1.1 christos if test "x$RESULT" = "xOK" ; then 431 1.1 christos RC=0 432 1.1 christos break 433 1.1 christos fi 434 1.1 christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 435 1.1 christos sleep $SLEEP1 436 1.1 christos done 437 1.1 christos 438 1.1 christos if test "x$RESULT" != "xOK" ; then 439 1.1 christos echo "consumer never received complete schema!" 440 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 441 1.1 christos exit 1 442 1.1 christos fi 443 1.1 christos 444 1.1 christos nullExclude="" nullOK="" 445 1.1 christos test $BACKEND = null && nullExclude="# " nullOK="OK" 446 1.1 christos 447 1.1 christos if [ "$BACKENDTYPE" = mod ]; then 448 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1 449 1.1 christos dn: cn=module,cn=config,cn=consumer 450 1.1 christos objectClass: olcModuleList 451 1.1 christos cn: module 452 1.1 christos olcModulePath: ../servers/slapd/back-$BACKEND 453 1.1 christos olcModuleLoad: back_$BACKEND.la 454 1.1 christos EOF 455 1.1 christos RC=$? 456 1.1 christos if test $RC != 0 ; then 457 1.1 christos echo "ldapadd failed for backend config ($RC)!" 458 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 459 1.1 christos exit $RC 460 1.1 christos fi 461 1.1 christos fi 462 1.1 christos 463 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1 464 1.1 christos dn: olcDatabase={2}$BACKEND,cn=config 465 1.1 christos objectClass: olcDatabaseConfig 466 1.1 christos ${nullExclude}objectClass: olc${BACKEND}Config 467 1.1 christos olcDatabase: {2}$BACKEND 468 1.1 christos olcSuffix: $BASEDN 469 1.1 christos ${nullExclude}olcDbDirectory: $DBDIR1B 470 1.1 christos olcRootDN: $MANAGERDN 471 1.1 christos olcRootPW: $PASSWD 472 1.1 christos olcSyncRepl: rid=002 provider=$URI1 binddn="$MANAGERDN" bindmethod=simple 473 1.1 christos credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE 474 1.1 christos retry="3 5 300 5" timeout=3 475 1.1 christos olcUpdateRef: $URI1 476 1.1 christos 477 1.1 christos dn: olcOverlay=syncprov,olcDatabase={2}${BACKEND},cn=config 478 1.1 christos changetype: add 479 1.1 christos objectClass: olcOverlayConfig 480 1.1 christos objectClass: olcSyncProvConfig 481 1.1 christos olcOverlay: syncprov 482 1.1 christos 483 1.1 christos dn: olcDatabase={1}$BACKEND,cn=config,cn=consumer 484 1.1 christos objectClass: olcDatabaseConfig 485 1.1 christos ${nullExclude}objectClass: olc${BACKEND}Config 486 1.1 christos olcDatabase: {1}$BACKEND 487 1.1 christos olcSuffix: $BASEDN 488 1.1 christos ${nullExclude}olcDbDirectory: $DBDIR2A 489 1.1 christos olcRootDN: $MANAGERDN 490 1.1 christos olcRootPW: $PASSWD 491 1.1 christos olcSyncRepl: rid=002 provider=$URI1 binddn="$MANAGERDN" bindmethod=simple 492 1.1 christos credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE 493 1.1 christos retry="3 5 300 5" timeout=3 494 1.1 christos olcUpdateRef: $URI1 495 1.1 christos 496 1.1 christos EOF 497 1.1 christos RC=$? 498 1.1 christos if test $RC != 0 ; then 499 1.1 christos echo "ldapadd failed for database config ($RC)!" 500 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 501 1.1 christos exit $RC 502 1.1 christos fi 503 1.1 christos 504 1.1 christos if test $INDEXDB = indexdb ; then 505 1.1 christos $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1 506 1.1 christos dn: olcDatabase={2}$BACKEND,cn=config 507 1.1 christos changetype: modify 508 1.1 christos add: olcDbIndex 509 1.1 christos olcDbIndex: objectClass,entryUUID,entryCSN eq 510 1.1 christos olcDbIndex: cn,uid pres,eq,sub 511 1.1 christos EOF 512 1.1 christos RC=$? 513 1.1 christos if test $RC != 0 ; then 514 1.1 christos echo "ldapadd modify for database config ($RC)!" 515 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 516 1.1 christos exit $RC 517 1.1 christos fi 518 1.1 christos fi 519 1.1 christos 520 1.1 christos echo "Using ldapadd to populate provider..." 521 1.1 christos $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDERED \ 522 1.1 christos >> $TESTOUT 2>&1 523 1.1 christos RC=$? 524 1.1 christos if test $RC != 0 ; then 525 1.1 christos echo "ldapadd failed for database config ($RC)!" 526 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 527 1.1 christos exit $RC 528 1.1 christos fi 529 1.1 christos 530 1.1 christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 531 1.1 christos sleep $SLEEP1 532 1.1 christos 533 1.1 christos echo "Using ldapsearch to check that syncrepl received database changes..." 534 1.1 christos RC=32 535 1.1 christos for i in 0 1 2 3 4 5; do 536 1.1 christos RESULT=`$LDAPSEARCH -H $URI2 \ 537 1.1 christos -s base -b "cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com" \ 538 1.1 christos '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'` 539 1.1 christos if test "x$RESULT$nullOK" = "xOK" ; then 540 1.1 christos RC=0 541 1.1 christos break 542 1.1 christos fi 543 1.1 christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..." 544 1.1 christos sleep $SLEEP1 545 1.1 christos done 546 1.1 christos 547 1.1 christos if test $RC != 0 ; then 548 1.1 christos echo "ldapsearch failed ($RC)!" 549 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 550 1.1 christos exit $RC 551 1.1 christos fi 552 1.1 christos 553 1.1 christos echo "Using ldapsearch to read all the entries from the provider..." 554 1.1 christos $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI1 -w $PASSWD \ 555 1.1 christos 'objectclass=*' > $PROVIDEROUT 2>&1 556 1.1 christos RC=$? 557 1.1 christos 558 1.1 christos if test $RC != 0 ; then 559 1.1 christos echo "ldapsearch failed at provider ($RC)!" 560 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 561 1.1 christos exit $RC 562 1.1 christos fi 563 1.1 christos 564 1.1 christos echo "Using ldapsearch to read all the entries from the consumer..." 565 1.1 christos $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI2 -w $PASSWD \ 566 1.1 christos 'objectclass=*' > $CONSUMEROUT 2>&1 567 1.1 christos RC=$? 568 1.1 christos 569 1.1 christos if test $RC != 0 ; then 570 1.1 christos echo "ldapsearch failed at consumer ($RC)!" 571 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 572 1.1 christos exit $RC 573 1.1 christos fi 574 1.1 christos 575 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS 576 1.1 christos 577 1.1 christos echo "Filtering provider results..." 578 1.1 christos $LDIFFILTER < $PROVIDEROUT > $PROVIDERFLT 579 1.1 christos echo "Filtering consumer results..." 580 1.1 christos $LDIFFILTER < $CONSUMEROUT > $CONSUMERFLT 581 1.1 christos 582 1.1 christos echo "Comparing retrieved entries from provider and consumer..." 583 1.1 christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT 584 1.1 christos 585 1.1 christos if test $? != 0 ; then 586 1.1 christos echo "test failed - provider and consumer databases differ" 587 1.1 christos exit 1 588 1.1 christos fi 589 1.1 christos 590 1.1 christos echo ">>>>> Test succeeded" 591 1.1 christos 592 1.1 christos test $KILLSERVERS != no && wait 593 1.1 christos 594 1.1 christos exit 0 595