]> git.sur5r.net Git - openldap/blob - tests/scripts/test019-syncreplication-cascade
Check ldapmodify for success.
[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 90 seconds for syncrepl to receive changes..."
207 sleep 90
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: member
237 member: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
238 member: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
239 -
240 add: member
241 member: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
242 member: 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 echo "Waiting 90 seconds for syncrepl to receive changes..."
289 sleep 90
290
291 echo "Using ldapsearch to read all the entries from the master..."
292 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
293         'objectclass=*' > $MASTEROUT 2>&1
294 RC=$?
295
296 if test $RC != 0 ; then
297         echo "ldapsearch failed at master ($RC)!"
298         test $KILLSERVERS != no && kill -HUP $KILLPIDS
299         exit $RC
300 fi
301
302 echo "Using ldapsearch to read all the entries from the R1 slave..."
303 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
304         'objectclass=*' > $SERVER2OUT 2>&1
305 RC=$?
306
307 if test $RC != 0 ; then
308         echo "ldapsearch failed at R1 slave ($RC)!"
309         test $KILLSERVERS != no && kill -HUP $KILLPIDS
310         exit $RC
311 fi
312
313 echo "Using ldapsearch to read all the entries from the R2 slave..."
314 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT3 \
315         'objectclass=*' > $SERVER3OUT 2>&1
316 RC=$?
317
318 if test $RC != 0 ; then
319         echo "ldapsearch failed at R2 slave ($RC)!"
320         test $KILLSERVERS != no && kill -HUP $KILLPIDS
321         exit $RC
322 fi
323
324 echo "Using ldapsearch to read all the entries from the P1 slave..."
325 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
326         'objectclass=*' > $SERVER4OUT 2>&1
327 RC=$?
328
329 if test $RC != 0 ; then
330         echo "ldapsearch failed at P1 slave ($RC)!"
331         test $KILLSERVERS != no && kill -HUP $KILLPIDS
332         exit $RC
333 fi
334
335 echo "Using ldapsearch to read all the entries from the P2 slave..."
336 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT5 \
337         'objectclass=*' > $SERVER5OUT 2>&1
338 RC=$?
339
340 if test $RC != 0 ; then
341         echo "ldapsearch failed at P2 slave ($RC)!"
342         test $KILLSERVERS != no && kill -HUP $KILLPIDS
343         exit $RC
344 fi
345
346 echo "Using ldapsearch to read all the entries from the P3 slave..."
347 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT6 \
348         'objectclass=*' > $SERVER6OUT 2>&1
349 RC=$?
350
351 if test $RC != 0 ; then
352         echo "ldapsearch failed at P3 slave ($RC)!"
353         test $KILLSERVERS != no && kill -HUP $KILLPIDS
354         exit $RC
355 fi
356
357 test $KILLSERVERS != no && kill -HUP $KILLPIDS
358
359 echo "Filtering master ldapsearch results..."
360 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
361 echo "Filtering R1 slave ldapsearch results..."
362 . $LDIFFILTER < $SERVER2OUT > $SERVER2FLT
363 echo "Filtering R2 slave ldapsearch results..."
364 . $LDIFFILTER < $SERVER3OUT > $SERVER3FLT
365 echo "Filtering P1 slave ldapsearch results..."
366 . $LDIFFILTER < $SERVER4OUT > $SERVER4FLT
367 echo "Filtering P2 slave ldapsearch results..."
368 . $LDIFFILTER < $SERVER5OUT > $SERVER5FLT
369 echo "Filtering P3 slave ldapsearch results..."
370 . $LDIFFILTER < $SERVER6OUT > $SERVER6FLT
371
372 echo "Comparing retrieved entries from master and R1 slave..."
373 $CMP $MASTERFLT $SERVER2FLT > $CMPOUT
374
375 if test $? != 0 ; then
376         echo "test failed - master and R1 slave databases differ"
377         exit 1
378 fi
379
380 echo "Comparing retrieved entries from master and R2 slave..."
381 $CMP $MASTERFLT $SERVER3FLT > $CMPOUT
382
383 if test $? != 0 ; then
384         echo "test failed - master and R2 slave databases differ"
385         exit 1
386 fi
387
388 echo "Comparing retrieved entries from master and P1 slave..."
389 $CMP $MASTERFLT $SERVER4FLT > $CMPOUT
390
391 if test $? != 0 ; then
392         echo "test failed - master and P1 slave databases differ"
393         exit 1
394 fi
395
396 echo "Comparing retrieved entries from master and P2 slave..."
397 $CMP $MASTERFLT $SERVER5FLT > $CMPOUT
398
399 if test $? != 0 ; then
400         echo "test failed - master and P2 slave databases differ"
401         exit 1
402 fi
403
404 echo "Comparing retrieved entries from master and P3 slave..."
405 $CMP $MASTERFLT $SERVER6FLT > $CMPOUT
406
407 if test $? != 0 ; then
408         echo "test failed - master and P3 slave databases differ"
409         exit 1
410 fi
411
412 echo ">>>>> Test succeeded"
413 exit 0