3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2007 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 echo "Using ldapadd to populate the producer directory..."
112 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
113 $LDIFORDEREDNOCP > /dev/null 2>&1
115 if test $RC != 0 ; then
116 echo "ldapadd failed ($RC)!"
117 test $KILLSERVERS != no && kill -HUP $KILLPIDS
121 echo "Waiting 15 seconds for syncrepl to receive changes..."
124 echo "Stopping the provider, sleeping 10 seconds and restarting it..."
128 echo "RESTART" >> $LOG1
129 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
131 if test $WAIT != 0 ; then
135 KILLPIDS="$PID $SLAVEPID"
139 echo "Using ldapsearch to check that producer slapd is running..."
140 for i in 0 1 2 3 4 5; do
141 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
142 'objectclass=*' > /dev/null 2>&1
144 if test $RC = 0 ; then
147 echo "Waiting 5 seconds for slapd to start..."
151 if test $RC != 0 ; then
152 echo "ldapsearch failed ($RC)!"
153 test $KILLSERVERS != no && kill -HUP $KILLPIDS
157 echo "Using ldapmodify to modify producer directory..."
160 # Do some modifications
163 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
164 $TESTOUT 2>&1 << EOMODS
165 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
176 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
181 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
184 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
185 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
188 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
189 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
191 dn: cn=All Staff,ou=Groups,dc=example,dc=com
195 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
197 objectclass: OpenLDAPperson
201 title: Chief Investigator, ITD
202 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
203 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
205 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
206 description: Very odd
207 facsimiletelephonenumber: +1 313 555 7557
208 telephonenumber: +1 313 555 8343
209 mail: gjensen@mailgw.example.com
210 homephone: +1 313 555 8844
212 dn: ou=Retired, ou=People, dc=example,dc=com
214 objectclass: organizationalUnit
217 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
219 objectclass: OpenLDAPperson
220 cn: Rosco P. Coltrane
223 description: Fat tycoon
225 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
227 newrdn: cn=Rosco P. Coltrane
229 newsuperior: ou=Retired, ou=People, dc=example,dc=com
231 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
237 if test $RC != 0 ; then
238 echo "ldapmodify failed ($RC)!"
239 test $KILLSERVERS != no && kill -HUP $KILLPIDS
243 echo "Using ldappasswd to change some passwords..."
244 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
245 'cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
248 if test $RC != 0 ; then
249 echo "ldapmodify failed ($RC)!"
250 test $KILLSERVERS != no && kill -HUP $KILLPIDS
254 echo "Waiting 15 seconds for syncrepl to receive changes..."
257 echo "Stopping consumer to test recovery..."
261 echo "Modifying more entries on the producer..."
262 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
263 $TESTOUT 2>&1 << EOMODS
264 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
267 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
272 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
274 objectclass: OpenLDAPperson
277 cn: Rosco P. Coltrane
281 echo "Restarting consumer..."
282 echo "RESTART" >> $LOG4
283 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING >> $LOG4 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 $PORT4 -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
314 echo "Trying to change some passwords on the consumer..."
315 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD \
316 'cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
319 if test $RC != 0 ; then
320 echo "ldapmodify failed ($RC)!"
321 test $KILLSERVERS != no && kill -HUP $KILLPIDS
325 echo "Waiting 15 seconds for syncrepl to receive changes..."
329 OPATTRS="entryUUID creatorsName createTimestamp modifiersName modifyTimestamp"
331 echo "Using ldapsearch to read all the entries from the producer..."
332 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
333 '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
336 if test $RC != 0 ; then
337 echo "ldapsearch failed at producer ($RC)!"
338 test $KILLSERVERS != no && kill -HUP $KILLPIDS
342 echo "Using ldapsearch to read all the entries from the consumer..."
343 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
344 '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
347 if test $RC != 0 ; then
348 echo "ldapsearch failed at consumer ($RC)!"
349 test $KILLSERVERS != no && kill -HUP $KILLPIDS
353 test $KILLSERVERS != no && kill -HUP $KILLPIDS
355 echo "Filtering producer results..."
356 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
357 echo "Filtering consumer results..."
358 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
360 echo "Comparing retrieved entries from producer and consumer..."
361 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
363 if test $? != 0 ; then
364 echo "test failed - producer and consumer databases differ"
368 echo ">>>>> Test succeeded"
370 test $KILLSERVERS != no && wait