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" && test "$BACKEND" != "ldif"; 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 $SLEEP1 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 echo "Waiting $SLEEP1 seconds for consumer to reconnect..."
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
237 dn: dc=testdomain1,dc=example,dc=com
239 newrdn: dc=itsdomain1
242 dn: dc=itsdomain1,dc=example,dc=com
245 description: Example, Inc. ITS test domain
247 dn: dc=testdomain2,dc=example,dc=com
249 newrdn: dc=itsdomain2
255 if test $RC != 0 ; then
256 echo "ldapmodify failed ($RC)!"
257 test $KILLSERVERS != no && kill -HUP $KILLPIDS
261 echo "Using ldappasswd to change some passwords..."
262 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
263 'cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
266 if test $RC != 0 ; then
267 echo "ldapmodify failed ($RC)!"
268 test $KILLSERVERS != no && kill -HUP $KILLPIDS
272 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
275 echo "Stopping consumer to test recovery..."
279 echo "Modifying more entries on the producer..."
280 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
281 $TESTOUT 2>&1 << EOMODS
282 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
285 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
290 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
292 objectclass: OpenLDAPperson
295 cn: Rosco P. Coltrane
297 dn: dc=itsdomain2,dc=example,dc=com
300 description: Example, Inc. itsdomain2 test domain
305 if test $RC != 0 ; then
306 echo "ldapmodify failed ($RC)!"
307 test $KILLSERVERS != no && kill -HUP $KILLPIDS
311 echo "Restarting consumer..."
312 echo "RESTART" >> $LOG4
313 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
315 if test $WAIT != 0 ; then
316 echo SLAVEPID $SLAVEPID
319 KILLPIDS="$PID $SLAVEPID"
321 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
324 if test ! $BACKLDAP = "ldapno" ; then
325 echo "Try updating the consumer slapd..."
326 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD > \
327 $TESTOUT 2>&1 << EOMODS
328 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
331 description: This write must fail because directed to a shadow context,
332 description: unless the chain overlay is configured appropriately ;)
337 if test $RC != 0 ; then
338 echo "ldapmodify failed ($RC)!"
339 test $KILLSERVERS != no && kill -HUP $KILLPIDS
344 echo "Trying to change some passwords on the consumer..."
345 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD \
346 'cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
349 if test $RC != 0 ; then
350 echo "ldapmodify failed ($RC)!"
351 test $KILLSERVERS != no && kill -HUP $KILLPIDS
355 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
359 OPATTRS="entryUUID creatorsName createTimestamp modifiersName modifyTimestamp"
361 echo "Using ldapsearch to read all the entries from the producer..."
362 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
363 '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
366 if test $RC != 0 ; then
367 echo "ldapsearch failed at producer ($RC)!"
368 test $KILLSERVERS != no && kill -HUP $KILLPIDS
372 echo "Using ldapsearch to read all the entries from the consumer..."
373 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
374 '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
377 if test $RC != 0 ; then
378 echo "ldapsearch failed at consumer ($RC)!"
379 test $KILLSERVERS != no && kill -HUP $KILLPIDS
383 test $KILLSERVERS != no && kill -HUP $KILLPIDS
385 echo "Filtering producer results..."
386 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
387 echo "Filtering consumer results..."
388 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
390 echo "Comparing retrieved entries from producer and consumer..."
391 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
393 if test $? != 0 ; then
394 echo "test failed - producer and consumer databases differ"
398 echo ">>>>> Test succeeded"
400 test $KILLSERVERS != no && wait