3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2012 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
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 # 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} ;;
22 echo "running defines.sh"
23 . $SRCDIR/scripts/defines.sh
25 if test $MONITORDB = "no" ; then
26 echo "Monitor backend not available, test skipped"
30 if test x$TESTLOOPS = x ; then
34 mkdir -p $TESTDIR $DBDIR1
37 # Populate and start up slapd server with some random data
40 echo "Running slapadd to build slapd database..."
41 . $CONFFILTER $BACKEND $MONITORDB < $MCONF > $ADDCONF
42 $SLAPADD -f $ADDCONF -l $LDIFORDERED
44 if test $RC != 0 ; then
45 echo "slapadd failed ($RC)!"
49 echo "Running slapindex to index slapd database..."
50 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
53 if test $RC != 0 ; then
54 echo "warning: slapindex failed ($RC)"
55 echo " assuming no indexing support"
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 &
62 if test $WAIT != 0 ; then
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
76 if test $RC = 0 ; then
79 echo "Waiting 5 seconds for slapd to start..."
83 if test $RC != 0 ; then
84 echo "mt-hot read failed ($RC)!"
85 test $KILLSERVERS != no && kill -HUP $KILLPIDS
89 cat /dev/null > $MTREADOUT
91 echo "Monitor searches"
92 # Perform a basic single threaded search on a single connection
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 \
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
104 if test $RC != 0 ; then
105 echo "slapd-mtread failed ($RC)!"
106 test $KILLSERVERS != no && kill -HUP $KILLPIDS
110 # Perform a basic multi-threaded search on a single connection
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 \
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
122 if test $RC != 0 ; then
123 echo "slapd-mtread failed ($RC)!"
124 test $KILLSERVERS != no && kill -HUP $KILLPIDS
128 # Perform a basic multi-threaded search on a single connection
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 \
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
140 if test $RC != 0 ; then
141 echo "slapd-mtread failed ($RC)!"
142 test $KILLSERVERS != no && kill -HUP $KILLPIDS
146 # Perform a single threaded random DB search on a single connection
147 echo "Random searches"
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
159 if test $RC != 0 ; then
160 echo "slapd-mtread failed ($RC)!"
161 test $KILLSERVERS != no && kill -HUP $KILLPIDS
165 # Perform a multi-threaded random DB search on a single connection
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
177 if test $RC != 0 ; then
178 echo "slapd-mtread failed ($RC)!"
179 test $KILLSERVERS != no && kill -HUP $KILLPIDS
183 # Perform a multi-threaded random DB search on a single connection
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
195 if test $RC != 0 ; then
196 echo "slapd-mtread failed ($RC)!"
197 test $KILLSERVERS != no && kill -HUP $KILLPIDS
201 # Perform a basic multi-threaded search using multiple connections
202 echo "Multiple threads and connection searches"
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 \
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
215 if test $RC != 0 ; then
216 echo "slapd-mtread failed ($RC)!"
217 test $KILLSERVERS != no && kill -HUP $KILLPIDS
221 # Perform a basic multi-threaded search using multiple connections
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 \
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
234 if test $RC != 0 ; then
235 echo "slapd-mtread failed ($RC)!"
236 test $KILLSERVERS != no && kill -HUP $KILLPIDS
240 # Perform a multi-threaded random DB search using multiple connections
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
253 if test $RC != 0 ; then
254 echo "slapd-mtread failed ($RC)!"
255 test $KILLSERVERS != no && kill -HUP $KILLPIDS
259 # Perform a multi-threaded random reads and writes using single connection
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
273 if test $RC != 0 ; then
274 echo "slapd-mtread failed ($RC)!"
275 test $KILLSERVERS != no && kill -HUP $KILLPIDS
279 # Perform a multi-threaded random reads and writes using multiple connections
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
293 if test $RC != 0 ; then
294 echo "slapd-mtread failed ($RC)!"
295 test $KILLSERVERS != no && kill -HUP $KILLPIDS
300 test $KILLSERVERS != no && kill -HUP $KILLPIDS
302 echo ">>>>> Test succeeded"