]> git.sur5r.net Git - openldap/blob - tests/scripts/test039-glue-ldap-concurrency
add some failed binds (but don't log too much)
[openldap] / tests / scripts / test039-glue-ldap-concurrency
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2006 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.
11 ##
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>.
15
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 echo ""
20
21 if test $BACKLDAP = ldapno ; then 
22         echo "ldap backend not available, test skipped"
23         exit 0
24 fi
25
26 if test $RWM = rwmno ; then 
27         echo "rwm (rewrite/remap) overlay not available, test skipped"
28         exit 0
29 fi 
30
31 if test x$TESTLOOPS = x ; then
32         TESTLOOPS=50
33 fi
34
35 rm -rf $TESTDIR
36
37 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
38
39 echo "Starting slapd on TCP/IP port $PORT1..."
40 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
41 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
42 PID=$!
43 if test $WAIT != 0 ; then
44     echo PID $PID
45     read foo
46 fi
47 KILLPIDS="$PID"
48
49 sleep 1
50
51 echo "Using ldapsearch to check that slapd is running..."
52 for i in 0 1 2 3 4 5; do
53         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
54                 'objectclass=*' > /dev/null 2>&1
55         RC=$?
56         if test $RC = 0 ; then
57                 break
58         fi
59         echo "Waiting 5 seconds for slapd to start..."
60         sleep 5
61 done
62 if test $RC != 0 ; then
63         echo "ldapsearch failed ($RC)!"
64         test $KILLSERVERS != no && kill -HUP $KILLPIDS
65         exit $RC
66 fi
67
68 echo "Using ldapadd to populate the database..."
69 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
70         $LDIFORDERED > $TESTOUT 2>&1
71 RC=$?
72 if test $RC != 0 ; then
73         echo "ldapadd failed ($RC)!"
74         test $KILLSERVERS != no && kill -HUP $KILLPIDS
75         exit $RC
76 fi
77
78 echo "Starting slapd on TCP/IP port $PORT2..."
79 . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
80 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
81 PID=$!
82 if test $WAIT != 0 ; then
83     echo PID $PID
84     read foo
85 fi
86 KILLPIDS="$KILLPIDS $PID"
87
88 sleep 1
89
90 echo "Using ldapsearch to check that slapd is running..."
91 for i in 0 1 2 3 4 5; do
92         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
93                 'objectclass=*' > /dev/null 2>&1
94         RC=$?
95         if test $RC = 0 ; then
96                 break
97         fi
98         echo "Waiting 5 seconds for slapd to start..."
99         sleep 5
100 done
101 if test $RC != 0 ; then
102         echo "ldapsearch failed ($RC)!"
103         test $KILLSERVERS != no && kill -HUP $KILLPIDS
104         exit $RC
105 fi
106
107 echo "Using ldapadd to populate the database..."
108 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
109         $LDIFMETA >> $TESTOUT 2>&1
110 RC=$?
111 if test $RC != 0 ; then
112         echo "ldapadd failed ($RC)!"
113         test $KILLSERVERS != no && kill -HUP $KILLPIDS
114         exit $RC
115 fi
116
117 echo "Starting slapd on TCP/IP port $PORT3..."
118 . $CONFFILTER $BACKEND $MONITORDB < $GLUELDAPCONF > $CONF3
119 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
120 PID=$!
121 if test $WAIT != 0 ; then
122     echo PID $PID
123     read foo
124 fi
125 KILLPIDS="$KILLPIDS $PID"
126
127 sleep 1
128
129 echo "Using ldapsearch to check that slapd is running..."
130 for i in 0 1 2 3 4 5; do
131         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
132                 'objectclass=*' > /dev/null 2>&1
133         RC=$?
134         if test $RC = 0 ; then
135                 break
136         fi
137         echo "Waiting 5 seconds for slapd to start..."
138         sleep 5
139 done
140 if test $RC != 0 ; then
141         echo "ldapsearch failed ($RC)!"
142         test $KILLSERVERS != no && kill -HUP $KILLPIDS
143         exit $RC
144 fi
145
146 cat /dev/null > $SEARCHOUT
147
148 mkdir -p $TESTDIR/$DATADIR
149 METABASEDN="o=Example,c=US"
150 for f in $DATADIR/do_* ; do
151         sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f
152 done
153
154 # add a read that matches only the local database, but selects 
155 # also the remote as candidate; this should be removed to compare
156 # execution times with test008...
157 for f in $TESTDIR/$DATADIR/do_read.* ; do
158         echo "ou=Meta,$METABASEDN" >> $f
159 done
160
161 # add a read that matches a referral in the local database only, 
162 # but selects also the remote as candidate; this should be removed 
163 # to compare execution times with test008...
164 for f in $TESTDIR/$DATADIR/do_read.* ; do
165         echo "cn=Somewhere,ou=Meta,$METABASEDN" >> $f
166 done
167
168 # add a bind that resolves to a referral
169 for f in $TESTDIR/$DATADIR/do_bind.* ; do
170         echo "cn=Foo,ou=Meta,$METABASEDN" >> $f
171         echo "bar" >> $f
172 done
173
174 echo "Using tester for concurrent server access..."
175 $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR/$DATADIR" -h $LOCALHOST -p $PORT3 \
176         -D "cn=Manager,$METABASEDN" -w $PASSWD -l $TESTLOOPS -r 20 -FF
177 RC=$?
178
179 if test $RC != 0 ; then
180         echo "slapd-tester failed ($RC)!"
181         test $KILLSERVERS != no && kill -HUP $KILLPIDS
182         exit $RC
183 fi 
184
185 echo "Using ldapsearch to retrieve all the entries..."
186 $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \
187                         '(objectClass=*)' > $SEARCHOUT 2>&1
188 RC=$?
189
190 test $KILLSERVERS != no && kill -HUP $KILLPIDS
191
192 if test $RC != 0 ; then
193         echo "ldapsearch failed ($RC)!"
194         exit $RC
195 fi
196
197 echo "Filtering ldapsearch results..."
198 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
199 echo "Filtering original ldif used to create database..."
200 . $LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT
201 echo "Comparing filter output..."
202 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
203
204 if test $? != 0 ; then
205         echo "comparison failed - slapd-ldap search/modification didn't succeed"
206         exit 1
207 fi
208
209 echo ">>>>> Test succeeded"
210
211 test $KILLSERVERS != no && wait
212
213 exit 0