replogfile ./test-db/slapd.replog
replica host=localhost:9010
- suffix="ou=People, o=University of Michigan, c=US"
- binddn="cn=Replica, o=University of Michigan, c=US"
+ suffix="ou=Groups, o=University of Michigan, c=US"
+ binddn="cn=Replica, ou=Groups, o=University of Michigan, c=US"
bindmethod=simple
credentials=secret
--- /dev/null
+# $OpenLDAP$
+#
+# slave slapd config -- for testing of replication
+#
+ucdata-path ./ucdata
+include ./schema/core.schema
+include ./schema/cosine.schema
+include ./schema/inetorgperson.schema
+#
+schemacheck off
+pidfile ./test-repl/slapd.pid
+argsfile ./test-repl/slapd.args
+
+#referral "ldap://localhost:9009/"
+
+#######################################################################
+# ldbm database definitions
+#######################################################################
+
+database @BACKEND@
+cachesize 0
+suffix "ou=Groups, o=University of Michigan, c=US"
+directory ./test-repl
+rootdn "cn=Replica, ou=Groups, o=University of Michigan, c=US"
+rootpw secret
+updatedn "cn=Replica, ou=Groups, o=University of Michigan, c=US"
+updateref "ldap://localhost:9009"
+#ldbm#index objectClass eq
+#ldbm#index cn,sn,uid pres,eq,sub
+#bdb#index objectClass eq
+#bdb#index cn,sn,uid pres,eq,sub
+lastmod on
+++ /dev/null
-dn: o=University of Michigan, c=US
-objectclass: top
-objectclass: organization
-objectclass: domainRelatedObject
-l: Ann Arbor, Michigan
-st: Michigan
-o: University of Michigan
-o: UMICH
-o: UM
-o: U-M
-o: U of M
-description: The University of Michigan at Ann Arbor
-postaladdress: University of Michigan $ 535 W. William St. $ Ann Arbor, MI 481
- 09 $ US
-telephonenumber: +1 313 764-1817
-associateddomain: umich.edu
=US
objectclass: top
objectclass: organizationalUnit
-ou: Information Technology Divisio
+ou: Information Technology Division
dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
member: cn=Manager, o=University of Michigan, c=US
pager: +1 313 555 2844
facsimiletelephonenumber: +1 313 555 9700
telephonenumber: +1 313 555 5331
+
SLAVECONF=$DATADIR/slapd-repl-slave.conf
REFSLAVECONF=$DATADIR/slapd-ref-slave.conf
SUBMASTERCONF=$DATADIR/slapd-repl-submaster.conf
+SUBSLAVECONF=$DATADIR/slapd-repl-subslave.conf
SCHEMACONF=$DATADIR/slapd-schema.conf
DBCONF=$DBDIR/slapd.conf
#CLIENTDIR=/usr/local/bin
LDIFFILTER=$SRCDIR/scripts/acfilter.sh
+SUBFILTER=$SRCDIR/scripts/subfilter.sh
+UNDIFFFILTER=$SRCDIR/scripts/undiff.sh
CONFFILTER=$SRCDIR/scripts/conf.sh
SLAPADD="../servers/slapd/tools/slapadd $LDAP_VERBOSE"
SEARCHOUT=$DBDIR/ldapsearch.out
SEARCHFLT=$DBDIR/ldapsearch.flt
LDIFFLT=$DBDIR/ldif.flt
+SUBFLT=$DBDIR/sub.flt
+SUBFLT2=$DBDIR/sub2.flt
MASTEROUT=$DBDIR/master.out
SLAVEOUT=$DBDIR/slave.out
+SUBMASTEROUT=$DBDIR/submaster.out
TESTOUT=$DBDIR/test.out
INITOUT=$DBDIR/init.out
SEARCHOUTMASTER=$DATADIR/search.out.master
--- /dev/null
+#! /bin/sh
+#
+# Strip entries that belong to subtree $2 (if any)
+#
+if test $# == 0 ; then
+ exit 1
+else
+ awk "/^dn:/&&!/$1\$/ {while (\$1!=\"\") {print \$0;getline} print \"\"}"
+fi
+
rm -f $DBDIR/[!C]*
echo "Cleaning up in $REPLDIR..."
rm -f $REPLDIR/[!C]*
+rm -f $REPLDIR/replica/[!C]*
echo "Starting master slapd on TCP/IP port $PORT..."
. $CONFFILTER $BACKEND < $SUBMASTERCONF > $DBCONF
fi
echo "Starting slave slapd on TCP/IP port $SLAVEPORT..."
-. $CONFFILTER $BACKEND < $SLAVECONF > $REPLCONF
+. $CONFFILTER $BACKEND < $SUBSLAVECONF > $REPLCONF
$SLAPD -f $REPLCONF -h $SLAVEURI -d $LVL $TIMING > $SLAVELOG 2>&1 &
SLAVEPID=$!
if test $WAIT != 0 ; then
fi
done
-echo "Creating base in subtree slave"
-$LDAPADD -D "$UPDATEDN" -h localhost -p $SLAVEPORT -w $PASSWD < \
- $LDIFBASE > /dev/null 2>&1
-RC=$?
-if test $RC != 0 ; then
- echo "ldapadd failed ($RC)!"
- kill -INT $PID $SLAVEPID
- kill -KILL $SLURPPID
- exit $RC
-fi
-
echo "Starting slurpd..."
$SLURPD -f $SUBMASTERCONF -d ${SLURPD_DEBUG-5} -t $REPLDIR > $SLURPLOG 2>&1 &
SLURPPID=$!
echo "Waiting 15 seconds for slurpd to send changes..."
sleep 15
-echo "Using ldapsearch to read the subtree entries from the master..."
-$LDAPSEARCH -S "" -b "$BASEDN" -s base -h localhost -p $PORT \
+echo "Using ldapsearch to read all the entries from the master..."
+$LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
'objectclass=*' > $MASTEROUT 2>&1
if test $RC != 0 ; then
exit $RC
fi
-$LDAPSEARCH -S "" -b "ou=People, $BASEDN" -h localhost -p $PORT \
- 'objectclass=*' >> $MASTEROUT 2>&1
+echo "Using ldapsearch to read the subtree entries from the master..."
+$LDAPSEARCH -S "" -b "ou=Groups, $BASEDN" -h localhost -p $PORT \
+ 'objectclass=*' > $SUBMASTEROUT 2>&1
if test $RC != 0 ; then
echo "ldapsearch failed ($RC)!"
fi
echo "Using ldapsearch to read all the entries from the slave..."
-$LDAPSEARCH -S "" -b "$BASEDN" -s base -h localhost -p $SLAVEPORT \
+$LDAPSEARCH -S "" -b "ou=Groups, $BASEDN" -h localhost -p $SLAVEPORT \
'objectclass=*' > $SLAVEOUT 2>&1
if test $RC != 0 ; then
exit $RC
fi
-$LDAPSEARCH -S "" -b "ou=People, $BASEDN" -h localhost -p $SLAVEPORT \
- 'objectclass=*' >> $SLAVEOUT 2>&1
-
-if test $RC != 0 ; then
- echo "ldapsearch failed ($RC)!"
- kill -INT $PID $SLAVEPID
- kill -KILL $SLURPPID
- exit $RC
-fi
-
kill -INT $PID $SLAVEPID
kill -KILL $SLURPPID
-SEARCHOUT=$MASTEROUT
+SEARCHOUT=$SUBMASTEROUT
LDIF=$SLAVEOUT
-echo "Filtering ldapsearch results..."
+echo "Filtering master ldapsearch results..."
. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
-echo "Filtering original ldif used to create database..."
+echo "Filtering slave ldapsearch results..."
. $LDIFFILTER < $LDIF > $LDIFFLT
echo "Comparing retrieved entries from master and slave..."
exit 1
fi
-echo ">>>>> Test succeeded"
+SEARCHOUT=$MASTEROUT
+
+echo "Filtering remaining data"
+. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
+
+echo "Stripping slave entries from master output..."
+$CMP $SEARCHFLT $LDIFFLT | $UNDIFFFILTER > $SUBFLT
+echo "Stripping subtree entries from master output..."
+. $SUBFILTER 'ou=Groups,[ ]?o=University of Michigan,[ ]?c=US' < $SEARCHOUT \
+ | $UNDIFFFILTER > $SUBFLT2
+
+echo "Comparing master minus subtree and master minus slave..."
+$CMP $SUBFLT $SUBFLT2 > $CMPOUT
+
+if test $? != 0 ; then
+ echo "test failed - master and slave databases differ"
+ exit 1
+fi
+
+echo ">>>>> Test succeeded"
exit 0
--- /dev/null
+#! /bin/sh
+#
+# Expunge "< " and "> " resulting from diff
+#
+awk '!/^[0-9]/ {print $0}' | \
+ sed "s/^< //" | \
+ sed "s/> //" | \
+ awk '/.+/ {print $0}'
+