3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2008 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 case $BACKEND in bdb | hdb | ldif) : ;; *)
17 echo "Test does not support $BACKEND backend, test skipped"
21 echo "running defines.sh"
22 . $SRCDIR/scripts/defines.sh
24 if test $SYNCPROV = syncprovno; then
25 echo "Syncrepl provider overlay not available, test skipped"
29 mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C $DBDIR2A $DBDIR2B
31 echo "Running slapadd to build glued slapd databases..."
32 . $CONFFILTER $BACKEND $MONITORDB < $GLUECONF > $CONF1
33 $SLAPADD -d $LVL -f $CONF1 -l $LDIFORDERED > $SLAPADDLOG1 2>&1
35 if test $RC != 0 ; then
36 echo "slapadd failed ($RC)!"
40 rm -rf $DBDIR1A/* $DBDIR1B/*
41 cp -pr $DBDIR1C $DBDIR2C
43 echo "Starting slapd 1 on TCP/IP port $PORT1..."
44 . $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF1 > $CONF1
45 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
47 if test $WAIT != 0 ; then
55 echo "Using ldapsearch to check that slapd 1 is running..."
56 for i in 0 1 2 3 4 5; do
57 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
58 '(objectclass=*)' > /dev/null 2>&1
60 if test $RC = 0 ; then
63 echo "Waiting 5 seconds for slapd to start..."
67 echo "Starting slapd 2 on TCP/IP port $PORT2..."
68 . $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF2 > $CONF2
69 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
71 if test $WAIT != 0 ; then
75 KILLPIDS="$KILLPIDS $PID"
79 echo "Using ldapsearch to check that slapd 2 is running..."
80 for i in 0 1 2 3 4 5; do
81 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
82 '(objectclass=*)' > /dev/null 2>&1
84 if test $RC = 0 ; then
87 echo "Waiting 5 seconds for slapd to start..."
91 SUBTREE1="ou=Information Technology Division,ou=People,dc=example,dc=com"
92 SUBTREE2="ou=Groups,dc=example,dc=com"
94 echo "Using ldapadd to populate subtree=\"${SUBTREE1}\" on port $PORT1..."
95 $LDAPADD -D "cn=Manager 1,$BASEDN" -w $PASSWD -h $LOCALHOST -p $PORT1 \
101 echo "ldapadd should have failed ($RC)!"
102 test $KILLSERVERS != no && kill -HUP $KILLPIDS
106 # Fine if we get alreadyExists or referrals
109 echo "ldapadd failed ($RC)!"
110 test $KILLSERVERS != no && kill -HUP $KILLPIDS
115 echo "Using ldapadd to populate subtree=\"${SUBTREE2}\" on port $PORT2..."
116 $LDAPADD -D "cn=Manager 2,$BASEDN" -w $PASSWD -h $LOCALHOST -p $PORT2 \
122 echo "ldapadd should have failed ($RC)!"
123 test $KILLSERVERS != no && kill -HUP $KILLPIDS
127 # Fine if we get alreadyExists or referrals
130 echo "ldapadd failed ($RC)!"
131 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 echo "Waiting $SLEEP seconds for shadow subtrees to sync..."
140 echo "Filtering original ldif used to create database..."
141 . $LDIFFILTER < $GLUESYNCOUT > $LDIFFLT
143 for P in $PORT1 $PORT2 ; do
144 echo "Using ldapsearch to read all the entries from port $P..."
145 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $P \
146 -S "" '(objectclass=*)' > "${SEARCHOUT}.${P}" 2>&1
149 if test $RC != 0 ; then
150 echo "ldapsearch failed ($RC)!"
151 test $KILLSERVERS != no && kill -HUP $KILLPIDS
155 echo "Filtering ldapsearch results..."
156 . $LDIFFILTER < "${SEARCHOUT}.${P}" > $SEARCHFLT
157 echo "Comparing filter output..."
158 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
160 if test $? != 0 ; then
161 echo "comparison failed - database was not created correctly"
162 test $KILLSERVERS != no && kill -HUP $KILLPIDS
167 echo "Testing ldapdelete propagation..."
168 $LDAPDELETE -D "cn=Manager 1,$BASEDN" -w $PASSWD -H $URI1 "$BABSDN" \
171 if test $RC != 0 ; then
172 echo "ldapdelete failed ($RC)!"
173 test $KILLSERVERS != no && kill -HUP $KILLPIDS
177 # This usually propagates immediately
180 $LDAPSEARCH -H $URI2 -b "$BABSDN" > $TESTOUT 2>&1
182 if test $RC = 0 ; then
183 echo "ldapsearch should have failed ($RC)!"
184 test $KILLSERVERS != no && kill -HUP $KILLPIDS
188 test $KILLSERVERS != no && kill -HUP $KILLPIDS
190 echo ">>>>> Test succeeded"
192 test $KILLSERVERS != no && wait