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 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test ! -x $SLURPD ; then
20 echo ">>>>> $SLURPD is not executable or does 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"
60 echo "Using ldapsearch to check that master slapd is running..."
61 for i in 0 1 2 3 4 5; do
62 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
63 'objectclass=*' > /dev/null 2>&1
65 if test $RC = 0 ; then
68 echo "Waiting 5 seconds for slapd to start..."
72 echo "Using ldapsearch to check that slave slapd is running..."
73 for i in 0 1 2 3 4 5; do
74 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
75 'objectclass=*' > /dev/null 2>&1
77 if test $RC = 0 ; then
80 echo "Waiting 5 seconds for slapd to start..."
84 echo "Starting slurpd..."
85 $SLURPD -f $CONF1 -d ${SLURPD_DEBUG-5} -t $DBDIR1B > $SLURPLOG 2>&1 &
87 if test $WAIT != 0 ; then
88 echo SLURPPID $SLURPPID
91 KILLPIDS="$KILLPIDS $SLURPPID"
93 echo "Using ldapadd to populate the master directory..."
94 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
95 $LDIFORDERED > /dev/null 2>&1
97 if test $RC != 0 ; then
98 echo "ldapadd failed ($RC)!"
99 test $KILLSERVERS != no && kill -HUP $KILLPIDS
103 echo "Waiting 15 seconds for slurpd to send changes..."
106 echo "Using ldapmodify to modify master directory..."
109 # Do some modifications
112 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
113 $TESTOUT 2>&1 << EOMODS
114 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
125 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example, dc=com
131 dn: cn=ITD Staff,ou=Groups,dc=example, dc=com
134 uniqueMember: cn=James A Jones 2, ou=Information Technology Division,
135 ou=People, dc=example, dc=com
136 uniqueMember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example, dc=com
139 uniqueMember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example, dc=com
140 uniqueMember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
142 dn: cn=All Staff,ou=Groups,dc=example, dc=com
146 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example, dc=com
148 objectclass: OpenLDAPperson
152 title: Chief Investigator, ITD
153 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
154 seealso: cn=All Staff, ou=Groups, dc=example, dc=com
156 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
157 description: Very odd
158 facsimiletelephonenumber: +1 313 555 7557
159 telephonenumber: +1 313 555 8343
160 mail: gjensen@mailgw.example.com
161 homephone: +1 313 555 8844
163 dn: ou=Retired, ou=People, dc=example, dc=com
165 objectclass: organizationalUnit
168 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example, dc=com
170 objectclass: OpenLDAPperson
171 cn: Rosco P. Coltrane
175 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example, dc=com
177 newrdn: cn=Rosco P. Coltrane
179 newsuperior: ou=Retired, ou=People, dc=example, dc=com
181 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example, dc=com
187 if test $RC != 0 ; then
188 echo "ldapmodify failed ($RC)!"
189 test $KILLSERVERS != no && kill -HUP $KILLPIDS
193 echo "Waiting 15 seconds for slurpd to send changes..."
196 echo "Stopping the slave..."
198 KILLPIDS="$PID $SLURPPID"
200 echo "Waiting for slave slapd to die..."
203 echo "Applying more changes to the master slapd..."
204 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
205 $TESTOUT 2>&1 << EOMODS
206 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
209 description: This change was applied after killing the slave slapd...
215 if test $RC != 0 ; then
216 echo "ldapmodify failed ($RC)!"
217 test $KILLSERVERS != no && kill -HUP $KILLPIDS
222 echo "Stopping slurpd..."
226 echo "Waiting for slurpd to die..."
229 echo "Applying more changes to the master slapd..."
230 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
231 $TESTOUT 2>&1 << EOMODS
232 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
235 description: This change was applied after killing slurpd...
241 if test $RC != 0 ; then
242 echo "ldapmodify failed ($RC)!"
243 test $KILLSERVERS != no && kill -HUP $KILLPIDS
247 echo "Restarting slave slapd on TCP/IP port $PORT2..."
248 echo "RESTART" >> $LOG2
249 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
251 if test $WAIT != 0 ; then
252 echo SLAVEPID $SLAVEPID
255 KILLPIDS="$KILLPIDS $SLAVEPID"
259 echo "Using ldapsearch to check that slave slapd is running..."
260 for i in 0 1 2 3 4 5; do
261 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
262 'objectclass=*' > /dev/null 2>&1
264 if test $RC = 0 ; then
267 echo "Waiting 5 seconds for slapd to start..."
271 echo "Restarting slurpd..."
272 echo "RESTART" >> $SLURPLOG
273 $SLURPD -f $CONF1 -d ${SLURPD_DEBUG-5} -t $DBDIR1B >> $SLURPLOG 2>&1 &
275 if test $WAIT != 0 ; then
276 echo SLURPPID $SLURPPID
279 KILLPIDS="$KILLPIDS $SLURPPID"
281 echo "Waiting 15 seconds for slurpd to send changes..."
284 if test ! $BACKLDAP = "ldapno" ; then
285 echo "Try updating the slave slapd..."
286 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
287 $TESTOUT 2>&1 << EOMODS
288 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
291 description: This write must fail because directed to a shadow context,
292 description: unless the chain overlay is configured appropriately ;)
297 if test $RC != 0 ; then
298 echo "ldapmodify failed ($RC)!"
299 test $KILLSERVERS != no && kill -HUP $KILLPIDS
303 echo "Waiting 15 seconds for slurpd to send changes..."
307 echo "Using ldapsearch to read all the entries from the master..."
308 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
309 'objectclass=*' > $MASTEROUT 2>&1
312 if test $RC != 0 ; then
313 echo "ldapsearch failed ($RC)!"
314 test $KILLSERVERS != no && kill -HUP $KILLPIDS
318 echo "Using ldapsearch to read all the entries from the slave..."
319 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
320 'objectclass=*' > $SLAVEOUT 2>&1
323 if test $RC != 0 ; then
324 echo "ldapsearch failed ($RC)!"
325 test $KILLSERVERS != no && kill -HUP $KILLPIDS
329 test $KILLSERVERS != no && kill -HUP $KILLPIDS
331 echo "Filtering master results..."
332 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
333 echo "Filtering slave results..."
334 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
336 echo "Comparing retrieved entries from master and slave..."
337 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
339 if test $? != 0 ; then
340 echo "test failed - master and slave databases differ"
344 echo ">>>>> Test succeeded"
346 test $KILLSERVERS != no && wait