3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2011 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"
27 if test $BACKEND = ldif ; then
28 # Onelevel search does not return entries in order of creation or CSN.
29 echo "$BACKEND backend unsuitable for syncprov logdb, test skipped"
33 mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR2
39 # - populate over ldap
40 # - perform some modifies and deleted
41 # - attempt to modify the consumer (referral or chain)
42 # - retrieve database over ldap and compare against expected results
45 echo "Starting provider slapd on TCP/IP port $PORT1..."
46 . $CONFFILTER $BACKEND $MONITORDB < $DSRMASTERCONF > $CONF1
47 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
49 if test $WAIT != 0 ; then
57 echo "Using ldapsearch to check that provider slapd is running..."
58 for i in 0 1 2 3 4 5; do
59 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
60 'objectclass=*' > /dev/null 2>&1
62 if test $RC = 0 ; then
65 echo "Waiting 5 seconds for slapd to start..."
69 if test $RC != 0 ; then
70 echo "ldapsearch failed ($RC)!"
71 test $KILLSERVERS != no && kill -HUP $KILLPIDS
75 echo "Using ldapadd to create the context prefix entries in the provider..."
76 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
77 $LDIFORDEREDCP > /dev/null 2>&1
79 if test $RC != 0 ; then
80 echo "ldapadd failed ($RC)!"
81 test $KILLSERVERS != no && kill -HUP $KILLPIDS
85 echo "Starting consumer slapd on TCP/IP port $PORT2..."
86 . $CONFFILTER $BACKEND $MONITORDB < $DSRSLAVECONF > $CONF2
87 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
89 if test $WAIT != 0 ; then
90 echo SLAVEPID $SLAVEPID
93 KILLPIDS="$KILLPIDS $SLAVEPID"
97 echo "Using ldapsearch to check that consumer slapd is running..."
98 for i in 0 1 2 3 4 5; do
99 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
100 'objectclass=*' > /dev/null 2>&1
102 if test $RC = 0 ; then
105 echo "Waiting 5 seconds for slapd to start..."
109 if test $RC != 0 ; then
110 echo "ldapsearch failed ($RC)!"
111 test $KILLSERVERS != no && kill -HUP $KILLPIDS
115 echo "Using ldapadd to populate the provider directory..."
116 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
117 $LDIFORDEREDNOCP > /dev/null 2>&1
119 if test $RC != 0 ; then
120 echo "ldapadd failed ($RC)!"
121 test $KILLSERVERS != no && kill -HUP $KILLPIDS
125 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
128 echo "Stopping the provider, sleeping 10 seconds and restarting it..."
131 echo "RESTART" >> $LOG1
132 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
134 if test $WAIT != 0 ; then
138 KILLPIDS="$PID $SLAVEPID"
142 echo "Using ldapsearch to check that provider slapd is running..."
143 for i in 0 1 2 3 4 5; do
144 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
145 'objectclass=*' > /dev/null 2>&1
147 if test $RC = 0 ; then
150 echo "Waiting 5 seconds for slapd to start..."
154 if test $RC != 0 ; then
155 echo "ldapsearch failed ($RC)!"
156 test $KILLSERVERS != no && kill -HUP $KILLPIDS
160 echo "Using ldapmodify to modify provider directory..."
163 # Do some modifications
166 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
167 $TESTOUT 2>&1 << EOMODS
168 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
179 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
184 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
187 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
188 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
191 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
192 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
194 dn: cn=All Staff,ou=Groups,dc=example,dc=com
198 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
200 objectclass: OpenLDAPperson
204 title: Chief Investigator, ITD
205 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
206 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
208 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
209 description: Very odd
210 facsimiletelephonenumber: +1 313 555 7557
211 telephonenumber: +1 313 555 8343
212 mail: gjensen@mailgw.example.com
213 homephone: +1 313 555 8844
215 dn: ou=Retired, ou=People, dc=example,dc=com
217 objectclass: organizationalUnit
220 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
222 objectclass: OpenLDAPperson
223 cn: Rosco P. Coltrane
226 description: Fat tycoon
228 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
230 newrdn: cn=Rosco P. Coltrane
232 newsuperior: ou=Retired, ou=People, dc=example,dc=com
234 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
239 if test $RC != 0 ; then
240 echo "ldapmodify failed ($RC)!"
241 test $KILLSERVERS != no && kill -HUP $KILLPIDS
245 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
248 echo "Using ldapsearch to read all the entries from the provider..."
249 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
250 'objectclass=*' \* + > $MASTEROUT 2>&1
253 if test $RC != 0 ; then
254 echo "ldapsearch failed at provider ($RC)!"
255 test $KILLSERVERS != no && kill -HUP $KILLPIDS
259 echo "Using ldapsearch to read all the entries from the consumer..."
260 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
261 'objectclass=*' \* + > $SLAVEOUT 2>&1
264 if test $RC != 0 ; then
265 echo "ldapsearch failed at consumer ($RC)!"
266 test $KILLSERVERS != no && kill -HUP $KILLPIDS
270 echo "Filtering provider results..."
271 $LDIFFILTER -s bdb=a,hdb=a < $MASTEROUT | grep -iv "^auditcontext:" > $MASTERFLT
272 echo "Filtering consumer results..."
273 $LDIFFILTER -s bdb=a,hdb=a < $SLAVEOUT | grep -iv "^auditcontext:" > $SLAVEFLT
275 echo "Comparing retrieved entries from provider and consumer..."
276 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
278 if test $? != 0 ; then
279 echo "test failed - provider and consumer databases differ"
280 test $KILLSERVERS != no && kill -HUP $KILLPIDS
284 echo "Stopping consumer to test recovery..."
288 echo "Modifying more entries on the provider..."
289 $LDAPMODIFY -v -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
290 $TESTOUT 2>&1 << EOMODS
291 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
294 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
299 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
301 objectclass: OpenLDAPperson
304 cn: Rosco P. Coltrane
306 dn: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com
310 dn: cn=All Staff,ou=Groups,dc=example,dc=com
312 newrdn: cn=Some Staff
317 echo "Restarting consumer..."
318 echo "RESTART" >> $LOG2
319 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
321 if test $WAIT != 0 ; then
322 echo SLAVEPID $SLAVEPID
325 KILLPIDS="$PID $SLAVEPID"
327 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
330 if test ! $BACKLDAP = "ldapno" ; then
331 echo "Try updating the consumer slapd..."
332 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
333 $TESTOUT 2>&1 << EOMODS
334 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
337 description: This write must fail because directed to a shadow context,
338 description: unless the chain overlay is configured appropriately ;)
343 if test $RC != 0 ; then
344 echo "ldapmodify failed ($RC)!"
345 test $KILLSERVERS != no && kill -HUP $KILLPIDS
349 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
353 echo "Using ldapsearch to read all the entries from the provider..."
354 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
355 'objectclass=*' \* + > $MASTEROUT 2>&1
358 if test $RC != 0 ; then
359 echo "ldapsearch failed at provider ($RC)!"
360 test $KILLSERVERS != no && kill -HUP $KILLPIDS
364 echo "Using ldapsearch to read all the entries from the consumer..."
365 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
366 'objectclass=*' \* + > $SLAVEOUT 2>&1
369 if test $RC != 0 ; then
370 echo "ldapsearch failed at consumer ($RC)!"
371 test $KILLSERVERS != no && kill -HUP $KILLPIDS
375 test $KILLSERVERS != no && kill -HUP $KILLPIDS
377 echo "Filtering provider results..."
378 $LDIFFILTER -s bdb=a,hdb=a < $MASTEROUT | grep -iv "^auditcontext:" > $MASTERFLT
379 echo "Filtering consumer results..."
380 $LDIFFILTER -s bdb=a,hdb=a < $SLAVEOUT | grep -iv "^auditcontext:" > $SLAVEFLT
382 echo "Comparing retrieved entries from provider and consumer..."
383 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
385 if test $? != 0 ; then
386 echo "test failed - provider and consumer databases differ"
390 echo ">>>>> Test succeeded"
392 test $KILLSERVERS != no && wait