2005-12-15 19:35:46 +08:00
|
|
|
#! /bin/sh
|
|
|
|
# $OpenLDAP$
|
|
|
|
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
##
|
2006-01-04 07:11:52 +08:00
|
|
|
## Copyright 1998-2006 The OpenLDAP Foundation.
|
2005-12-15 19:35:46 +08:00
|
|
|
## All rights reserved.
|
|
|
|
##
|
|
|
|
## Redistribution and use in source and binary forms, with or without
|
|
|
|
## modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
## Public License.
|
|
|
|
##
|
|
|
|
## A copy of this license is available in the file LICENSE in the
|
|
|
|
## top-level directory of the distribution or, alternatively, at
|
|
|
|
## <http://www.OpenLDAP.org/license.html>.
|
|
|
|
|
|
|
|
if test "$BACKEND" != "bdb" && test "$BACKEND" != "hdb" ; then
|
|
|
|
echo "Test does not support $BACKEND"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2005-12-27 01:04:04 +08:00
|
|
|
# test now handles known issues
|
|
|
|
#if test x"$PROXYSYNC" = x ; then
|
|
|
|
# echo "Test disabled; set PROXYSYNC=yes to enable"
|
|
|
|
# exit 0
|
|
|
|
#fi
|
2005-12-15 19:35:46 +08:00
|
|
|
|
|
|
|
echo "running defines.sh"
|
|
|
|
. $SRCDIR/scripts/defines.sh
|
|
|
|
|
|
|
|
if test $BACKLDAP = ldapno; then
|
|
|
|
echo "LDAP backend not available, test skipped"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test $SYNCPROV = syncprovno; then
|
|
|
|
echo "Syncrepl provider overlay not available, test skipped"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2005-12-16 01:34:43 +08:00
|
|
|
if test $MONITORDB = no; then
|
|
|
|
echo "Monitor backend not available, test skipped"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2005-12-15 19:35:46 +08:00
|
|
|
mkdir -p $TESTDIR $DBDIR1 $DBDIR2
|
|
|
|
|
|
|
|
#
|
|
|
|
# Test replication:
|
|
|
|
# - start master
|
|
|
|
# - start slave
|
|
|
|
# - populate over ldap
|
|
|
|
# - perform some modifies and deleted
|
|
|
|
# - attempt to modify the slave (referral or chain)
|
|
|
|
# - retrieve database over ldap and compare against expected results
|
|
|
|
#
|
|
|
|
|
|
|
|
echo "Starting master slapd on TCP/IP port $PORT1..."
|
|
|
|
. $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
|
|
|
|
$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
|
|
|
|
MASTERPID=$!
|
|
|
|
if test $WAIT != 0 ; then
|
|
|
|
echo MASTERPID $MASTERPID
|
|
|
|
read foo
|
|
|
|
fi
|
|
|
|
KILLPIDS="$MASTERPID"
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
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 $PORT1 \
|
2005-12-16 01:34:43 +08:00
|
|
|
'(objectClass=*)' > /dev/null 2>&1
|
2005-12-15 19:35:46 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC = 0 ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
echo "Waiting 5 seconds for slapd to start..."
|
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Using ldapadd to create the context prefix entry in the master..."
|
|
|
|
$LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
|
|
|
|
$LDIFORDEREDCP > /dev/null 2>&1
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapadd failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Starting slave slapd on TCP/IP port $PORT2..."
|
2005-12-16 01:34:43 +08:00
|
|
|
. $CONFFILTER $BACKEND $MONITORDB < $RSLAVECONF > $CONF2
|
2005-12-15 19:35:46 +08:00
|
|
|
$SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
|
|
|
|
SLAVEPID=$!
|
|
|
|
if test $WAIT != 0 ; then
|
|
|
|
echo SLAVEPID $SLAVEPID
|
|
|
|
read foo
|
|
|
|
fi
|
|
|
|
KILLPIDS="$MASTERPID $SLAVEPID"
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
echo "Using ldapsearch to check that slave slapd is running..."
|
|
|
|
for i in 0 1 2 3 4 5; do
|
|
|
|
$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
|
2005-12-16 01:34:43 +08:00
|
|
|
'(objectClass=*)' > /dev/null 2>&1
|
2005-12-15 19:35:46 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC = 0 ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
echo "Waiting 5 seconds for slapd to start..."
|
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Starting proxy slapd on TCP/IP port $PORT3..."
|
|
|
|
. $CONFFILTER $BACKEND $MONITORDB < $PLSRSLAVECONF > $CONF3
|
|
|
|
$SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
|
|
|
|
PROXYPID=$!
|
|
|
|
if test $WAIT != 0 ; then
|
|
|
|
echo PROXYPID $PROXYPID
|
|
|
|
read foo
|
|
|
|
fi
|
|
|
|
KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
echo "Using ldapsearch to check that proxy slapd is running..."
|
|
|
|
for i in 0 1 2 3 4 5; do
|
|
|
|
$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
|
2005-12-16 01:34:43 +08:00
|
|
|
'(objectClass=*)' > /dev/null 2>&1
|
2005-12-15 19:35:46 +08:00
|
|
|
RC=$?
|
2005-12-16 02:07:15 +08:00
|
|
|
if test $RC = 0 -o $RC = 53 ; then
|
2005-12-15 19:35:46 +08:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
echo "Waiting 5 seconds for slapd to start..."
|
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
|
2005-12-16 02:07:15 +08:00
|
|
|
case $RC in
|
|
|
|
0 )
|
|
|
|
echo "ldapsearch should have failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit -1
|
|
|
|
;;
|
|
|
|
53)
|
|
|
|
;;
|
|
|
|
*)
|
2005-12-15 19:35:46 +08:00
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
2005-12-16 02:07:15 +08:00
|
|
|
;;
|
|
|
|
esac
|
2005-12-15 19:35:46 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
CHECK=1
|
|
|
|
echo "$CHECK > Using ldapadd to populate the master directory..."
|
2005-12-15 19:35:46 +08:00
|
|
|
$LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
|
|
|
|
$LDIFORDEREDNOCP > /dev/null 2>&1
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapadd failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
2005-12-16 03:13:05 +08:00
|
|
|
SLEEP=15
|
|
|
|
echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
|
|
|
|
sleep $SLEEP
|
2005-12-15 19:35:46 +08:00
|
|
|
|
2005-12-15 21:46:54 +08:00
|
|
|
#echo "Using ldapsearch to read all the entries from the master..."
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
|
2005-12-16 05:43:46 +08:00
|
|
|
'(objectClass=*)' > "${MASTEROUT}.1" 2>&1
|
2005-12-15 21:46:54 +08:00
|
|
|
RC=$?
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed at master ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
#echo "Using ldapsearch to read all the entries from the slave..."
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2005-12-16 05:43:46 +08:00
|
|
|
'(objectClass=*)' > "${SLAVEOUT}.1" 2>&1
|
2005-12-15 21:46:54 +08:00
|
|
|
RC=$?
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed at slave ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
#echo "Filtering master results..."
|
2005-12-16 05:43:46 +08:00
|
|
|
. $LDIFFILTER < "${MASTEROUT}.1" > $MASTERFLT
|
2005-12-15 21:46:54 +08:00
|
|
|
#echo "Filtering slave results..."
|
2005-12-16 05:43:46 +08:00
|
|
|
. $LDIFFILTER < "${SLAVEOUT}.1" > $SLAVEFLT
|
2005-12-15 21:46:54 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
echo "$CHECK < Comparing retrieved entries from master and slave..."
|
2005-12-15 21:46:54 +08:00
|
|
|
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT
|
|
|
|
|
|
|
|
if test $? != 0 ; then
|
|
|
|
echo "test failed - master and slave databases differ"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
CHECK=`expr $CHECK + 1`
|
2005-12-16 03:13:05 +08:00
|
|
|
SLEEP=10
|
2006-04-15 19:22:38 +08:00
|
|
|
echo "$CHECK > Stopping the provider, sleeping $SLEEP seconds and restarting it..."
|
2005-12-15 19:35:46 +08:00
|
|
|
kill -HUP "$MASTERPID"
|
2006-01-11 13:45:05 +08:00
|
|
|
wait $MASTERPID
|
2005-12-16 03:13:05 +08:00
|
|
|
sleep $SLEEP
|
|
|
|
|
|
|
|
echo "======================= RESTART =======================" >> $LOG1
|
2005-12-15 19:35:46 +08:00
|
|
|
$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
|
|
|
|
MASTERPID=$!
|
|
|
|
if test $WAIT != 0 ; then
|
|
|
|
echo MASTERPID $MASTERPID
|
|
|
|
read foo
|
|
|
|
fi
|
|
|
|
KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
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 $PORT1 \
|
2005-12-16 01:34:43 +08:00
|
|
|
'(objectClass=*)' > /dev/null 2>&1
|
2005-12-15 19:35:46 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC = 0 ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
echo "Waiting 5 seconds for slapd to start..."
|
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Using ldapmodify to modify master directory..."
|
|
|
|
|
|
|
|
#
|
|
|
|
# Do some modifications
|
|
|
|
#
|
|
|
|
|
|
|
|
$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
|
|
|
|
$TESTOUT 2>&1 << EOMODS
|
|
|
|
dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
|
|
|
|
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, dc=example,dc=com
|
|
|
|
changetype: modify
|
|
|
|
replace: drink
|
|
|
|
drink: Iced Tea
|
|
|
|
|
|
|
|
dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
|
|
|
|
changetype: modify
|
|
|
|
delete: uniquemember
|
|
|
|
uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
|
|
|
|
uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
|
|
|
|
-
|
|
|
|
add: uniquemember
|
|
|
|
uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
|
|
|
|
uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
|
|
|
|
|
2005-12-16 00:32:26 +08:00
|
|
|
dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc
|
|
|
|
=com
|
2005-12-15 19:35:46 +08:00
|
|
|
changetype: modify
|
2005-12-16 00:32:26 +08:00
|
|
|
delete: cn
|
|
|
|
cn: Biiff Jensen
|
2005-12-15 19:35:46 +08:00
|
|
|
|
|
|
|
dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
|
|
|
|
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, dc=example,dc=com
|
|
|
|
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, dc=example,dc=com
|
|
|
|
changetype: add
|
|
|
|
objectclass: organizationalUnit
|
|
|
|
ou: Retired
|
|
|
|
|
|
|
|
dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
|
|
|
|
changetype: add
|
|
|
|
objectclass: OpenLDAPperson
|
|
|
|
cn: Rosco P. Coltrane
|
|
|
|
sn: Coltrane
|
|
|
|
uid: rosco
|
|
|
|
description: Fat tycoon
|
|
|
|
|
|
|
|
dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
|
|
|
|
changetype: modrdn
|
|
|
|
newrdn: cn=Rosco P. Coltrane
|
|
|
|
deleteoldrdn: 1
|
|
|
|
newsuperior: ou=Retired, ou=People, dc=example,dc=com
|
|
|
|
|
|
|
|
dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
|
|
|
|
changetype: delete
|
|
|
|
EOMODS
|
|
|
|
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapmodify failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
2005-12-16 03:13:05 +08:00
|
|
|
SLEEP=15
|
|
|
|
echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
|
|
|
|
sleep $SLEEP
|
2005-12-15 19:35:46 +08:00
|
|
|
|
2005-12-15 21:46:54 +08:00
|
|
|
#echo "Using ldapsearch to read all the entries from the master..."
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
|
2005-12-16 05:43:46 +08:00
|
|
|
'(objectClass=*)' > "${MASTEROUT}.2" 2>&1
|
2005-12-15 21:46:54 +08:00
|
|
|
RC=$?
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed at master ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
#echo "Using ldapsearch to read all the entries from the slave..."
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2005-12-16 05:43:46 +08:00
|
|
|
'(objectClass=*)' > "${SLAVEOUT}.2" 2>&1
|
2005-12-15 21:46:54 +08:00
|
|
|
RC=$?
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed at slave ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
#echo "Filtering master results..."
|
2005-12-16 05:43:46 +08:00
|
|
|
. $LDIFFILTER < "${MASTEROUT}.2" > $MASTERFLT
|
2005-12-15 21:46:54 +08:00
|
|
|
#echo "Filtering slave results..."
|
2005-12-16 05:43:46 +08:00
|
|
|
. $LDIFFILTER < "${SLAVEOUT}.2" > $SLAVEFLT
|
2005-12-15 21:46:54 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
echo "$CHECK < Comparing retrieved entries from master and slave..."
|
2005-12-15 21:46:54 +08:00
|
|
|
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT
|
|
|
|
|
|
|
|
if test $? != 0 ; then
|
|
|
|
echo "test failed - master and slave databases differ"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
CHECK=`expr $CHECK + 1`
|
|
|
|
echo "$CHECK > Stopping proxy to test recovery..."
|
2005-12-15 19:35:46 +08:00
|
|
|
kill -HUP $PROXYPID
|
2006-01-11 13:45:05 +08:00
|
|
|
wait $PROXYPID
|
2005-12-15 19:35:46 +08:00
|
|
|
|
|
|
|
echo "Modifying more entries on the master..."
|
|
|
|
$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
|
|
|
|
$TESTOUT 2>&1 << EOMODS
|
|
|
|
dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
|
|
|
|
changetype: modify
|
|
|
|
add: description
|
|
|
|
description: proxy is down...
|
|
|
|
|
|
|
|
dn: cn=James T. Kirk, ou=Retired, ou=People, dc=example,dc=com
|
|
|
|
changetype: add
|
|
|
|
objectclass: OpenLDAPperson
|
|
|
|
sn: Kirk
|
2005-12-16 01:34:43 +08:00
|
|
|
uid: jtk
|
2005-12-15 19:35:46 +08:00
|
|
|
cn: James T. Kirk
|
|
|
|
|
2005-12-16 01:34:43 +08:00
|
|
|
dn: cn=Tiberius J. Hooker, ou=Retired, ou=People, dc=example,dc=com
|
|
|
|
changetype: add
|
|
|
|
objectclass: OpenLDAPperson
|
|
|
|
sn: Hooker
|
|
|
|
uid: tjh
|
|
|
|
cn: Tiberius J. Hooker
|
|
|
|
|
2005-12-15 19:35:46 +08:00
|
|
|
EOMODS
|
|
|
|
|
|
|
|
echo "Restarting proxy..."
|
2005-12-16 03:13:05 +08:00
|
|
|
echo "======================= RESTART =======================" >> $LOG3
|
2005-12-15 19:35:46 +08:00
|
|
|
$SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
|
|
|
|
PROXYPID=$!
|
|
|
|
if test $WAIT != 0 ; then
|
|
|
|
echo PROXYPID $PROXYPID
|
|
|
|
read foo
|
|
|
|
fi
|
|
|
|
KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
|
|
|
|
|
2005-12-16 03:13:05 +08:00
|
|
|
SLEEP=25
|
|
|
|
echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
|
|
|
|
sleep $SLEEP
|
2005-12-15 19:35:46 +08:00
|
|
|
|
2005-12-15 21:46:54 +08:00
|
|
|
#echo "Using ldapsearch to read all the entries from the master..."
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
|
2005-12-16 05:43:46 +08:00
|
|
|
'(objectClass=*)' > "${MASTEROUT}.3" 2>&1
|
2005-12-15 21:46:54 +08:00
|
|
|
RC=$?
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed at master ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
#echo "Using ldapsearch to read all the entries from the slave..."
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2005-12-16 05:43:46 +08:00
|
|
|
'(objectClass=*)' > "${SLAVEOUT}.3" 2>&1
|
2005-12-15 21:46:54 +08:00
|
|
|
RC=$?
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed at slave ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
#echo "Filtering master results..."
|
2005-12-16 05:43:46 +08:00
|
|
|
. $LDIFFILTER < "${MASTEROUT}.3" > $MASTERFLT
|
2005-12-15 21:46:54 +08:00
|
|
|
#echo "Filtering slave results..."
|
2005-12-16 05:43:46 +08:00
|
|
|
. $LDIFFILTER < "${SLAVEOUT}.3" > $SLAVEFLT
|
2005-12-15 21:46:54 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
echo "$CHECK < Comparing retrieved entries from master and slave..."
|
2005-12-15 21:46:54 +08:00
|
|
|
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT
|
|
|
|
|
|
|
|
if test $? != 0 ; then
|
|
|
|
echo "test failed - master and slave databases differ"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
CHECK=`expr $CHECK + 1`
|
|
|
|
echo "$CHECK > Try updating the slave slapd..."
|
|
|
|
$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
|
|
|
|
$TESTOUT 2>&1 << EOMODS
|
2005-12-15 19:35:46 +08:00
|
|
|
dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
|
|
|
|
changetype: modify
|
|
|
|
add: description
|
|
|
|
description: This write must fail because directed to a shadow context,
|
|
|
|
description: unless the chain overlay is configured appropriately ;)
|
|
|
|
|
|
|
|
EOMODS
|
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapmodify failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
2005-12-15 19:35:46 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
SLEEP=15
|
|
|
|
echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
|
|
|
|
sleep $SLEEP
|
2005-12-15 19:35:46 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
#echo "Using ldapsearch to read all the entries from the master..."
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
|
|
|
|
'(objectClass=*)' > "${MASTEROUT}.4" 2>&1
|
|
|
|
RC=$?
|
2005-12-15 19:35:46 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed at master ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
2005-12-15 19:35:46 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
#echo "Using ldapsearch to read all the entries from the slave..."
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
|
|
|
'(objectClass=*)' > "${SLAVEOUT}.4" 2>&1
|
|
|
|
RC=$?
|
2005-12-15 19:35:46 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed at slave ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
2005-12-15 19:35:46 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
#echo "Filtering master results..."
|
|
|
|
. $LDIFFILTER < "${MASTEROUT}.4" > $MASTERFLT
|
|
|
|
#echo "Filtering slave results..."
|
|
|
|
. $LDIFFILTER < "${SLAVEOUT}.4" > $SLAVEFLT
|
2005-12-15 19:35:46 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
echo "$CHECK < Comparing retrieved entries from master and slave..."
|
|
|
|
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT
|
2005-12-15 19:35:46 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
if test $? != 0 ; then
|
|
|
|
echo "test failed - master and slave databases differ"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit 1
|
2005-12-15 19:35:46 +08:00
|
|
|
fi
|
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
CHECK=`expr $CHECK + 1`
|
|
|
|
echo "$CHECK > Stopping consumer to test recovery..."
|
2005-12-16 00:32:26 +08:00
|
|
|
kill -HUP $SLAVEPID
|
2006-01-11 13:45:05 +08:00
|
|
|
wait $SLAVEPID
|
2005-12-16 00:32:26 +08:00
|
|
|
|
|
|
|
echo "Modifying more entries on the master..."
|
|
|
|
$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
|
|
|
|
$TESTOUT 2>&1 << EOMODS
|
|
|
|
dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
|
|
|
|
changetype: modify
|
|
|
|
add: drink
|
|
|
|
drink: Mad Dog 20/20
|
|
|
|
|
|
|
|
EOMODS
|
|
|
|
|
2006-01-11 15:38:21 +08:00
|
|
|
SLEEP=10
|
|
|
|
echo "Waiting $SLEEP seconds for syncrepl to retry..."
|
|
|
|
sleep $SLEEP
|
|
|
|
|
2005-12-16 00:32:26 +08:00
|
|
|
echo "Restarting consumer..."
|
2005-12-16 03:13:05 +08:00
|
|
|
echo "======================= RESTART =======================" >> $LOG2
|
2005-12-16 00:32:26 +08:00
|
|
|
$SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
|
|
|
|
SLAVEPID=$!
|
|
|
|
if test $WAIT != 0 ; then
|
|
|
|
echo SLAVEPID $SLAVEPID
|
|
|
|
read foo
|
|
|
|
fi
|
|
|
|
KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
|
|
|
|
|
2005-12-16 03:13:05 +08:00
|
|
|
SLEEP=25
|
|
|
|
echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
|
|
|
|
sleep $SLEEP
|
2005-12-16 00:32:26 +08:00
|
|
|
|
|
|
|
#echo "Using ldapsearch to read all the entries from the master..."
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
|
2005-12-16 05:43:46 +08:00
|
|
|
'(objectClass=*)' > "${MASTEROUT}.5" 2>&1
|
2005-12-16 00:32:26 +08:00
|
|
|
RC=$?
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed at master ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
#echo "Using ldapsearch to read all the entries from the slave..."
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2005-12-16 05:43:46 +08:00
|
|
|
'(objectClass=*)' > "${SLAVEOUT}.5" 2>&1
|
2005-12-16 00:32:26 +08:00
|
|
|
RC=$?
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed at slave ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
#echo "Filtering master results..."
|
2005-12-16 05:43:46 +08:00
|
|
|
. $LDIFFILTER < "${MASTEROUT}.5" > $MASTERFLT
|
2005-12-16 00:32:26 +08:00
|
|
|
#echo "Filtering slave results..."
|
2005-12-16 05:43:46 +08:00
|
|
|
. $LDIFFILTER < "${SLAVEOUT}.5" > $SLAVEFLT
|
2005-12-16 00:32:26 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
echo "$CHECK < Comparing retrieved entries from master and slave..."
|
2005-12-16 00:32:26 +08:00
|
|
|
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT
|
|
|
|
|
|
|
|
if test $? != 0 ; then
|
2006-04-15 19:22:38 +08:00
|
|
|
# FIXME: keep the original workaround in place, in case we needed again
|
|
|
|
if test 1 = 1 ; then
|
|
|
|
echo "test failed - master and slave databases differ"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit 1
|
|
|
|
fi
|
2005-12-17 00:21:41 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
echo " test failed - master and slave databases differ (ignored by now)"
|
2006-01-11 13:45:05 +08:00
|
|
|
echo " Stopping proxy to see if it auto-recovers..."
|
2005-12-17 00:21:41 +08:00
|
|
|
kill -HUP $PROXYPID
|
2006-01-11 13:45:05 +08:00
|
|
|
wait $PROXYPID
|
2005-12-17 00:21:41 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
echo " ${CHECK}.1 > Restarting proxy..."
|
2005-12-17 00:21:41 +08:00
|
|
|
echo "======================= RESTART =======================" >> $LOG3
|
|
|
|
$SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING >> $LOG3 2>&1 &
|
|
|
|
PROXYPID=$!
|
|
|
|
if test $WAIT != 0 ; then
|
|
|
|
echo PROXYPID $PROXYPID
|
|
|
|
read foo
|
|
|
|
fi
|
|
|
|
KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
|
|
|
|
|
|
|
|
SLEEP=15
|
|
|
|
echo " Waiting $SLEEP seconds for syncrepl to receive changes..."
|
|
|
|
sleep $SLEEP
|
|
|
|
|
|
|
|
#echo "Using ldapsearch to read all the entries from the slave..."
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
|
|
|
'(objectClass=*)' > "${SLAVEOUT}.5.1" 2>&1
|
|
|
|
RC=$?
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo " ldapsearch failed at slave ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
#echo "Filtering slave results..."
|
|
|
|
. $LDIFFILTER < "${SLAVEOUT}.5.1" > $SLAVEFLT
|
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
echo " ${CHECK}.1 < Comparing retrieved entries from master and slave..."
|
2005-12-17 00:21:41 +08:00
|
|
|
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT
|
|
|
|
|
|
|
|
if test $? != 0 ; then
|
|
|
|
echo " test failed - master and slave databases differ"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit 1
|
|
|
|
fi
|
2005-12-16 00:32:26 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
2006-04-15 19:22:38 +08:00
|
|
|
# Modifications formerly known to fail
|
2005-12-16 00:32:26 +08:00
|
|
|
#
|
2006-04-15 19:22:38 +08:00
|
|
|
CHECK=`expr $CHECK + 1`
|
|
|
|
echo "$CHECK > Performing modifications that were formerly known to fail..."
|
2005-12-16 00:32:26 +08:00
|
|
|
$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
|
|
|
|
$TESTOUT 2>&1 << EOMODS
|
|
|
|
# First, back out previous change
|
|
|
|
dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
|
|
|
|
changetype: modify
|
|
|
|
delete: drink
|
|
|
|
drink: Mad Dog 20/20
|
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
# From now on, perform modifications that were formerly known to fail
|
2005-12-16 00:32:26 +08:00
|
|
|
dn: cn=All Staff,ou=Groups,dc=example,dc=com
|
|
|
|
changetype: modify
|
|
|
|
delete: description
|
|
|
|
|
|
|
|
EOMODS
|
|
|
|
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapmodify failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
2005-12-16 03:13:05 +08:00
|
|
|
SLEEP=15
|
|
|
|
echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
|
|
|
|
sleep $SLEEP
|
2005-12-16 00:32:26 +08:00
|
|
|
|
|
|
|
#echo "Using ldapsearch to read all the entries from the master..."
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
|
2005-12-16 05:43:46 +08:00
|
|
|
'(objectClass=*)' > "${MASTEROUT}.6" 2>&1
|
2005-12-16 00:32:26 +08:00
|
|
|
RC=$?
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed at master ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
#echo "Using ldapsearch to read all the entries from the slave..."
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2005-12-16 05:43:46 +08:00
|
|
|
'(objectClass=*)' > "${SLAVEOUT}.6" 2>&1
|
2005-12-16 00:32:26 +08:00
|
|
|
RC=$?
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed at slave ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
#echo "Filtering master results..."
|
2005-12-16 05:43:46 +08:00
|
|
|
. $LDIFFILTER < "${MASTEROUT}.6" > $MASTERFLT
|
2005-12-16 00:32:26 +08:00
|
|
|
#echo "Filtering slave results..."
|
2005-12-16 05:43:46 +08:00
|
|
|
. $LDIFFILTER < "${SLAVEOUT}.6" > $SLAVEFLT
|
2005-12-16 00:32:26 +08:00
|
|
|
|
2006-04-15 19:22:38 +08:00
|
|
|
echo "$CHECK < Comparing retrieved entries from master and slave..."
|
2005-12-16 00:32:26 +08:00
|
|
|
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT
|
|
|
|
|
|
|
|
if test $? != 0 ; then
|
|
|
|
echo "test failed - master and slave databases differ (ignored by now)"
|
|
|
|
#echo "test failed - master and slave databases differ"
|
|
|
|
#test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
#exit 1
|
|
|
|
fi
|
|
|
|
|
2005-12-15 21:46:54 +08:00
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
|
2005-12-15 19:35:46 +08:00
|
|
|
echo ">>>>> Test succeeded"
|
2006-01-11 13:25:09 +08:00
|
|
|
|
|
|
|
test $KILLSERVERS != no && wait
|
|
|
|
|
2005-12-15 19:35:46 +08:00
|
|
|
exit 0
|