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 to the master slapd..."
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 to the master slapd..."
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 echo "RESTART" >> $LOG2
247 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
249 if test $WAIT != 0 ; then
250 echo SLAVEPID $SLAVEPID
253 KILLPIDS="$KILLPIDS $SLAVEPID"
255 echo "Using ldapsearch to check that slave slapd is running..."
256 for i in 0 1 2 3 4 5; do
257 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
258 'objectclass=*' > /dev/null 2>&1
260 if test $RC = 0 ; then
263 echo "Waiting 5 seconds for slapd to start..."
267 echo "Restarting slurpd..."
268 echo "RESTART" >> $SLURPLOG
269 $SLURPD -f $CONF1 -d ${SLURPD_DEBUG-5} -t $DBDIR1B >> $SLURPLOG 2>&1 &
271 if test $WAIT != 0 ; then
272 echo SLURPPID $SLURPPID
275 KILLPIDS="$KILLPIDS $SLURPPID"
277 echo "Waiting 15 seconds for slurpd to send changes..."
280 echo "Try updating the slave slapd..."
281 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
282 $TESTOUT 2>&1 << EOMODS
283 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
286 description: This write must fail because directed to a shadow context,
287 description: unless the chain overlay is configured appropriately ;)
293 if test $BACKLDAP = "ldapno" ; then
294 # expect 10 (LDAP_REFERRAL)...
295 if test $RC != 10 ; then
296 echo "ldapmodify should have failed ($RC)!"
297 test $KILLSERVERS != no && kill -HUP $KILLPIDS
302 # expect 0 (LDAP_SUCCESS)...
303 if test $RC != 0 ; then
304 echo "ldapmodify failed ($RC)!"
305 test $KILLSERVERS != no && kill -HUP $KILLPIDS
309 echo "Waiting 15 seconds for slurpd to send changes..."
313 echo "Using ldapsearch to read all the entries from the master..."
314 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
315 'objectclass=*' > $MASTEROUT 2>&1
318 if test $RC != 0 ; then
319 echo "ldapsearch failed ($RC)!"
320 test $KILLSERVERS != no && kill -HUP $KILLPIDS
324 echo "Using ldapsearch to read all the entries from the slave..."
325 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
326 'objectclass=*' > $SLAVEOUT 2>&1
329 if test $RC != 0 ; then
330 echo "ldapsearch failed ($RC)!"
331 test $KILLSERVERS != no && kill -HUP $KILLPIDS
335 test $KILLSERVERS != no && kill -HUP $KILLPIDS
337 echo "Filtering master results..."
338 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
339 echo "Filtering slave results..."
340 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
342 echo "Comparing retrieved entries from master and slave..."
343 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
345 if test $? != 0 ; then
346 echo "test failed - master and slave databases differ"
350 echo ">>>>> Test succeeded"