Debian Codegraph @

tests/scripts/lloadd/test002-load

raw
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 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 if test x$TESTLOOPS = x ; then
20 TESTLOOPS=50
21 fi
22
23 if test x$TESTCHILDREN = x ; then
24 TESTCHILDREN=20
25 fi
26
27 if test x$MAXRETRIES = x ; then
28 MAXRETRIES=5
29 fi
30
31 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
32
33 $SLAPPASSWD -g -n >$CONFIGPWF
34 echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
35
36 echo "Running slapadd to build slapd database..."
37 . $CONFFILTER $BACKEND < $CONF > $CONF2
38 $SLAPADD -f $CONF2 -l $LDIFORDERED
39 RC=$?
40 if test $RC != 0 ; then
41 echo "slapadd failed ($RC)!"
42 exit $RC
43 fi
44
45 echo "Starting a slapd on TCP/IP port $PORT2..."
46 $SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
47 PID=$!
48 if test $WAIT != 0 ; then
49 echo PID $PID
50 read foo
51 fi
52 PID2="$PID"
53 KILLPIDS="$PID"
54
55 for i in 0 1 2 3 4 5; do
56 $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
57 '(objectclass=*)' > /dev/null 2>&1
58 RC=$?
59 if test $RC = 0 ; then
60 break
61 fi
62 echo "Waiting $SLEEP1 seconds for slapd to start..."
63 sleep $SLEEP1
64 done
65 if test $RC != 0 ; then
66 echo "ldapsearch failed ($RC)!"
67 test $KILLSERVERS != no && kill -HUP $KILLPIDS
68 exit $RC
69 fi
70
71 echo "Running slapadd to build slapd database..."
72 . $CONFFILTER $BACKEND < $CONFTWO > $CONF3
73 $SLAPADD -f $CONF3 -l $LDIFORDERED
74 RC=$?
75 if test $RC != 0 ; then
76 echo "slapadd failed ($RC)!"
77 test $KILLSERVERS != no && kill -HUP $KILLPIDS
78 exit $RC
79 fi
80
81 echo "Running slapindex to index slapd database..."
82 $SLAPINDEX -f $CONF3
83 RC=$?
84 if test $RC != 0 ; then
85 echo "warning: slapindex failed ($RC)"
86 echo " assuming no indexing support"
87 fi
88
89 echo "Starting second slapd on TCP/IP port $PORT3..."
90 $SLAPD -f $CONF3 -h $URI3 -d $LVL > $LOG3 2>&1 &
91 PID=$!
92 if test $WAIT != 0 ; then
93 echo PID $PID
94 read foo
95 fi
96 PID2="$PID"
97 KILLPIDS="$KILLPIDS $PID"
98
99 sleep $SLEEP0
100
101 echo "Testing slapd searching..."
102 for i in 0 1 2 3 4 5; do
103 $LDAPSEARCH -s base -b "$MONITOR" -H $URI3 \
104 '(objectclass=*)' > /dev/null 2>&1
105 RC=$?
106 if test $RC = 0 ; then
107 break
108 fi
109 echo "Waiting $SLEEP1 seconds for slapd to start..."
110 sleep $SLEEP1
111 done
112 if test $RC != 0 ; then
113 echo "ldapsearch failed ($RC)!"
114 test $KILLSERVERS != no && kill -HUP $KILLPIDS
115 exit $RC
116 fi
117
118 echo "Starting lloadd on TCP/IP port $PORT1..."
119 . $CONFFILTER $BACKEND < $LLOADDCONF > $CONF1.lloadd
120 if test $AC_lloadd = lloaddyes; then
121 $LLOADD -f $CONF1.lloadd -h $URI1 -d $LVL > $LOG1 2>&1 &
122 else
123 . $CONFFILTER $BACKEND < $SLAPDLLOADCONF > $CONF1.slapd
124 # FIXME: this won't work on Windows, but lloadd doesn't support Windows yet
125 $SLAPD -f $CONF1.slapd -h $URI6 -d $LVL > $LOG1 2>&1 &
126 fi
127 PID=$!
128 if test $WAIT != 0 ; then
129 echo PID $PID
130 read foo
131 fi
132 KILLPIDS="$KILLPIDS $PID"
133
134 echo "Testing slapd searching..."
135 for i in 0 1 2 3 4 5; do
136 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
137 '(objectclass=*)' > /dev/null 2>&1
138 RC=$?
139 if test $RC = 0 ; then
140 break
141 fi
142 echo "Waiting $SLEEP1 seconds for lloadd to start..."
143 sleep $SLEEP1
144 done
145
146 if test $RC != 0 ; then
147 echo "ldapsearch failed ($RC)!"
148 test $KILLSERVERS != no && kill -HUP $KILLPIDS
149 exit $RC
150 fi
151
152 # fix test data to include back-monitor, if available
153 # NOTE: copies do_* files from $DATADIR to $TESTDIR
154 $MONITORDATA "$DATADIR" "$TESTDIR"
155
156
157 echo "Using tester for concurrent server access ($TESTCHILDREN x $TESTLOOPS ops)..."
158 $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR" \
159 -H $URI1 -D "$MANAGERDN" -w $PASSWD \
160 -t 1 -l $TESTLOOPS -r $MAXRETRIES -j $TESTCHILDREN \
161 -i '*INVALID_CREDENTIALS,*BUSY,UNWILLING_TO_PERFORM'
162 RC=$?
163
164 test $KILLSERVERS != no && kill -HUP $KILLPIDS
165
166 if test $RC != 0 ; then
167 echo "slapd-tester failed ($RC)!"
168 exit $RC
169 fi
170
171 echo ">>>>> Test succeeded"
172
173 test $KILLSERVERS != no && wait
174
175 exit 0