3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2010 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"
24 mkdir -p $TESTDIR $DBDIR1 $DBDIR4
30 # - populate over ldap
31 # - perform some modifies and deleted
32 # - attempt to modify the consumer (referral or chain)
33 # - retrieve database over ldap and compare against expected results
36 echo "Starting producer slapd on TCP/IP port $PORT1..."
37 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
38 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
40 if test $WAIT != 0 ; then
48 echo "Using ldapsearch to check that producer slapd is running..."
49 for i in 0 1 2 3 4 5; do
50 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
51 'objectclass=*' > /dev/null 2>&1
53 if test $RC = 0 ; then
56 echo "Waiting 5 seconds for slapd to start..."
60 if test $RC != 0 ; then
61 echo "ldapsearch failed ($RC)!"
62 test $KILLSERVERS != no && kill -HUP $KILLPIDS
66 echo "Using ldapadd to create the context prefix entry in the producer..."
67 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
68 $LDIFORDEREDCP > /dev/null 2>&1
70 if test $RC != 0 ; then
71 echo "ldapadd failed ($RC)!"
72 test $KILLSERVERS != no && kill -HUP $KILLPIDS
76 echo "Starting consumer slapd on TCP/IP port $PORT4..."
77 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
78 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
80 if test $WAIT != 0 ; then
81 echo SLAVEPID $SLAVEPID
84 KILLPIDS="$KILLPIDS $SLAVEPID"
88 echo "Using ldapsearch to check that consumer slapd is running..."
89 for i in 0 1 2 3 4 5; do
90 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT4 \
91 'objectclass=*' > /dev/null 2>&1
93 if test $RC = 0 ; then
96 echo "Waiting 5 seconds for slapd to start..."
100 if test $RC != 0 ; then
101 echo "ldapsearch failed ($RC)!"
102 test $KILLSERVERS != no && kill -HUP $KILLPIDS
106 echo "Using ldapadd to populate the producer directory..."
107 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
108 $LDIFORDEREDNOCP > /dev/null 2>&1
110 if test $RC != 0 ; then
111 echo "ldapadd failed ($RC)!"
112 test $KILLSERVERS != no && kill -HUP $KILLPIDS
116 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
119 echo "Stopping the provider, sleeping 10 seconds and restarting it..."
123 echo "RESTART" >> $LOG1
124 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
126 if test $WAIT != 0 ; then
130 KILLPIDS="$PID $SLAVEPID"
134 echo "Using ldapsearch to check that producer slapd is running..."
135 for i in 0 1 2 3 4 5; do
136 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
137 'objectclass=*' > /dev/null 2>&1
139 if test $RC = 0 ; then
142 echo "Waiting 5 seconds for slapd to start..."
146 echo "Waiting $SLEEP1 seconds for consumer to reconnect..."
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
232 dn: dc=testdomain1,dc=example,dc=com
234 newrdn: dc=itsdomain1
237 dn: dc=itsdomain1,dc=example,dc=com
240 description: Example, Inc. ITS test domain
242 dn: dc=testdomain2,dc=example,dc=com
244 newrdn: dc=itsdomain2
250 if test $RC != 0 ; then
251 echo "ldapmodify failed ($RC)!"
252 test $KILLSERVERS != no && kill -HUP $KILLPIDS
256 echo "Using ldappasswd to change some passwords..."
257 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
258 'cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
261 if test $RC != 0 ; then
262 echo "ldapmodify failed ($RC)!"
263 test $KILLSERVERS != no && kill -HUP $KILLPIDS
267 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
270 echo "Stopping consumer to test recovery..."
274 echo "Modifying more entries on the producer..."
275 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
276 $TESTOUT 2>&1 << EOMODS
277 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
280 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
285 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
287 objectclass: OpenLDAPperson
290 cn: Rosco P. Coltrane
292 dn: dc=itsdomain2,dc=example,dc=com
295 description: Example, Inc. itsdomain2 test domain
300 if test $RC != 0 ; then
301 echo "ldapmodify failed ($RC)!"
302 test $KILLSERVERS != no && kill -HUP $KILLPIDS
306 echo "Restarting consumer..."
307 echo "RESTART" >> $LOG4
308 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
310 if test $WAIT != 0 ; then
311 echo SLAVEPID $SLAVEPID
314 KILLPIDS="$PID $SLAVEPID"
316 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
319 if test ! $BACKLDAP = "ldapno" ; then
320 echo "Try updating the consumer slapd..."
321 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD > \
322 $TESTOUT 2>&1 << EOMODS
323 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
326 description: This write must fail because directed to a shadow context,
327 description: unless the chain overlay is configured appropriately ;)
332 if test $RC != 0 ; then
333 echo "ldapmodify failed ($RC)!"
334 test $KILLSERVERS != no && kill -HUP $KILLPIDS
339 echo "Trying to change some passwords on the consumer..."
340 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD \
341 'cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
344 if test $RC != 0 ; then
345 echo "ldapmodify failed ($RC)!"
346 test $KILLSERVERS != no && kill -HUP $KILLPIDS
350 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
354 OPATTRS="entryUUID creatorsName createTimestamp modifiersName modifyTimestamp"
356 echo "Using ldapsearch to read all the entries from the producer..."
357 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
358 '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
361 if test $RC != 0 ; then
362 echo "ldapsearch failed at producer ($RC)!"
363 test $KILLSERVERS != no && kill -HUP $KILLPIDS
367 echo "Using ldapsearch to read all the entries from the consumer..."
368 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
369 '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
372 if test $RC != 0 ; then
373 echo "ldapsearch failed at consumer ($RC)!"
374 test $KILLSERVERS != no && kill -HUP $KILLPIDS
378 test $KILLSERVERS != no && kill -HUP $KILLPIDS
380 echo "Filtering producer results..."
381 $LDIFFILTER < $MASTEROUT > $MASTERFLT
382 echo "Filtering consumer results..."
383 $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
385 echo "Comparing retrieved entries from producer and consumer..."
386 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
388 if test $? != 0 ; then
389 echo "test failed - producer and consumer databases differ"
393 echo ">>>>> Test succeeded"
395 test $KILLSERVERS != no && wait