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