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 #### No longer experimental, IMHO
27 ###if test "x$TEST_META" = "xno" ; then
28 ### echo '### Test disabled by "TEST_META=no"; unset TEST_META to re-enable'
32 ### echo "### this test is experimental; in case of problems,"
33 ### echo "### set \"TEST_META=no\" to disable, and report thru"
34 ### echo "### the Issue Tracking System <http://www.openldap.org/its/>"
38 if test x$TESTLOOPS = x ; then
44 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
46 # NOTE: this could be added to all tests...
47 if test "$BACKEND" = "bdb" || test "$BACKEND" = "hdb" ; then
48 if test "x$DB_CONFIG" != "x" ; then \
49 if test -f $DB_CONFIG ; then
50 echo "==> using DB_CONFIG \"$DB_CONFIG\""
54 echo "==> DB_CONFIG must point to a valid file (ignored)"
57 echo "==> set \"DB_CONFIG\" to the DB_CONFIG file you want to use for the test."
62 echo "Starting slapd on TCP/IP port $PORT1..."
63 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
64 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
66 if test $WAIT != 0 ; then
74 echo "Using ldapsearch to check that slapd is running..."
75 for i in 0 1 2 3 4 5; do
76 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
77 'objectclass=*' > /dev/null 2>&1
79 if test $RC = 0 ; then
82 echo "Waiting 5 seconds for slapd to start..."
85 if test $RC != 0 ; then
86 echo "ldapsearch failed ($RC)!"
87 test $KILLSERVERS != no && kill -HUP $KILLPIDS
91 echo "Using ldapadd to populate the database..."
92 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
93 $LDIFORDERED > $TESTOUT 2>&1
95 if test $RC != 0 ; then
96 echo "ldapadd failed ($RC)!"
97 test $KILLSERVERS != no && kill -HUP $KILLPIDS
101 echo "Starting slapd on TCP/IP port $PORT2..."
102 . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
103 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
105 if test $WAIT != 0 ; then
109 KILLPIDS="$KILLPIDS $PID"
113 echo "Using ldapsearch to check that slapd is running..."
114 for i in 0 1 2 3 4 5; do
115 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
116 'objectclass=*' > /dev/null 2>&1
118 if test $RC = 0 ; then
121 echo "Waiting 5 seconds for slapd to start..."
124 if test $RC != 0 ; then
125 echo "ldapsearch failed ($RC)!"
126 test $KILLSERVERS != no && kill -HUP $KILLPIDS
130 echo "Using ldapadd to populate the database..."
131 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
132 $LDIFMETA >> $TESTOUT 2>&1
134 if test $RC != 0 ; then
135 echo "ldapadd failed ($RC)!"
136 test $KILLSERVERS != no && kill -HUP $KILLPIDS
140 echo "Starting slapd on TCP/IP port $PORT3..."
141 . $CONFFILTER $BACKEND $MONITORDB < $METACONF > $CONF3
142 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
144 if test $WAIT != 0 ; then
148 KILLPIDS="$KILLPIDS $PID"
152 echo "Using ldapsearch to check that slapd is running..."
153 for i in 0 1 2 3 4 5; do
154 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
155 'objectclass=*' > /dev/null 2>&1
157 if test $RC = 0 ; then
160 echo "Waiting 5 seconds for slapd to start..."
163 if test $RC != 0 ; then
164 echo "ldapsearch failed ($RC)!"
165 test $KILLSERVERS != no && kill -HUP $KILLPIDS
169 cat /dev/null > $SEARCHOUT
171 mkdir -p $TESTDIR/$DATADIR
172 METABASEDN="o=Example,c=US"
173 for f in $DATADIR/do_* ; do
174 sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f
177 # add a read that matches only the local database, but selects
178 # also the remote as candidate; this should be removed to compare
179 # execution times with test008...
180 for f in $TESTDIR/$DATADIR/do_read.* ; do
181 echo "ou=Meta,$METABASEDN" >> $f
184 # add a read that matches a referral in the local database only,
185 # but selects also the remote as candidate; this should be removed
186 # to compare execution times with test008...
187 for f in $TESTDIR/$DATADIR/do_read.* ; do
188 echo "cn=Somewhere,ou=Meta,$METABASEDN" >> $f
191 # add a bind that resolves to a referral
192 for f in $TESTDIR/$DATADIR/do_bind.* ; do
193 echo "cn=Foo,ou=Meta,$METABASEDN" >> $f
199 echo "Using tester for concurrent server access..."
200 $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR/$DATADIR" -h $LOCALHOST -p $PORT3 \
201 -D "cn=Manager,$METABASEDN" -w $PASSWD -l $TESTLOOPS -r 20 -FF \
205 if test $RC != 0 ; then
206 echo "slapd-tester failed ($RC)!"
207 test $KILLSERVERS != no && kill -HUP $KILLPIDS
211 echo "Using ldapsearch to retrieve all the entries..."
212 $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \
213 'objectClass=*' > $SEARCHOUT 2>&1
216 test $KILLSERVERS != no && kill -HUP $KILLPIDS
218 if test $RC != 0 ; then
219 echo "ldapsearch failed ($RC)!"
223 echo "Filtering ldapsearch results..."
224 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
225 echo "Filtering original ldif used to create database..."
226 . $LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT
227 echo "Comparing filter output..."
228 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
230 if test $? != 0 ; then
231 echo "comparison failed - slapd-meta search/modification didn't succeed"
235 echo ">>>>> Test succeeded"
237 test $KILLSERVERS != no && wait