2 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ## Copyright 1998-2006 The OpenLDAP Foundation.
5 ## All rights reserved.
7 ## Redistribution and use in source and binary forms, with or without
8 ## modification, are permitted only as authorized by the OpenLDAP
11 ## A copy of this license is available in the file LICENSE in the
12 ## top-level directory of the distribution or, alternatively, at
13 ## <http://www.OpenLDAP.org/license.html>.
15 if test "$BACKEND" != "bdb" && test "$BACKEND" != "hdb" ; then
16 echo "Test does not support $BACKEND"
20 echo "running defines.sh"
21 . $SRCDIR/scripts/defines.sh
23 mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C $DBDIR2A $DBDIR2B
25 echo "Running slapadd to build glued slapd databases..."
26 . $CONFFILTER $BACKEND $MONITORDB < $GLUECONF > $CONF1
27 $SLAPADD -d $LVL -f $CONF1 -l $LDIFORDERED > $SLAPADDLOG1 2>&1
29 if test $RC != 0 ; then
30 echo "slapadd failed ($RC)!"
34 rm -f $DBDIR1A/* $DBDIR1B/*
35 cp -pr $DBDIR1C $DBDIR2C
37 echo "Starting slapd 1 on TCP/IP port $PORT1..."
38 . $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF1 > $CONF1
39 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
41 if test $WAIT != 0 ; then
49 echo "Using ldapsearch to check that slapd 1 is running..."
50 for i in 0 1 2 3 4 5; do
51 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
52 '(objectclass=*)' > /dev/null 2>&1
54 if test $RC = 0 ; then
57 echo "Waiting 5 seconds for slapd to start..."
61 echo "Starting slapd 2 on TCP/IP port $PORT2..."
62 . $CONFFILTER $BACKEND $MONITORDB < $GLUESYNCCONF2 > $CONF2
63 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
65 if test $WAIT != 0 ; then
69 KILLPIDS="$KILLPIDS $PID"
73 echo "Using ldapsearch to check that slapd 2 is running..."
74 for i in 0 1 2 3 4 5; do
75 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
76 '(objectclass=*)' > /dev/null 2>&1
78 if test $RC = 0 ; then
81 echo "Waiting 5 seconds for slapd to start..."
85 SUBTREE1="ou=Information Technology Division,ou=People,dc=example,dc=com"
86 SUBTREE2="ou=Groups,dc=example,dc=com"
88 echo "Using ldapadd to populate subtree=\"${SUBTREE1}\" on port $PORT1..."
89 $LDAPADD -D "cn=Manager 1,$BASEDN" -w $PASSWD -h $LOCALHOST -p $PORT1 \
95 echo "ldapadd should have failed ($RC)!"
96 test $KILLSERVERS != no && kill -HUP $KILLPIDS
100 # Fine if we get alreadyExists or referrals
103 echo "ldapadd failed ($RC)!"
104 test $KILLSERVERS != no && kill -HUP $KILLPIDS
109 echo "Using ldapadd to populate subtree=\"${SUBTREE2}\" on port $PORT2..."
110 $LDAPADD -D "cn=Manager 2,$BASEDN" -w $PASSWD -h $LOCALHOST -p $PORT2 \
116 echo "ldapadd should have failed ($RC)!"
117 test $KILLSERVERS != no && kill -HUP $KILLPIDS
121 # Fine if we get alreadyExists or referrals
124 echo "ldapadd failed ($RC)!"
125 test $KILLSERVERS != no && kill -HUP $KILLPIDS
131 echo "Waiting $SLEEP seconds for shadow subtrees to sync..."
134 echo "Filtering original ldif used to create database..."
135 . $LDIFFILTER < $GLUESYNCOUT > $LDIFFLT
137 for P in $PORT1 $PORT2 ; do
138 echo "Using ldapsearch to read all the entries from port $P..."
139 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $P \
140 -S "" '(objectclass=*)' > "${SEARCHOUT}.${P}" 2>&1
143 if test $RC != 0 ; then
144 echo "ldapsearch failed ($RC)!"
145 test $KILLSERVERS != no && kill -HUP $KILLPIDS
149 echo "Filtering ldapsearch results..."
150 . $LDIFFILTER < "${SEARCHOUT}.${P}" > $SEARCHFLT
151 echo "Comparing filter output..."
152 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
154 if test $? != 0 ; then
155 echo "comparison failed - database was not created correctly"
156 test $KILLSERVERS != no && kill -HUP $KILLPIDS
161 test $KILLSERVERS != no && kill -HUP $KILLPIDS
163 echo ">>>>> Test succeeded"
165 test $KILLSERVERS != no && wait