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