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