test019-syncreplication-cascade revision 1.1.1.2 1 #! /bin/sh
2 # OpenLDAP: pkg/ldap/tests/scripts/test019-syncreplication-cascade,v 1.19.2.9 2009/03/05 23:32:21 quanah Exp
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 $DBDIR2 $DBDIR3 $DBDIR4 $DBDIR5 $DBDIR6
30
31 #
32 # Test replication:
33 # - start master
34 # - start slave
35 # - populate over ldap
36 # - perform some modifies and deleted
37 # - retrieve database over ldap and compare against expected results
38 #
39
40 echo "Starting master slapd on TCP/IP port $PORT1..."
41 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
42 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
43 PID=$!
44 if test $WAIT != 0 ; then
45 echo PID $PID
46 read foo
47 fi
48 KILLPIDS="$PID"
49
50 sleep 1
51
52 echo "Using ldapsearch to check that master slapd (pid=$PID) is running..."
53 for i in 0 1 2 3 4 5; do
54 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
55 'objectclass=*' > /dev/null 2>&1
56 RC=$?
57 if test $RC = 0 ; then
58 break
59 fi
60 echo "Waiting 5 seconds for slapd to start..."
61 sleep 5
62 done
63
64 if test $RC != 0 ; then
65 echo "ldapsearch failed ($RC)!"
66 test $KILLSERVERS != no && kill -HUP $KILLPIDS
67 exit $RC
68 fi
69
70 echo "Using ldapadd to create the context prefix entry in the master..."
71 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
72 $LDIFORDEREDCP > /dev/null 2>&1
73 RC=$?
74 if test $RC != 0 ; then
75 echo "ldapadd failed ($RC)!"
76 test $KILLSERVERS != no && kill -HUP $KILLPIDS
77 exit $RC
78 fi
79
80 echo "Starting R1 slave slapd on TCP/IP port $PORT2..."
81 . $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $CONF2
82 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
83 SLAVEPID=$!
84 if test $WAIT != 0 ; then
85 echo SLAVE R1 PID $SLAVEPID
86 read foo
87 fi
88 KILLPIDS="$KILLPIDS $SLAVEPID"
89
90 sleep 1
91
92 echo "Using ldapsearch to check that R1 slave slapd (pid=$SLAVEPID) is running..."
93 for i in 0 1 2 3 4 5; do
94 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
95 'objectclass=*' > /dev/null 2>&1
96 RC=$?
97 if test $RC = 0 ; then
98 break
99 fi
100 echo "Waiting 5 seconds for R1 slapd to start..."
101 sleep 5
102 done
103
104 if test $RC != 0 ; then
105 echo "ldapsearch failed ($RC)!"
106 test $KILLSERVERS != no && kill -HUP $KILLPIDS
107 exit $RC
108 fi
109
110 echo "Starting R2 slave slapd on TCP/IP port $PORT3..."
111 . $CONFFILTER $BACKEND $MONITORDB < $R2SRSLAVECONF > $CONF3
112 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
113 SLAVEPID=$!
114 if test $WAIT != 0 ; then
115 echo SLAVE R2 PID $SLAVEPID
116 read foo
117 fi
118 KILLPIDS="$KILLPIDS $SLAVEPID"
119
120 sleep 1
121
122 echo "Using ldapsearch to check that R2 slave slapd (pid=$SLAVEPID) is running..."
123 for i in 0 1 2 3 4 5; do
124 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
125 'objectclass=*' > /dev/null 2>&1
126 RC=$?
127 if test $RC = 0 ; then
128 break
129 fi
130 echo "Waiting 5 seconds for R2 slave slapd to start..."
131 sleep 5
132 done
133
134 if test $RC != 0 ; then
135 echo "ldapsearch failed ($RC)!"
136 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 exit $RC
138 fi
139
140 echo "Starting P1 slave slapd on TCP/IP port $PORT4..."
141 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
142 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
143 SLAVEPID=$!
144 if test $WAIT != 0 ; then
145 echo SLAVE P1 PID $SLAVEPID
146 read foo
147 fi
148 KILLPIDS="$KILLPIDS $SLAVEPID"
149
150 sleep 1
151
152 echo "Using ldapsearch to check that P1 slave slapd (pid=$SLAVEPID) is running..."
153 for i in 0 1 2 3 4 5; do
154 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT4 \
155 'objectclass=*' > /dev/null 2>&1
156 RC=$?
157 if test $RC = 0 ; then
158 break
159 fi
160 echo "Waiting 5 seconds for P1 slave slapd to start..."
161 sleep 5
162 done
163
164 if test $RC != 0 ; then
165 echo "ldapsearch failed ($RC)!"
166 test $KILLSERVERS != no && kill -HUP $KILLPIDS
167 exit $RC
168 fi
169
170 echo "Starting P2 slave slapd on TCP/IP port $PORT5..."
171 . $CONFFILTER $BACKEND $MONITORDB < $P2SRSLAVECONF > $CONF5
172 $SLAPD -f $CONF5 -h $URI5 -d $LVL $TIMING > $LOG5 2>&1 &
173 SLAVEPID=$!
174 if test $WAIT != 0 ; then
175 echo SLAVE P2 PID $SLAVEPID
176 read foo
177 fi
178 KILLPIDS="$KILLPIDS $SLAVEPID"
179
180 sleep 1
181
182 echo "Using ldapsearch to check that P2 slave slapd (pid=$SLAVEPID) is running..."
183 for i in 0 1 2 3 4 5; do
184 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT5 \
185 'objectclass=*' > /dev/null 2>&1
186 RC=$?
187 if test $RC = 0 ; then
188 break
189 fi
190 echo "Waiting 5 seconds for P2 slave slapd to start..."
191 sleep 5
192 done
193
194 if test $RC != 0 ; then
195 echo "ldapsearch failed ($RC)!"
196 test $KILLSERVERS != no && kill -HUP $KILLPIDS
197 exit $RC
198 fi
199
200 echo "Starting P3 slave slapd on TCP/IP port $PORT6..."
201 . $CONFFILTER $BACKEND $MONITORDB < $P3SRSLAVECONF > $CONF6
202 $SLAPD -f $CONF6 -h $URI6 -d $LVL $TIMING > $LOG6 2>&1 &
203 SLAVEPID=$!
204 if test $WAIT != 0 ; then
205 echo SLAVE P3 PID $SLAVEPID
206 read foo
207 fi
208 KILLPIDS="$KILLPIDS $SLAVEPID"
209
210 sleep 1
211
212 echo "Using ldapsearch to check that P3 slave slapd (pid=$SLAVEPID) is running..."
213 for i in 0 1 2 3 4 5; do
214 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT6 \
215 'objectclass=*' > /dev/null 2>&1
216 RC=$?
217 if test $RC = 0 ; then
218 break
219 fi
220 echo "Waiting 5 seconds for P3 slave slapd to start..."
221 sleep 5
222 done
223
224 if test $RC != 0 ; then
225 echo "ldapsearch failed ($RC)!"
226 test $KILLSERVERS != no && kill -HUP $KILLPIDS
227 exit $RC
228 fi
229
230 echo "Using ldapadd to populate the master directory..."
231 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
232 $LDIFORDEREDNOCP > /dev/null 2>&1
233 RC=$?
234 if test $RC != 0 ; then
235 echo "ldapadd failed ($RC)!"
236 test $KILLSERVERS != no && kill -HUP $KILLPIDS
237 exit $RC
238 fi
239
240 echo "Waiting $SLEEP2 seconds for syncrepl to receive changes..."
241 sleep $SLEEP2
242
243 echo "Using ldapmodify to modify master directory..."
244
245 #
246 # Do some modifications
247 #
248
249 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
250 $TESTOUT 2>&1 << EOMODS
251 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
252 changetype: modify
253 add: drink
254 drink: Orange Juice
255 -
256 delete: sn
257 sn: Jones
258 -
259 add: sn
260 sn: Jones
261
262 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
263 changetype: modify
264 replace: drink
265 drink: Iced Tea
266 drink: Mad Dog 20/20
267
268 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
269 changetype: modify
270 delete: uniquemember
271 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
272 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
273 -
274 add: uniquemember
275 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
276 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
277
278 dn: cn=All Staff,ou=Groups,dc=example,dc=com
279 changetype: modify
280 delete: description
281
282 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
283 changetype: add
284 objectclass: OpenLDAPperson
285 cn: Gern Jensen
286 sn: Jensen
287 uid: gjensen
288 title: Chief Investigator, ITD
289 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
290 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
291 drink: Coffee
292 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
293 description: Very odd
294 facsimiletelephonenumber: +1 313 555 7557
295 telephonenumber: +1 313 555 8343
296 mail: gjensen@mailgw.example.com
297 homephone: +1 313 555 8844
298
299 dn: ou=Retired, ou=People, dc=example,dc=com
300 changetype: add
301 objectclass: organizationalUnit
302 ou: Retired
303
304 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
305 changetype: add
306 objectclass: OpenLDAPperson
307 cn: Rosco P. Coltrane
308 sn: Coltrane
309 uid: rosco
310
311 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
312 changetype: modrdn
313 newrdn: cn=Rosco P. Coltrane
314 deleteoldrdn: 1
315 newsuperior: ou=Retired, ou=People, dc=example,dc=com
316
317 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
318 changetype: delete
319
320 dn: dc=testdomain1,dc=example,dc=com
321 changetype: modrdn
322 newrdn: dc=itsdomain1
323 deleteoldrdn: 1
324
325 dn: dc=itsdomain1,dc=example,dc=com
326 changetype: modify
327 replace: description
328 description: Example, Inc. ITS test domain
329
330 dn: dc=testdomain2,dc=example,dc=com
331 changetype: modrdn
332 newrdn: dc=itsdomain2
333 deleteoldrdn: 1
334
335 EOMODS
336
337 RC=$?
338 if test $RC != 0 ; then
339 echo "ldapmodify failed ($RC)!"
340 test $KILLSERVERS != no && kill -HUP $KILLPIDS
341 exit $RC
342 fi
343
344 echo "Waiting $SLEEP2 seconds for syncrepl to receive changes..."
345 sleep $SLEEP2
346
347 echo "Performing modify alone on provider..."
348 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
349 $TESTOUT 2>&1 << EOMODS
350 dn: dc=itsdomain2,dc=example,dc=com
351 changetype: modify
352 replace: description
353 description: Example, Inc. itsdomain2 test domain
354
355 EOMODS
356
357 RC=$?
358 if test $RC != 0 ; then
359 echo "ldapmodify failed ($RC)!"
360 test $KILLSERVERS != no && kill -HUP $KILLPIDS
361 exit $RC
362 fi
363
364 echo "Waiting $SLEEP2 seconds for syncrepl to receive changes..."
365 sleep $SLEEP2
366
367 echo "Using ldapsearch to read all the entries from the master..."
368 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
369 '(objectClass=*)' '*' entryCSN > $MASTEROUT 2>&1
370 RC=$?
371
372 if test $RC != 0 ; then
373 echo "ldapsearch failed at master ($RC)!"
374 test $KILLSERVERS != no && kill -HUP $KILLPIDS
375 exit $RC
376 fi
377
378 echo "Using ldapsearch to read all the entries from the R1 slave..."
379 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
380 '(objectClass=*)' '*' entryCSN > $SERVER2OUT 2>&1
381 RC=$?
382
383 if test $RC != 0 ; then
384 echo "ldapsearch failed at R1 slave ($RC)!"
385 test $KILLSERVERS != no && kill -HUP $KILLPIDS
386 exit $RC
387 fi
388
389 echo "Using ldapsearch to read all the entries from the R2 slave..."
390 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT3 \
391 '(objectClass=*)' '*' entryCSN > $SERVER3OUT 2>&1
392 RC=$?
393
394 if test $RC != 0 ; then
395 echo "ldapsearch failed at R2 slave ($RC)!"
396 test $KILLSERVERS != no && kill -HUP $KILLPIDS
397 exit $RC
398 fi
399
400 echo "Using ldapsearch to read all the entries from the P1 slave..."
401 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
402 '(objectClass=*)' '*' entryCSN > $SERVER4OUT 2>&1
403 RC=$?
404
405 if test $RC != 0 ; then
406 echo "ldapsearch failed at P1 slave ($RC)!"
407 test $KILLSERVERS != no && kill -HUP $KILLPIDS
408 exit $RC
409 fi
410
411 echo "Using ldapsearch to read all the entries from the P2 slave..."
412 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT5 \
413 '(objectClass=*)' '*' entryCSN > $SERVER5OUT 2>&1
414 RC=$?
415
416 if test $RC != 0 ; then
417 echo "ldapsearch failed at P2 slave ($RC)!"
418 test $KILLSERVERS != no && kill -HUP $KILLPIDS
419 exit $RC
420 fi
421
422 echo "Using ldapsearch to read all the entries from the P3 slave..."
423 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT6 \
424 '(objectClass=*)' '*' entryCSN > $SERVER6OUT 2>&1
425 RC=$?
426
427 if test $RC != 0 ; then
428 echo "ldapsearch failed at P3 slave ($RC)!"
429 test $KILLSERVERS != no && kill -HUP $KILLPIDS
430 exit $RC
431 fi
432
433 test $KILLSERVERS != no && kill -HUP $KILLPIDS
434
435 echo "Filtering master ldapsearch results..."
436 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
437 echo "Filtering R1 slave ldapsearch results..."
438 . $LDIFFILTER < $SERVER2OUT > $SERVER2FLT
439 echo "Filtering R2 slave ldapsearch results..."
440 . $LDIFFILTER < $SERVER3OUT > $SERVER3FLT
441 echo "Filtering P1 slave ldapsearch results..."
442 . $LDIFFILTER < $SERVER4OUT > $SERVER4FLT
443 echo "Filtering P2 slave ldapsearch results..."
444 . $LDIFFILTER < $SERVER5OUT > $SERVER5FLT
445 echo "Filtering P3 slave ldapsearch results..."
446 . $LDIFFILTER < $SERVER6OUT > $SERVER6FLT
447
448 echo "Comparing retrieved entries from master and R1 slave..."
449 $CMP $MASTERFLT $SERVER2FLT > $CMPOUT
450
451 if test $? != 0 ; then
452 echo "test failed - master and R1 slave databases differ"
453 exit 1
454 fi
455
456 echo "Comparing retrieved entries from master and R2 slave..."
457 $CMP $MASTERFLT $SERVER3FLT > $CMPOUT
458
459 if test $? != 0 ; then
460 echo "test failed - master and R2 slave databases differ"
461 exit 1
462 fi
463
464 echo "Comparing retrieved entries from master and P1 slave..."
465 $CMP $MASTERFLT $SERVER4FLT > $CMPOUT
466
467 if test $? != 0 ; then
468 echo "test failed - master and P1 slave databases differ"
469 exit 1
470 fi
471
472 echo "Comparing retrieved entries from master and P2 slave..."
473 $CMP $MASTERFLT $SERVER5FLT > $CMPOUT
474
475 if test $? != 0 ; then
476 echo "test failed - master and P2 slave databases differ"
477 exit 1
478 fi
479
480 echo "Comparing retrieved entries from master and P3 slave..."
481 $CMP $MASTERFLT $SERVER6FLT > $CMPOUT
482
483 if test $? != 0 ; then
484 echo "test failed - master and P3 slave databases differ"
485 exit 1
486 fi
487
488 echo ">>>>> Test succeeded"
489
490 test $KILLSERVERS != no && wait
491
492 exit 0
493