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 # to be removed some time...
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
47 ITSDIR=$DATADIR/regressions/its$ITS
48 ITSCONF=$ITSDIR/slapd-meta.conf
50 # NOTE: this could be added to all tests...
51 if test "$BACKEND" = "bdb" || test "$BACKEND" = "hdb" ; then
52 if test "x$DB_CONFIG" != "x" ; then \
53 if test -f $DB_CONFIG ; then
54 echo "==> using DB_CONFIG \"$DB_CONFIG\""
58 echo "==> DB_CONFIG must point to a valid file (ignored)"
61 echo "==> set \"DB_CONFIG\" to the DB_CONFIG file you want to use for the test."
66 echo "Starting slapd on TCP/IP port $PORT1..."
67 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
68 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
70 if test $WAIT != 0 ; then
78 echo "Using ldapsearch to check that slapd is running..."
79 for i in 0 1 2 3 4 5; do
80 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
81 'objectclass=*' > /dev/null 2>&1
83 if test $RC = 0 ; then
86 echo "Waiting 5 seconds for slapd to start..."
89 if test $RC != 0 ; then
90 echo "ldapsearch failed ($RC)!"
91 test $KILLSERVERS != no && kill -HUP $KILLPIDS
95 echo "Using ldapadd to populate the database..."
96 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
97 $LDIFORDERED > $TESTOUT 2>&1
99 if test $RC != 0 ; then
100 echo "ldapadd failed ($RC)!"
101 test $KILLSERVERS != no && kill -HUP $KILLPIDS
105 echo "Using ldapadd to add the referral..."
106 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD << EOMODS \
108 dn: cn=Meta,dc=example,dc=com
109 objectClass: referral
110 objectClass: extensibleObject
112 ref: ${URI2}ou=Meta,dc=example,dc=com
116 if test $RC != 0 ; then
117 echo "ldapadd failed ($RC)!"
118 test $KILLSERVERS != no && kill -HUP $KILLPIDS
122 echo "Starting slapd on TCP/IP port $PORT2..."
123 . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
124 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
126 if test $WAIT != 0 ; then
130 KILLPIDS="$KILLPIDS $PID"
134 echo "Using ldapsearch to check that slapd is running..."
135 for i in 0 1 2 3 4 5; do
136 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
137 'objectclass=*' > /dev/null 2>&1
139 if test $RC = 0 ; then
142 echo "Waiting 5 seconds for slapd to start..."
145 if test $RC != 0 ; then
146 echo "ldapsearch failed ($RC)!"
147 test $KILLSERVERS != no && kill -HUP $KILLPIDS
151 echo "Using ldapadd to populate the database..."
152 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
153 $LDIFMETA >> $TESTOUT 2>&1
155 if test $RC != 0 ; then
156 echo "ldapadd failed ($RC)!"
157 test $KILLSERVERS != no && kill -HUP $KILLPIDS
161 echo "Starting slapd on TCP/IP port $PORT3..."
162 . $CONFFILTER $BACKEND $MONITORDB < $ITSCONF > $CONF3
163 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
165 if test $WAIT != 0 ; then
169 KILLPIDS="$KILLPIDS $PID"
173 echo "Using ldapsearch to check that slapd is running..."
174 for i in 0 1 2 3 4 5; do
175 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
176 'objectclass=*' > /dev/null 2>&1
178 if test $RC = 0 ; then
181 echo "Waiting 5 seconds for slapd to start..."
184 if test $RC != 0 ; then
185 echo "ldapsearch failed ($RC)!"
186 test $KILLSERVERS != no && kill -HUP $KILLPIDS
190 cat /dev/null > $SEARCHOUT
192 mkdir -p $TESTDIR/$DATADIR
193 METABASEDN="o=Example,c=US"
194 #for f in $DATADIR/do_* ; do
195 # sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f
198 # add a read that matches only the local database, but selects
199 # also the remote as candidate; this should be removed to compare
200 # execution times with test008...
201 #for f in $TESTDIR/$DATADIR/do_read.* ; do
202 # echo "ou=Meta,$METABASEDN" >> $f
205 # add a read that matches a referral in the local database only,
206 # but selects also the remote as candidate; this should be removed
207 # to compare execution times with test008...
208 #for f in $TESTDIR/$DATADIR/do_read.* ; do
209 # echo "cn=Somewhere,ou=Meta,$METABASEDN" >> $f
212 # add a bind that resolves to a referral
213 #for f in $TESTDIR/$DATADIR/do_bind.* ; do
214 # echo "cn=Foo,ou=Meta,$METABASEDN" >> $f
285 > $TESTDIR/$DATADIR/do_search.0
287 echo "Using tester for concurrent server access..."
288 $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR/$DATADIR" -h $LOCALHOST -p $PORT3 \
289 -D "cn=Manager,$METABASEDN" -w $PASSWD -l $TESTLOOPS -r 20 -FF
292 if test $RC != 0 ; then
293 echo "slapd-tester failed ($RC)!"
294 test $KILLSERVERS != no && kill -HUP $KILLPIDS
298 echo "Using ldapsearch to retrieve all the entries..."
299 $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \
300 '(objectClass=*)' > $SEARCHOUT 2>&1
303 test $KILLSERVERS != no && kill -HUP $KILLPIDS
305 if test $RC != 0 ; then
306 echo "ldapsearch failed ($RC)!"
310 echo "Filtering ldapsearch results..."
311 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
312 echo "Filtering original ldif used to create database..."
313 $LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT
314 echo "Comparing filter output..."
315 $BCMP $SEARCHFLT $LDIFFLT > $CMPOUT
317 if test $? != 0 ; then
318 echo "comparison failed - slapd-meta search/modification didn't succeed"
322 echo ">>>>> Test succeeded"
324 test $KILLSERVERS != no && wait