]> git.sur5r.net Git - openldap/blob - tests/scripts/test060-mt-hot
Merge remote branch 'origin/mdb.master'
[openldap] / tests / scripts / test060-mt-hot
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2011 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 # The default debug level logs more than 1Gb:
17 SLAPD_DEBUG=${SLAPD_DEBUG_MT_HOT-stats}
18
19 echo "running defines.sh"
20 . $SRCDIR/scripts/defines.sh
21
22 if test $MONITORDB = "no" ; then 
23         echo "Monitor backend not available, test skipped"
24         exit 0
25 fi 
26
27 if test x$TESTLOOPS = x ; then
28         TESTLOOPS=50
29 fi
30
31 mkdir -p $TESTDIR $DBDIR1
32
33 #
34 # Populate and start up slapd server with some random data
35 #
36
37 echo "Running slapadd to build slapd database..."
38 . $CONFFILTER $BACKEND $MONITORDB < $MCONF > $ADDCONF
39 $SLAPADD -f $ADDCONF -l $LDIFORDERED
40 RC=$?
41 if test $RC != 0 ; then
42         echo "slapadd failed ($RC)!"
43         exit $RC
44 fi
45
46 echo "Running slapindex to index slapd database..."
47 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
48 $SLAPINDEX -f $CONF1
49 RC=$?
50 if test $RC != 0 ; then
51         echo "warning: slapindex failed ($RC)"
52         echo "  assuming no indexing support"
53 fi
54
55 echo "Starting slapd on TCP/IP port $PORT1..."
56 echo $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING
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
62 fi
63 KILLPIDS="$PID"
64
65 sleep 1
66
67 # Perform a basic search, make sure of a functional setup
68 echo "Testing basic monitor search..."
69 for i in 0 1 2 3 4 5; do
70         $LDAPSEARCH -s base -b "$MONITORDN" -H $URI1 \
71                 '(objectclass=*)' > /dev/null 2>&1
72         RC=$?
73         if test $RC = 0 ; then
74                 break
75         fi
76         echo "Waiting 5 seconds for slapd to start..."
77         sleep 5
78 done
79
80 if test $RC != 0 ; then
81         echo "mt-hot read failed ($RC)!"
82         test $KILLSERVERS != no && kill -HUP $KILLPIDS
83         exit $RC
84 fi
85
86 cat /dev/null > $MTREADOUT
87
88 echo "Monitor searches"
89 # Perform a basic single threaded search on a single connection
90 THR=1
91 OUTER=1
92 INNER=`expr $TESTLOOPS \* 1000`
93 echo "Testing basic mt-hot search: $THR threads ($OUTER x $INNER) loops..."
94 echo $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
95         -e "$MONITORDN" \
96         -m $THR -L $OUTER -l $INNER
97 $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
98         -e "$MONITORDN" -f "(objectclass=*)" \
99         -m $THR -L $OUTER -l $INNER >> $MTREADOUT 2>&1
100 RC=$?
101 if test $RC != 0 ; then
102         echo "slapd-mtread failed ($RC)!"
103         test $KILLSERVERS != no && kill -HUP $KILLPIDS
104         exit $RC
105 fi
106
107 # Perform a basic multi-threaded search on a single connection
108 THR=5
109 OUTER=1
110 INNER=`expr $TESTLOOPS \* 200`
111 echo "Testing basic mt-hot search: $THR threads ($OUTER x $INNER) loops..."
112 echo $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
113         -e "$MONITORDN" \
114         -m $THR -L $OUTER -l $INNER
115 $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
116         -e "$MONITORDN" -f "(objectclass=*)" \
117         -m $THR -L $OUTER -l $INNER >> $MTREADOUT 2>&1
118 RC=$?
119 if test $RC != 0 ; then
120         echo "slapd-mtread failed ($RC)!"
121         test $KILLSERVERS != no && kill -HUP $KILLPIDS
122         exit $RC
123 fi
124
125 # Perform a basic multi-threaded search on a single connection
126 THR=100
127 OUTER=5
128 INNER=`expr $TESTLOOPS \* 2`
129 echo "Testing basic mt-hot search: $THR threads ($OUTER x $INNER) loops..."
130 echo $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
131         -e "$MONITORDN" \
132         -m $THR -L $OUTER -l $INNER
133 $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
134         -e "$MONITORDN" -f "(objectclass=*)" \
135         -m $THR -L $OUTER -l $INNER >> $MTREADOUT 2>&1
136 RC=$?
137 if test $RC != 0 ; then
138         echo "slapd-mtread failed ($RC)!"
139         test $KILLSERVERS != no && kill -HUP $KILLPIDS
140         exit $RC
141 fi
142
143 # Perform a single threaded random DB search on a single connection
144 echo "Random searches"
145 THR=1
146 OUTER=1
147 INNER=`expr $TESTLOOPS \* 1000`
148 echo "Testing random mt-hot search: $THR threads ($OUTER x $INNER) loops..."
149 echo $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
150         -e "$BASEDN" -f "(objectclass=*)" \
151         -m $THR -L $OUTER -l $INNER
152 $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
153         -e "$BASEDN" -f "(objectclass=*)" \
154         -m $THR -L $OUTER -l $INNER >> $MTREADOUT 2>&1
155 RC=$?
156 if test $RC != 0 ; then
157         echo "slapd-mtread failed ($RC)!"
158         test $KILLSERVERS != no && kill -HUP $KILLPIDS
159         exit $RC
160 fi
161
162 # Perform a multi-threaded random DB search on a single connection
163 THR=5
164 OUTER=1
165 INNER=`expr $TESTLOOPS \* 200`
166 echo "Testing random mt-hot search: $THR threads ($OUTER x $INNER) loops..."
167 echo $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
168         -e "$BASEDN" -f "(objectclass=*)" \
169         -m $THR -L $OUTER -l $INNER
170 $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
171         -e "$BASEDN" -f "(objectclass=*)" \
172         -m $THR -L $OUTER -l $INNER >> $MTREADOUT 2>&1
173 RC=$?
174 if test $RC != 0 ; then
175         echo "slapd-mtread failed ($RC)!"
176         test $KILLSERVERS != no && kill -HUP $KILLPIDS
177         exit $RC
178 fi
179
180 # Perform a multi-threaded random DB search on a single connection
181 THR=100
182 OUTER=5
183 INNER=`expr $TESTLOOPS \* 2`
184 echo "Testing random mt-hot search: $THR threads ($OUTER x $INNER) loops..."
185 echo $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
186         -e "$BASEDN" -f "(objectclass=*)" \
187         -m $THR -L $OUTER -l $INNER
188 $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
189         -e "$BASEDN" -f "(objectclass=*)" \
190         -m $THR -L $OUTER -l $INNER >> $MTREADOUT 2>&1
191 RC=$?
192 if test $RC != 0 ; then
193         echo "slapd-mtread failed ($RC)!"
194         test $KILLSERVERS != no && kill -HUP $KILLPIDS
195         exit $RC
196 fi
197
198 # Perform a basic multi-threaded search using multiple connections
199 echo "Multiple threads and connection searches"
200 CONN=5
201 THR=5
202 OUTER=1
203 INNER=`expr $TESTLOOPS \* 200`
204 echo "Testing basic mt-hot search: $THR threads $CONN conns ($OUTER x $INNER) loops..."
205 echo $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
206         -e "$MONITORDN" \
207         -c $CONN -m $THR -L $OUTER -l $INNER
208 $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
209         -e "$MONITORDN" -f "(objectclass=*)" \
210         -c $CONN -m $THR -L $OUTER -l $INNER >> $MTREADOUT 2>&1
211 RC=$?
212 if test $RC != 0 ; then
213         echo "slapd-mtread failed ($RC)!"
214         test $KILLSERVERS != no && kill -HUP $KILLPIDS
215         exit $RC
216 fi
217
218 # Perform a basic multi-threaded search using multiple connections
219 CONN=5
220 THR=50
221 OUTER=5
222 INNER=`expr $TESTLOOPS \* 20`
223 echo "Testing basic mt-hot search: $THR threads $CONN conns ($OUTER x $INNER) loops..."
224 echo $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
225         -e "$MONITORDN" \
226         -c $CONN -m $THR -L $OUTER -l $INNER
227 $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
228         -e "$MONITORDN" -f "(objectclass=*)" \
229         -c $CONN -m $THR -L $OUTER -l $INNER >> $MTREADOUT 2>&1
230 RC=$?
231 if test $RC != 0 ; then
232         echo "slapd-mtread failed ($RC)!"
233         test $KILLSERVERS != no && kill -HUP $KILLPIDS
234         exit $RC
235 fi
236
237 # Perform a multi-threaded random DB search using multiple connections
238 CONN=5
239 THR=100
240 OUTER=5
241 INNER=`expr $TESTLOOPS \* 2`
242 echo "Testing random mt-hot search: $THR threads $CONN conns ($OUTER x $INNER) loops..."
243 echo $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
244         -e "$BASEDN" -f "(objectclass=*)" \
245         -c $CONN -m $THR -L $OUTER -l $INNER
246 $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
247         -e "$BASEDN" -f "(objectclass=*)" \
248         -c $CONN -m $THR -L $OUTER -l $INNER >> $MTREADOUT 2>&1
249 RC=$?
250 if test $RC != 0 ; then
251         echo "slapd-mtread failed ($RC)!"
252         test $KILLSERVERS != no && kill -HUP $KILLPIDS
253         exit $RC
254 fi
255
256 # Perform a multi-threaded random reads and writes using single connection
257 CONN=1
258 THR=10
259 WTHR=10
260 OUTER=5
261 INNER=`expr $TESTLOOPS \* 2`
262 echo "Testing random mt-hot r/w search: $THR read threads $WTHR write threads $CONN conns ($OUTER x $INNER) loops..."
263 echo $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
264         -e "$BASEDN" -f "(&(!(cn=rwtest*))(objectclass=*))" \
265         -c $CONN -m $THR -M $WTHR -L $OUTER -l $INNER
266 $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
267         -e "$BASEDN" -f "(&(!(cn=rwtest*))(objectclass=*))" \
268         -c $CONN -m $THR -M $WTHR -L $OUTER -l $INNER >> $MTREADOUT 2>&1
269 RC=$?
270 if test $RC != 0 ; then
271         echo "slapd-mtread failed ($RC)!"
272         test $KILLSERVERS != no && kill -HUP $KILLPIDS
273         exit $RC
274 fi
275
276 # Perform a multi-threaded random reads and writes using multiple connections
277 CONN=5
278 THR=10
279 WTHR=10
280 OUTER=5
281 INNER=`expr $TESTLOOPS \* 2`
282 echo "Testing random mt-hot r/w search: $THR read threads $WTHR write threads $CONN conns ($OUTER x $INNER) loops..."
283 echo $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
284         -e "$BASEDN" -f "(&(!(cn=rwtest*))(objectclass=*))" \
285         -c $CONN -m $THR -M $WTHR -L $OUTER -l $INNER
286 $SLAPDMTREAD -H $URI1 -D "$MANAGERDN" -w $PASSWD \
287         -e "$BASEDN" -f "(&(!(cn=rwtest*))(objectclass=*))" \
288         -c $CONN -m $THR -M $WTHR -L $OUTER -l $INNER >> $MTREADOUT 2>&1
289 RC=$?
290 if test $RC != 0 ; then
291         echo "slapd-mtread failed ($RC)!"
292         test $KILLSERVERS != no && kill -HUP $KILLPIDS
293         exit $RC
294 fi
295
296
297 test $KILLSERVERS != no && kill -HUP $KILLPIDS
298
299 echo ">>>>> Test succeeded"
300
301 exit 0