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