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