]> git.sur5r.net Git - openldap/blob - tests/scripts/test039-glue-ldap-concurrency
add new glued ldap concurrency test
[openldap] / tests / scripts / test039-glue-ldap-concurrency
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2005 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 echo ""
20
21 if test $BACKLDAP = ldapno ; then 
22         echo "ldap backend not available, test skipped"
23         exit 0
24 fi
25
26 if test $GLUE = "glueno" ; then 
27         echo "glue overlay not available, test skipped"
28         exit 0
29 fi 
30
31 if test $RWM = rwmno ; then 
32         echo "rwm (rewrite/remap) overlay not available, test skipped"
33         exit 0
34 fi 
35
36 rm -rf $TESTDIR
37
38 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
39
40 echo "Starting slapd on TCP/IP port $PORT1..."
41 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
42 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
43 PID=$!
44 if test $WAIT != 0 ; then
45     echo PID $PID
46     read foo
47 fi
48 KILLPIDS="$PID"
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 $PORT1 \
53                 'objectclass=*' > /dev/null 2>&1
54         RC=$?
55         if test $RC = 0 ; then
56                 break
57         fi
58         echo "Waiting 5 seconds for slapd to start..."
59         sleep 5
60 done
61 if test $RC != 0 ; then
62         echo "ldapsearch failed ($RC)!"
63         test $KILLSERVERS != no && kill -HUP $KILLPIDS
64         exit $RC
65 fi
66
67 echo "Using ldapadd to populate the database..."
68 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
69         $LDIFORDERED > $TESTOUT 2>&1
70 RC=$?
71 if test $RC != 0 ; then
72         echo "ldapadd failed ($RC)!"
73         test $KILLSERVERS != no && kill -HUP $KILLPIDS
74         exit $RC
75 fi
76
77 echo "Starting slapd on TCP/IP port $PORT2..."
78 . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
79 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
80 PID=$!
81 if test $WAIT != 0 ; then
82     echo PID $PID
83     read foo
84 fi
85 KILLPIDS="$KILLPIDS $PID"
86
87 echo "Using ldapsearch to check that slapd is running..."
88 for i in 0 1 2 3 4 5; do
89         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
90                 'objectclass=*' > /dev/null 2>&1
91         RC=$?
92         if test $RC = 0 ; then
93                 break
94         fi
95         echo "Waiting 5 seconds for slapd to start..."
96         sleep 5
97 done
98 if test $RC != 0 ; then
99         echo "ldapsearch failed ($RC)!"
100         test $KILLSERVERS != no && kill -HUP $KILLPIDS
101         exit $RC
102 fi
103
104 echo "Using ldapadd to populate the database..."
105 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
106         $LDIFMETA >> $TESTOUT 2>&1
107 RC=$?
108 if test $RC != 0 ; then
109         echo "ldapadd failed ($RC)!"
110         test $KILLSERVERS != no && kill -HUP $KILLPIDS
111         exit $RC
112 fi
113
114 echo "Starting slapd on TCP/IP port $PORT3..."
115 . $CONFFILTER $BACKEND $MONITORDB < $GLUELDAPCONF > $CONF3
116 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
117 PID=$!
118 if test $WAIT != 0 ; then
119     echo PID $PID
120     read foo
121 fi
122 KILLPIDS="$KILLPIDS $PID"
123
124 echo "Using ldapsearch to check that slapd is running..."
125 for i in 0 1 2 3 4 5; do
126         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
127                 'objectclass=*' > /dev/null 2>&1
128         RC=$?
129         if test $RC = 0 ; then
130                 break
131         fi
132         echo "Waiting 5 seconds for slapd to start..."
133         sleep 5
134 done
135 if test $RC != 0 ; then
136         echo "ldapsearch failed ($RC)!"
137         test $KILLSERVERS != no && kill -HUP $KILLPIDS
138         exit $RC
139 fi
140
141 cat /dev/null > $SEARCHOUT
142
143 mkdir -p $TESTDIR/$DATADIR
144 METABASEDN="o=Example,c=US"
145 for f in $DATADIR/do_* ; do
146         sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f
147 done
148
149 # add a read that matches only the local database, but selects 
150 # also the remote as candidate; this should be removed to compare
151 # execution times with test008...
152 for f in $TESTDIR/$DATADIR/do_read.* ; do
153         echo "ou=Meta,$METABASEDN" >> $f
154 done
155
156 # add a read that matches a referral in the local database only, 
157 # but selects also the remote as candidate; this should be removed 
158 # to compare execution times with test008...
159 for f in $TESTDIR/$DATADIR/do_read.* ; do
160         echo "cn=Somewhere,ou=Meta,$METABASEDN" >> $f
161 done
162
163 echo "Using tester for concurrent server access..."
164 $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR/$DATADIR" -h $LOCALHOST -p $PORT3 -D "cn=Manager,$METABASEDN" -w $PASSWD -l 50 # -r 20
165 RC=$?
166
167 if test $RC != 0 ; then
168         echo "slapd-tester failed ($RC)!"
169         test $KILLSERVERS != no && kill -HUP $KILLPIDS
170         exit $RC
171 fi 
172
173 echo "Using ldapsearch to retrieve all the entries..."
174 $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \
175                         '(objectClass=*)' > $SEARCHOUT 2>&1
176 RC=$?
177
178 test $KILLSERVERS != no && kill -HUP $KILLPIDS
179
180 if test $RC != 0 ; then
181         echo "ldapsearch failed ($RC)!"
182         exit $RC
183 fi
184
185 echo "Filtering ldapsearch results..."
186 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
187 echo "Filtering original ldif used to create database..."
188 . $LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT
189 echo "Comparing filter output..."
190 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
191
192 if test $? != 0 ; then
193         echo "comparison failed - meta search/modification didn't succeed"
194         exit 1
195 fi
196
197 echo ">>>>> Test succeeded"
198 exit 0
199