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