2002-01-11 17:26:01 +08:00
|
|
|
#! /bin/sh
|
|
|
|
# $OpenLDAP$
|
|
|
|
|
|
|
|
SRCDIR="."
|
|
|
|
if test $# -ge 1 ; then
|
|
|
|
SRCDIR=$1; shift
|
|
|
|
fi
|
2002-05-17 17:11:30 +08:00
|
|
|
BACKEND=bdb
|
2002-01-11 17:26:01 +08:00
|
|
|
if test $# -ge 1 ; then
|
|
|
|
BACKEND=$1; shift
|
|
|
|
fi
|
2002-06-19 14:00:48 +08:00
|
|
|
MONITORDB=no
|
|
|
|
if test $# -ge 1 ; then
|
|
|
|
MONITORDB=$1; shift
|
|
|
|
fi
|
2002-01-11 17:26:01 +08:00
|
|
|
WAIT=0
|
|
|
|
if test $# -ge 1 ; then
|
|
|
|
WAIT=1; shift
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "running defines.sh"
|
|
|
|
. $SRCDIR/scripts/defines.sh
|
|
|
|
|
|
|
|
echo "Cleaning up in $DBDIR..."
|
|
|
|
|
2002-01-14 07:52:17 +08:00
|
|
|
mkdir $DBDIR/C_db1 $DBDIR/C_db2 $DBDIR/C_db3
|
2002-01-11 17:26:01 +08:00
|
|
|
|
2002-01-14 07:52:17 +08:00
|
|
|
rm -f $DBDIR/[!C]* $DBDIR/C_db?/*
|
2002-01-11 17:26:01 +08:00
|
|
|
|
|
|
|
echo "Running slapadd to build glued slapd databases..."
|
2002-06-19 14:00:48 +08:00
|
|
|
. $CONFFILTER $BACKEND $MONITORDB < $GLUECONF > $DBCONF
|
2002-01-11 17:26:01 +08:00
|
|
|
$SLAPADD -d $LVL -f $DBCONF -l $LDIFORDERED > $DBDIR/slapadd.log 2>&1
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "slapadd failed ($RC)!"
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Starting slapd on TCP/IP port $PORT..."
|
|
|
|
$SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
|
|
|
|
PID=$!
|
|
|
|
if test $WAIT != 0 ; then
|
|
|
|
echo PID $PID
|
|
|
|
read foo
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Using ldapsearch to retrieve all the entries..."
|
|
|
|
cd test-db
|
|
|
|
for i in 0 1 2 3 4 5; do
|
2002-01-21 14:35:04 +08:00
|
|
|
../$LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT > ../$SEARCHOUT 2>&1
|
2002-01-11 17:26:01 +08:00
|
|
|
RC=$?
|
2002-09-01 19:39:08 +08:00
|
|
|
if test $RC = 0 ; then
|
|
|
|
break
|
2002-01-11 17:26:01 +08:00
|
|
|
fi
|
2002-09-01 19:39:08 +08:00
|
|
|
echo "Waiting 5 seconds for slapd to start..."
|
|
|
|
sleep 5
|
2002-01-11 17:26:01 +08:00
|
|
|
done
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
kill -HUP $PID
|
2002-02-01 06:54:13 +08:00
|
|
|
echo "Sleeping for 5 seconds to let slapd exit..."
|
|
|
|
sleep 5
|
2002-01-11 17:26:01 +08:00
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Filtering ldapsearch results..."
|
|
|
|
. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
|
|
|
|
echo "Filtering original ldif used to create database..."
|
|
|
|
. $LDIFFILTER < $LDIFGLUED > $LDIFFLT
|
|
|
|
echo "Comparing filter output..."
|
|
|
|
$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
|
|
|
|
|
|
|
|
if test $? != 0 ; then
|
|
|
|
echo "comparison failed - database was not created correctly"
|
|
|
|
echo $SEARCHFLT $LDIFFLT
|
2002-01-16 01:26:44 +08:00
|
|
|
$DIFF $SEARCHFLT $LDIFFLT
|
2002-01-11 17:26:01 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "OK... Cleaning up in $DBDIR..."
|
|
|
|
|
2002-01-14 07:52:17 +08:00
|
|
|
rm -f $DBDIR/C_db?/*
|
2002-01-11 17:26:01 +08:00
|
|
|
|
|
|
|
echo "Starting slapd on TCP/IP port $PORT..."
|
|
|
|
$SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
|
|
|
|
PID=$!
|
|
|
|
if test $WAIT != 0 ; then
|
|
|
|
echo PID $PID
|
|
|
|
read foo
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Using ldapsearch to check that slapd is running..."
|
|
|
|
for i in 0 1 2 3 4 5; do
|
2002-01-21 14:35:04 +08:00
|
|
|
$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
|
2002-01-11 17:26:01 +08:00
|
|
|
'objectclass=*' > /dev/null 2>&1
|
|
|
|
RC=$?
|
2002-09-01 19:39:08 +08:00
|
|
|
if test $RC = 0 ; then
|
|
|
|
break
|
2002-01-11 17:26:01 +08:00
|
|
|
fi
|
2002-09-01 19:39:08 +08:00
|
|
|
echo "Waiting 5 seconds for slapd to start..."
|
|
|
|
sleep 5
|
2002-01-11 17:26:01 +08:00
|
|
|
done
|
|
|
|
|
|
|
|
echo "Using ldapadd to populate the glued database..."
|
2002-01-21 14:35:04 +08:00
|
|
|
$LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
|
2002-01-11 17:26:01 +08:00
|
|
|
$LDIFORDERED > $TESTOUT 2>&1
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapadd failed ($RC)!"
|
|
|
|
kill -HUP $PID
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Using ldapsearch to read all the entries..."
|
2002-01-21 14:35:04 +08:00
|
|
|
$LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT \
|
2002-01-11 17:26:01 +08:00
|
|
|
'objectclass=*' > $SEARCHOUT 2>&1
|
2002-05-17 17:11:30 +08:00
|
|
|
RC=$?
|
2002-01-11 17:26:01 +08:00
|
|
|
|
|
|
|
kill -HUP $PID
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Filtering ldapsearch results..."
|
|
|
|
. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
|
|
|
|
echo "Filtering original ldif used to create database..."
|
|
|
|
. $LDIFFILTER < $LDIFGLUED > $LDIFFLT
|
|
|
|
echo "Comparing filter output..."
|
|
|
|
$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
|
|
|
|
|
|
|
|
if test $? != 0 ; then
|
|
|
|
echo "comparison failed - database was not created correctly"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ">>>>> Test succeeded"
|
|
|
|
|
|
|
|
|
|
|
|
exit 0
|