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