3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2005 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" -a "$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 slave (referral or chain)
38 # - retrieve database over ldap and compare against expected results
41 echo "Starting master 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
51 echo "Using ldapsearch to check that master slapd is running..."
52 for i in 0 1 2 3 4 5; do
53 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
54 'objectclass=*' > /dev/null 2>&1
56 if test $RC = 0 ; then
59 echo "Waiting 5 seconds for slapd to start..."
63 if test $RC != 0 ; then
64 echo "ldapsearch failed ($RC)!"
65 test $KILLSERVERS != no && kill -HUP $KILLPIDS
69 echo "Using ldapadd to create the context prefix entry in the master..."
70 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
71 $LDIFORDEREDCP > /dev/null 2>&1
73 if test $RC != 0 ; then
74 echo "ldapadd failed ($RC)!"
75 test $KILLSERVERS != no && kill -HUP $KILLPIDS
79 echo "Starting slave slapd on TCP/IP port $PORT4..."
80 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
81 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
83 if test $WAIT != 0 ; then
84 echo SLAVEPID $SLAVEPID
87 KILLPIDS="$KILLPIDS $SLAVEPID"
89 echo "Using ldapsearch to check that slave slapd is running..."
90 for i in 0 1 2 3 4 5; do
91 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT4 \
92 'objectclass=*' > /dev/null 2>&1
94 if test $RC = 0 ; then
97 echo "Waiting 5 seconds for slapd to start..."
101 if test $RC != 0 ; then
102 echo "ldapsearch failed ($RC)!"
103 test $KILLSERVERS != no && kill -HUP $KILLPIDS
107 echo "Using ldapadd to populate the master directory..."
108 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
109 $LDIFORDEREDNOCP > /dev/null 2>&1
111 if test $RC != 0 ; then
112 echo "ldapadd failed ($RC)!"
113 test $KILLSERVERS != no && kill -HUP $KILLPIDS
117 echo "Waiting 15 seconds for syncrepl to receive changes..."
120 echo "Stopping the provider, sleeping 10 seconds and restarting it..."
123 echo "RESTART" >> $LOG1
124 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
126 if test $WAIT != 0 ; then
130 KILLPIDS="$PID $SLAVEPID"
132 echo "Using ldapsearch to check that master slapd is running..."
133 for i in 0 1 2 3 4 5; do
134 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
135 'objectclass=*' > /dev/null 2>&1
137 if test $RC = 0 ; then
140 echo "Waiting 5 seconds for slapd to start..."
144 if test $RC != 0 ; then
145 echo "ldapsearch failed ($RC)!"
146 test $KILLSERVERS != no && kill -HUP $KILLPIDS
150 echo "Using ldapmodify to modify master directory..."
153 # Do some modifications
156 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
157 $TESTOUT 2>&1 << EOMODS
158 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
169 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
174 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
177 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
178 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
181 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
182 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
184 dn: cn=All Staff,ou=Groups,dc=example,dc=com
188 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
190 objectclass: OpenLDAPperson
194 title: Chief Investigator, ITD
195 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
196 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
198 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
199 description: Very odd
200 facsimiletelephonenumber: +1 313 555 7557
201 telephonenumber: +1 313 555 8343
202 mail: gjensen@mailgw.example.com
203 homephone: +1 313 555 8844
205 dn: ou=Retired, ou=People, dc=example,dc=com
207 objectclass: organizationalUnit
210 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
212 objectclass: OpenLDAPperson
213 cn: Rosco P. Coltrane
216 description: Fat tycoon
218 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
220 newrdn: cn=Rosco P. Coltrane
222 newsuperior: ou=Retired, ou=People, dc=example,dc=com
224 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
230 if test $RC != 0 ; then
231 echo "ldapmodify failed ($RC)!"
232 test $KILLSERVERS != no && kill -HUP $KILLPIDS
236 echo "Waiting 15 seconds for syncrepl to receive changes..."
239 echo "Stopping consumer to test recovery..."
243 echo "Modifying more entries on the master..."
244 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
245 $TESTOUT 2>&1 << EOMODS
246 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
249 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
254 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
256 objectclass: OpenLDAPperson
259 cn: Rosco P. Coltrane
263 echo "Restarting consumer..."
264 echo "RESTART" >> $LOG4
265 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
267 if test $WAIT != 0 ; then
268 echo SLAVEPID $SLAVEPID
271 KILLPIDS="$PID $SLAVEPID"
273 echo "Waiting 25 seconds for syncrepl to receive changes..."
276 echo "Try updating the slave slapd..."
277 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD > \
278 $TESTOUT 2>&1 << EOMODS
279 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
282 description: This write must fail because directed to a shadow context,
283 description: unless the chain overlay is configured appropriately ;)
289 if test $BACKLDAP = "ldapno" ; then
290 # expect 10 (LDAP_REFERRAL)...
291 if test $RC != 10 ; then
292 echo "ldapmodify should have failed ($RC)!"
293 test $KILLSERVERS != no && kill -HUP $KILLPIDS
298 # expect 0 (LDAP_SUCCESS)...
299 if test $RC != 0 ; then
300 echo "ldapmodify failed ($RC)!"
301 test $KILLSERVERS != no && kill -HUP $KILLPIDS
305 echo "Waiting 5 seconds for syncrepl to send changes..."
309 echo "Using ldapsearch to read all the entries from the master..."
310 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
311 'objectclass=*' > $MASTEROUT 2>&1
314 if test $RC != 0 ; then
315 echo "ldapsearch failed at master ($RC)!"
316 test $KILLSERVERS != no && kill -HUP $KILLPIDS
320 echo "Using ldapsearch to read all the entries from the slave..."
321 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
322 'objectclass=*' > $SLAVEOUT 2>&1
325 if test $RC != 0 ; then
326 echo "ldapsearch failed at slave ($RC)!"
327 test $KILLSERVERS != no && kill -HUP $KILLPIDS
331 test $KILLSERVERS != no && kill -HUP $KILLPIDS
333 echo "Filtering master results..."
334 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
335 echo "Filtering slave results..."
336 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
338 echo "Comparing retrieved entries from master and slave..."
339 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
341 if test $? != 0 ; then
342 echo "test failed - master and slave databases differ"
346 echo ">>>>> Test succeeded"