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