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 provider 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 provider 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 provider..."
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 MORELDIF=$TESTDIR/more.ldif
107 TESTOUT1=$TESTDIR/testout1.out
108 TESTOUT2=$TESTDIR/testout2.out
109 sed -e 's/[Oo][Uu]=/ou=More /g' -e 's/^[Oo][Uu]: /ou: More /' \
110 -e 's/cn=Manager/cn=More Manager/g' \
111 -e 's/^cn: Manager/cn: More Manager/' \
112 $LDIFORDEREDNOCP > $MORELDIF
114 echo "Using ldapadd to populate the provider directory..."
115 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
116 $LDIFORDEREDNOCP > $TESTOUT1 2>&1 &
118 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
119 $MORELDIF > $TESTOUT2 2>&1 &
123 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
126 echo "Stopping the provider, sleeping 10 seconds and restarting it..."
130 echo "RESTART" >> $LOG1
131 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
133 if test $WAIT != 0 ; then
137 KILLPIDS="$PID $SLAVEPID"
141 echo "Using ldapsearch to check that provider slapd is running..."
142 for i in 0 1 2 3 4 5; do
143 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
144 'objectclass=*' > /dev/null 2>&1
146 if test $RC = 0 ; then
149 echo "Waiting 5 seconds for slapd to start..."
153 if test $RC != 0 ; then
154 echo "ldapsearch failed ($RC)!"
155 test $KILLSERVERS != no && kill -HUP $KILLPIDS
159 echo "Waiting 10 seconds to let the system catch up"
162 echo "Using ldapmodify to modify provider directory..."
165 # Do some modifications
168 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
169 $TESTOUT 2>&1 << EOMODS
170 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
181 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
186 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
189 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
190 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
193 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
194 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
196 dn: cn=All Staff,ou=Groups,dc=example,dc=com
200 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
202 objectclass: OpenLDAPperson
206 title: Chief Investigator, ITD
207 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
208 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
210 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
211 description: Very odd
212 facsimiletelephonenumber: +1 313 555 7557
213 telephonenumber: +1 313 555 8343
214 mail: gjensen@mailgw.example.com
215 homephone: +1 313 555 8844
217 dn: ou=Retired, ou=People, dc=example,dc=com
219 objectclass: organizationalUnit
222 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
224 objectclass: OpenLDAPperson
225 cn: Rosco P. Coltrane
228 description: Fat tycoon
230 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
232 newrdn: cn=Rosco P. Coltrane
234 newsuperior: ou=Retired, ou=People, dc=example,dc=com
236 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
242 if test $RC != 0 ; then
243 echo "ldapmodify failed ($RC)!"
244 test $KILLSERVERS != no && kill -HUP $KILLPIDS
248 echo "Using ldappasswd to change some passwords..."
249 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
250 'cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
253 if test $RC != 0 ; then
254 echo "ldapmodify failed ($RC)!"
255 test $KILLSERVERS != no && kill -HUP $KILLPIDS
259 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
262 echo "Stopping consumer to test recovery..."
266 echo "Modifying more entries on the provider..."
267 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
268 $TESTOUT 2>&1 << EOMODS
269 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
272 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
277 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
279 objectclass: OpenLDAPperson
282 cn: Rosco P. Coltrane
286 echo "Restarting consumer..."
287 echo "RESTART" >> $LOG4
288 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
290 if test $WAIT != 0 ; then
291 echo SLAVEPID $SLAVEPID
294 KILLPIDS="$PID $SLAVEPID"
296 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
299 if test ! $BACKLDAP = "ldapno" ; then
300 echo "Try updating the consumer slapd..."
301 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD > \
302 $TESTOUT 2>&1 << EOMODS
303 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
306 description: This write must fail because directed to a shadow context,
307 description: unless the chain overlay is configured appropriately ;)
312 if test $RC != 0 ; then
313 echo "ldapmodify failed ($RC)!"
314 test $KILLSERVERS != no && kill -HUP $KILLPIDS
319 echo "Trying to change some passwords on the consumer..."
320 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD \
321 'cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
324 if test $RC != 0 ; then
325 echo "ldapmodify failed ($RC)!"
326 test $KILLSERVERS != no && kill -HUP $KILLPIDS
330 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
334 OPATTRS="entryUUID creatorsName createTimestamp modifiersName modifyTimestamp"
336 echo "Using ldapsearch to read all the entries from the provider..."
337 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
338 '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
341 if test $RC != 0 ; then
342 echo "ldapsearch failed at provider ($RC)!"
343 test $KILLSERVERS != no && kill -HUP $KILLPIDS
347 echo "Using ldapsearch to read all the entries from the consumer..."
348 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
349 '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
352 if test $RC != 0 ; then
353 echo "ldapsearch failed at consumer ($RC)!"
354 test $KILLSERVERS != no && kill -HUP $KILLPIDS
358 test $KILLSERVERS != no && kill -HUP $KILLPIDS
360 echo "Filtering provider results..."
361 $LDIFFILTER < $MASTEROUT > $MASTERFLT
362 echo "Filtering consumer results..."
363 $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
365 echo "Comparing retrieved entries from provider and consumer..."
366 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
368 if test $? != 0 ; then
369 echo "test failed - provider and consumer databases differ"
373 echo ">>>>> Test succeeded"
375 test $KILLSERVERS != no && wait