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 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test ! -x $SLURPD ; then
20 echo ">>>>> $SLURPD is not executable or do not exist."
21 echo ">>>>> Test skipped."
25 mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR2
29 # - start master (slapd1)
30 # - start slave (slapd2)
32 # - populate over ldap
33 # - perform some modifies and deleted
34 # - attempt to modify the slave (referral or chain)
35 # - retrieve database over ldap and compare against expected results
38 echo "Starting master slapd on TCP/IP port $PORT1..."
39 . $CONFFILTER $BACKEND $MONITORDB < $MASTERCONF > $CONF1
40 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
42 if test $WAIT != 0 ; then
48 echo "Starting slave slapd on TCP/IP port $PORT2..."
49 . $CONFFILTER $BACKEND $MONITORDB < $SLAVECONF > $CONF2
50 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
52 if test $WAIT != 0 ; then
53 echo SLAVEPID $SLAVEPID
56 KILLPIDS="$KILLPIDS $SLAVEPID"
58 echo "Using ldapsearch to check that master slapd is running..."
59 for i in 0 1 2 3 4 5; do
60 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
61 'objectclass=*' > /dev/null 2>&1
63 if test $RC = 0 ; then
66 echo "Waiting 5 seconds for slapd to start..."
70 echo "Using ldapsearch to check that slave slapd is running..."
71 for i in 0 1 2 3 4 5; do
72 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
73 'objectclass=*' > /dev/null 2>&1
75 if test $RC = 0 ; then
78 echo "Waiting 5 seconds for slapd to start..."
82 echo "Starting slurpd..."
83 $SLURPD -f $CONF1 -d ${SLURPD_DEBUG-5} -t $DBDIR1B > $SLURPLOG 2>&1 &
85 if test $WAIT != 0 ; then
86 echo SLURPPID $SLURPPID
89 KILLPIDS="$KILLPIDS $SLURPPID"
91 echo "Using ldapadd to populate the master directory..."
92 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
93 $LDIFORDERED > /dev/null 2>&1
95 if test $RC != 0 ; then
96 echo "ldapadd failed ($RC)!"
97 test $KILLSERVERS != no && kill -HUP $KILLPIDS
101 echo "Waiting 15 seconds for slurpd to send changes..."
104 echo "Using ldapmodify to modify master directory..."
107 # Do some modifications
110 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
111 $TESTOUT 2>&1 << EOMODS
112 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
123 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example, dc=com
129 dn: cn=ITD Staff,ou=Groups,dc=example, dc=com
132 uniqueMember: cn=James A Jones 2, ou=Information Technology Division,
133 ou=People, dc=example, dc=com
134 uniqueMember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example, dc=com
137 uniqueMember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example, dc=com
138 uniqueMember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
140 dn: cn=All Staff,ou=Groups,dc=example, dc=com
144 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example, dc=com
146 objectclass: OpenLDAPperson
150 title: Chief Investigator, ITD
151 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
152 seealso: cn=All Staff, ou=Groups, dc=example, dc=com
154 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
155 description: Very odd
156 facsimiletelephonenumber: +1 313 555 7557
157 telephonenumber: +1 313 555 8343
158 mail: gjensen@mailgw.example.com
159 homephone: +1 313 555 8844
161 dn: ou=Retired, ou=People, dc=example, dc=com
163 objectclass: organizationalUnit
166 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example, dc=com
168 objectclass: OpenLDAPperson
169 cn: Rosco P. Coltrane
173 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example, dc=com
175 newrdn: cn=Rosco P. Coltrane
177 newsuperior: ou=Retired, ou=People, dc=example, dc=com
179 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example, dc=com
185 if test $RC != 0 ; then
186 echo "ldapmodify failed ($RC)!"
187 test $KILLSERVERS != no && kill -HUP $KILLPIDS
191 echo "Waiting 15 seconds for slurpd to send changes..."
194 echo "Stopping the slave..."
196 KILLPIDS="$PID $SLURPPID"
198 echo "Waiting 5 seconds for slave slapd to die..."
201 echo "Applying more changes..."
202 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
203 $TESTOUT 2>&1 << EOMODS
204 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
207 description: This change was applied after killing the slave slapd...
213 if test $RC != 0 ; then
214 echo "ldapmodify failed ($RC)!"
215 test $KILLSERVERS != no && kill -HUP $KILLPIDS
220 echo "Stopping slurpd..."
224 echo "Waiting 5 seconds for slurpd to die..."
227 echo "Applying more changes..."
228 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
229 $TESTOUT 2>&1 << EOMODS
230 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
233 description: This change was applied after killing slurpd...
239 if test $RC != 0 ; then
240 echo "ldapmodify failed ($RC)!"
241 test $KILLSERVERS != no && kill -HUP $KILLPIDS
245 echo "Restarting slave slapd on TCP/IP port $PORT2..."
246 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
248 if test $WAIT != 0 ; then
249 echo SLAVEPID $SLAVEPID
252 KILLPIDS="$KILLPIDS $SLAVEPID"
254 echo "Using ldapsearch to check that slave slapd is running..."
255 for i in 0 1 2 3 4 5; do
256 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
257 'objectclass=*' > /dev/null 2>&1
259 if test $RC = 0 ; then
262 echo "Waiting 5 seconds for slapd to start..."
266 echo "Starting slurpd..."
267 $SLURPD -f $CONF1 -d ${SLURPD_DEBUG-5} -t $DBDIR1B >> $SLURPLOG 2>&1 &
269 if test $WAIT != 0 ; then
270 echo SLURPPID $SLURPPID
273 KILLPIDS="$KILLPIDS $SLURPPID"
275 echo "Waiting 15 seconds for slurpd to send changes..."
278 echo "Try updating the slave slapd..."
279 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
280 $TESTOUT 2>&1 << EOMODS
281 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
284 description: This write must fail because directed to a shadow context,
285 description: unless the chain overlay is configured appropriately ;)
291 if test $BACKLDAP = "ldapno" ; then
292 # expect 10 (LDAP_REFERRAL)...
293 if test $RC != 10 ; then
294 echo "ldapmodify should have failed ($RC)!"
295 test $KILLSERVERS != no && kill -HUP $KILLPIDS
300 # expect 0 (LDAP_SUCCESS)...
301 if test $RC != 0 ; then
302 echo "ldapmodify failed ($RC)!"
303 test $KILLSERVERS != no && kill -HUP $KILLPIDS
307 echo "Waiting 5 seconds for slurpd to send changes..."
311 echo "Using ldapsearch to read all the entries from the master..."
312 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
313 'objectclass=*' > $MASTEROUT 2>&1
316 if test $RC != 0 ; then
317 echo "ldapsearch failed ($RC)!"
318 test $KILLSERVERS != no && kill -HUP $KILLPIDS
322 echo "Using ldapsearch to read all the entries from the slave..."
323 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
324 'objectclass=*' > $SLAVEOUT 2>&1
327 if test $RC != 0 ; then
328 echo "ldapsearch failed ($RC)!"
329 test $KILLSERVERS != no && kill -HUP $KILLPIDS
333 test $KILLSERVERS != no && kill -HUP $KILLPIDS
335 echo "Filtering master results..."
336 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
337 echo "Filtering slave results..."
338 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
340 echo "Comparing retrieved entries from master and slave..."
341 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
343 if test $? != 0 ; then
344 echo "test failed - master and slave databases differ"
348 echo ">>>>> Test succeeded"