]> git.sur5r.net Git - openldap/blob - tests/scripts/test008-concurrency
Added optional 3rd parameter, to make the script display the slapd pid
[openldap] / tests / scripts / test008-concurrency
1 #! /bin/sh
2 # $OpenLDAP$
3
4 SRCDIR="."
5 if test $# -ge 1 ; then
6         SRCDIR=$1; shift
7 fi
8 BACKEND=ldbm
9 if test $# -ge 1 ; then
10         BACKEND=$1; shift
11 fi
12 WAIT=0
13 if test $# -ge 1 ; then
14         WAIT=1; shift
15 fi
16
17 echo "running defines.sh"
18 . $SRCDIR/scripts/defines.sh
19
20 echo "Datadir is $DATADIR"
21
22 echo "Cleaning up in $DBDIR..."
23
24 rm -f $DBDIR/[!C]*
25
26 echo "Running slapadd to build slapd database..."
27 . $CONFFILTER $BACKEND < $CONF > $DBCONF
28 $SLAPADD -f $DBCONF -l $LDIFORDERED
29 RC=$?
30 if test $RC != 0 ; then
31         echo "slapadd failed ($RC)!"
32         exit $RC
33 fi
34
35 echo "Waiting 5 seconds for slapadd to build slapd database..."
36 sleep 5
37
38 echo "Starting slapd on TCP/IP port $PORT..."
39 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
40 PID=$!
41 if test $WAIT != 0 ; then
42     echo PID $PID
43     read foo
44 fi
45
46 echo "Using ldapsearch to check that slapd is running..."
47 for i in 0 1 2 3 4 5; do
48         $LDAPSEARCH -s base -b "$MONITOR" -h localhost -p $PORT \
49                 'objectclass=*' > /dev/null 2>&1
50         RC=$?
51         if test $RC = 1 ; then
52                 echo "Waiting 5 seconds for slapd to start..."
53                 sleep 5
54         fi
55 done
56
57 echo "Using tester for concurrent server access..."
58 $SLAPDTESTER -b "$BASEDN" -P "$PROGDIR" -d "$DATADIR" -h localhost -p $PORT -D "$MANAGERDN" -w $PASSWD -l 50
59 RC=$?
60
61 if test $RC != 0 ; then
62         echo "slapd-tester failed ($RC)!"
63         exit $RC
64 fi 
65
66 echo "Using ldapsearch to retrieve all the entries..."
67 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
68                         'objectClass=*' > $SEARCHOUT 2>&1
69 RC=$?
70
71 kill -HUP $PID
72
73 if test $RC != 0 ; then
74         echo "ldapsearch failed ($RC)!"
75         exit $RC
76 fi
77
78 echo "Filtering ldapsearch results..."
79 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
80 echo "Filtering original ldif used to create database..."
81 . $LDIFFILTER < $LDIF > $LDIFFLT
82 echo "Comparing filter output..."
83 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
84
85 if test $? != 0 ; then
86         echo "comparison failed - database was not created correctly"
87         exit 1
88 fi
89
90 echo ">>>>> Test succeeded"
91
92
93 exit 0