3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2009 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 $SYNCPROV = syncprovno; then
20 echo "Syncrepl provider overlay not available, test skipped"
23 if test $ACCESSLOG = accesslogno; then
24 echo "Accesslog overlay not available, test skipped"
28 mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR2
34 # - populate over ldap
35 # - perform some modifies and deleted
36 # - attempt to modify the consumer (referral or chain)
37 # - retrieve database over ldap and compare against expected results
40 echo "Starting producer slapd on TCP/IP port $PORT1..."
41 . $CONFFILTER $BACKEND $MONITORDB < $DSRMASTERCONF > $CONF1
42 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
44 if test $WAIT != 0 ; then
52 echo "Using ldapsearch to check that producer slapd is running..."
53 for i in 0 1 2 3 4 5; do
54 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
55 'objectclass=*' > /dev/null 2>&1
57 if test $RC = 0 ; then
60 echo "Waiting 5 seconds for slapd to start..."
64 if test $RC != 0 ; then
65 echo "ldapsearch failed ($RC)!"
66 test $KILLSERVERS != no && kill -HUP $KILLPIDS
70 echo "Using ldapadd to create the context prefix entries in the producer..."
71 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
72 $LDIFORDEREDCP > /dev/null 2>&1
74 if test $RC != 0 ; then
75 echo "ldapadd failed ($RC)!"
76 test $KILLSERVERS != no && kill -HUP $KILLPIDS
80 echo "Starting consumer slapd on TCP/IP port $PORT2..."
81 . $CONFFILTER $BACKEND $MONITORDB < $DSRSLAVECONF > $CONF2
82 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
84 if test $WAIT != 0 ; then
85 echo SLAVEPID $SLAVEPID
88 KILLPIDS="$KILLPIDS $SLAVEPID"
92 echo "Using ldapsearch to check that consumer slapd is running..."
93 for i in 0 1 2 3 4 5; do
94 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
95 'objectclass=*' > /dev/null 2>&1
97 if test $RC = 0 ; then
100 echo "Waiting 5 seconds for slapd to start..."
104 if test $RC != 0 ; then
105 echo "ldapsearch failed ($RC)!"
106 test $KILLSERVERS != no && kill -HUP $KILLPIDS
110 echo "Using ldapadd to populate the producer directory..."
111 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
112 $LDIFORDEREDNOCP > /dev/null 2>&1
114 if test $RC != 0 ; then
115 echo "ldapadd failed ($RC)!"
116 test $KILLSERVERS != no && kill -HUP $KILLPIDS
120 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
123 echo "Stopping the provider, sleeping 10 seconds and restarting it..."
126 echo "RESTART" >> $LOG1
127 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
129 if test $WAIT != 0 ; then
133 KILLPIDS="$PID $SLAVEPID"
137 echo "Using ldapsearch to check that producer slapd is running..."
138 for i in 0 1 2 3 4 5; do
139 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
140 'objectclass=*' > /dev/null 2>&1
142 if test $RC = 0 ; then
145 echo "Waiting 5 seconds for slapd to start..."
149 if test $RC != 0 ; then
150 echo "ldapsearch failed ($RC)!"
151 test $KILLSERVERS != no && kill -HUP $KILLPIDS
155 echo "Using ldapmodify to modify producer directory..."
158 # Do some modifications
161 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
162 $TESTOUT 2>&1 << EOMODS
163 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
174 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
179 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
182 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
183 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
186 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
187 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
189 dn: cn=All Staff,ou=Groups,dc=example,dc=com
193 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
195 objectclass: OpenLDAPperson
199 title: Chief Investigator, ITD
200 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
201 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
203 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
204 description: Very odd
205 facsimiletelephonenumber: +1 313 555 7557
206 telephonenumber: +1 313 555 8343
207 mail: gjensen@mailgw.example.com
208 homephone: +1 313 555 8844
210 dn: ou=Retired, ou=People, dc=example,dc=com
212 objectclass: organizationalUnit
215 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
217 objectclass: OpenLDAPperson
218 cn: Rosco P. Coltrane
221 description: Fat tycoon
223 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
225 newrdn: cn=Rosco P. Coltrane
227 newsuperior: ou=Retired, ou=People, dc=example,dc=com
229 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
234 if test $RC != 0 ; then
235 echo "ldapmodify failed ($RC)!"
236 test $KILLSERVERS != no && kill -HUP $KILLPIDS
240 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
243 echo "Stopping consumer to test recovery..."
247 echo "Modifying more entries on the producer..."
248 $LDAPMODIFY -v -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
249 $TESTOUT 2>&1 << EOMODS
250 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
253 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
258 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
260 objectclass: OpenLDAPperson
263 cn: Rosco P. Coltrane
265 dn: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com
269 dn: cn=All Staff,ou=Groups,dc=example,dc=com
271 newrdn: cn=Some Staff
276 echo "Restarting consumer..."
277 echo "RESTART" >> $LOG2
278 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
280 if test $WAIT != 0 ; then
281 echo SLAVEPID $SLAVEPID
284 KILLPIDS="$PID $SLAVEPID"
286 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
289 if test ! $BACKLDAP = "ldapno" ; then
290 echo "Try updating the consumer slapd..."
291 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
292 $TESTOUT 2>&1 << EOMODS
293 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
296 description: This write must fail because directed to a shadow context,
297 description: unless the chain overlay is configured appropriately ;)
302 if test $RC != 0 ; then
303 echo "ldapmodify failed ($RC)!"
304 test $KILLSERVERS != no && kill -HUP $KILLPIDS
308 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
312 echo "Using ldapsearch to read all the entries from the producer..."
313 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
314 'objectclass=*' \* + > $MASTEROUT 2>&1
317 if test $RC != 0 ; then
318 echo "ldapsearch failed at producer ($RC)!"
319 test $KILLSERVERS != no && kill -HUP $KILLPIDS
323 echo "Using ldapsearch to read all the entries from the consumer..."
324 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
325 'objectclass=*' \* + > $SLAVEOUT 2>&1
328 if test $RC != 0 ; then
329 echo "ldapsearch failed at consumer ($RC)!"
330 test $KILLSERVERS != no && kill -HUP $KILLPIDS
334 test $KILLSERVERS != no && kill -HUP $KILLPIDS
336 echo "Filtering producer results..."
337 $LDIFFILTER < $MASTEROUT | grep -iv "^auditcontext:" > $MASTERFLT
338 echo "Filtering consumer results..."
339 $LDIFFILTER < $SLAVEOUT | grep -iv "^auditcontext:" > $SLAVEFLT
341 echo "Comparing retrieved entries from producer and consumer..."
342 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
344 if test $? != 0 ; then
345 echo "test failed - producer and consumer databases differ"
349 echo ">>>>> Test succeeded"
351 test $KILLSERVERS != no && wait