Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / openldap / dist / tests / scripts / test036-meta-concurrency
blobae75d978c12c8fce75e16407089e74454426b206
1 #! /bin/sh
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/>.
4 ##
5 ## Copyright 1998-2008 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
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
19 echo ""
21 if test $BACKMETA = metano ; then
22 echo "meta backend not available, test skipped"
23 exit 0
26 if test $BACKLDAP = ldapno ; then
27 echo "ldap backend not available, test skipped"
28 exit 0
31 if test x$TESTLOOPS = x ; then
32 TESTLOOPS=50
35 rm -rf $TESTDIR
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\""
44 cp $DB_CONFIG $DBDIR1
45 cp $DB_CONFIG $DBDIR2
46 else
47 echo "==> DB_CONFIG must point to a valid file (ignored)"
49 else
50 echo "==> set \"DB_CONFIG\" to the DB_CONFIG file you want to use for the test."
52 echo ""
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 &
58 PID=$!
59 if test $WAIT != 0 ; then
60 echo PID $PID
61 read foo
63 KILLPIDS="$PID"
65 sleep 1
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
71 RC=$?
72 if test $RC = 0 ; then
73 break
75 echo "Waiting 5 seconds for slapd to start..."
76 sleep 5
77 done
78 if test $RC != 0 ; then
79 echo "ldapsearch failed ($RC)!"
80 test $KILLSERVERS != no && kill -HUP $KILLPIDS
81 exit $RC
84 echo "Using ldapadd to populate the database..."
85 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
86 $LDIFORDERED > $TESTOUT 2>&1
87 RC=$?
88 if test $RC != 0 ; then
89 echo "ldapadd failed ($RC)!"
90 test $KILLSERVERS != no && kill -HUP $KILLPIDS
91 exit $RC
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 &
97 PID=$!
98 if test $WAIT != 0 ; then
99 echo PID $PID
100 read foo
102 KILLPIDS="$KILLPIDS $PID"
104 sleep 1
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
110 RC=$?
111 if test $RC = 0 ; then
112 break
114 echo "Waiting 5 seconds for slapd to start..."
115 sleep 5
116 done
117 if test $RC != 0 ; then
118 echo "ldapsearch failed ($RC)!"
119 test $KILLSERVERS != no && kill -HUP $KILLPIDS
120 exit $RC
123 echo "Using ldapadd to populate the database..."
124 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
125 $LDIFMETA >> $TESTOUT 2>&1
126 RC=$?
127 if test $RC != 0 ; then
128 echo "ldapadd failed ($RC)!"
129 test $KILLSERVERS != no && kill -HUP $KILLPIDS
130 exit $RC
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 &
136 PID=$!
137 if test $WAIT != 0 ; then
138 echo PID $PID
139 read foo
141 KILLPIDS="$KILLPIDS $PID"
143 sleep 1
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
149 RC=$?
150 if test $RC = 0 ; then
151 break
153 echo "Waiting 5 seconds for slapd to start..."
154 sleep 5
155 done
156 if test $RC != 0 ; then
157 echo "ldapsearch failed ($RC)!"
158 test $KILLSERVERS != no && kill -HUP $KILLPIDS
159 exit $RC
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
168 done
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
175 done
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
182 done
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
187 echo "bar" >> $f
188 echo "" >> $f
189 echo "" >> $f
190 done
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 \
195 -i '!REFERRAL'
196 RC=$?
198 if test $RC != 0 ; then
199 echo "slapd-tester failed ($RC)!"
200 test $KILLSERVERS != no && kill -HUP $KILLPIDS
201 exit $RC
204 echo "Using ldapsearch to retrieve all the entries..."
205 $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \
206 'objectClass=*' > $SEARCHOUT 2>&1
207 RC=$?
209 test $KILLSERVERS != no && kill -HUP $KILLPIDS
211 if test $RC != 0 ; then
212 echo "ldapsearch failed ($RC)!"
213 exit $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"
225 exit 1
228 echo ">>>>> Test succeeded"
230 test $KILLSERVERS != no && wait
232 exit 0