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 "Using ldapmodify to modify master directory..."
123 # Do some modifications
126 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
127 $TESTOUT 2>&1 << EOMODS
128 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
139 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
144 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
147 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
148 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
151 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
152 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
154 dn: cn=All Staff,ou=Groups,dc=example,dc=com
158 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
160 objectclass: OpenLDAPperson
164 title: Chief Investigator, ITD
165 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
166 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
168 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
169 description: Very odd
170 facsimiletelephonenumber: +1 313 555 7557
171 telephonenumber: +1 313 555 8343
172 mail: gjensen@mailgw.example.com
173 homephone: +1 313 555 8844
175 dn: ou=Retired, ou=People, dc=example,dc=com
177 objectclass: organizationalUnit
180 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
182 objectclass: OpenLDAPperson
183 cn: Rosco P. Coltrane
186 description: Fat tycoon
188 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
190 newrdn: cn=Rosco P. Coltrane
192 newsuperior: ou=Retired, ou=People, dc=example,dc=com
194 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
200 if test $RC != 0 ; then
201 echo "ldapmodify failed ($RC)!"
202 test $KILLSERVERS != no && kill -HUP $KILLPIDS
206 echo "Waiting 15 seconds for syncrepl to receive changes..."
209 echo "Stopping consumer to test recovery..."
213 echo "Modifying more entries on the master..."
214 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
215 $TESTOUT 2>&1 << EOMODS
216 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
219 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
224 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
226 objectclass: OpenLDAPperson
229 cn: Rosco P. Coltrane
233 echo "Restarting consumer..."
234 echo "RESTART" >> $LOG4
235 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
237 if test $WAIT != 0 ; then
238 echo SLAVEPID $SLAVEPID
241 KILLPIDS="$PID $SLAVEPID"
243 echo "Waiting 25 seconds for syncrepl to receive changes..."
246 echo "Try updating the slave slapd..."
247 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD > \
248 $TESTOUT 2>&1 << EOMODS
249 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
252 description: This write must fail because directed to a shadow context,
253 description: unless the chain overlay is configured appropriately ;)
259 if test $BACKLDAP = "ldapno" ; then
260 # expect 10 (LDAP_REFERRAL)...
261 if test $RC != 10 ; then
262 echo "ldapmodify should have failed ($RC)!"
263 test $KILLSERVERS != no && kill -HUP $KILLPIDS
268 # expect 0 (LDAP_SUCCESS)...
269 if test $RC != 0 ; then
270 echo "ldapmodify failed ($RC)!"
271 test $KILLSERVERS != no && kill -HUP $KILLPIDS
275 echo "Waiting 5 seconds for syncrepl to send changes..."
279 echo "Using ldapsearch to read all the entries from the master..."
280 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
281 'objectclass=*' > $MASTEROUT 2>&1
284 if test $RC != 0 ; then
285 echo "ldapsearch failed at master ($RC)!"
286 test $KILLSERVERS != no && kill -HUP $KILLPIDS
290 echo "Using ldapsearch to read all the entries from the slave..."
291 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
292 'objectclass=*' > $SLAVEOUT 2>&1
295 if test $RC != 0 ; then
296 echo "ldapsearch failed at slave ($RC)!"
297 test $KILLSERVERS != no && kill -HUP $KILLPIDS
301 test $KILLSERVERS != no && kill -HUP $KILLPIDS
303 echo "Filtering master results..."
304 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
305 echo "Filtering slave results..."
306 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
308 echo "Comparing retrieved entries from master and slave..."
309 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
311 if test $? != 0 ; then
312 echo "test failed - master and slave databases differ"
316 echo ">>>>> Test succeeded"