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