openldap/tests/scripts/test020-syncreplication-cascading

443 lines
12 KiB
Plaintext
Raw Normal View History

2003-06-26 14:12:55 +08:00
#! /bin/sh
# $OpenLDAP$
SRCDIR="."
if test $# -ge 1 ; then
SRCDIR=$1; shift
fi
. $SRCDIR/scripts/args.sh $*
echo "running defines.sh"
. $SRCDIR/scripts/defines.sh
#
# Test replication:
# - start master
# - start slave
# - populate over ldap
# - perform some modifies and deleted
# - retrieve database over ldap and compare against expected results
#
echo "Cleaning up in $DBDIR..."
rm -f $DBDIR/[!C]*
2003-06-26 15:18:50 +08:00
echo "Resetting $R1REPLDIR..."
rm -rf $R1REPLDIR
mkdir $R1REPLDIR
echo "Resetting $R2REPLDIR..."
rm -rf $R2REPLDIR
mkdir $R2REPLDIR
echo "Resetting $P1REPLDIR..."
rm -rf $P1REPLDIR
mkdir $P1REPLDIR
echo "Resetting $P2REPLDIR..."
rm -rf $P2REPLDIR
mkdir $P2REPLDIR
echo "Resetting $P3REPLDIR..."
rm -rf $P3REPLDIR
mkdir $P3REPLDIR
2003-06-26 14:12:55 +08:00
SAVE=$BACKEND
if test $BACKEND = ldbm; then
if test $SYNCREPL = no; then
echo "Sync replication requires back-bdb or back-hdb"
exit 0
fi
BACKEND=$SYNCREPL
fi
2003-06-26 14:12:55 +08:00
echo "Starting master slapd on TCP/IP port $PORT..."
. $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $DBCONF
$SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
PID=$!
if test $WAIT != 0 ; then
echo PID $PID
read foo
fi
BACKEND=$SAVE
2003-06-26 14:12:55 +08:00
echo "Waiting 5 seconds to wait for master to start..."
sleep 5
echo "Using ldapsearch to check that master slapd is running..."
for i in 0 1 2 3 4 5; do
$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
'objectclass=*' > /dev/null 2>&1
RC=$?
if test $RC = 0 ; then
break
fi
echo "Waiting 5 seconds for slapd to start..."
sleep 5
done
echo "Using ldapadd to create the context prefix entry in the master..."
$LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
$LDIFORDEREDCP > /dev/null 2>&1
RC=$?
if test $RC != 0 ; then
echo "ldapadd failed ($RC)!"
kill -HUP $PID
exit $RC
fi
SAVE=$BACKEND
if test $BACKEND = ldbm; then
if test $SYNCREPL = no; then
echo "Sync replication requires back-bdb or back-hdb"
exit 0
fi
BACKEND=$SYNCREPL
fi
2003-06-26 14:12:55 +08:00
echo "Starting R1 slave slapd on TCP/IP port $R1SLAVEPORT..."
. $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $R1REPLCONF
$SLAPD -f $R1REPLCONF -h $R1SLAVEURI -d $LVL $TIMING > $R1SLAVELOG 2>&1 &
R1SLAVEPID=$!
if test $WAIT != 0 ; then
echo SLAVE R1 PID $R1SLAVEPID
read foo
fi
BACKEND=$SAVE
2003-06-26 14:12:55 +08:00
echo "Using ldapsearch to check that R1 slave slapd is running..."
for i in 0 1 2 3 4 5; do
$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $R1SLAVEPORT \
'objectclass=*' > /dev/null 2>&1
RC=$?
if test $RC = 0 ; then
break
fi
echo "Waiting 5 seconds for R1 slapd to start..."
sleep 5
done
echo "Waiting for the R1 slave to replicate..."
sleep 10
echo "Starting R2 slave slapd on TCP/IP port $R2SLAVEPORT..."
. $CONFFILTER $BACKEND $MONITORDB < $R2SRSLAVECONF > $R2REPLCONF
$SLAPD -f $R2REPLCONF -h $R2SLAVEURI -d $LVL $TIMING > $R2SLAVELOG 2>&1 &
R2SLAVEPID=$!
if test $WAIT != 0 ; then
echo SLAVE R2 PID $R2SLAVEPID
read foo
fi
echo "Using ldapsearch to check that the R2 slave slapd is running..."
for i in 0 1 2 3 4 5; do
$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $R2SLAVEPORT \
'objectclass=*' > /dev/null 2>&1
RC=$?
if test $RC = 0 ; then
break
fi
echo "Waiting 5 seconds for R2 slave slapd to start..."
sleep 5
done
echo "Waiting for the R2 slave to replicate..."
sleep 10
SAVE=$BACKEND
if test $BACKEND = ldbm; then
if test $SYNCREPL = no; then
echo "Sync replication requires back-bdb or back-hdb"
exit 0
fi
BACKEND=$SYNCREPL
fi
2003-06-26 14:12:55 +08:00
echo "Starting P1 slave slapd on TCP/IP port $P1SLAVEPORT..."
. $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $P1REPLCONF
$SLAPD -f $P1REPLCONF -h $P1SLAVEURI -d $LVL $TIMING > $P1SLAVELOG 2>&1 &
P1SLAVEPID=$!
if test $WAIT != 0 ; then
echo SLAVE P1 PID $P1SLAVEPID
read foo
fi
BACKEND=$SAVE
2003-06-26 14:12:55 +08:00
echo "Using ldapsearch to check that the P1 slave slapd is running..."
for i in 0 1 2 3 4 5; do
$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $P1SLAVEPORT \
'objectclass=*' > /dev/null 2>&1
RC=$?
if test $RC = 0 ; then
break
fi
echo "Waiting 5 seconds for P1 slave slapd to start..."
sleep 5
done
echo "Waiting for the P1 slave to replicate..."
sleep 10
echo "Starting P2 slave slapd on TCP/IP port $P2SLAVEPORT..."
. $CONFFILTER $BACKEND $MONITORDB < $P2SRSLAVECONF > $P2REPLCONF
$SLAPD -f $P2REPLCONF -h $P2SLAVEURI -d $LVL $TIMING > $P2SLAVELOG 2>&1 &
P2SLAVEPID=$!
if test $WAIT != 0 ; then
echo SLAVE P2 PID $P2SLAVEPID
read foo
fi
echo "Using ldapsearch to check that the P2 slave slapd is running..."
for i in 0 1 2 3 4 5; do
$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $P2SLAVEPORT \
'objectclass=*' > /dev/null 2>&1
RC=$?
if test $RC = 0 ; then
break
fi
echo "Waiting 5 seconds for P2 slave slapd to start..."
sleep 5
done
echo "Starting P3 slave slapd on TCP/IP port $P3SLAVEPORT..."
. $CONFFILTER $BACKEND $MONITORDB < $P3SRSLAVECONF > $P3REPLCONF
$SLAPD -f $P3REPLCONF -h $P3SLAVEURI -d $LVL $TIMING > $P3SLAVELOG 2>&1 &
P3SLAVEPID=$!
if test $WAIT != 0 ; then
echo SLAVE P3 PID $P3SLAVEPID
read foo
fi
echo "Using ldapsearch to check that the P3 slave slapd is running..."
for i in 0 1 2 3 4 5; do
$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $P3SLAVEPORT \
'objectclass=*' > /dev/null 2>&1
RC=$?
if test $RC = 0 ; then
break
fi
echo "Waiting 5 seconds for P3 slave slapd to start..."
sleep 5
done
echo "Using ldapadd to populate the master directory..."
$LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
$LDIFORDEREDNOCP > /dev/null 2>&1
RC=$?
if test $RC != 0 ; then
echo "ldapadd failed ($RC)!"
kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
exit $RC
fi
echo "Waiting 90 seconds for syncrepl to receive changes..."
sleep 90
2003-06-26 14:12:55 +08:00
echo "Using ldapmodify to modify master directory..."
#
# Do some modifications
#
$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD > \
$TESTOUT 2>&1 << EOMODS
dn: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
changetype: modify
add: drink
drink: Orange Juice
-
delete: sn
sn: Jones
-
add: sn
sn: Jones
dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
changetype: modify
replace: drink
drink: Iced Tea
drink: Mad Dog 20/20
dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
changetype: modify
delete: member
member: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
member: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
-
add: member
member: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
member: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
changetype: modify
delete: description
dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
changetype: add
objectclass: OpenLDAPperson
cn: Gern Jensen
sn: Jensen
uid: gjensen
title: Chief Investigator, ITD
postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
seealso: cn=All Staff, ou=Groups, o=University of Michigan, c=US
drink: Coffee
homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
description: Very odd
facsimiletelephonenumber: +1 313 555 7557
telephonenumber: +1 313 555 8343
mail: gjensen@mailgw.example.com
homephone: +1 313 555 8844
dn: ou=Retired, ou=People, o=University of Michigan, c=US
changetype: add
objectclass: organizationalUnit
ou: Retired
dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
changetype: add
objectclass: OpenLDAPperson
cn: Rosco P. Coltrane
sn: Coltrane
uid: rosco
dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
changetype: modrdn
newrdn: cn=Rosco P. Coltrane
deleteoldrdn: 1
newsuperior: ou=Retired, ou=People, o=University of Michigan, c=US
dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
changetype: delete
EOMODS
echo "Waiting 90 seconds for syncrepl to receive changes..."
sleep 90
2003-06-26 14:12:55 +08:00
echo "Using ldapsearch to read all the entries from the master..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
'objectclass=*' > $MASTEROUT 2>&1
RC=$?
if test $RC != 0 ; then
echo "ldapsearch failed at master ($RC)!"
kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
exit $RC
fi
echo "Using ldapsearch to read all the entries from the R1 slave..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $R1SLAVEPORT \
'objectclass=*' > $R1SLAVEOUT 2>&1
RC=$?
if test $RC != 0 ; then
echo "ldapsearch failed at R1 slave ($RC)!"
kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
exit $RC
fi
echo "Using ldapsearch to read all the entries from the R2 slave..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $R2SLAVEPORT \
'objectclass=*' > $R2SLAVEOUT 2>&1
RC=$?
if test $RC != 0 ; then
echo "ldapsearch failed at R2 slave ($RC)!"
kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
exit $RC
fi
echo "Using ldapsearch to read all the entries from the P1 slave..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $P1SLAVEPORT \
'objectclass=*' > $P1SLAVEOUT 2>&1
RC=$?
if test $RC != 0 ; then
echo "ldapsearch failed at R1 slave ($RC)!"
kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
exit $RC
fi
echo "Using ldapsearch to read all the entries from the P2 slave..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $P2SLAVEPORT \
'objectclass=*' > $P2SLAVEOUT 2>&1
RC=$?
if test $RC != 0 ; then
echo "ldapsearch failed at R2 slave ($RC)!"
kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
exit $RC
fi
echo "Using ldapsearch to read all the entries from the P3 slave..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $P3SLAVEPORT \
'objectclass=*' > $P3SLAVEOUT 2>&1
RC=$?
if test $RC != 0 ; then
echo "ldapsearch failed at R2 slave ($RC)!"
kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
exit $RC
fi
kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
SEARCHOUT=$MASTEROUT
R1LDIF=$R1SLAVEOUT
R2LDIF=$R2SLAVEOUT
P1LDIF=$P1SLAVEOUT
P2LDIF=$P2SLAVEOUT
P3LDIF=$P3SLAVEOUT
echo "Filtering master ldapsearch results..."
. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
echo "Filtering R1 slave ldapsearch results..."
. $LDIFFILTER < $R1LDIF > $R1LDIFFLT
echo "Filtering R2 slave ldapsearch results..."
. $LDIFFILTER < $R2LDIF > $R2LDIFFLT
echo "Filtering P1 slave ldapsearch results..."
. $LDIFFILTER < $P1LDIF > $P1LDIFFLT
echo "Filtering P2 slave ldapsearch results..."
. $LDIFFILTER < $P2LDIF > $P2LDIFFLT
echo "Filtering P3 slave ldapsearch results..."
. $LDIFFILTER < $P3LDIF > $P3LDIFFLT
echo "Comparing retrieved entries from master and R1 slave..."
$CMP $SEARCHFLT $R1LDIFFLT > $CMPOUT
if test $? != 0 ; then
echo "test failed - master and R1 slave databases differ"
exit 1
fi
echo "Comparing retrieved entries from master and R2 slave..."
$CMP $SEARCHFLT $R2LDIFFLT > $CMPOUT
if test $? != 0 ; then
echo "test failed - master and R2 slave databases differ"
exit 1
fi
echo "Comparing retrieved entries from master and P1 slave..."
$CMP $SEARCHFLT $P1LDIFFLT > $CMPOUT
if test $? != 0 ; then
echo "test failed - master and P1 slave databases differ"
exit 1
fi
echo "Comparing retrieved entries from master and P2 slave..."
$CMP $SEARCHFLT $P2LDIFFLT > $CMPOUT
if test $? != 0 ; then
echo "test failed - master and P2 slave databases differ"
exit 1
fi
echo "Comparing retrieved entries from master and P3 slave..."
2003-07-11 08:54:05 +08:00
$CMP $SEARCHFLT $P3LDIFFLT > $CMPOUT
2003-06-26 14:12:55 +08:00
if test $? != 0 ; then
echo "test failed - master and P3 slave databases differ"
exit 1
fi
echo ">>>>> Test succeeded"
exit 0