xref: /netbsd-src/external/bsd/openldap/dist/tests/scripts/lloadd/test002-load (revision e670fd5c413e99c2f6a37901bb21c537fcd322d2)
1*e670fd5cSchristos#! /bin/sh
2*e670fd5cSchristos# $OpenLDAP$
3*e670fd5cSchristos## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4*e670fd5cSchristos##
5*e670fd5cSchristos## Copyright 1998-2021 The OpenLDAP Foundation.
6*e670fd5cSchristos## All rights reserved.
7*e670fd5cSchristos##
8*e670fd5cSchristos## Redistribution and use in source and binary forms, with or without
9*e670fd5cSchristos## modification, are permitted only as authorized by the OpenLDAP
10*e670fd5cSchristos## Public License.
11*e670fd5cSchristos##
12*e670fd5cSchristos## A copy of this license is available in the file LICENSE in the
13*e670fd5cSchristos## top-level directory of the distribution or, alternatively, at
14*e670fd5cSchristos## <http://www.OpenLDAP.org/license.html>.
15*e670fd5cSchristos
16*e670fd5cSchristosecho "running defines.sh"
17*e670fd5cSchristos. $SRCDIR/scripts/defines.sh
18*e670fd5cSchristos
19*e670fd5cSchristosif test x$TESTLOOPS = x ; then
20*e670fd5cSchristos    TESTLOOPS=50
21*e670fd5cSchristosfi
22*e670fd5cSchristos
23*e670fd5cSchristosif test x$TESTCHILDREN = x ; then
24*e670fd5cSchristos    TESTCHILDREN=20
25*e670fd5cSchristosfi
26*e670fd5cSchristos
27*e670fd5cSchristosif test x$MAXRETRIES = x ; then
28*e670fd5cSchristos    MAXRETRIES=5
29*e670fd5cSchristosfi
30*e670fd5cSchristos
31*e670fd5cSchristosmkdir -p $TESTDIR $DBDIR1 $DBDIR2
32*e670fd5cSchristos
33*e670fd5cSchristos$SLAPPASSWD -g -n >$CONFIGPWF
34*e670fd5cSchristosecho "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
35*e670fd5cSchristos
36*e670fd5cSchristosecho "Running slapadd to build slapd database..."
37*e670fd5cSchristos. $CONFFILTER $BACKEND < $CONF > $CONF2
38*e670fd5cSchristos$SLAPADD -f $CONF2 -l $LDIFORDERED
39*e670fd5cSchristosRC=$?
40*e670fd5cSchristosif test $RC != 0 ; then
41*e670fd5cSchristos    echo "slapadd failed ($RC)!"
42*e670fd5cSchristos    exit $RC
43*e670fd5cSchristosfi
44*e670fd5cSchristos
45*e670fd5cSchristosecho "Starting a slapd on TCP/IP port $PORT2..."
46*e670fd5cSchristos$SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
47*e670fd5cSchristosPID=$!
48*e670fd5cSchristosif test $WAIT != 0 ; then
49*e670fd5cSchristos    echo PID $PID
50*e670fd5cSchristos    read foo
51*e670fd5cSchristosfi
52*e670fd5cSchristosPID2="$PID"
53*e670fd5cSchristosKILLPIDS="$PID"
54*e670fd5cSchristos
55*e670fd5cSchristosfor i in 0 1 2 3 4 5; do
56*e670fd5cSchristos    $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
57*e670fd5cSchristos        '(objectclass=*)' > /dev/null 2>&1
58*e670fd5cSchristos    RC=$?
59*e670fd5cSchristos    if test $RC = 0 ; then
60*e670fd5cSchristos        break
61*e670fd5cSchristos    fi
62*e670fd5cSchristos    echo "Waiting $SLEEP1 seconds for slapd to start..."
63*e670fd5cSchristos    sleep $SLEEP1
64*e670fd5cSchristosdone
65*e670fd5cSchristosif test $RC != 0 ; then
66*e670fd5cSchristos    echo "ldapsearch failed ($RC)!"
67*e670fd5cSchristos    test $KILLSERVERS != no && kill -HUP $KILLPIDS
68*e670fd5cSchristos    exit $RC
69*e670fd5cSchristosfi
70*e670fd5cSchristos
71*e670fd5cSchristosecho "Running slapadd to build slapd database..."
72*e670fd5cSchristos. $CONFFILTER $BACKEND < $CONFTWO > $CONF3
73*e670fd5cSchristos$SLAPADD -f $CONF3 -l $LDIFORDERED
74*e670fd5cSchristosRC=$?
75*e670fd5cSchristosif test $RC != 0 ; then
76*e670fd5cSchristos    echo "slapadd failed ($RC)!"
77*e670fd5cSchristos    exit $RC
78*e670fd5cSchristosfi
79*e670fd5cSchristos
80*e670fd5cSchristosecho "Running slapindex to index slapd database..."
81*e670fd5cSchristos$SLAPINDEX -f $CONF3
82*e670fd5cSchristosRC=$?
83*e670fd5cSchristosif test $RC != 0 ; then
84*e670fd5cSchristos    echo "warning: slapindex failed ($RC)"
85*e670fd5cSchristos    echo "  assuming no indexing support"
86*e670fd5cSchristosfi
87*e670fd5cSchristos
88*e670fd5cSchristosecho "Starting second slapd on TCP/IP port $PORT3..."
89*e670fd5cSchristos$SLAPD -f $CONF3 -h $URI3 -d $LVL > $LOG3 2>&1 &
90*e670fd5cSchristosPID=$!
91*e670fd5cSchristosif test $WAIT != 0 ; then
92*e670fd5cSchristos    echo PID $PID
93*e670fd5cSchristos    read foo
94*e670fd5cSchristosfi
95*e670fd5cSchristosPID2="$PID"
96*e670fd5cSchristosKILLPIDS="$KILLPIDS $PID"
97*e670fd5cSchristos
98*e670fd5cSchristossleep $SLEEP0
99*e670fd5cSchristos
100*e670fd5cSchristosecho "Testing slapd searching..."
101*e670fd5cSchristosfor i in 0 1 2 3 4 5; do
102*e670fd5cSchristos    $LDAPSEARCH -s base -b "$MONITOR" -H $URI3 \
103*e670fd5cSchristos        '(objectclass=*)' > /dev/null 2>&1
104*e670fd5cSchristos    RC=$?
105*e670fd5cSchristos    if test $RC = 0 ; then
106*e670fd5cSchristos        break
107*e670fd5cSchristos    fi
108*e670fd5cSchristos    echo "Waiting $SLEEP1 seconds for slapd to start..."
109*e670fd5cSchristos    sleep $SLEEP1
110*e670fd5cSchristosdone
111*e670fd5cSchristosif test $RC != 0 ; then
112*e670fd5cSchristos    echo "ldapsearch failed ($RC)!"
113*e670fd5cSchristos    test $KILLSERVERS != no && kill -HUP $KILLPIDS
114*e670fd5cSchristos    exit $RC
115*e670fd5cSchristosfi
116*e670fd5cSchristos
117*e670fd5cSchristosecho "Starting lloadd on TCP/IP port $PORT1..."
118*e670fd5cSchristos. $CONFFILTER $BACKEND < $LLOADDCONF > $CONF1.lloadd
119*e670fd5cSchristosif test $AC_lloadd = lloaddyes; then
120*e670fd5cSchristos    $LLOADD -f $CONF1.lloadd -h $URI1 -d $LVL > $LOG1 2>&1 &
121*e670fd5cSchristoselse
122*e670fd5cSchristos    . $CONFFILTER $BACKEND < $SLAPDLLOADCONF > $CONF1.slapd
123*e670fd5cSchristos    # FIXME: this won't work on Windows, but lloadd doesn't support Windows yet
124*e670fd5cSchristos    $SLAPD -f $CONF1.slapd -h $URI6 -d $LVL > $LOG1 2>&1 &
125*e670fd5cSchristosfi
126*e670fd5cSchristosPID=$!
127*e670fd5cSchristosif test $WAIT != 0 ; then
128*e670fd5cSchristos    echo PID $PID
129*e670fd5cSchristos    read foo
130*e670fd5cSchristosfi
131*e670fd5cSchristosKILLPIDS="$KILLPIDS $PID"
132*e670fd5cSchristos
133*e670fd5cSchristosecho "Testing slapd searching..."
134*e670fd5cSchristosfor i in 0 1 2 3 4 5; do
135*e670fd5cSchristos    $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
136*e670fd5cSchristos        '(objectclass=*)' > /dev/null 2>&1
137*e670fd5cSchristos    RC=$?
138*e670fd5cSchristos    if test $RC = 0 ; then
139*e670fd5cSchristos        break
140*e670fd5cSchristos    fi
141*e670fd5cSchristos    echo "Waiting $SLEEP1 seconds for lloadd to start..."
142*e670fd5cSchristos    sleep $SLEEP1
143*e670fd5cSchristosdone
144*e670fd5cSchristos
145*e670fd5cSchristosif test $RC != 0 ; then
146*e670fd5cSchristos    echo "ldapsearch failed ($RC)!"
147*e670fd5cSchristos    test $KILLSERVERS != no && kill -HUP $KILLPIDS
148*e670fd5cSchristos    exit $RC
149*e670fd5cSchristosfi
150*e670fd5cSchristos
151*e670fd5cSchristos# fix test data to include back-monitor, if available
152*e670fd5cSchristos# NOTE: copies do_* files from $DATADIR to $TESTDIR
153*e670fd5cSchristos$MONITORDATA "$DATADIR" "$TESTDIR"
154*e670fd5cSchristos
155*e670fd5cSchristos
156*e670fd5cSchristosecho "Using tester for concurrent server access ($TESTCHILDREN x $TESTLOOPS ops)..."
157*e670fd5cSchristos$SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR" \
158*e670fd5cSchristos    -H $URI1 -D "$MANAGERDN" -w $PASSWD \
159*e670fd5cSchristos    -t 1 -l $TESTLOOPS -r $MAXRETRIES -j $TESTCHILDREN \
160*e670fd5cSchristos    -i '*INVALID_CREDENTIALS,*BUSY,UNWILLING_TO_PERFORM'
161*e670fd5cSchristosRC=$?
162*e670fd5cSchristos
163*e670fd5cSchristostest $KILLSERVERS != no && kill -HUP $KILLPIDS
164*e670fd5cSchristos
165*e670fd5cSchristosif test $RC != 0 ; then
166*e670fd5cSchristos    echo "slapd-tester failed ($RC)!"
167*e670fd5cSchristos    exit $RC
168*e670fd5cSchristosfi
169*e670fd5cSchristos
170*e670fd5cSchristosecho ">>>>> Test succeeded"
171*e670fd5cSchristos
172*e670fd5cSchristostest $KILLSERVERS != no && wait
173*e670fd5cSchristos
174*e670fd5cSchristosexit 0
175