3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2009 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
37 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
39 # NOTE: this could be added to all tests...
40 if test "$BACKEND" = "bdb" || test "$BACKEND" = "hdb" ; then
41 if test "x$DB_CONFIG" != "x" ; then \
42 if test -f $DB_CONFIG ; then
43 echo "==> using DB_CONFIG \"$DB_CONFIG\""
47 echo "==> DB_CONFIG must point to a valid file (ignored)"
50 echo "==> set \"DB_CONFIG\" to the DB_CONFIG file you want to use for the test."
55 echo "Starting slapd on TCP/IP port $PORT1..."
56 . $CONFFILTER $BACKEND $MONITORDB < $METACONF1 > $CONF1
57 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
59 if test $WAIT != 0 ; then
67 echo "Using ldapsearch to check that slapd is running..."
68 for i in 0 1 2 3 4 5; do
69 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
70 'objectclass=*' > /dev/null 2>&1
72 if test $RC = 0 ; then
75 echo "Waiting 5 seconds for slapd to start..."
78 if test $RC != 0 ; then
79 echo "ldapsearch failed ($RC)!"
80 test $KILLSERVERS != no && kill -HUP $KILLPIDS
84 echo "Using ldapadd to populate the database..."
85 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
86 $LDIFORDERED > $TESTOUT 2>&1
88 if test $RC != 0 ; then
89 echo "ldapadd failed ($RC)!"
90 test $KILLSERVERS != no && kill -HUP $KILLPIDS
94 echo "Starting slapd on TCP/IP port $PORT2..."
95 . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
96 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
98 if test $WAIT != 0 ; then
102 KILLPIDS="$KILLPIDS $PID"
106 echo "Using ldapsearch to check that slapd is running..."
107 for i in 0 1 2 3 4 5; do
108 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
109 'objectclass=*' > /dev/null 2>&1
111 if test $RC = 0 ; then
114 echo "Waiting 5 seconds for slapd to start..."
117 if test $RC != 0 ; then
118 echo "ldapsearch failed ($RC)!"
119 test $KILLSERVERS != no && kill -HUP $KILLPIDS
123 echo "Using ldapadd to populate the database..."
124 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
125 $LDIFMETA >> $TESTOUT 2>&1
127 if test $RC != 0 ; then
128 echo "ldapadd failed ($RC)!"
129 test $KILLSERVERS != no && kill -HUP $KILLPIDS
133 echo "Starting slapd on TCP/IP port $PORT3..."
134 . $CONFFILTER $BACKEND $MONITORDB < $METACONF > $CONF3
135 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
137 if test $WAIT != 0 ; then
141 KILLPIDS="$KILLPIDS $PID"
145 echo "Using ldapsearch to check that slapd is running..."
146 for i in 0 1 2 3 4 5; do
147 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
148 'objectclass=*' > /dev/null 2>&1
150 if test $RC = 0 ; then
153 echo "Waiting 5 seconds for slapd to start..."
156 if test $RC != 0 ; then
157 echo "ldapsearch failed ($RC)!"
158 test $KILLSERVERS != no && kill -HUP $KILLPIDS
162 cat /dev/null > $SEARCHOUT
164 mkdir -p $TESTDIR/$DATADIR
165 METABASEDN="o=Example,c=US"
166 for f in $DATADIR/do_* ; do
167 sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f
170 # add a read that matches only the local database, but selects
171 # also the remote as candidate; this should be removed to compare
172 # execution times with test008...
173 for f in $TESTDIR/$DATADIR/do_read.* ; do
174 echo "ou=Meta,$METABASEDN" >> $f
177 # add a read that matches a referral in the local database only,
178 # but selects also the remote as candidate; this should be removed
179 # to compare execution times with test008...
180 for f in $TESTDIR/$DATADIR/do_read.* ; do
181 echo "cn=Somewhere,ou=Meta,$METABASEDN" >> $f
184 # add a bind that resolves to a referral
185 for f in $TESTDIR/$DATADIR/do_bind.* ; do
186 echo "cn=Foo,ou=Meta,$METABASEDN" >> $f
192 # fix test data to include back-monitor, if available
193 # NOTE: copies do_* files from $TESTDIR/$DATADIR to $TESTDIR
194 $MONITORDATA "$MONITORDB" "$TESTDIR/$DATADIR" "$TESTDIR"
196 echo "Using tester for concurrent server access..."
197 $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR" -h $LOCALHOST -p $PORT3 \
198 -D "cn=Manager,$METABASEDN" -w $PASSWD -l $TESTLOOPS -r 20 -FF \
202 if test $RC != 0 ; then
203 echo "slapd-tester failed ($RC)!"
204 test $KILLSERVERS != no && kill -HUP $KILLPIDS
208 echo "Using ldapsearch to retrieve all the entries..."
209 $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \
210 'objectClass=*' > $SEARCHOUT 2>&1
213 test $KILLSERVERS != no && kill -HUP $KILLPIDS
215 if test $RC != 0 ; then
216 echo "ldapsearch failed ($RC)!"
220 echo "Filtering ldapsearch results..."
221 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
222 echo "Filtering original ldif used to create database..."
223 . $LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT
224 echo "Comparing filter output..."
225 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
227 if test $? != 0 ; then
228 echo "comparison failed - slapd-meta search/modification didn't succeed"
232 echo ">>>>> Test succeeded"
234 test $KILLSERVERS != no && wait