3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2013 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 $BACKMETA = metano ; then
22 echo "meta backend not available, test skipped"
26 if test $BACKLDAP = ldapno ; then
27 echo "ldap backend not available, test skipped"
31 if test x$TESTLOOPS = x ; then
35 if test x$TESTCHILDREN = x ; then
41 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
43 # NOTE: this could be added to all tests...
44 if test "$BACKEND" = "bdb" || test "$BACKEND" = "hdb" ; then
45 if test "x$DB_CONFIG" != "x" ; then \
46 if test -f $DB_CONFIG ; then
47 echo "==> using DB_CONFIG \"$DB_CONFIG\""
51 echo "==> DB_CONFIG must point to a valid file (ignored)"
54 echo "==> set \"DB_CONFIG\" to the DB_CONFIG file you want to use for the test."
59 echo "Starting slapd on TCP/IP port $PORT1..."
60 . $CONFFILTER $BACKEND $MONITORDB < $METACONF1 > $CONF1
61 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
63 if test $WAIT != 0 ; then
71 echo "Using ldapsearch to check that slapd is running..."
72 for i in 0 1 2 3 4 5; do
73 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
74 'objectclass=*' > /dev/null 2>&1
76 if test $RC = 0 ; then
79 echo "Waiting 5 seconds for slapd to start..."
82 if test $RC != 0 ; then
83 echo "ldapsearch failed ($RC)!"
84 test $KILLSERVERS != no && kill -HUP $KILLPIDS
88 echo "Using ldapadd to populate the database..."
89 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
90 $LDIFORDERED > $TESTOUT 2>&1
92 if test $RC != 0 ; then
93 echo "ldapadd failed ($RC)!"
94 test $KILLSERVERS != no && kill -HUP $KILLPIDS
98 echo "Starting slapd on TCP/IP port $PORT2..."
99 . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
100 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
102 if test $WAIT != 0 ; then
106 KILLPIDS="$KILLPIDS $PID"
110 echo "Using ldapsearch to check that slapd is running..."
111 for i in 0 1 2 3 4 5; do
112 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
113 'objectclass=*' > /dev/null 2>&1
115 if test $RC = 0 ; then
118 echo "Waiting 5 seconds for slapd to start..."
121 if test $RC != 0 ; then
122 echo "ldapsearch failed ($RC)!"
123 test $KILLSERVERS != no && kill -HUP $KILLPIDS
127 echo "Using ldapadd to populate the database..."
128 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
129 $LDIFMETA >> $TESTOUT 2>&1
131 if test $RC != 0 ; then
132 echo "ldapadd failed ($RC)!"
133 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 echo "Starting slapd on TCP/IP port $PORT3..."
138 . $CONFFILTER $BACKEND $MONITORDB < $METACONF > $CONF3
139 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
141 if test $WAIT != 0 ; then
145 KILLPIDS="$KILLPIDS $PID"
149 echo "Using ldapsearch to check that slapd is running..."
150 for i in 0 1 2 3 4 5; do
151 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
152 'objectclass=*' > /dev/null 2>&1
154 if test $RC = 0 ; then
157 echo "Waiting 5 seconds for slapd to start..."
160 if test $RC != 0 ; then
161 echo "ldapsearch failed ($RC)!"
162 test $KILLSERVERS != no && kill -HUP $KILLPIDS
166 cat /dev/null > $SEARCHOUT
168 mkdir -p $TESTDIR/$DATADIR
169 METABASEDN="o=Example,c=US"
170 for f in $DATADIR/do_* ; do
171 sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f
174 # add a read that matches only the local database, but selects
175 # also the remote as candidate; this should be removed to compare
176 # execution times with test008...
177 for f in $TESTDIR/$DATADIR/do_read.* ; do
178 echo "ou=Meta,$METABASEDN" >> $f
181 # add a read that matches a referral in the local database only,
182 # but selects also the remote as candidate; this should be removed
183 # to compare execution times with test008...
184 for f in $TESTDIR/$DATADIR/do_read.* ; do
185 echo "cn=Somewhere,ou=Meta,$METABASEDN" >> $f
188 # add a bind that resolves to a referral
189 for f in $TESTDIR/$DATADIR/do_bind.* ; do
190 echo "cn=Foo,ou=Meta,$METABASEDN" >> $f
196 # fix test data to include back-monitor, if available
197 # NOTE: copies do_* files from $TESTDIR/$DATADIR to $TESTDIR
198 $MONITORDATA "$MONITORDB" "$TESTDIR/$DATADIR" "$TESTDIR"
200 BINDDN="cn=Manager,o=Local"
202 echo "Using tester for concurrent server access..."
203 $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR" -h $LOCALHOST -p $PORT3 \
204 -D "$BINDDN" -w $PASSWD -l $TESTLOOPS -j $TESTCHILDREN \
205 -r 20 -i '!REFERRAL' -i '*INVALID_CREDENTIALS' -SS
208 if test $RC != 0 ; then
209 echo "slapd-tester failed ($RC)!"
210 test $KILLSERVERS != no && kill -HUP $KILLPIDS
214 echo "Using ldapsearch to retrieve all the entries..."
215 $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \
216 'objectClass=*' > $SEARCHOUT 2>&1
219 test $KILLSERVERS != no && kill -HUP $KILLPIDS
221 if test $RC != 0 ; then
222 echo "ldapsearch failed ($RC)!"
226 echo "Filtering ldapsearch results..."
227 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
228 echo "Filtering original ldif used to create database..."
229 $LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT
230 echo "Comparing filter output..."
231 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
233 if test $? != 0 ; then
234 echo "comparison failed - slapd-meta search/modification didn't succeed"
238 echo ">>>>> Test succeeded"
240 test $KILLSERVERS != no && wait