3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2006 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 < \
77 $LDIFORDEREDCP > /dev/null 2>&1
79 if test $RC != 0 ; then
80 echo "ldapadd failed ($RC)!"
81 test $KILLSERVERS != no && kill -HUP $KILLPIDS
85 echo "Starting slave slapd on TCP/IP port $PORT2..."
86 . $CONFFILTER $BACKEND $MONITORDB < $DSRSLAVECONF > $CONF2
87 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
89 if test $WAIT != 0 ; then
90 echo SLAVEPID $SLAVEPID
93 KILLPIDS="$KILLPIDS $SLAVEPID"
97 echo "Using ldapsearch to check that slave slapd is running..."
98 for i in 0 1 2 3 4 5; do
99 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
100 'objectclass=*' > /dev/null 2>&1
102 if test $RC = 0 ; then
105 echo "Waiting 5 seconds for slapd to start..."
109 if test $RC != 0 ; then
110 echo "ldapsearch failed ($RC)!"
111 test $KILLSERVERS != no && kill -HUP $KILLPIDS
115 echo "Using ldapadd to populate the master directory..."
116 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
117 $LDIFORDEREDNOCP > /dev/null 2>&1
119 if test $RC != 0 ; then
120 echo "ldapadd failed ($RC)!"
121 test $KILLSERVERS != no && kill -HUP $KILLPIDS
125 echo "Waiting 15 seconds for syncrepl to receive changes..."
128 echo "Stopping the provider, sleeping 10 seconds and restarting it..."
131 echo "RESTART" >> $LOG1
132 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
134 if test $WAIT != 0 ; then
138 KILLPIDS="$PID $SLAVEPID"
142 echo "Using ldapsearch to check that master slapd is running..."
143 for i in 0 1 2 3 4 5; do
144 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
145 'objectclass=*' > /dev/null 2>&1
147 if test $RC = 0 ; then
150 echo "Waiting 5 seconds for slapd to start..."
154 if test $RC != 0 ; then
155 echo "ldapsearch failed ($RC)!"
156 test $KILLSERVERS != no && kill -HUP $KILLPIDS
160 echo "Using ldapmodify to modify master 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
240 if test $RC != 0 ; then
241 echo "ldapmodify failed ($RC)!"
242 test $KILLSERVERS != no && kill -HUP $KILLPIDS
246 echo "Waiting 15 seconds for syncrepl to receive changes..."
249 echo "Stopping consumer to test recovery..."
253 echo "Modifying more entries on the master..."
254 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
255 $TESTOUT 2>&1 << EOMODS
256 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
259 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
264 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
266 objectclass: OpenLDAPperson
269 cn: Rosco P. Coltrane
273 echo "Restarting consumer..."
274 echo "RESTART" >> $LOG2
275 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
277 if test $WAIT != 0 ; then
278 echo SLAVEPID $SLAVEPID
281 KILLPIDS="$PID $SLAVEPID"
283 echo "Waiting 25 seconds for syncrepl to receive changes..."
286 if test ! $BACKLDAP = "ldapno" ; then
287 echo "Try updating the slave slapd..."
288 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
289 $TESTOUT 2>&1 << EOMODS
290 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
293 description: This write must fail because directed to a shadow context,
294 description: unless the chain overlay is configured appropriately ;)
299 if test $RC != 0 ; then
300 echo "ldapmodify failed ($RC)!"
301 test $KILLSERVERS != no && kill -HUP $KILLPIDS
305 echo "Waiting 15 seconds for syncrepl to receive 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 $PORT2 \
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"
348 test $KILLSERVERS != no && wait