-LDIF2LDBM=../servers/slapd/tools/ldif2ldbm
+
+DATADIR=$SRCDIR/data
+PROGDIR=./progs
+
+if test "$BACKEND" = "bdb2" ; then
+ LDIF2LDBM=../servers/slapd/tools/ldif2ldbm-bdb2
+ CONF=$DATADIR/slapd-bdb2-master.conf
+ ACLCONF=$DATADIR/slapd-bdb2-acl.conf
+ MASTERCONF=$DATADIR/slapd-bdb2-repl-master.conf
+ SLAVECONF=$DATADIR/slapd-bdb2-repl-slave.conf
+ TIMING="-t"
+else
+ LDIF2LDBM=../servers/slapd/tools/ldif2ldbm
+ CONF=$DATADIR/slapd-master.conf
+ ACLCONF=$DATADIR/slapd-acl.conf
+ MASTERCONF=$DATADIR/slapd-repl-master.conf
+ SLAVECONF=$DATADIR/slapd-repl-slave.conf
+fi
+
+if test "$LDAP_PROTO" ; then
+ PROTO="-P $LDAP_PROTO"
+fi
+
+PASSWDCONF=$DATADIR/slapd-passwd.conf
+
+CLIENTDIR=../clients/tools
+#CLIENTDIR=/usr/local/bin
+
SLAPD=../servers/slapd/slapd
SLURPD=../servers/slurpd/slurpd
-LDAPSEARCH=../clients/tools/ldapsearch
-LDAPMODIFY=../clients/tools/ldapmodify
-LDAPADD=../clients/tools/ldapadd
+LDAPSEARCH="$CLIENTDIR/ldapsearch $PROTO"
+LDAPMODIFY="$CLIENTDIR/ldapmodify $PROTO"
+LDAPADD="$CLIENTDIR/ldapadd $PROTO"
+LDAPMODRDN="$CLIENTDIR/ldapmodrdn $PROTO"
+SLAPDTESTER=$PROGDIR/slapd-tester
+LVL=${SLAPD_DEBUG-5}
+ADDR=127.0.0.1
PORT=9009
SLAVEPORT=9010
DBDIR=./test-db
REPLDIR=./test-repl
-CONF=./data/slapd-master.conf
-ACLCONF=./data/slapd-acl.conf
-MASTERCONF=./data/slapd-repl-master.conf
-SLAVECONF=./data/slapd-repl-slave.conf
-LDIF=./data/test.ldif
-LDIFORDERED=./data/test-ordered.ldif
+LDIF=$DATADIR/test.ldif
+LDIFORDERED=$DATADIR/test-ordered.ldif
+MONITOR="cn=monitor"
BASEDN="o=University of Michigan, c=US"
MANAGERDN="cn=Manager, o=University of Michigan, c=US"
PASSWD=secret
BABSDN="cn=Barbara Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US"
BJORNSDN="cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US"
JAJDN="cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US"
+MASTERLOG=$DBDIR/master.log
+SLAVELOG=$DBDIR/slave.log
+SLURPLOG=$DBDIR/slurp.log
SEARCHOUT=$DBDIR/ldapsearch.out
+SEARCHFLT=$DBDIR/ldapsearch.flt
+LDIFFLT=$DBDIR/ldif.flt
MASTEROUT=$DBDIR/master.out
SLAVEOUT=$DBDIR/slave.out
TESTOUT=$DBDIR/ldapsearch.out
-SEARCHOUTMASTER=./data/search.out.master
-MODIFYOUTMASTER=./data/modify.out.master
-ADDDELOUTMASTER=./data/adddel.out.master
-MODRDNOUTMASTER=./data/modrdn.out.master
-ACLOUTMASTER=./data/acl.out.master
-REPLOUTMASTER=./data/repl.out.master
-MODSRCHFILTERS=./data/modify.search.filters
+SEARCHOUTMASTER=$DATADIR/search.out.master
+MODIFYOUTMASTER=$DATADIR/modify.out.master
+ADDDELOUTMASTER=$DATADIR/adddel.out.master
+MODRDNOUTMASTER0=$DATADIR/modrdn.out.master.0
+MODRDNOUTMASTER1=$DATADIR/modrdn.out.master.1
+MODRDNOUTMASTER2=$DATADIR/modrdn.out.master.2
+MODRDNOUTMASTER3=$DATADIR/modrdn.out.master.3
+ACLOUTMASTER=$DATADIR/acl.out.master
+REPLOUTMASTER=$DATADIR/repl.out.master
+MODSRCHFILTERS=$DATADIR/modify.search.filters
-#!/bin/sh
+#! /bin/sh
-. scripts/defines.sh
+if test $# -eq 0 ; then
+ SRCDIR="."
+else
+ SRCDIR=$1; shift
+fi
+if test $# -eq 1 ; then
+ BACKEND=$1; shift
+fi
+echo "running defines.sh $SRCDIR $BACKEND"
+. $SRCDIR/scripts/defines.sh
echo "Cleaning up in $DBDIR..."
-rm -f $DBDIR/*
+rm -f $DBDIR/[!C]*
echo "Starting slapd on TCP/IP port $PORT..."
-$SLAPD -f $CONF -p $PORT -d 1 > /dev/null 2>&1 &
+$SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
PID=$!
echo "Using ldapsearch to check that slapd is running..."
for i in 0 1 2 3 4 5; do
- $LDAPSEARCH -L -b "$BASEDN" -h localhost -p $PORT \
- 'cn=Monitor' > /dev/null 2>&1
+ $LDAPSEARCH -L -b "$MONITOR" -h localhost -p $PORT \
+ 'objectclass=*' > /dev/null 2>&1
RC=$?
- if [ $RC = 1 ]; then
+ if test $RC = 1 ; then
echo "Waiting 5 seconds for slapd to start..."
sleep 5
fi
done
-echo "Using ldapmodify to populate the database..."
-$LDAPMODIFY -a -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD < \
+echo "Using ldapadd to populate the database..."
+$LDAPADD -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD < \
$LDIFORDERED > /dev/null 2>&1
RC=$?
-if [ $RC != 0 ]; then
- echo "ldapmodify failed!"
+if test $RC != 0 ; then
+ echo "ldapadd failed!"
kill -HUP $PID
exit $RC
fi
echo "Using ldapsearch to read all the entries..."
$LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
- 'objectclass=*' | egrep -iv '^creatorsname:|^createtimestamp:' > \
- $SEARCHOUT 2>&1
+ 'objectclass=*' > $SEARCHOUT 2>&1
kill -HUP $PID
-if [ $RC != 0 ]; then
+if test $RC != 0 ; then
echo "ldapsearch failed!"
exit $RC
fi
-echo "Comparing retrieved entries to LDIF file used to create database"
-cmp $SEARCHOUT $LDIF
-if [ $? != 0 ]; then
+echo "Filtering ldapsearch results..."
+. $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
+echo "Filtering original ldif used to create database..."
+. $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
+echo "Comparing filter output..."
+cmp $SEARCHFLT $LDIFFLT
+
+if test $? != 0 ; then
echo "comparison failed - database was not created correctly"
exit 1
fi
-#!/bin/sh
+#! /bin/sh
-. scripts/defines.sh
+if test $# -eq 0 ; then
+ SRCDIR="."
+else
+ SRCDIR=$1; shift
+fi
+if test $# -eq 1 ; then
+ BACKEND=$1; shift
+fi
+
+echo "running defines.sh $SRCDIR $BACKEND"
+. $SRCDIR/scripts/defines.sh
echo "Cleaning up in $DBDIR..."
-rm -f $DBDIR/*
+rm -f $DBDIR/[!C]*
echo "Running ldif2ldbm to build slapd database..."
$LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
RC=$?
-if [ $RC != 0 ]; then
+if test $RC != 0 ; then
echo "ldif2ldbm failed!"
exit $RC
fi
echo "Starting slapd on TCP/IP port $PORT..."
-$SLAPD -f $ACLCONF -p $PORT -d 1 > /dev/null 2>&1 &
+$SLAPD -f $ACLCONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
PID=$!
echo "Testing slapd access control..."
for i in 0 1 2 3 4 5; do
- $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
- 'cn=Monitor' > /dev/null 2>&1
+ $LDAPSEARCH -L -b "$MONITOR" -h localhost -p $PORT \
+ 'objectclass=*' > /dev/null 2>&1
RC=$?
- if [ $RC = 1 ]; then
+ if test $RC = 1 ; then
echo "Waiting 5 seconds for slapd to start..."
sleep 5
fi
done
-if [ $RC != 0 ]; then
+if test $RC != 0 ; then
echo "ldapsearch failed!"
kill -HUP $PID
exit $RC
echo "Using ldapsearch to retrieve all the entries..."
$LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
- 'objectClass=*' | egrep -iv '^modifytimestamp|^modifiersname' \
- >> $SEARCHOUT 2>&1
+ 'objectClass=*' | . $SRCDIR/scripts/acfilter.sh >> $SEARCHOUT 2>&1
RC=$?
kill -HUP $PID
-if [ $RC != 0 ]; then
+if test $RC != 0 ; then
echo "ldapsearch failed!"
exit $RC
fi
-echo "Comparing database to reference file"
-cmp $SEARCHOUT $ACLOUTMASTER
-if [ $? != 0 ]; then
+LDIF=$ACLOUTMASTER
+
+echo "Filtering ldapsearch results..."
+. $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
+echo "Filtering original ldif used to create database..."
+. $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
+echo "Comparing filter output..."
+cmp $SEARCHFLT $LDIFFLT
+
+if test $? != 0 ; then
echo "comparison failed - modify operations did not complete correctly"
exit 1
fi
-#!/bin/sh
+#! /bin/sh
#
# Test replication:
# - retrieve database over ldap and compare against expected results
#
-. scripts/defines.sh
+if test $# -eq 0 ; then
+ SRCDIR="."
+else
+ SRCDIR=$1; shift
+fi
+if test $# -eq 1 ; then
+ BACKEND=$1; shift
+fi
+
+echo "running defines.sh $SRCDIR $BACKEND"
+. $SRCDIR/scripts/defines.sh
+
+if test ! -x $SLURPD ; then
+ echo ">>>>> $SLURPD is not executable or do not exist."
+ echo ">>>>> Test skipped."
+ exit 0
+fi
echo "Cleaning up in $DBDIR..."
-rm -f $DBDIR/*
+rm -f $DBDIR/[!C]*
echo "Cleaning up in $REPLDIR..."
-rm -f $REPLDIR/*
+rm -f $REPLDIR/[!C]*
echo "Starting master slapd on TCP/IP port $PORT..."
-$SLAPD -f $MASTERCONF -p $PORT -d 1 > /dev/null 2>&1 &
+$SLAPD -f $MASTERCONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
PID=$!
echo "Starting slave slapd on TCP/IP port $SLAVEPORT..."
-$SLAPD -f $SLAVECONF -p $SLAVEPORT -d 1 > /dev/null 2>&1 &
+$SLAPD -f $SLAVECONF -p $SLAVEPORT -d $LVL $TIMING > $SLAVELOG 2>&1 &
SLAVEPID=$!
echo "Using ldapsearch to check that master slapd is running..."
for i in 0 1 2 3 4 5; do
- $LDAPSEARCH -L -b "$BASEDN" -h localhost -p $PORT \
- 'cn=Monitor' > /dev/null 2>&1
+ $LDAPSEARCH -L -b "$MONITOR" -h localhost -p $PORT \
+ 'objectclass=*' > /dev/null 2>&1
RC=$?
- if [ $RC = 1 ]; then
+ if test $RC = 1 ; then
echo "Waiting 5 seconds for slapd to start..."
sleep 5
fi
echo "Using ldapsearch to check that slave slapd is running..."
for i in 0 1 2 3 4 5; do
- $LDAPSEARCH -L -b "$BASEDN" -h localhost -p $SLAVEPORT \
- 'cn=Monitor' > /dev/null 2>&1
+ $LDAPSEARCH -L -b "$MONITOR" -h localhost -p $SLAVEPORT \
+ 'objectclass=*' > /dev/null 2>&1
RC=$?
- if [ $RC = 1 ]; then
+ if test $RC = 1 ; then
echo "Waiting 5 seconds for slapd to start..."
sleep 5
fi
done
echo "Starting slurpd..."
-$SLURPD -f $MASTERCONF -d 4 -t $REPLDIR > /dev/null 2>&1 &
+$SLURPD -f $MASTERCONF -d 4 -t $REPLDIR > $SLURPLOG 2>&1 &
SLURPPID=$!
-echo "Using ldapmodify to populate the database..."
-$LDAPMODIFY -a -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD < \
+echo "Using ldapadd to populate the database..."
+$LDAPADD -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD < \
$LDIFORDERED > /dev/null 2>&1
RC=$?
-if [ $RC != 0 ]; then
- echo "ldapmodify failed!"
+if test $RC != 0 ; then
+ echo "ldapadd failed!"
kill -HUP $PID $SLAVEPID $SLURPPID
exit $RC
fi
EOMODS
-echo "Waiting 10 seconds for slurpd to send changes..."
-sleep 10
+echo "Waiting 15 seconds for slurpd to send changes..."
+sleep 15
echo "Using ldapsearch to read all the entries from the master..."
$LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
'objectclass=*' > $MASTEROUT 2>&1
-if [ $RC != 0 ]; then
+if test $RC != 0 ; then
echo "ldapsearch failed!"
kill -HUP $PID $SLAVEPID $SLURPPID
exit $RC
$LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $SLAVEPORT \
'objectclass=*' > $SLAVEOUT 2>&1
-if [ $RC != 0 ]; then
+if test $RC != 0 ; then
echo "ldapsearch failed!"
kill -HUP $PID $SLAVEPID $SLURPPID
exit $RC
kill -HUP $PID $SLAVEPID $SLURPPID
+SEARCHOUT=$MASTEROUT
+LDIF=$SLAVEOUT
+
+echo "Filtering ldapsearch results..."
+. $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
+echo "Filtering original ldif used to create database..."
+. $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
+
echo "Comparing retrieved entries from master and slave..."
-cmp $MASTEROUT $SLAVEOUT
-if [ $? != 0 ]; then
+cmp $SEARCHFLT $LDIFFLT
+
+if test $? != 0 ; then
echo "test failed - master and slave databases differ"
exit 1
fi