2 # $OpenLDAP: pkg/ldap/tests/scripts/test043-delta-syncrepl,v 1.4.2.3 2008/02/11 23:26:51 kurt Exp $
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2008 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
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>.
16 if test "$BACKEND" != "bdb" && test "$BACKEND" != "hdb" ; then
17 echo "Test does not support $BACKEND"
21 echo "running defines.sh"
22 .
$SRCDIR/scripts
/defines.sh
24 if test $SYNCPROV = syncprovno
; then
25 echo "Syncrepl provider overlay not available, test skipped"
28 if test $ACCESSLOG = accesslogno
; then
29 echo "Accesslog overlay not available, test skipped"
33 mkdir
-p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR2
39 # - populate over ldap
40 # - perform some modifies and deleted
41 # - attempt to modify the consumer (referral or chain)
42 # - retrieve database over ldap and compare against expected results
45 echo "Starting producer slapd on TCP/IP port $PORT1..."
46 .
$CONFFILTER $BACKEND $MONITORDB < $DSRMASTERCONF > $CONF1
47 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
49 if test $WAIT != 0 ; then
57 echo "Using ldapsearch to check that producer slapd is running..."
58 for i
in 0 1 2 3 4 5; do
59 $LDAPSEARCH -s base
-b "$MONITOR" -h $LOCALHOST -p $PORT1 \
60 'objectclass=*' > /dev
/null
2>&1
62 if test $RC = 0 ; then
65 echo "Waiting 5 seconds for slapd to start..."
69 if test $RC != 0 ; then
70 echo "ldapsearch failed ($RC)!"
71 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
75 echo "Using ldapadd to create the context prefix entries in the producer..."
76 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
77 $LDIFORDEREDCP > /dev
/null
2>&1
79 if test $RC != 0 ; then
80 echo "ldapadd failed ($RC)!"
81 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
85 echo "Starting consumer slapd on TCP/IP port $PORT2..."
86 .
$CONFFILTER $BACKEND $MONITORDB < $DSRSLAVECONF > $CONF2
87 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
89 if test $WAIT != 0 ; then
90 echo SLAVEPID
$SLAVEPID
93 KILLPIDS
="$KILLPIDS $SLAVEPID"
97 echo "Using ldapsearch to check that consumer slapd is running..."
98 for i
in 0 1 2 3 4 5; do
99 $LDAPSEARCH -s base
-b "$MONITOR" -h $LOCALHOST -p $PORT2 \
100 'objectclass=*' > /dev
/null
2>&1
102 if test $RC = 0 ; then
105 echo "Waiting 5 seconds for slapd to start..."
109 if test $RC != 0 ; then
110 echo "ldapsearch failed ($RC)!"
111 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
115 echo "Using ldapadd to populate the producer directory..."
116 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
117 $LDIFORDEREDNOCP > /dev
/null
2>&1
119 if test $RC != 0 ; then
120 echo "ldapadd failed ($RC)!"
121 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
125 echo "Waiting 15 seconds for syncrepl to receive changes..."
128 echo "Stopping the provider, sleeping 10 seconds and restarting it..."
131 echo "RESTART" >> $LOG1
132 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
134 if test $WAIT != 0 ; then
138 KILLPIDS
="$PID $SLAVEPID"
142 echo "Using ldapsearch to check that producer slapd is running..."
143 for i
in 0 1 2 3 4 5; do
144 $LDAPSEARCH -s base
-b "$MONITOR" -h $LOCALHOST -p $PORT1 \
145 'objectclass=*' > /dev
/null
2>&1
147 if test $RC = 0 ; then
150 echo "Waiting 5 seconds for slapd to start..."
154 if test $RC != 0 ; then
155 echo "ldapsearch failed ($RC)!"
156 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
160 echo "Using ldapmodify to modify producer directory..."
163 # Do some modifications
166 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
167 $TESTOUT 2>&1 << EOMODS
168 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
179 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
184 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
187 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
188 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
191 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
192 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
194 dn: cn=All Staff,ou=Groups,dc=example,dc=com
198 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
200 objectclass: OpenLDAPperson
204 title: Chief Investigator, ITD
205 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
206 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
208 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
209 description: Very odd
210 facsimiletelephonenumber: +1 313 555 7557
211 telephonenumber: +1 313 555 8343
212 mail: gjensen@mailgw.example.com
213 homephone: +1 313 555 8844
215 dn: ou=Retired, ou=People, dc=example,dc=com
217 objectclass: organizationalUnit
220 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
222 objectclass: OpenLDAPperson
223 cn: Rosco P. Coltrane
226 description: Fat tycoon
228 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
230 newrdn: cn=Rosco P. Coltrane
232 newsuperior: ou=Retired, ou=People, dc=example,dc=com
234 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
239 if test $RC != 0 ; then
240 echo "ldapmodify failed ($RC)!"
241 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
245 echo "Waiting 15 seconds for syncrepl to receive changes..."
248 echo "Stopping consumer to test recovery..."
252 echo "Modifying more entries on the producer..."
253 $LDAPMODIFY -v -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn
>> \
254 $TESTOUT 2>&1 << EOMODS
255 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
258 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
263 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
265 objectclass: OpenLDAPperson
268 cn: Rosco P. Coltrane
270 dn: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com
274 dn: cn=All Staff,ou=Groups,dc=example,dc=com
276 newrdn: cn=Some Staff
281 echo "Restarting consumer..."
282 echo "RESTART" >> $LOG2
283 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
285 if test $WAIT != 0 ; then
286 echo SLAVEPID
$SLAVEPID
289 KILLPIDS
="$PID $SLAVEPID"
291 echo "Waiting 25 seconds for syncrepl to receive changes..."
294 if test ! $BACKLDAP = "ldapno" ; then
295 echo "Try updating the consumer slapd..."
296 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
297 $TESTOUT 2>&1 << EOMODS
298 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
301 description: This write must fail because directed to a shadow context,
302 description: unless the chain overlay is configured appropriately ;)
307 if test $RC != 0 ; then
308 echo "ldapmodify failed ($RC)!"
309 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
313 echo "Waiting 15 seconds for syncrepl to receive changes..."
317 echo "Using ldapsearch to read all the entries from the producer..."
318 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
319 'objectclass=*' \
* + > $MASTEROUT 2>&1
322 if test $RC != 0 ; then
323 echo "ldapsearch failed at producer ($RC)!"
324 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
328 echo "Using ldapsearch to read all the entries from the consumer..."
329 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
330 'objectclass=*' \
* + > $SLAVEOUT 2>&1
333 if test $RC != 0 ; then
334 echo "ldapsearch failed at consumer ($RC)!"
335 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
339 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
341 echo "Filtering producer results..."
342 .
$LDIFFILTER < $MASTEROUT |
grep -iv "^auditcontext:" > $MASTERFLT
343 echo "Filtering consumer results..."
344 .
$LDIFFILTER < $SLAVEOUT |
grep -iv "^auditcontext:" > $SLAVEFLT
346 echo "Comparing retrieved entries from producer and consumer..."
347 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
349 if test $?
!= 0 ; then
350 echo "test failed - producer and consumer databases differ"
354 echo ">>>>> Test succeeded"
356 test $KILLSERVERS != no
&& wait