3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2007 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 x$TESTLOOPS = x ; then
32 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
34 # NOTE: this could be added to all tests...
35 if test "$BACKEND" = "bdb" || test "$BACKEND" = "hdb" ; then
36 if test "x$DB_CONFIG" != "x" ; then \
37 if test -f $DB_CONFIG ; then
38 echo "==> using DB_CONFIG \"$DB_CONFIG\""
42 echo "==> DB_CONFIG must point to a valid file (ignored)"
45 echo "==> set \"DB_CONFIG\" to the DB_CONFIG file you want to use for the test."
50 echo "Starting slapd on TCP/IP port $PORT1..."
51 . $CONFFILTER $BACKEND $MONITORDB < $METACONF1 > $CONF1
52 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
54 if test $WAIT != 0 ; then
62 echo "Using ldapsearch to check that slapd is running..."
63 for i in 0 1 2 3 4 5; do
64 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
65 'objectclass=*' > /dev/null 2>&1
67 if test $RC = 0 ; then
70 echo "Waiting 5 seconds for slapd to start..."
73 if test $RC != 0 ; then
74 echo "ldapsearch failed ($RC)!"
75 test $KILLSERVERS != no && kill -HUP $KILLPIDS
79 echo "Using ldapadd to populate the database..."
80 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
81 $LDIFORDERED > $TESTOUT 2>&1
83 if test $RC != 0 ; then
84 echo "ldapadd failed ($RC)!"
85 test $KILLSERVERS != no && kill -HUP $KILLPIDS
89 echo "Starting slapd on TCP/IP port $PORT2..."
90 . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
91 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
93 if test $WAIT != 0 ; then
97 KILLPIDS="$KILLPIDS $PID"
101 echo "Using ldapsearch to check that slapd is running..."
102 for i in 0 1 2 3 4 5; do
103 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
104 'objectclass=*' > /dev/null 2>&1
106 if test $RC = 0 ; then
109 echo "Waiting 5 seconds for slapd to start..."
112 if test $RC != 0 ; then
113 echo "ldapsearch failed ($RC)!"
114 test $KILLSERVERS != no && kill -HUP $KILLPIDS
118 echo "Using ldapadd to populate the database..."
119 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
120 $LDIFMETA >> $TESTOUT 2>&1
122 if test $RC != 0 ; then
123 echo "ldapadd failed ($RC)!"
124 test $KILLSERVERS != no && kill -HUP $KILLPIDS
128 echo "Starting slapd on TCP/IP port $PORT3..."
129 . $CONFFILTER $BACKEND $MONITORDB < $METACONF > $CONF3
130 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
132 if test $WAIT != 0 ; then
136 KILLPIDS="$KILLPIDS $PID"
140 echo "Using ldapsearch to check that slapd is running..."
141 for i in 0 1 2 3 4 5; do
142 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
143 'objectclass=*' > /dev/null 2>&1
145 if test $RC = 0 ; then
148 echo "Waiting 5 seconds for slapd to start..."
151 if test $RC != 0 ; then
152 echo "ldapsearch failed ($RC)!"
153 test $KILLSERVERS != no && kill -HUP $KILLPIDS
157 cat /dev/null > $SEARCHOUT
159 mkdir -p $TESTDIR/$DATADIR
160 METABASEDN="o=Example,c=US"
161 for f in $DATADIR/do_* ; do
162 sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f
165 # add a read that matches only the local database, but selects
166 # also the remote as candidate; this should be removed to compare
167 # execution times with test008...
168 for f in $TESTDIR/$DATADIR/do_read.* ; do
169 echo "ou=Meta,$METABASEDN" >> $f
172 # add a read that matches a referral in the local database only,
173 # but selects also the remote as candidate; this should be removed
174 # to compare execution times with test008...
175 for f in $TESTDIR/$DATADIR/do_read.* ; do
176 echo "cn=Somewhere,ou=Meta,$METABASEDN" >> $f
179 # add a bind that resolves to a referral
180 for f in $TESTDIR/$DATADIR/do_bind.* ; do
181 echo "cn=Foo,ou=Meta,$METABASEDN" >> $f
187 echo "Using tester for concurrent server access..."
188 $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR/$DATADIR" -h $LOCALHOST -p $PORT3 \
189 -D "cn=Manager,$METABASEDN" -w $PASSWD -l $TESTLOOPS -r 20 -FF \
193 if test $RC != 0 ; then
194 echo "slapd-tester failed ($RC)!"
195 test $KILLSERVERS != no && kill -HUP $KILLPIDS
199 echo "Using ldapsearch to retrieve all the entries..."
200 $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \
201 'objectClass=*' > $SEARCHOUT 2>&1
204 test $KILLSERVERS != no && kill -HUP $KILLPIDS
206 if test $RC != 0 ; then
207 echo "ldapsearch failed ($RC)!"
211 echo "Filtering ldapsearch results..."
212 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
213 echo "Filtering original ldif used to create database..."
214 . $LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT
215 echo "Comparing filter output..."
216 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
218 if test $? != 0 ; then
219 echo "comparison failed - slapd-meta search/modification didn't succeed"
223 echo ">>>>> Test succeeded"
225 test $KILLSERVERS != no && wait