]> git.sur5r.net Git - openldap/blob - tests/scripts/test054-syncreplication-parallel-load
For ITS#5810: Use progs/ldif-filter. Retire scripts/acfilter.sh.
[openldap] / tests / scripts / test054-syncreplication-parallel-load
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2009 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 if test "$BACKEND" != "bdb" && test "$BACKEND" != "hdb" ; then
17         echo "Test does not support $BACKEND"
18         exit 0
19 fi
20
21 echo "running defines.sh"
22 . $SRCDIR/scripts/defines.sh
23
24 if test $SYNCPROV = syncprovno; then 
25         echo "Syncrepl provider overlay not available, test skipped"
26         exit 0
27 fi 
28
29 mkdir -p $TESTDIR $DBDIR1 $DBDIR4
30
31 #
32 # Test replication:
33 # - start producer
34 # - start consumer
35 # - populate over ldap
36 # - perform some modifies and deleted
37 # - attempt to modify the consumer (referral or chain)
38 # - retrieve database over ldap and compare against expected results
39 #
40
41 echo "Starting producer slapd on TCP/IP port $PORT1..."
42 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
43 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
44 PID=$!
45 if test $WAIT != 0 ; then
46     echo PID $PID
47     read foo
48 fi
49 KILLPIDS="$PID"
50
51 sleep 1
52
53 echo "Using ldapsearch to check that producer slapd is running..."
54 for i in 0 1 2 3 4 5; do
55         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
56                 'objectclass=*' > /dev/null 2>&1
57         RC=$?
58         if test $RC = 0 ; then
59                 break
60         fi
61         echo "Waiting 5 seconds for slapd to start..."
62         sleep 5
63 done
64
65 if test $RC != 0 ; then
66         echo "ldapsearch failed ($RC)!"
67         test $KILLSERVERS != no && kill -HUP $KILLPIDS
68         exit $RC
69 fi
70
71 echo "Using ldapadd to create the context prefix entry in the producer..."
72 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
73         $LDIFORDEREDCP > /dev/null 2>&1
74 RC=$?
75 if test $RC != 0 ; then
76         echo "ldapadd failed ($RC)!"
77         test $KILLSERVERS != no && kill -HUP $KILLPIDS
78         exit $RC
79 fi
80
81 echo "Starting consumer slapd on TCP/IP port $PORT4..."
82 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
83 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
84 SLAVEPID=$!
85 if test $WAIT != 0 ; then
86     echo SLAVEPID $SLAVEPID
87     read foo
88 fi
89 KILLPIDS="$KILLPIDS $SLAVEPID"
90
91 sleep 1
92
93 echo "Using ldapsearch to check that consumer slapd is running..."
94 for i in 0 1 2 3 4 5; do
95         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT4 \
96                 'objectclass=*' > /dev/null 2>&1
97         RC=$?
98         if test $RC = 0 ; then
99                 break
100         fi
101         echo "Waiting 5 seconds for slapd to start..."
102         sleep 5
103 done
104
105 if test $RC != 0 ; then
106         echo "ldapsearch failed ($RC)!"
107         test $KILLSERVERS != no && kill -HUP $KILLPIDS
108         exit $RC
109 fi
110
111 MORELDIF=$TESTDIR/more.ldif
112 TESTOUT1=$TESTDIR/testout1.out
113 TESTOUT2=$TESTDIR/testout2.out
114 sed -e 's/[Oo][Uu]=/ou=More /g' -e 's/^[Oo][Uu]: /ou: More /' \
115         -e 's/cn=Manager/cn=More Manager/g' \
116         -e 's/^cn: Manager/cn: More Manager/' \
117         $LDIFORDEREDNOCP > $MORELDIF
118
119 echo "Using ldapadd to populate the producer directory..."
120 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
121         $LDIFORDEREDNOCP > $TESTOUT1 2>&1  &
122 C1PID=$!
123 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
124         $MORELDIF > $TESTOUT2 2>&1 &
125 C2PID=$!
126 wait $C1PID $C2PID
127
128 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
129 sleep $SLEEP1
130
131 echo "Stopping the provider, sleeping 10 seconds and restarting it..."
132 kill -HUP "$PID"
133 wait $PID
134 sleep 10
135 echo "RESTART" >> $LOG1
136 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
137 PID=$!
138 if test $WAIT != 0 ; then
139     echo PID $PID
140     read foo
141 fi
142 KILLPIDS="$PID $SLAVEPID"
143
144 sleep 1
145
146 echo "Using ldapsearch to check that producer slapd is running..."
147 for i in 0 1 2 3 4 5; do
148         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
149                 'objectclass=*' > /dev/null 2>&1
150         RC=$?
151         if test $RC = 0 ; then
152                 break
153         fi
154         echo "Waiting 5 seconds for slapd to start..."
155         sleep 5
156 done
157
158 if test $RC != 0 ; then
159         echo "ldapsearch failed ($RC)!"
160         test $KILLSERVERS != no && kill -HUP $KILLPIDS
161         exit $RC
162 fi
163
164 echo "Waiting 10 seconds to let the system catch up"
165 sleep 10
166
167 echo "Using ldapmodify to modify producer directory..."
168
169 #
170 # Do some modifications
171 #
172
173 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
174         $TESTOUT 2>&1 << EOMODS
175 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
176 changetype: modify
177 add: drink
178 drink: Orange Juice
179 -
180 delete: sn
181 sn: Jones
182 -
183 add: sn
184 sn: Jones
185
186 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
187 changetype: modify
188 replace: drink
189 drink: Iced Tea
190
191 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
192 changetype: modify
193 delete: uniquemember
194 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
195 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
196 -
197 add: uniquemember
198 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
199 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
200
201 dn: cn=All Staff,ou=Groups,dc=example,dc=com
202 changetype: modify
203 delete: description
204
205 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
206 changetype: add
207 objectclass: OpenLDAPperson
208 cn: Gern Jensen
209 sn: Jensen
210 uid: gjensen
211 title: Chief Investigator, ITD
212 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
213 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
214 drink: Coffee
215 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
216 description: Very odd
217 facsimiletelephonenumber: +1 313 555 7557
218 telephonenumber: +1 313 555 8343
219 mail: gjensen@mailgw.example.com
220 homephone: +1 313 555 8844
221
222 dn: ou=Retired, ou=People, dc=example,dc=com
223 changetype: add
224 objectclass: organizationalUnit
225 ou: Retired
226
227 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
228 changetype: add
229 objectclass: OpenLDAPperson
230 cn: Rosco P. Coltrane
231 sn: Coltrane
232 uid: rosco
233 description: Fat tycoon
234
235 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
236 changetype: modrdn
237 newrdn: cn=Rosco P. Coltrane
238 deleteoldrdn: 1
239 newsuperior: ou=Retired, ou=People, dc=example,dc=com
240
241 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
242 changetype: delete
243
244 EOMODS
245
246 RC=$?
247 if test $RC != 0 ; then
248         echo "ldapmodify failed ($RC)!"
249         test $KILLSERVERS != no && kill -HUP $KILLPIDS
250         exit $RC
251 fi
252
253 echo "Using ldappasswd to change some passwords..."
254 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
255         'cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
256         > $TESTOUT 2>&1
257 RC=$?
258 if test $RC != 0 ; then
259         echo "ldapmodify failed ($RC)!"
260         test $KILLSERVERS != no && kill -HUP $KILLPIDS
261         exit $RC
262 fi
263
264 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
265 sleep $SLEEP1
266
267 echo "Stopping consumer to test recovery..."
268 kill -HUP $SLAVEPID
269 wait $SLAVEPID
270
271 echo "Modifying more entries on the producer..."
272 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
273         $TESTOUT 2>&1 << EOMODS
274 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
275 changetype: delete
276
277 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
278 changetype: modify
279 add: drink
280 drink: Mad Dog 20/20
281
282 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
283 changetype: add
284 objectclass: OpenLDAPperson
285 sn: Coltrane
286 uid: rosco
287 cn: Rosco P. Coltrane
288
289 EOMODS
290
291 echo "Restarting consumer..."
292 echo "RESTART" >> $LOG4
293 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
294 SLAVEPID=$!
295 if test $WAIT != 0 ; then
296     echo SLAVEPID $SLAVEPID
297     read foo
298 fi
299 KILLPIDS="$PID $SLAVEPID"
300
301 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
302 sleep $SLEEP1
303
304 if test ! $BACKLDAP = "ldapno" ; then
305         echo "Try updating the consumer slapd..."
306         $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD > \
307                 $TESTOUT 2>&1 << EOMODS
308 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
309 changetype: modify
310 add: description
311 description: This write must fail because directed to a shadow context,
312 description: unless the chain overlay is configured appropriately ;)
313
314 EOMODS
315
316         RC=$?
317         if test $RC != 0 ; then
318                 echo "ldapmodify failed ($RC)!"
319                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
320                 exit $RC
321         fi
322
323         # ITS#4964
324         echo "Trying to change some passwords on the consumer..."
325         $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD \
326                 'cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
327                 > $TESTOUT 2>&1
328         RC=$?
329         if test $RC != 0 ; then
330                 echo "ldapmodify failed ($RC)!"
331                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
332                 exit $RC
333         fi
334
335         echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
336         sleep $SLEEP1
337 fi
338
339 OPATTRS="entryUUID creatorsName createTimestamp modifiersName modifyTimestamp"
340
341 echo "Using ldapsearch to read all the entries from the producer..."
342 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
343         '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
344 RC=$?
345
346 if test $RC != 0 ; then
347         echo "ldapsearch failed at producer ($RC)!"
348         test $KILLSERVERS != no && kill -HUP $KILLPIDS
349         exit $RC
350 fi
351
352 echo "Using ldapsearch to read all the entries from the consumer..."
353 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
354         '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
355 RC=$?
356
357 if test $RC != 0 ; then
358         echo "ldapsearch failed at consumer ($RC)!"
359         test $KILLSERVERS != no && kill -HUP $KILLPIDS
360         exit $RC
361 fi
362
363 test $KILLSERVERS != no && kill -HUP $KILLPIDS
364
365 echo "Filtering producer results..."
366 $LDIFFILTER < $MASTEROUT > $MASTERFLT
367 echo "Filtering consumer results..."
368 $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
369
370 echo "Comparing retrieved entries from producer and consumer..."
371 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
372
373 if test $? != 0 ; then
374         echo "test failed - producer and consumer databases differ"
375         exit 1
376 fi
377
378 echo ">>>>> Test succeeded"
379
380 test $KILLSERVERS != no && wait
381
382 exit 0