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 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
21 if test $BACKLDAP = ldapno ; then
22 echo "ldap backend not available, test skipped"
26 if test $RWM = rwmno ; then
27 echo "rwm (rewrite/remap) overlay not available, test skipped"
31 if test x$TESTLOOPS = x ; then
35 if test x$TESTOLOOPS = x ; then
41 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
43 echo "Starting slapd on TCP/IP port $PORT1..."
44 . $CONFFILTER $BACKEND $MONITORDB < $METACONF1 > $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 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..."
66 if test $RC != 0 ; then
67 echo "ldapsearch failed ($RC)!"
68 test $KILLSERVERS != no && kill -HUP $KILLPIDS
72 echo "Using ldapadd to populate the database..."
73 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
74 $LDIFORDERED > $TESTOUT 2>&1
76 if test $RC != 0 ; then
77 echo "ldapadd failed ($RC)!"
78 test $KILLSERVERS != no && kill -HUP $KILLPIDS
82 echo "Starting slapd on TCP/IP port $PORT2..."
83 . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
84 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
86 if test $WAIT != 0 ; then
90 KILLPIDS="$KILLPIDS $PID"
94 echo "Using ldapsearch to check that slapd is running..."
95 for i in 0 1 2 3 4 5; do
96 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
97 'objectclass=*' > /dev/null 2>&1
99 if test $RC = 0 ; then
102 echo "Waiting 5 seconds for slapd to start..."
105 if test $RC != 0 ; then
106 echo "ldapsearch failed ($RC)!"
107 test $KILLSERVERS != no && kill -HUP $KILLPIDS
111 echo "Using ldapadd to populate the database..."
112 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
113 $LDIFMETA >> $TESTOUT 2>&1
115 if test $RC != 0 ; then
116 echo "ldapadd failed ($RC)!"
117 test $KILLSERVERS != no && kill -HUP $KILLPIDS
121 echo "Starting slapd on TCP/IP port $PORT3..."
122 . $CONFFILTER $BACKEND $MONITORDB < $GLUELDAPCONF > $CONF3
123 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
125 if test $WAIT != 0 ; then
129 KILLPIDS="$KILLPIDS $PID"
133 echo "Using ldapsearch to check that slapd is running..."
134 for i in 0 1 2 3 4 5; do
135 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
136 'objectclass=*' > /dev/null 2>&1
138 if test $RC = 0 ; then
141 echo "Waiting 5 seconds for slapd to start..."
144 if test $RC != 0 ; then
145 echo "ldapsearch failed ($RC)!"
146 test $KILLSERVERS != no && kill -HUP $KILLPIDS
150 cat /dev/null > $SEARCHOUT
152 mkdir -p $TESTDIR/$DATADIR
153 METABASEDN="o=Example,c=US"
154 for f in $DATADIR/do_* ; do
155 sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f
158 # add a read that matches only the local database, but selects
159 # also the remote as candidate; this should be removed to compare
160 # execution times with test008...
161 for f in $TESTDIR/$DATADIR/do_read.* ; do
162 echo "ou=Meta,$METABASEDN" >> $f
165 # add a read that matches a referral in the local database only,
166 # but selects also the remote as candidate; this should be removed
167 # to compare execution times with test008...
168 for f in $TESTDIR/$DATADIR/do_read.* ; do
169 echo "cn=Somewhere,ou=Meta,$METABASEDN" >> $f
172 # add a bind that resolves to a referral
173 for f in $TESTDIR/$DATADIR/do_bind.* ; do
174 echo "cn=Foo,ou=Meta,$METABASEDN" >> $f
180 # fix test data to include back-monitor, if available
181 # NOTE: copies do_* files from $TESTDIR/$DATADIR to $TESTDIR
182 $MONITORDATA "$MONITORDB" "$TESTDIR/$DATADIR" "$TESTDIR"
184 echo "Using tester for concurrent server access..."
185 $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR" -h $LOCALHOST -p $PORT3 \
186 -D "cn=Manager,$METABASEDN" -w $PASSWD \
187 -l $TESTLOOPS -L $TESTOLOOPS -r 20 -FF \
191 if test $RC != 0 ; then
192 echo "slapd-tester failed ($RC)!"
193 test $KILLSERVERS != no && kill -HUP $KILLPIDS
197 echo "Using ldapsearch to retrieve all the entries..."
198 $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \
199 '(objectClass=*)' > $SEARCHOUT 2>&1
202 test $KILLSERVERS != no && kill -HUP $KILLPIDS
204 if test $RC != 0 ; then
205 echo "ldapsearch failed ($RC)!"
209 echo "Filtering ldapsearch results..."
210 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
211 echo "Filtering original ldif used to create database..."
212 . $LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT
213 echo "Comparing filter output..."
214 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
216 if test $? != 0 ; then
217 echo "comparison failed - slapd-ldap search/modification didn't succeed"
221 echo ">>>>> Test succeeded"
223 test $KILLSERVERS != no && wait