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