Home | History | Annotate | Line # | Download | only in scripts
      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 MPR=${MPR-4}
     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 interval=00:00:00:03"
     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 delta-sync mpr
     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 # - break replication
     60      1.1  christos # - modify each server separately
     61      1.1  christos # - restore replication
     62      1.1  christos # - compare results
     63      1.1  christos #
     64      1.1  christos 
     65      1.1  christos nullExclude=""
     66      1.1  christos test $BACKEND = null && nullExclude="# "
     67      1.1  christos 
     68      1.1  christos KILLPIDS=
     69      1.1  christos 
     70      1.1  christos echo "Initializing server configurations..."
     71      1.1  christos n=1
     72      1.1  christos while [ $n -le $MPR ]; do
     73      1.1  christos 
     74      1.1  christos DBDIR=${XDIR}$n/db
     75      1.1  christos CFDIR=${XDIR}$n/slapd.d
     76      1.1  christos 
     77      1.1  christos mkdir -p ${XDIR}$n $DBDIR.1 $DBDIR.2 $CFDIR
     78      1.1  christos 
     79      1.1  christos cat > $TMP <<EOF
     80      1.1  christos dn: cn=config
     81      1.1  christos objectClass: olcGlobal
     82      1.1  christos cn: config
     83      1.1  christos EOF
     84      1.1  christos 
     85      1.1  christos o=1
     86      1.1  christos while [ $o -le $MPR ]; do
     87      1.1  christos PORT=`expr $BASEPORT + $o`
     88      1.1  christos URI="ldap://${LOCALHOST}:$PORT/"
     89      1.1  christos echo "olcServerID: $o $URI" >> $TMP
     90      1.1  christos o=`expr $o + 1`
     91      1.1  christos done
     92      1.1  christos echo "" >> $TMP
     93      1.1  christos 
     94      1.1  christos if [ "$SYNCPROV" = syncprovmod -o "$ACCESSLOG" = accesslogmod ]; then
     95      1.1  christos   cat <<EOF >> $TMP
     96      1.1  christos dn: cn=module,cn=config
     97      1.1  christos objectClass: olcModuleList
     98      1.1  christos cn: module
     99      1.1  christos olcModulePath: $TESTWD/../servers/slapd/overlays
    100      1.1  christos EOF
    101      1.1  christos   if [ "$SYNCPROV" = syncprovmod ]; then
    102      1.1  christos   echo "olcModuleLoad: syncprov.la" >> $TMP
    103      1.1  christos   fi
    104      1.1  christos   if [ "$ACCESSLOG" = accesslogmod ]; then
    105      1.1  christos   echo "olcModuleLoad: accesslog.la" >> $TMP
    106      1.1  christos   fi
    107      1.1  christos   echo "" >> $TMP
    108      1.1  christos fi
    109      1.1  christos 
    110      1.1  christos if [ "$BACKENDTYPE" = mod ]; then
    111      1.1  christos cat <<EOF >> $TMP
    112      1.1  christos dn: cn=module,cn=config
    113      1.1  christos objectClass: olcModuleList
    114      1.1  christos cn: module
    115      1.1  christos olcModulePath: $TESTWD/../servers/slapd/back-$BACKEND
    116      1.1  christos olcModuleLoad: back_$BACKEND.la
    117      1.1  christos 
    118      1.1  christos EOF
    119      1.1  christos fi
    120      1.1  christos 
    121      1.1  christos MYURI=`eval echo '$URI'$n`
    122      1.1  christos PROVIDERURI=`eval echo '$URI'$o`
    123      1.1  christos if test $INDEXDB = indexdb ; then
    124      1.1  christos INDEX1="olcDbIndex: objectClass,entryCSN,reqStart,reqDN,reqResult eq"
    125      1.1  christos INDEX2="olcDbIndex: objectClass,entryCSN,entryUUID eq"
    126      1.1  christos else
    127      1.1  christos INDEX1=
    128      1.1  christos INDEX2=
    129      1.1  christos fi
    130      1.1  christos cat >> $TMP <<EOF
    131      1.1  christos dn: cn=schema,cn=config
    132      1.1  christos objectclass: olcSchemaconfig
    133      1.1  christos cn: schema
    134      1.1  christos 
    135      1.1  christos include: file://$ABS_SCHEMADIR/core.ldif
    136      1.1  christos 
    137      1.1  christos include: file://$ABS_SCHEMADIR/cosine.ldif
    138      1.1  christos 
    139      1.1  christos include: file://$ABS_SCHEMADIR/inetorgperson.ldif
    140      1.1  christos 
    141      1.1  christos include: file://$ABS_SCHEMADIR/openldap.ldif
    142      1.1  christos 
    143      1.1  christos include: file://$ABS_SCHEMADIR/nis.ldif
    144      1.1  christos 
    145      1.1  christos dn: olcDatabase={0}config,cn=config
    146      1.1  christos objectClass: olcDatabaseConfig
    147      1.1  christos olcDatabase: {0}config
    148      1.1  christos olcRootPW:< file://$CONFIGPWF
    149      1.1  christos 
    150      1.1  christos dn: olcDatabase={1}$BACKEND,cn=config
    151      1.1  christos objectClass: olcDatabaseConfig
    152      1.1  christos ${nullExclude}objectClass: olc${BACKEND}Config
    153      1.1  christos olcDatabase: {1}$BACKEND
    154      1.1  christos olcSuffix: cn=log
    155      1.1  christos ${nullExclude}olcDbDirectory: ${DBDIR}.1
    156      1.1  christos olcRootDN: $MANAGERDN
    157      1.1  christos $INDEX1
    158      1.1  christos 
    159      1.1  christos dn: olcOverlay=syncprov,olcDatabase={1}$BACKEND,cn=config
    160      1.1  christos objectClass: olcOverlayConfig
    161      1.1  christos objectClass: olcSyncProvConfig
    162      1.1  christos olcOverlay: syncprov
    163      1.1  christos olcSpNoPresent: TRUE
    164      1.1  christos olcSpReloadHint: TRUE
    165      1.1  christos 
    166      1.1  christos dn: olcDatabase={2}$BACKEND,cn=config
    167      1.1  christos objectClass: olcDatabaseConfig
    168      1.1  christos ${nullExclude}objectClass: olc${BACKEND}Config
    169      1.1  christos olcDatabase: {2}$BACKEND
    170      1.1  christos olcSuffix: $BASEDN
    171      1.1  christos ${nullExclude}olcDbDirectory: ${DBDIR}.2
    172      1.1  christos olcRootDN: $MANAGERDN
    173      1.1  christos olcRootPW: $PASSWD
    174      1.1  christos EOF
    175      1.1  christos 
    176      1.1  christos o=1
    177      1.1  christos while [ $o -le $MPR ]; do
    178      1.1  christos PORT=`expr $BASEPORT + $o`
    179      1.1  christos URI="ldap://${LOCALHOST}:$PORT/"
    180      1.1  christos cat >>$TMP <<EOF
    181      1.1  christos olcSyncRepl: rid=00$o provider=$URI binddn="$MANAGERDN" bindmethod=simple
    182      1.1  christos   credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
    183      1.1  christos   retry="3 +" timeout=3 logbase="cn=log"
    184      1.1  christos   logfilter="(&(objectclass=auditWriteObject)(reqresult=0))"
    185      1.1  christos   syncdata=accesslog
    186      1.1  christos EOF
    187      1.1  christos o=`expr $o + 1`
    188      1.1  christos done
    189      1.1  christos 
    190      1.1  christos cat >> $TMP <<EOF
    191      1.1  christos olcMultiProvider: TRUE
    192      1.1  christos $INDEX2
    193      1.1  christos 
    194      1.1  christos dn: olcOverlay=syncprov,olcDatabase={2}$BACKEND,cn=config
    195      1.1  christos objectClass: olcOverlayConfig
    196      1.1  christos objectClass: olcSyncProvConfig
    197      1.1  christos olcOverlay: syncprov
    198      1.1  christos 
    199      1.1  christos dn: olcOverlay=accesslog,olcDatabase={2}$BACKEND,cn=config
    200      1.1  christos objectClass: olcOverlayConfig
    201      1.1  christos objectClass: olcAccessLogConfig
    202      1.1  christos olcOverlay: accesslog
    203      1.1  christos olcAccessLogDB: cn=log
    204      1.1  christos olcAccessLogOps: writes
    205      1.1  christos olcAccessLogSuccess: TRUE
    206      1.1  christos 
    207      1.1  christos EOF
    208      1.1  christos cat <<EOF >> $TMP
    209      1.1  christos dn: olcDatabase={3}monitor,cn=config
    210      1.1  christos objectClass: olcDatabaseConfig
    211      1.1  christos objectClass: olcmonitorConfig
    212      1.1  christos olcDatabase: {3}monitor
    213      1.1  christos 
    214      1.1  christos EOF
    215      1.1  christos 
    216      1.1  christos $SLAPADD -F $CFDIR -n 0  -d-1< $TMP > $TESTOUT 2>&1
    217  1.1.1.2  christos RC=$?
    218  1.1.1.2  christos if test $RC != 0 ; then
    219  1.1.1.2  christos 	echo "slapadd failed ($RC)!"
    220  1.1.1.2  christos 	exit $RC
    221  1.1.1.2  christos fi
    222  1.1.1.2  christos 
    223      1.1  christos PORT=`eval echo '$PORT'$n`
    224      1.1  christos echo "Starting server $n on TCP/IP port $PORT..."
    225      1.1  christos cd ${XDIR}${n}
    226      1.1  christos LOG=`eval echo '$LOG'$n`
    227      1.1  christos $SLAPD -F slapd.d -h $MYURI -d $LVL > $LOG 2>&1 &
    228      1.1  christos PID=$!
    229      1.1  christos if test $WAIT != 0 ; then
    230      1.1  christos     echo PID $PID
    231      1.1  christos     read foo
    232      1.1  christos fi
    233      1.1  christos KILLPIDS="$PID $KILLPIDS"
    234      1.1  christos cd $TESTWD
    235      1.1  christos 
    236      1.1  christos echo "Using ldapsearch to check that server $n is running..."
    237      1.1  christos sleep 1
    238      1.1  christos for i in 0 1 2 3 4 5; do
    239      1.1  christos 	$LDAPSEARCH -s base -b "" -H $MYURI \
    240      1.1  christos 		'objectclass=*' > /dev/null 2>&1
    241      1.1  christos 	RC=$?
    242      1.1  christos 	if test $RC = 0 ; then
    243      1.1  christos 		break
    244      1.1  christos 	fi
    245      1.1  christos 	echo "Waiting 5 seconds for slapd to start..."
    246      1.1  christos 	sleep 5
    247      1.1  christos done
    248      1.1  christos 
    249      1.1  christos if test $RC != 0 ; then
    250      1.1  christos 	echo "ldapsearch failed ($RC)!"
    251      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    252      1.1  christos 	exit $RC
    253      1.1  christos fi
    254      1.1  christos 
    255      1.1  christos if [ $n = 1 ]; then
    256      1.1  christos echo "Using ldapadd for context on server 1..."
    257      1.1  christos $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDEREDCP \
    258      1.1  christos 	>> $TESTOUT 2>&1
    259      1.1  christos RC=$?
    260      1.1  christos if test $RC != 0 ; then
    261      1.1  christos 	echo "ldapadd failed for server $n database ($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 fi
    266      1.1  christos 
    267      1.1  christos n=`expr $n + 1`
    268      1.1  christos done
    269      1.1  christos 
    270      1.1  christos echo "Using ldapadd to populate server 1..."
    271      1.1  christos $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDEREDNOCP \
    272      1.1  christos 	>> $TESTOUT 2>&1
    273      1.1  christos RC=$?
    274      1.1  christos if test $RC != 0 ; then
    275      1.1  christos 	echo "ldapadd failed for server $n database ($RC)!"
    276      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    277      1.1  christos 	exit $RC
    278      1.1  christos fi
    279      1.1  christos 
    280      1.1  christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    281      1.1  christos sleep $SLEEP1
    282      1.1  christos 
    283      1.1  christos n=1
    284      1.1  christos while [ $n -le $MPR ]; do
    285      1.1  christos PORT=`expr $BASEPORT + $n`
    286      1.1  christos URI="ldap://${LOCALHOST}:$PORT/"
    287      1.1  christos 
    288      1.1  christos echo "Using ldapsearch to read all the entries from server $n..."
    289      1.1  christos $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD  \
    290      1.1  christos 	'objectclass=*' > $TESTDIR/server$n.out 2>&1
    291      1.1  christos RC=$?
    292      1.1  christos 
    293      1.1  christos if test $RC != 0 ; then
    294      1.1  christos 	echo "ldapsearch failed at server $n ($RC)!"
    295      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    296      1.1  christos 	exit $RC
    297      1.1  christos fi
    298      1.1  christos $LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt
    299      1.1  christos n=`expr $n + 1`
    300      1.1  christos done
    301      1.1  christos 
    302      1.1  christos n=2
    303      1.1  christos while [ $n -le $MPR ]; do
    304      1.1  christos echo "Comparing retrieved entries from server 1 and server $n..."
    305      1.1  christos $CMP $PROVIDERFLT $TESTDIR/server$n.flt > $CMPOUT
    306      1.1  christos 
    307      1.1  christos if test $? != 0 ; then
    308      1.1  christos 	echo "test failed - server 1 and server $n databases differ"
    309      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    310      1.1  christos 	exit 1
    311      1.1  christos fi
    312      1.1  christos n=`expr $n + 1`
    313      1.1  christos done
    314      1.1  christos 
    315      1.1  christos echo "Using ldapadd to populate server 2..."
    316      1.1  christos cp $LDIFADD1 $TESTDIR/add.ldif
    317      1.1  christos echo "displayName: The other" >>$TESTDIR/add.ldif
    318      1.1  christos $LDAPADD -D "$MANAGERDN" -H $URI2 -w $PASSWD -f $TESTDIR/add.ldif \
    319      1.1  christos 	>> $TESTOUT 2>&1
    320      1.1  christos RC=$?
    321      1.1  christos if test $RC != 0 ; then
    322      1.1  christos 	echo "ldapadd failed for server 2 database ($RC)!"
    323      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    324      1.1  christos 	exit $RC
    325      1.1  christos fi
    326      1.1  christos 
    327      1.1  christos THEDN="cn=James A Jones 2,ou=Alumni Association,ou=People,dc=example,dc=com"
    328      1.1  christos sleep 1
    329      1.1  christos for i in 1 2 3; do
    330      1.1  christos 	$LDAPSEARCH -S "" -b "$THEDN" -H $URI1 \
    331      1.1  christos 		-s base '(objectClass=*)' entryCSN > "${PROVIDEROUT}.$i" 2>&1
    332      1.1  christos 	RC=$?
    333      1.1  christos 
    334      1.1  christos 	if test $RC = 0 ; then
    335      1.1  christos 		break
    336      1.1  christos 	fi
    337      1.1  christos 
    338      1.1  christos 	if test $RC != 32 ; then
    339      1.1  christos 		echo "ldapsearch failed at consumer ($RC)!"
    340      1.1  christos 		test $KILLSERVERS != no && kill -HUP $KILLPIDS
    341      1.1  christos 		exit $RC
    342      1.1  christos 	fi
    343      1.1  christos 
    344      1.1  christos 	echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    345      1.1  christos 	sleep $SLEEP1
    346      1.1  christos done
    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 all the entries from server $n..."
    354      1.1  christos $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD  \
    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 $LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt
    364      1.1  christos n=`expr $n + 1`
    365      1.1  christos done
    366      1.1  christos 
    367      1.1  christos n=2
    368      1.1  christos while [ $n -le $MPR ]; do
    369      1.1  christos echo "Comparing retrieved entries from server 1 and server $n..."
    370      1.1  christos $CMP $PROVIDERFLT $TESTDIR/server$n.flt > $CMPOUT
    371      1.1  christos 
    372      1.1  christos if test $? != 0 ; then
    373      1.1  christos 	echo "test failed - server 1 and server $n databases differ"
    374      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    375      1.1  christos 	exit 1
    376      1.1  christos fi
    377      1.1  christos n=`expr $n + 1`
    378      1.1  christos done
    379      1.1  christos 
    380      1.1  christos echo "Breaking replication between server 1 and 2..."
    381      1.1  christos n=1
    382      1.1  christos while [ $n -le 2 ]; do
    383      1.1  christos MYURI=`eval echo '$URI'$n`
    384      1.1  christos o=`expr $n - 1`
    385      1.1  christos $LDAPMODIFY -D cn=config -H $MYURI -y $CONFIGPWF > $TESTOUT 2>&1 <<EOF
    386      1.1  christos dn: olcDatabase={2}$BACKEND,cn=config
    387      1.1  christos changetype: modify
    388      1.1  christos delete: olcSyncRepl
    389      1.1  christos -
    390      1.1  christos 
    391      1.1  christos EOF
    392      1.1  christos RC=$?
    393      1.1  christos if test $RC != 0 ; then
    394      1.1  christos 	echo "ldapmodify failed for server $n config ($RC)!"
    395      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    396      1.1  christos 	exit $RC
    397      1.1  christos fi
    398      1.1  christos n=`expr $n + 1`
    399      1.1  christos done
    400      1.1  christos 
    401      1.1  christos echo "Using ldapmodify to force conflicts between server 1 and 2..."
    402      1.1  christos $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
    403      1.1  christos 	>> $TESTOUT 2>&1 << EOF
    404      1.1  christos dn: $THEDN
    405      1.1  christos changetype: modify
    406      1.1  christos add: description
    407      1.1  christos description: Amazing
    408      1.1  christos -
    409      1.1  christos add: displayName
    410      1.1  christos displayName: James the Second
    411      1.1  christos -
    412      1.1  christos delete: displayName
    413      1.1  christos displayName: The other
    414  1.1.1.2  christos -
    415  1.1.1.2  christos replace: mail
    416  1.1.1.2  christos mail: jaj2@mail.alumni.example.com
    417      1.1  christos 
    418      1.1  christos EOF
    419      1.1  christos RC=$?
    420      1.1  christos if test $RC != 0 ; then
    421      1.1  christos 	echo "ldapmodify failed for server 1 database ($RC)!"
    422      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    423      1.1  christos 	exit $RC
    424      1.1  christos fi
    425      1.1  christos 
    426      1.1  christos $LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \
    427      1.1  christos 	>> $TESTOUT 2>&1 << EOF
    428      1.1  christos dn: $THEDN
    429      1.1  christos changetype: modify
    430      1.1  christos replace: employeetype
    431      1.1  christos -
    432      1.1  christos add: description
    433      1.1  christos description: Stupendous
    434      1.1  christos -
    435      1.1  christos add: displayName
    436      1.1  christos displayName: James II
    437      1.1  christos -
    438      1.1  christos delete: displayName
    439      1.1  christos displayName: The other
    440  1.1.1.2  christos -
    441  1.1.1.2  christos add: mail
    442  1.1.1.2  christos mail: jaj2@moo.net
    443      1.1  christos 
    444      1.1  christos EOF
    445      1.1  christos RC=$?
    446      1.1  christos if test $RC != 0 ; then
    447      1.1  christos 	echo "ldapmodify failed for server 2 database ($RC)!"
    448      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    449      1.1  christos 	exit $RC
    450      1.1  christos fi
    451      1.1  christos 
    452      1.1  christos $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
    453      1.1  christos 	>> $TESTOUT 2>&1 << EOF
    454      1.1  christos dn: $THEDN
    455      1.1  christos changetype: modify
    456      1.1  christos delete: description
    457      1.1  christos description: Outstanding
    458      1.1  christos -
    459      1.1  christos add: description
    460      1.1  christos description: Mindboggling
    461      1.1  christos 
    462      1.1  christos EOF
    463      1.1  christos RC=$?
    464      1.1  christos if test $RC != 0 ; then
    465      1.1  christos 	echo "ldapmodify failed for server 1 database ($RC)!"
    466      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    467      1.1  christos 	exit $RC
    468      1.1  christos fi
    469      1.1  christos 
    470      1.1  christos $LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \
    471      1.1  christos 	>> $TESTOUT 2>&1 << EOF
    472      1.1  christos dn: $THEDN
    473      1.1  christos changetype: modify
    474      1.1  christos delete: description
    475      1.1  christos description: OutStanding
    476      1.1  christos -
    477      1.1  christos add: description
    478      1.1  christos description: Bizarre
    479      1.1  christos 
    480      1.1  christos EOF
    481      1.1  christos RC=$?
    482      1.1  christos if test $RC != 0 ; then
    483      1.1  christos 	echo "ldapmodify failed for server 2 database ($RC)!"
    484      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    485      1.1  christos 	exit $RC
    486      1.1  christos fi
    487      1.1  christos 
    488      1.1  christos $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
    489      1.1  christos 	>> $TESTOUT 2>&1 << EOF
    490      1.1  christos dn: $THEDN
    491      1.1  christos changetype: modify
    492      1.1  christos add: carLicense
    493      1.1  christos carLicense: 123-XYZ
    494      1.1  christos -
    495      1.1  christos add: employeeNumber
    496      1.1  christos employeeNumber: 32
    497      1.1  christos 
    498      1.1  christos EOF
    499      1.1  christos RC=$?
    500      1.1  christos if test $RC != 0 ; then
    501      1.1  christos 	echo "ldapmodify failed for server 1 database ($RC)!"
    502      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    503      1.1  christos 	exit $RC
    504      1.1  christos fi
    505      1.1  christos 
    506      1.1  christos $LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \
    507      1.1  christos 	>> $TESTOUT 2>&1 << EOF
    508      1.1  christos dn: $THEDN
    509      1.1  christos changetype: modify
    510      1.1  christos add: employeeType
    511      1.1  christos employeeType: deadwood
    512      1.1  christos -
    513      1.1  christos add: employeeNumber
    514      1.1  christos employeeNumber: 64
    515      1.1  christos 
    516      1.1  christos EOF
    517      1.1  christos RC=$?
    518      1.1  christos if test $RC != 0 ; then
    519      1.1  christos 	echo "ldapmodify failed for server 2 database ($RC)!"
    520      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    521      1.1  christos 	exit $RC
    522      1.1  christos fi
    523      1.1  christos 
    524      1.1  christos $LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
    525      1.1  christos 	>> $TESTOUT 2>&1 << EOF
    526      1.1  christos dn: $THEDN
    527      1.1  christos changetype: modify
    528      1.1  christos replace: sn
    529      1.1  christos sn: Replaced later
    530      1.1  christos -
    531      1.1  christos replace: sn
    532      1.1  christos sn: Surname
    533      1.1  christos EOF
    534      1.1  christos RC=$?
    535      1.1  christos if test $RC != 0 ; then
    536      1.1  christos 	echo "ldapmodify failed for server 1 database ($RC)!"
    537      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    538      1.1  christos 	exit $RC
    539      1.1  christos fi
    540      1.1  christos 
    541      1.1  christos echo "Restoring replication between server 1 and 2..."
    542      1.1  christos cat > $TMP <<EOF
    543      1.1  christos dn: olcDatabase={2}$BACKEND,cn=config
    544      1.1  christos changetype: modify
    545      1.1  christos add: olcSyncRepl
    546      1.1  christos EOF
    547      1.1  christos n=1
    548      1.1  christos while [ $n -le $MPR ]; do
    549      1.1  christos MYURI=`eval echo '$URI'$n`
    550      1.1  christos PROVIDERURI=`eval echo '$URI'$n`
    551      1.1  christos cat >> $TMP <<EOF
    552      1.1  christos olcSyncRepl: rid=00$n provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple
    553      1.1  christos   credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
    554      1.1  christos   retry="3 +" timeout=3 logbase="cn=log"
    555      1.1  christos   logfilter="(&(objectclass=auditWriteObject)(reqresult=0))"
    556      1.1  christos   syncdata=accesslog
    557      1.1  christos EOF
    558      1.1  christos n=`expr $n + 1`
    559      1.1  christos done
    560      1.1  christos cat >> $TMP <<EOF
    561      1.1  christos -
    562      1.1  christos replace: olcMultiProvider
    563      1.1  christos olcMultiProvider: TRUE
    564      1.1  christos EOF
    565      1.1  christos n=1
    566      1.1  christos while [ $n -le 2 ]; do
    567      1.1  christos MYURI=`eval echo '$URI'$n`
    568      1.1  christos $LDAPMODIFY -D cn=config -H $MYURI -y $CONFIGPWF > $TESTOUT 2>&1 <$TMP
    569      1.1  christos RC=$?
    570      1.1  christos if test $RC != 0 ; then
    571      1.1  christos 	echo "ldapmodify failed for server $n config ($RC)!"
    572      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    573      1.1  christos 	exit $RC
    574      1.1  christos fi
    575      1.1  christos n=`expr $n + 1`
    576      1.1  christos done
    577      1.1  christos 
    578      1.1  christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
    579      1.1  christos sleep $SLEEP1
    580      1.1  christos 
    581      1.1  christos n=1
    582      1.1  christos while [ $n -le $MPR ]; do
    583      1.1  christos PORT=`expr $BASEPORT + $n`
    584      1.1  christos URI="ldap://${LOCALHOST}:$PORT/"
    585      1.1  christos 
    586      1.1  christos echo "Using ldapsearch to read all the entries from server $n..."
    587      1.1  christos $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD  \
    588      1.1  christos 	'objectclass=*' > $TESTDIR/server$n.out 2>&1
    589      1.1  christos RC=$?
    590      1.1  christos 
    591      1.1  christos if test $RC != 0 ; then
    592      1.1  christos 	echo "ldapsearch failed at server $n ($RC)!"
    593      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    594      1.1  christos 	exit $RC
    595      1.1  christos fi
    596      1.1  christos $LDIFFILTER -s a < $TESTDIR/server$n.out > $TESTDIR/server$n.flt
    597      1.1  christos n=`expr $n + 1`
    598      1.1  christos done
    599      1.1  christos 
    600      1.1  christos n=2
    601      1.1  christos while [ $n -le $MPR ]; do
    602      1.1  christos echo "Comparing retrieved entries from server 1 and server $n..."
    603      1.1  christos $CMP $PROVIDERFLT $TESTDIR/server$n.flt > $CMPOUT
    604      1.1  christos 
    605      1.1  christos if test $? != 0 ; then
    606      1.1  christos 	echo "test failed - server 1 and server $n databases differ"
    607      1.1  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    608      1.1  christos 	exit 1
    609      1.1  christos fi
    610      1.1  christos n=`expr $n + 1`
    611      1.1  christos done
    612      1.1  christos 
    613      1.1  christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
    614      1.1  christos 
    615      1.1  christos echo ">>>>> Test succeeded"
    616      1.1  christos 
    617      1.1  christos test $KILLSERVERS != no && wait
    618      1.1  christos 
    619      1.1  christos exit 0
    620