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