3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2009 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"
29 mkdir -p $TESTDIR $DBDIR1 $DBDIR4
35 # - populate over ldap
36 # - perform some modifies and deleted
37 # - attempt to modify the consumer (referral or chain)
38 # - retrieve database over ldap and compare against expected results
41 echo "Starting producer slapd on TCP/IP port $PORT1..."
42 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
43 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
45 if test $WAIT != 0 ; then
53 echo "Using ldapsearch to check that producer slapd is running..."
54 for i in 0 1 2 3 4 5; do
55 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
56 'objectclass=*' > /dev/null 2>&1
58 if test $RC = 0 ; then
61 echo "Waiting 5 seconds for slapd to start..."
65 if test $RC != 0 ; then
66 echo "ldapsearch failed ($RC)!"
67 test $KILLSERVERS != no && kill -HUP $KILLPIDS
71 echo "Using ldapadd to create the context prefix entry in the producer..."
72 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
73 $LDIFORDEREDCP > /dev/null 2>&1
75 if test $RC != 0 ; then
76 echo "ldapadd failed ($RC)!"
77 test $KILLSERVERS != no && kill -HUP $KILLPIDS
81 echo "Starting consumer slapd on TCP/IP port $PORT4..."
82 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
83 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
85 if test $WAIT != 0 ; then
86 echo SLAVEPID $SLAVEPID
89 KILLPIDS="$KILLPIDS $SLAVEPID"
93 echo "Using ldapsearch to check that consumer slapd is running..."
94 for i in 0 1 2 3 4 5; do
95 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT4 \
96 'objectclass=*' > /dev/null 2>&1
98 if test $RC = 0 ; then
101 echo "Waiting 5 seconds for slapd to start..."
105 if test $RC != 0 ; then
106 echo "ldapsearch failed ($RC)!"
107 test $KILLSERVERS != no && kill -HUP $KILLPIDS
111 MORELDIF=$TESTDIR/more.ldif
112 TESTOUT1=$TESTDIR/testout1.out
113 TESTOUT2=$TESTDIR/testout2.out
114 sed -e 's/[Oo][Uu]=/ou=More /g' -e 's/^[Oo][Uu]: /ou: More /' \
115 -e 's/cn=Manager/cn=More Manager/g' \
116 -e 's/^cn: Manager/cn: More Manager/' \
117 $LDIFORDEREDNOCP > $MORELDIF
119 echo "Using ldapadd to populate the producer directory..."
120 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
121 $LDIFORDEREDNOCP > $TESTOUT1 2>&1 &
123 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
124 $MORELDIF > $TESTOUT2 2>&1 &
128 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
131 echo "Stopping the provider, sleeping 10 seconds and restarting it..."
135 echo "RESTART" >> $LOG1
136 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
138 if test $WAIT != 0 ; then
142 KILLPIDS="$PID $SLAVEPID"
146 echo "Using ldapsearch to check that producer slapd is running..."
147 for i in 0 1 2 3 4 5; do
148 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
149 'objectclass=*' > /dev/null 2>&1
151 if test $RC = 0 ; then
154 echo "Waiting 5 seconds for slapd to start..."
158 if test $RC != 0 ; then
159 echo "ldapsearch failed ($RC)!"
160 test $KILLSERVERS != no && kill -HUP $KILLPIDS
164 echo "Waiting 10 seconds to let the system catch up"
167 echo "Using ldapmodify to modify producer directory..."
170 # Do some modifications
173 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
174 $TESTOUT 2>&1 << EOMODS
175 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
186 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
191 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
194 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
195 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
198 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
199 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
201 dn: cn=All Staff,ou=Groups,dc=example,dc=com
205 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
207 objectclass: OpenLDAPperson
211 title: Chief Investigator, ITD
212 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
213 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
215 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
216 description: Very odd
217 facsimiletelephonenumber: +1 313 555 7557
218 telephonenumber: +1 313 555 8343
219 mail: gjensen@mailgw.example.com
220 homephone: +1 313 555 8844
222 dn: ou=Retired, ou=People, dc=example,dc=com
224 objectclass: organizationalUnit
227 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
229 objectclass: OpenLDAPperson
230 cn: Rosco P. Coltrane
233 description: Fat tycoon
235 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
237 newrdn: cn=Rosco P. Coltrane
239 newsuperior: ou=Retired, ou=People, dc=example,dc=com
241 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
247 if test $RC != 0 ; then
248 echo "ldapmodify failed ($RC)!"
249 test $KILLSERVERS != no && kill -HUP $KILLPIDS
253 echo "Using ldappasswd to change some passwords..."
254 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
255 'cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
258 if test $RC != 0 ; then
259 echo "ldapmodify failed ($RC)!"
260 test $KILLSERVERS != no && kill -HUP $KILLPIDS
264 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
267 echo "Stopping consumer to test recovery..."
271 echo "Modifying more entries on the producer..."
272 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
273 $TESTOUT 2>&1 << EOMODS
274 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
277 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
282 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
284 objectclass: OpenLDAPperson
287 cn: Rosco P. Coltrane
291 echo "Restarting consumer..."
292 echo "RESTART" >> $LOG4
293 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
295 if test $WAIT != 0 ; then
296 echo SLAVEPID $SLAVEPID
299 KILLPIDS="$PID $SLAVEPID"
301 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
304 if test ! $BACKLDAP = "ldapno" ; then
305 echo "Try updating the consumer slapd..."
306 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD > \
307 $TESTOUT 2>&1 << EOMODS
308 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
311 description: This write must fail because directed to a shadow context,
312 description: unless the chain overlay is configured appropriately ;)
317 if test $RC != 0 ; then
318 echo "ldapmodify failed ($RC)!"
319 test $KILLSERVERS != no && kill -HUP $KILLPIDS
324 echo "Trying to change some passwords on the consumer..."
325 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD \
326 'cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
329 if test $RC != 0 ; then
330 echo "ldapmodify failed ($RC)!"
331 test $KILLSERVERS != no && kill -HUP $KILLPIDS
335 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
339 OPATTRS="entryUUID creatorsName createTimestamp modifiersName modifyTimestamp"
341 echo "Using ldapsearch to read all the entries from the producer..."
342 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
343 '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
346 if test $RC != 0 ; then
347 echo "ldapsearch failed at producer ($RC)!"
348 test $KILLSERVERS != no && kill -HUP $KILLPIDS
352 echo "Using ldapsearch to read all the entries from the consumer..."
353 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
354 '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
357 if test $RC != 0 ; then
358 echo "ldapsearch failed at consumer ($RC)!"
359 test $KILLSERVERS != no && kill -HUP $KILLPIDS
363 test $KILLSERVERS != no && kill -HUP $KILLPIDS
365 echo "Filtering producer results..."
366 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
367 echo "Filtering consumer results..."
368 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
370 echo "Comparing retrieved entries from producer and consumer..."
371 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
373 if test $? != 0 ; then
374 echo "test failed - producer and consumer databases differ"
378 echo ">>>>> Test succeeded"
380 test $KILLSERVERS != no && wait