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" && 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 slave (referral or chain)
42 # - retrieve database over ldap and compare against expected results
45 echo "Starting master 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 master 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 master..."
76 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD <<EOF \
79 objectclass: applicationProcess
84 if test $RC != 0 ; then
85 echo "ldapadd failed ($RC)!"
86 test $KILLSERVERS != no && kill -HUP $KILLPIDS
89 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
90 $LDIFORDEREDCP > /dev/null 2>&1
92 if test $RC != 0 ; then
93 echo "ldapadd failed ($RC)!"
94 test $KILLSERVERS != no && kill -HUP $KILLPIDS
98 echo "Starting slave slapd on TCP/IP port $PORT2..."
99 . $CONFFILTER $BACKEND $MONITORDB < $DSRSLAVECONF > $CONF2
100 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
102 if test $WAIT != 0 ; then
103 echo SLAVEPID $SLAVEPID
106 KILLPIDS="$KILLPIDS $SLAVEPID"
110 echo "Using ldapsearch to check that slave slapd is running..."
111 for i in 0 1 2 3 4 5; do
112 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
113 'objectclass=*' > /dev/null 2>&1
115 if test $RC = 0 ; then
118 echo "Waiting 5 seconds for slapd to start..."
122 if test $RC != 0 ; then
123 echo "ldapsearch failed ($RC)!"
124 test $KILLSERVERS != no && kill -HUP $KILLPIDS
128 echo "Using ldapadd to populate the master directory..."
129 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
130 $LDIFORDEREDNOCP > /dev/null 2>&1
132 if test $RC != 0 ; then
133 echo "ldapadd failed ($RC)!"
134 test $KILLSERVERS != no && kill -HUP $KILLPIDS
138 echo "Waiting 15 seconds for syncrepl to receive changes..."
141 echo "Stopping the provider, sleeping 10 seconds and restarting it..."
144 echo "RESTART" >> $LOG1
145 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
147 if test $WAIT != 0 ; then
151 KILLPIDS="$PID $SLAVEPID"
155 echo "Using ldapsearch to check that master slapd is running..."
156 for i in 0 1 2 3 4 5; do
157 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
158 'objectclass=*' > /dev/null 2>&1
160 if test $RC = 0 ; then
163 echo "Waiting 5 seconds for slapd to start..."
167 if test $RC != 0 ; then
168 echo "ldapsearch failed ($RC)!"
169 test $KILLSERVERS != no && kill -HUP $KILLPIDS
173 echo "Using ldapmodify to modify master directory..."
176 # Do some modifications
179 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
180 $TESTOUT 2>&1 << EOMODS
181 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
192 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
197 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
200 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
201 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
204 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
205 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
207 dn: cn=All Staff,ou=Groups,dc=example,dc=com
211 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
213 objectclass: OpenLDAPperson
217 title: Chief Investigator, ITD
218 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
219 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
221 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
222 description: Very odd
223 facsimiletelephonenumber: +1 313 555 7557
224 telephonenumber: +1 313 555 8343
225 mail: gjensen@mailgw.example.com
226 homephone: +1 313 555 8844
228 dn: ou=Retired, ou=People, dc=example,dc=com
230 objectclass: organizationalUnit
233 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
235 objectclass: OpenLDAPperson
236 cn: Rosco P. Coltrane
239 description: Fat tycoon
241 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
243 newrdn: cn=Rosco P. Coltrane
245 newsuperior: ou=Retired, ou=People, dc=example,dc=com
247 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
253 if test $RC != 0 ; then
254 echo "ldapmodify failed ($RC)!"
255 test $KILLSERVERS != no && kill -HUP $KILLPIDS
259 echo "Waiting 15 seconds for syncrepl to receive changes..."
262 echo "Stopping consumer to test recovery..."
266 echo "Modifying more entries on the master..."
267 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
268 $TESTOUT 2>&1 << EOMODS
269 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
272 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
277 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
279 objectclass: OpenLDAPperson
282 cn: Rosco P. Coltrane
286 echo "Restarting consumer..."
287 echo "RESTART" >> $LOG2
288 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
290 if test $WAIT != 0 ; then
291 echo SLAVEPID $SLAVEPID
294 KILLPIDS="$PID $SLAVEPID"
296 echo "Waiting 25 seconds for syncrepl to receive changes..."
299 if test ! $BACKLDAP = "ldapno" ; then
300 echo "Try updating the slave slapd..."
301 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
302 $TESTOUT 2>&1 << EOMODS
303 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
306 description: This write must fail because directed to a shadow context,
307 description: unless the chain overlay is configured appropriately ;)
312 if test $RC != 0 ; then
313 echo "ldapmodify failed ($RC)!"
314 test $KILLSERVERS != no && kill -HUP $KILLPIDS
318 echo "Waiting 15 seconds for syncrepl to receive changes..."
322 echo "Using ldapsearch to read all the entries from the master..."
323 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
324 'objectclass=*' > $MASTEROUT 2>&1
327 if test $RC != 0 ; then
328 echo "ldapsearch failed at master ($RC)!"
329 test $KILLSERVERS != no && kill -HUP $KILLPIDS
333 echo "Using ldapsearch to read all the entries from the slave..."
334 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
335 'objectclass=*' > $SLAVEOUT 2>&1
338 if test $RC != 0 ; then
339 echo "ldapsearch failed at slave ($RC)!"
340 test $KILLSERVERS != no && kill -HUP $KILLPIDS
344 test $KILLSERVERS != no && kill -HUP $KILLPIDS
346 echo "Filtering master results..."
347 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
348 echo "Filtering slave results..."
349 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
351 echo "Comparing retrieved entries from master and slave..."
352 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
354 if test $? != 0 ; then
355 echo "test failed - master and slave databases differ"
359 echo ">>>>> Test succeeded"