2 # $OpenLDAP: pkg/ldap/tests/scripts/test036-meta-concurrency,v 1.17.2.6 2008/07/09 23:51:35 quanah Exp $
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2008 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 echo "Using tester for concurrent server access..."
193 $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR/$DATADIR" -h $LOCALHOST -p $PORT3 \
194 -D "cn=Manager,$METABASEDN" -w $PASSWD -l $TESTLOOPS -r 20 -FF \
198 if test $RC != 0 ; then
199 echo "slapd-tester failed ($RC)!"
200 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
204 echo "Using ldapsearch to retrieve all the entries..."
205 $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \
206 'objectClass=*' > $SEARCHOUT 2>&1
209 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
211 if test $RC != 0 ; then
212 echo "ldapsearch failed ($RC)!"
216 echo "Filtering ldapsearch results..."
217 .
$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
218 echo "Filtering original ldif used to create database..."
219 .
$LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT
220 echo "Comparing filter output..."
221 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
223 if test $?
!= 0 ; then
224 echo "comparison failed - slapd-meta search/modification didn't succeed"
228 echo ">>>>> Test succeeded"
230 test $KILLSERVERS != no
&& wait