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