Skip to content
Snippets Groups Projects
Commit 7c846b4c authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

more meaningful subtree replication test

parent f65d9b30
No related branches found
No related tags found
No related merge requests found
......@@ -31,7 +31,7 @@ lastmod on
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
# $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
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
......@@ -34,7 +34,7 @@ dn: ou=Information Technology Division, ou=People, o=University of Michigan, c
=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
......@@ -311,3 +311,4 @@ homephone: +1 313 555 8421
pager: +1 313 555 2844
facsimiletelephonenumber: +1 313 555 9700
telephonenumber: +1 313 555 5331
......@@ -14,6 +14,7 @@ MASTERCONF=$DATADIR/slapd-repl-master.conf
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
......@@ -29,6 +30,8 @@ CLIENTDIR=../clients/tools
#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"
......@@ -70,8 +73,11 @@ SLURPLOG=$DBDIR/slurp.log
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
......
#! /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
......@@ -38,6 +38,7 @@ echo "Cleaning up in $DBDIR..."
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
......@@ -49,7 +50,7 @@ if test $WAIT != 0 ; then
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
......@@ -79,17 +80,6 @@ for i in 0 1 2 3 4 5; do
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=$!
......@@ -186,8 +176,8 @@ EOMODS
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
......@@ -197,8 +187,9 @@ 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)!"
......@@ -208,7 +199,7 @@ if test $RC != 0 ; then
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
......@@ -218,25 +209,15 @@ 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..."
......@@ -247,7 +228,26 @@ if test $? != 0 ; then
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
#! /bin/sh
#
# Expunge "< " and "> " resulting from diff
#
awk '!/^[0-9]/ {print $0}' | \
sed "s/^< //" | \
sed "s/> //" | \
awk '/.+/ {print $0}'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment