]> git.sur5r.net Git - openldap/blob - tests/scripts/sql-test001-concurrency
large X (for version.sh)
[openldap] / tests / scripts / sql-test001-concurrency
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2008 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 $BACKSQL = "sqlno" ; then 
20         echo "SQL backend not available, test skipped"
21         exit 0
22 fi 
23
24 if test $RDBMS = "rdbmsno" ; then
25         echo "SQL test not requested, test skipped"
26         exit 0
27 fi
28
29 SQLDATADIR=$TESTDIR/sql-concurrency
30 mkdir -p $TESTDIR $SQLDATADIR
31
32 echo "Starting slapd on TCP/IP port $PORT1..."
33 . $CONFFILTER $BACKEND $MONITORDB < $SQLCONF > $CONF1
34 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
35 PID=$!
36 if test $WAIT != 0 ; then
37     echo PID $PID
38     read foo
39 fi
40 KILLPIDS="$PID"
41
42 echo "Testing SQL backend concurrency..."
43 for i in 0 1 2 3 4 5; do
44         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
45                 'objectclass=*' > /dev/null 2>&1
46         RC=$?
47         if test $RC = 0 ; then
48                 break
49         fi
50         echo "Waiting 5 seconds for slapd to start..."
51         sleep 5
52 done
53
54 if test $RC != 0 ; then
55         echo "ldapsearch failed ($RC)!"
56         test $KILLSERVERS != no && kill -HUP $KILLPIDS
57         exit $RC
58 fi
59
60 echo "Using ldapsearch to retrieve all the entries..."
61 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
62                         '(objectClass=*)' > $SEARCHOUT 2>&1
63 RC=$?
64
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 "Filtering original ldif used to create database..."
72 . $LDIFFILTER < $SEARCHOUT > $LDIFFLT
73
74 if test "${RDBMSWRITE}" != "yes"; then
75         echo "write test disabled for ${RDBMS}; set SLAPD_USE_SQLWRITE=yes to enable"
76         cp $SQLCONCURRENCYDIR/do_read* $SQLCONCURRENCYDIR/do_search* \
77                 $SQLDATADIR
78 else
79         case ${RDBMS} in
80                 # list here the RDBMSes whose mapping allows writes
81         pgsql|ibmdb2)
82                 cp $SQLCONCURRENCYDIR/do_* $SQLDATADIR
83                 ;;
84         *)
85                 echo "write is not supported for ${RDBMS}; performing read-only concurrency test"
86                 cp $SQLCONCURRENCYDIR/do_read* $SQLCONCURRENCYDIR/do_search* \
87                         $SQLDATADIR
88                 ;;
89         esac
90 fi
91
92 echo "Using tester for concurrent server access..."
93 $SLAPDTESTER -P "$PROGDIR" -d "$SQLDATADIR" \
94         -h $LOCALHOST -p $PORT1 -D "$MANAGERDN" -w $PASSWD -l 5 -j 4
95 RC=$?
96
97 if test $RC != 0 ; then
98         echo "slapd-tester failed ($RC)!"
99         test $KILLSERVERS != no && kill -HUP $KILLPIDS
100         exit $RC
101 fi 
102
103 echo "Using ldapsearch to retrieve all the entries..."
104 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
105                         '(objectClass=*)' > $SEARCHOUT 2>&1
106 RC=$?
107
108 test $KILLSERVERS != no && kill -HUP $KILLPIDS
109
110 if test $RC != 0 ; then
111         echo "ldapsearch failed ($RC)!"
112         exit $RC
113 fi
114
115 echo "Filtering ldapsearch results..."
116 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
117 echo "Comparing filter output..."
118 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
119
120 if test $? != 0 ; then
121         echo "comparison failed - database was not created correctly"
122         exit 1
123 fi
124
125 echo ">>>>> Test succeeded"
126 exit 0
127