# $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
##
-## Copyright 1998-2006 The OpenLDAP Foundation.
+## Copyright 1998-2007 The OpenLDAP Foundation.
## All rights reserved.
##
## Redistribution and use in source and binary forms, with or without
$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
'(objectClass=*)' > /dev/null 2>&1
RC=$?
- if test $RC = 0 -o $RC = 53 ; then
+ if test $RC = 0 || test $RC = 53 ; then
break
fi
echo "Waiting 5 seconds for slapd to start..."
exit $RC
fi
-SLEEP=15
-echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
-sleep $SLEEP
+# get master contextCSN
+$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
+ '(objectClass=*)' -s base contextCSN > "${MASTEROUT}.$CHECK" 2>&1
+RC=$?
+if test $RC != 0 ; then
+ echo "ldapsearch failed at master ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+fi
+
+# check slave contextCSN
+sleep 1
+for i in 1 2 3; do
+ $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
+ '(objectClass=*)' -s base contextCSN > "${SLAVEOUT}.$CHECK" 2>&1
+ RC=$?
+
+ if test $RC != 0 ; then
+ echo "ldapsearch failed at slave ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+ fi
+
+ $CMP ${MASTEROUT}.$CHECK ${SLAVEOUT}.$CHECK > $CMPOUT
+
+ if test $? = 0 ; then
+ break
+ fi
+
+ SLEEP=5
+ echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
+ sleep $SLEEP
+done
#echo "Using ldapsearch to read all the entries from the master..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
- '(objectClass=*)' > "${MASTEROUT}.1" 2>&1
+ '(objectClass=*)' > "${MASTEROUT}.$CHECK" 2>&1
RC=$?
if test $RC != 0 ; then
#echo "Using ldapsearch to read all the entries from the slave..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
- '(objectClass=*)' > "${SLAVEOUT}.1" 2>&1
+ '(objectClass=*)' > "${SLAVEOUT}.$CHECK" 2>&1
RC=$?
if test $RC != 0 ; then
fi
#echo "Filtering master results..."
-. $LDIFFILTER < "${MASTEROUT}.1" > $MASTERFLT
+. $LDIFFILTER < "${MASTEROUT}.$CHECK" > $MASTERFLT
#echo "Filtering slave results..."
-. $LDIFFILTER < "${SLAVEOUT}.1" > $SLAVEFLT
+. $LDIFFILTER < "${SLAVEOUT}.$CHECK" > $SLAVEFLT
echo "$CHECK < Comparing retrieved entries from master and slave..."
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT
exit $RC
fi
-SLEEP=15
-echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
-sleep $SLEEP
+# get master contextCSN
+$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
+ '(objectClass=*)' -s base contextCSN > "${MASTEROUT}.$CHECK" 2>&1
+RC=$?
+if test $RC != 0 ; then
+ echo "ldapsearch failed at master ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+fi
+
+# check slave contextCSN
+for i in 1 2 3; do
+ SLEEP=5
+ echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
+ sleep $SLEEP
+
+ $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
+ '(objectClass=*)' -s base contextCSN > "${SLAVEOUT}.$CHECK" 2>&1
+ RC=$?
+
+ if test $RC != 0 ; then
+ echo "ldapsearch failed at slave ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+ fi
+
+ $CMP ${MASTEROUT}.$CHECK ${SLAVEOUT}.$CHECK > $CMPOUT
+
+ if test $? = 0 ; then
+ break
+ fi
+done
#echo "Using ldapsearch to read all the entries from the master..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
- '(objectClass=*)' > "${MASTEROUT}.2" 2>&1
+ '(objectClass=*)' > "${MASTEROUT}.$CHECK" 2>&1
RC=$?
if test $RC != 0 ; then
#echo "Using ldapsearch to read all the entries from the slave..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
- '(objectClass=*)' > "${SLAVEOUT}.2" 2>&1
+ '(objectClass=*)' > "${SLAVEOUT}.$CHECK" 2>&1
RC=$?
if test $RC != 0 ; then
fi
#echo "Filtering master results..."
-. $LDIFFILTER < "${MASTEROUT}.2" > $MASTERFLT
+. $LDIFFILTER < "${MASTEROUT}.$CHECK" > $MASTERFLT
#echo "Filtering slave results..."
-. $LDIFFILTER < "${SLAVEOUT}.2" > $SLAVEFLT
+. $LDIFFILTER < "${SLAVEOUT}.$CHECK" > $SLAVEFLT
echo "$CHECK < Comparing retrieved entries from master and slave..."
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT
fi
KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
-SLEEP=25
-echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
-sleep $SLEEP
+# get master contextCSN
+$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
+ '(objectClass=*)' -s base contextCSN > "${MASTEROUT}.$CHECK" 2>&1
+RC=$?
+if test $RC != 0 ; then
+ echo "ldapsearch failed at master ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+fi
+
+# check slave contextCSN
+for i in 1 2 3 4 5; do
+ SLEEP=5
+ echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
+ sleep $SLEEP
+
+ $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
+ '(objectClass=*)' -s base contextCSN > "${SLAVEOUT}.$CHECK" 2>&1
+ RC=$?
+
+ if test $RC != 0 ; then
+ echo "ldapsearch failed at slave ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+ fi
+
+ $CMP ${MASTEROUT}.$CHECK ${SLAVEOUT}.$CHECK > $CMPOUT
+
+ if test $? = 0 ; then
+ break
+ fi
+done
#echo "Using ldapsearch to read all the entries from the master..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
- '(objectClass=*)' > "${MASTEROUT}.3" 2>&1
+ '(objectClass=*)' > "${MASTEROUT}.$CHECK" 2>&1
RC=$?
if test $RC != 0 ; then
#echo "Using ldapsearch to read all the entries from the slave..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
- '(objectClass=*)' > "${SLAVEOUT}.3" 2>&1
+ '(objectClass=*)' > "${SLAVEOUT}.$CHECK" 2>&1
RC=$?
if test $RC != 0 ; then
fi
#echo "Filtering master results..."
-. $LDIFFILTER < "${MASTEROUT}.3" > $MASTERFLT
+. $LDIFFILTER < "${MASTEROUT}.$CHECK" > $MASTERFLT
#echo "Filtering slave results..."
-. $LDIFFILTER < "${SLAVEOUT}.3" > $SLAVEFLT
+. $LDIFFILTER < "${SLAVEOUT}.$CHECK" > $SLAVEFLT
echo "$CHECK < Comparing retrieved entries from master and slave..."
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT
exit $RC
fi
-SLEEP=15
-echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
-sleep $SLEEP
+# get master contextCSN
+$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
+ '(objectClass=*)' -s base contextCSN > "${MASTEROUT}.$CHECK" 2>&1
+RC=$?
+if test $RC != 0 ; then
+ echo "ldapsearch failed at master ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+fi
+
+# check slave contextCSN
+sleep 1
+
+for i in 1 2 3; do
+ $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
+ '(objectClass=*)' -s base contextCSN > "${SLAVEOUT}.$CHECK" 2>&1
+ RC=$?
+
+ if test $RC != 0 ; then
+ echo "ldapsearch failed at slave ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+ fi
+
+ $CMP ${MASTEROUT}.$CHECK ${SLAVEOUT}.$CHECK > $CMPOUT
+
+ if test $? = 0 ; then
+ break
+ fi
+
+ SLEEP=5
+ echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
+ sleep $SLEEP
+done
#echo "Using ldapsearch to read all the entries from the master..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
- '(objectClass=*)' > "${MASTEROUT}.4" 2>&1
+ '(objectClass=*)' > "${MASTEROUT}.$CHECK" 2>&1
RC=$?
if test $RC != 0 ; then
#echo "Using ldapsearch to read all the entries from the slave..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
-'(objectClass=*)' > "${SLAVEOUT}.4" 2>&1
+'(objectClass=*)' > "${SLAVEOUT}.$CHECK" 2>&1
RC=$?
if test $RC != 0 ; then
fi
#echo "Filtering master results..."
-. $LDIFFILTER < "${MASTEROUT}.4" > $MASTERFLT
+. $LDIFFILTER < "${MASTEROUT}.$CHECK" > $MASTERFLT
#echo "Filtering slave results..."
-. $LDIFFILTER < "${SLAVEOUT}.4" > $SLAVEFLT
+. $LDIFFILTER < "${SLAVEOUT}.$CHECK" > $SLAVEFLT
echo "$CHECK < Comparing retrieved entries from master and slave..."
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT
fi
KILLPIDS="$MASTERPID $SLAVEPID $PROXYPID"
-SLEEP=25
-echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
-sleep $SLEEP
+# get master contextCSN
+$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
+ '(objectClass=*)' -s base contextCSN > "${MASTEROUT}.$CHECK" 2>&1
+RC=$?
+if test $RC != 0 ; then
+ echo "ldapsearch failed at master ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+fi
+
+# check slave contextCSN
+
+for i in 1 2 3 4 5; do
+ SLEEP=5
+ echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
+ sleep $SLEEP
+
+ $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
+ '(objectClass=*)' -s base contextCSN > "${SLAVEOUT}.$CHECK" 2>&1
+ RC=$?
+
+ if test $RC != 0 ; then
+ echo "ldapsearch failed at slave ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+ fi
+
+ $CMP ${MASTEROUT}.$CHECK ${SLAVEOUT}.$CHECK > $CMPOUT
+
+ if test $? = 0 ; then
+ break
+ fi
+done
#echo "Using ldapsearch to read all the entries from the master..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
- '(objectClass=*)' > "${MASTEROUT}.5" 2>&1
+ '(objectClass=*)' > "${MASTEROUT}.$CHECK" 2>&1
RC=$?
if test $RC != 0 ; then
#echo "Using ldapsearch to read all the entries from the slave..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
- '(objectClass=*)' > "${SLAVEOUT}.5" 2>&1
+ '(objectClass=*)' > "${SLAVEOUT}.$CHECK" 2>&1
RC=$?
if test $RC != 0 ; then
fi
#echo "Filtering master results..."
-. $LDIFFILTER < "${MASTEROUT}.5" > $MASTERFLT
+. $LDIFFILTER < "${MASTEROUT}.$CHECK" > $MASTERFLT
#echo "Filtering slave results..."
-. $LDIFFILTER < "${SLAVEOUT}.5" > $SLAVEFLT
+. $LDIFFILTER < "${SLAVEOUT}.$CHECK" > $SLAVEFLT
echo "$CHECK < Comparing retrieved entries from master and slave..."
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT
exit $RC
fi
-SLEEP=15
-echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
-sleep $SLEEP
+# get master contextCSN
+$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
+ '(objectClass=*)' -s base contextCSN > "${MASTEROUT}.$CHECK" 2>&1
+RC=$?
+if test $RC != 0 ; then
+ echo "ldapsearch failed at master ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+fi
+
+# check slave contextCSN
+sleep 1
+for i in 1 2 3; do
+ $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
+ '(objectClass=*)' -s base contextCSN > "${SLAVEOUT}.$CHECK" 2>&1
+ RC=$?
+
+ if test $RC != 0 ; then
+ echo "ldapsearch failed at slave ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+ fi
+
+ $CMP ${MASTEROUT}.$CHECK ${SLAVEOUT}.$CHECK > $CMPOUT
+
+ if test $? = 0 ; then
+ break
+ fi
+
+ SLEEP=5
+ echo "Waiting $SLEEP seconds for syncrepl to receive changes..."
+ sleep $SLEEP
+done
#echo "Using ldapsearch to read all the entries from the master..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
- '(objectClass=*)' > "${MASTEROUT}.6" 2>&1
+ '(objectClass=*)' > "${MASTEROUT}.$CHECK" 2>&1
RC=$?
if test $RC != 0 ; then
#echo "Using ldapsearch to read all the entries from the slave..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
- '(objectClass=*)' > "${SLAVEOUT}.6" 2>&1
+ '(objectClass=*)' > "${SLAVEOUT}.$CHECK" 2>&1
RC=$?
if test $RC != 0 ; then
fi
#echo "Filtering master results..."
-. $LDIFFILTER < "${MASTEROUT}.6" > $MASTERFLT
+. $LDIFFILTER < "${MASTEROUT}.$CHECK" > $MASTERFLT
#echo "Filtering slave results..."
-. $LDIFFILTER < "${SLAVEOUT}.6" > $SLAVEFLT
+. $LDIFFILTER < "${SLAVEOUT}.$CHECK" > $SLAVEFLT
echo "$CHECK < Comparing retrieved entries from master and slave..."
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT