]> git.sur5r.net Git - openldap/blob - tests/data/regressions/its4448/its4448
Happy New Year
[openldap] / tests / data / regressions / its4448 / its4448
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2018 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 if test x$TESTLOOPS = x ; then
39         TESTLOOPS=50
40 fi
41
42 rm -rf $TESTDIR
43
44 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
45
46 ITS=4448
47 ITSDIR=$DATADIR/regressions/its$ITS
48 ITSCONF=$ITSDIR/slapd-meta.conf
49
50 # NOTE: this could be added to all tests...
51 if test "$BACKEND" = "bdb" || test "$BACKEND" = "hdb" ; then
52         if test "x$DB_CONFIG" != "x" ; then \
53                 if test -f $DB_CONFIG ; then
54                         echo "==> using DB_CONFIG \"$DB_CONFIG\""
55                         cp $DB_CONFIG $DBDIR1
56                         cp $DB_CONFIG $DBDIR2
57                 else
58                         echo "==> DB_CONFIG must point to a valid file (ignored)"
59                 fi
60         else
61                 echo "==> set \"DB_CONFIG\" to the DB_CONFIG file you want to use for the test."
62         fi
63         echo ""
64 fi
65
66 echo "Starting slapd on TCP/IP port $PORT1..."
67 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
68 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
69 PID=$!
70 if test $WAIT != 0 ; then
71     echo PID $PID
72     read foo
73 fi
74 KILLPIDS="$PID"
75
76 sleep 1
77
78 echo "Using ldapsearch to check that slapd is running..."
79 for i in 0 1 2 3 4 5; do
80         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
81                 'objectclass=*' > /dev/null 2>&1
82         RC=$?
83         if test $RC = 0 ; then
84                 break
85         fi
86         echo "Waiting 5 seconds for slapd to start..."
87         sleep 5
88 done
89 if test $RC != 0 ; then
90         echo "ldapsearch failed ($RC)!"
91         test $KILLSERVERS != no && kill -HUP $KILLPIDS
92         exit $RC
93 fi
94
95 echo "Using ldapadd to populate the database..."
96 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
97         $LDIFORDERED > $TESTOUT 2>&1
98 RC=$?
99 if test $RC != 0 ; then
100         echo "ldapadd failed ($RC)!"
101         test $KILLSERVERS != no && kill -HUP $KILLPIDS
102         exit $RC
103 fi
104
105 echo "Using ldapadd to add the referral..."
106 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD << EOMODS \
107         > $TESTOUT 2>&1
108 dn: cn=Meta,dc=example,dc=com
109 objectClass: referral
110 objectClass: extensibleObject
111 cn: Meta
112 ref: ${URI2}ou=Meta,dc=example,dc=com
113 EOMODS
114
115 RC=$?
116 if test $RC != 0 ; then
117         echo "ldapadd failed ($RC)!"
118         test $KILLSERVERS != no && kill -HUP $KILLPIDS
119         exit $RC
120 fi
121
122 echo "Starting slapd on TCP/IP port $PORT2..."
123 . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
124 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
125 PID=$!
126 if test $WAIT != 0 ; then
127     echo PID $PID
128     read foo
129 fi
130 KILLPIDS="$KILLPIDS $PID"
131
132 sleep 1
133
134 echo "Using ldapsearch to check that slapd is running..."
135 for i in 0 1 2 3 4 5; do
136         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
137                 'objectclass=*' > /dev/null 2>&1
138         RC=$?
139         if test $RC = 0 ; then
140                 break
141         fi
142         echo "Waiting 5 seconds for slapd to start..."
143         sleep 5
144 done
145 if test $RC != 0 ; then
146         echo "ldapsearch failed ($RC)!"
147         test $KILLSERVERS != no && kill -HUP $KILLPIDS
148         exit $RC
149 fi
150
151 echo "Using ldapadd to populate the database..."
152 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
153         $LDIFMETA >> $TESTOUT 2>&1
154 RC=$?
155 if test $RC != 0 ; then
156         echo "ldapadd failed ($RC)!"
157         test $KILLSERVERS != no && kill -HUP $KILLPIDS
158         exit $RC
159 fi
160
161 echo "Starting slapd on TCP/IP port $PORT3..."
162 . $CONFFILTER $BACKEND $MONITORDB < $ITSCONF > $CONF3
163 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
164 PID=$!
165 if test $WAIT != 0 ; then
166     echo PID $PID
167     read foo
168 fi
169 KILLPIDS="$KILLPIDS $PID"
170
171 sleep 1
172
173 echo "Using ldapsearch to check that slapd is running..."
174 for i in 0 1 2 3 4 5; do
175         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
176                 'objectclass=*' > /dev/null 2>&1
177         RC=$?
178         if test $RC = 0 ; then
179                 break
180         fi
181         echo "Waiting 5 seconds for slapd to start..."
182         sleep 5
183 done
184 if test $RC != 0 ; then
185         echo "ldapsearch failed ($RC)!"
186         test $KILLSERVERS != no && kill -HUP $KILLPIDS
187         exit $RC
188 fi
189
190 cat /dev/null > $SEARCHOUT
191
192 mkdir -p $TESTDIR/$DATADIR
193 METABASEDN="o=Example,c=US"
194 #for f in $DATADIR/do_* ; do
195 #       sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f
196 #done
197
198 # add a read that matches only the local database, but selects 
199 # also the remote as candidate; this should be removed to compare
200 # execution times with test008...
201 #for f in $TESTDIR/$DATADIR/do_read.* ; do
202 #       echo "ou=Meta,$METABASEDN" >> $f
203 #done
204
205 # add a read that matches a referral in the local database only, 
206 # but selects also the remote as candidate; this should be removed 
207 # to compare execution times with test008...
208 #for f in $TESTDIR/$DATADIR/do_read.* ; do
209 #       echo "cn=Somewhere,ou=Meta,$METABASEDN" >> $f
210 #done
211
212 # add a bind that resolves to a referral
213 #for f in $TESTDIR/$DATADIR/do_bind.* ; do
214 #       echo "cn=Foo,ou=Meta,$METABASEDN" >> $f
215 #       echo "bar" >> $f
216 #       echo "" >> $f
217 #       echo "" >> $f
218 #done
219
220 echo \
221 "$METABASEDN
222 (cn=John Belushi)
223 $METABASEDN
224 (cn=Meta)
225 $METABASEDN
226 (cn=Foo Bar)
227 $METABASEDN
228 (cn=Dan Aykroyd)
229 $METABASEDN
230 (cn=John Belushi)
231 $METABASEDN
232 (cn=Meta)
233 $METABASEDN
234 (cn=Foo Bar)
235 $METABASEDN
236 (cn=Dan Aykroyd)
237 $METABASEDN
238 (cn=John Belushi)
239 $METABASEDN
240 (cn=Meta)
241 $METABASEDN
242 (cn=Foo Bar)
243 $METABASEDN
244 (cn=Dan Aykroyd)
245 $METABASEDN
246 (cn=John Belushi)
247 $METABASEDN
248 (cn=Meta)
249 $METABASEDN
250 (cn=Foo Bar)
251 $METABASEDN
252 (cn=Dan Aykroyd)
253 $METABASEDN
254 (cn=John Belushi)
255 $METABASEDN
256 (cn=Meta)
257 $METABASEDN
258 (cn=Foo Bar)
259 $METABASEDN
260 (cn=Dan Aykroyd)
261 $METABASEDN
262 (cn=John Belushi)
263 $METABASEDN
264 (cn=Meta)
265 $METABASEDN
266 (cn=Foo Bar)
267 $METABASEDN
268 (cn=Dan Aykroyd)
269 $METABASEDN
270 (cn=John Belushi)
271 $METABASEDN
272 (cn=Meta)
273 $METABASEDN
274 (cn=Foo Bar)
275 $METABASEDN
276 (cn=Dan Aykroyd)
277 $METABASEDN
278 (cn=John Belushi)
279 $METABASEDN
280 (cn=Meta)
281 $METABASEDN
282 (cn=Foo Bar)
283 $METABASEDN
284 (cn=Dan Aykroyd)" \
285 > $TESTDIR/$DATADIR/do_search.0
286
287 echo "Using tester for concurrent server access..."
288 $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR/$DATADIR" -h $LOCALHOST -p $PORT3 \
289         -D "cn=Manager,$METABASEDN" -w $PASSWD -l $TESTLOOPS -r 20 -FF
290 RC=$?
291
292 if test $RC != 0 ; then
293         echo "slapd-tester failed ($RC)!"
294         test $KILLSERVERS != no && kill -HUP $KILLPIDS
295         exit $RC
296 fi 
297
298 echo "Using ldapsearch to retrieve all the entries..."
299 $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \
300                         '(objectClass=*)' > $SEARCHOUT 2>&1
301 RC=$?
302
303 test $KILLSERVERS != no && kill -HUP $KILLPIDS
304
305 if test $RC != 0 ; then
306         echo "ldapsearch failed ($RC)!"
307         exit $RC
308 fi
309
310 echo "Filtering ldapsearch results..."
311 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
312 echo "Filtering original ldif used to create database..."
313 $LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT
314 echo "Comparing filter output..."
315 $BCMP $SEARCHFLT $LDIFFLT > $CMPOUT
316
317 if test $? != 0 ; then
318         echo "comparison failed - slapd-meta search/modification didn't succeed"
319         exit 1
320 fi
321
322 echo ">>>>> Test succeeded"
323
324 test $KILLSERVERS != no && wait
325
326 exit 0