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