]> git.sur5r.net Git - openldap/blob - tests/scripts/test036-meta-concurrency
Sync with HEAD in prep for 2.3.3beta
[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 "### 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" -o "$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 echo "Using ldapsearch to check that slapd is running..."
69 for i in 0 1 2 3 4 5; do
70         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
71                 'objectclass=*' > /dev/null 2>&1
72         RC=$?
73         if test $RC = 0 ; then
74                 break
75         fi
76         echo "Waiting 5 seconds for slapd to start..."
77         sleep 5
78 done
79 if test $RC != 0 ; then
80         echo "ldapsearch failed ($RC)!"
81         test $KILLSERVERS != no && kill -HUP $KILLPIDS
82         exit $RC
83 fi
84
85 echo "Using ldapadd to populate the database..."
86 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
87         $LDIFORDERED > $TESTOUT 2>&1
88 RC=$?
89 if test $RC != 0 ; then
90         echo "ldapadd failed ($RC)!"
91         test $KILLSERVERS != no && kill -HUP $KILLPIDS
92         exit $RC
93 fi
94
95 echo "Starting slapd on TCP/IP port $PORT2..."
96 . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
97 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
98 PID=$!
99 if test $WAIT != 0 ; then
100     echo PID $PID
101     read foo
102 fi
103 KILLPIDS="$KILLPIDS $PID"
104
105 echo "Using ldapsearch to check that slapd is running..."
106 for i in 0 1 2 3 4 5; do
107         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
108                 'objectclass=*' > /dev/null 2>&1
109         RC=$?
110         if test $RC = 0 ; then
111                 break
112         fi
113         echo "Waiting 5 seconds for slapd to start..."
114         sleep 5
115 done
116 if test $RC != 0 ; then
117         echo "ldapsearch failed ($RC)!"
118         test $KILLSERVERS != no && kill -HUP $KILLPIDS
119         exit $RC
120 fi
121
122 echo "Using ldapadd to populate the database..."
123 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
124         $LDIFMETA >> $TESTOUT 2>&1
125 RC=$?
126 if test $RC != 0 ; then
127         echo "ldapadd failed ($RC)!"
128         test $KILLSERVERS != no && kill -HUP $KILLPIDS
129         exit $RC
130 fi
131
132 echo "Starting slapd on TCP/IP port $PORT3..."
133 . $CONFFILTER $BACKEND $MONITORDB < $METACONF > $CONF3
134 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
135 PID=$!
136 if test $WAIT != 0 ; then
137     echo PID $PID
138     read foo
139 fi
140 KILLPIDS="$KILLPIDS $PID"
141
142 echo "Using ldapsearch to check that slapd is running..."
143 for i in 0 1 2 3 4 5; do
144         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
145                 'objectclass=*' > /dev/null 2>&1
146         RC=$?
147         if test $RC = 0 ; then
148                 break
149         fi
150         echo "Waiting 5 seconds for slapd to start..."
151         sleep 5
152 done
153 if test $RC != 0 ; then
154         echo "ldapsearch failed ($RC)!"
155         test $KILLSERVERS != no && kill -HUP $KILLPIDS
156         exit $RC
157 fi
158
159 cat /dev/null > $SEARCHOUT
160
161 mkdir -p $TESTDIR/$DATADIR
162 METABASEDN="o=Example,c=US"
163 for f in $DATADIR/do_* ; do
164         sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f
165 done
166
167 # add a read that matches only the local database, but selects 
168 # also the remote as candidate; this should be removed to compare
169 # execution times with test008...
170 for f in $TESTDIR/$DATADIR/do_read.* ; do
171         echo "ou=Meta,$METABASEDN" >> $f
172 done
173
174 # add a read that matches a referral in the local database only, 
175 # but selects also the remote as candidate; this should be removed 
176 # to compare execution times with test008...
177 for f in $TESTDIR/$DATADIR/do_read.* ; do
178         echo "cn=Somewhere,ou=Meta,$METABASEDN" >> $f
179 done
180
181 echo "Using tester for concurrent server access..."
182 $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR/$DATADIR" -h $LOCALHOST -p $PORT3 -D "cn=Manager,$METABASEDN" -w $PASSWD -l 50 # -r 20
183 RC=$?
184
185 if test $RC != 0 ; then
186         echo "slapd-tester failed ($RC)!"
187         test $KILLSERVERS != no && kill -HUP $KILLPIDS
188         exit $RC
189 fi 
190
191 echo "Using ldapsearch to retrieve all the entries..."
192 $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \
193                         'objectClass=*' > $SEARCHOUT 2>&1
194 RC=$?
195
196 test $KILLSERVERS != no && kill -HUP $KILLPIDS
197
198 if test $RC != 0 ; then
199         echo "ldapsearch failed ($RC)!"
200         exit $RC
201 fi
202
203 echo "Filtering ldapsearch results..."
204 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
205 echo "Filtering original ldif used to create database..."
206 . $LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT
207 echo "Comparing filter output..."
208 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
209
210 if test $? != 0 ; then
211         echo "comparison failed - meta search/modification didn't succeed"
212         exit 1
213 fi
214
215 echo ">>>>> Test succeeded"
216 exit 0
217