3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2016 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
39 if test x$TESTCHILDREN = x ; then
45 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
47 echo "Starting slapd on TCP/IP port $PORT1..."
48 . $CONFFILTER $BACKEND $MONITORDB < $METACONF1 > $CONF1
49 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
51 if test $WAIT != 0 ; then
59 echo "Using ldapsearch to check that slapd is running..."
60 for i in 0 1 2 3 4 5; do
61 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
62 'objectclass=*' > /dev/null 2>&1
64 if test $RC = 0 ; then
67 echo "Waiting 5 seconds for slapd to start..."
70 if test $RC != 0 ; then
71 echo "ldapsearch failed ($RC)!"
72 test $KILLSERVERS != no && kill -HUP $KILLPIDS
76 echo "Using ldapadd to populate the database..."
77 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
78 $LDIFORDERED > $TESTOUT 2>&1
80 if test $RC != 0 ; then
81 echo "ldapadd failed ($RC)!"
82 test $KILLSERVERS != no && kill -HUP $KILLPIDS
86 echo "Starting slapd on TCP/IP port $PORT2..."
87 . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
88 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
90 if test $WAIT != 0 ; then
94 KILLPIDS="$KILLPIDS $PID"
98 echo "Using ldapsearch to check that slapd is running..."
99 for i in 0 1 2 3 4 5; do
100 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
101 'objectclass=*' > /dev/null 2>&1
103 if test $RC = 0 ; then
106 echo "Waiting 5 seconds for slapd to start..."
109 if test $RC != 0 ; then
110 echo "ldapsearch failed ($RC)!"
111 test $KILLSERVERS != no && kill -HUP $KILLPIDS
115 echo "Using ldapadd to populate the database..."
116 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
117 $LDIFMETA >> $TESTOUT 2>&1
119 if test $RC != 0 ; then
120 echo "ldapadd failed ($RC)!"
121 test $KILLSERVERS != no && kill -HUP $KILLPIDS
125 echo "Starting slapd on TCP/IP port $PORT3..."
126 . $CONFFILTER $BACKEND $MONITORDB < $GLUELDAPCONF > $CONF3
127 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
129 if test $WAIT != 0 ; then
133 KILLPIDS="$KILLPIDS $PID"
137 echo "Using ldapsearch to check that slapd is running..."
138 for i in 0 1 2 3 4 5; do
139 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
140 'objectclass=*' > /dev/null 2>&1
142 if test $RC = 0 ; then
145 echo "Waiting 5 seconds for slapd to start..."
148 if test $RC != 0 ; then
149 echo "ldapsearch failed ($RC)!"
150 test $KILLSERVERS != no && kill -HUP $KILLPIDS
154 cat /dev/null > $SEARCHOUT
156 mkdir -p $TESTDIR/$DATADIR
157 METABASEDN="o=Example,c=US"
158 for f in $DATADIR/do_* ; do
159 sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f
162 # add a read that matches only the local database, but selects
163 # also the remote as candidate; this should be removed to compare
164 # execution times with test008...
165 for f in $TESTDIR/$DATADIR/do_read.* ; do
166 echo "ou=Meta,$METABASEDN" >> $f
169 # add a read that matches a referral in the local database only,
170 # but selects also the remote as candidate; this should be removed
171 # to compare execution times with test008...
172 for f in $TESTDIR/$DATADIR/do_read.* ; do
173 echo "cn=Somewhere,ou=Meta,$METABASEDN" >> $f
176 # add a bind that resolves to a referral
177 for f in $TESTDIR/$DATADIR/do_bind.* ; do
178 echo "cn=Foo,ou=Meta,$METABASEDN" >> $f
184 # fix test data to include back-monitor, if available
185 # NOTE: copies do_* files from $TESTDIR/$DATADIR to $TESTDIR
186 $MONITORDATA "$MONITORDB" "$TESTDIR/$DATADIR" "$TESTDIR"
188 echo "Using tester for concurrent server access..."
189 BINDDN="cn=Manager,o=Local"
191 $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR" -h $LOCALHOST -p $PORT3 \
192 -D "$BINDDN" -w $PASSWD \
193 -l $TESTLOOPS -L $TESTOLOOPS -j $TESTCHILDREN -r 20 \
194 -i '!REFERRAL' -i '*INVALID_CREDENTIALS' -SS
197 if test $RC != 0 ; then
198 echo "slapd-tester failed ($RC)!"
199 test $KILLSERVERS != no && kill -HUP $KILLPIDS
203 echo "Using ldapsearch to retrieve all the entries..."
204 $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \
205 '(objectClass=*)' > $SEARCHOUT 2>&1
208 test $KILLSERVERS != no && kill -HUP $KILLPIDS
210 if test $RC != 0 ; then
211 echo "ldapsearch failed ($RC)!"
215 echo "Filtering ldapsearch results..."
216 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
217 echo "Filtering original ldif used to create database..."
218 $LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT
219 echo "Comparing filter output..."
220 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
222 if test $? != 0 ; then
223 echo "comparison failed - slapd-ldap search/modification didn't succeed"
227 echo ">>>>> Test succeeded"
229 test $KILLSERVERS != no && wait