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 OPATTRS="entryUUID creatorsName createTimestamp modifiersName modifyTimestamp"
21 if test $SYNCPROV = syncprovno; then
22 echo "Syncrepl provider overlay not available, test skipped"
26 mkdir -p $TESTDIR $DBDIR1 $DBDIR4
32 # - populate over ldap
33 # - perform some modifies and deleted
34 # - attempt to modify the consumer (referral or chain)
35 # - retrieve database over ldap and compare against expected results
38 echo "Starting producer slapd on TCP/IP port $PORT1..."
39 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
40 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
42 if test $WAIT != 0 ; then
50 echo "Using ldapsearch to check that producer slapd is running..."
51 for i in 0 1 2 3 4 5; do
52 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
53 'objectclass=*' > /dev/null 2>&1
55 if test $RC = 0 ; then
58 echo "Waiting 5 seconds for slapd to start..."
62 if test $RC != 0 ; then
63 echo "ldapsearch failed ($RC)!"
64 test $KILLSERVERS != no && kill -HUP $KILLPIDS
68 echo "Using ldapadd to create the context prefix entry in the producer..."
69 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
70 $LDIFORDEREDCP > /dev/null 2>&1
72 if test $RC != 0 ; then
73 echo "ldapadd failed ($RC)!"
74 test $KILLSERVERS != no && kill -HUP $KILLPIDS
78 echo "Starting consumer slapd on TCP/IP port $PORT4..."
79 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
80 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
82 if test $WAIT != 0 ; then
83 echo SLAVEPID $SLAVEPID
86 KILLPIDS="$KILLPIDS $SLAVEPID"
90 echo "Using ldapsearch to check that consumer slapd is running..."
91 for i in 0 1 2 3 4 5; do
92 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT4 \
93 'objectclass=*' > /dev/null 2>&1
95 if test $RC = 0 ; then
98 echo "Waiting 5 seconds for slapd to start..."
102 if test $RC != 0 ; then
103 echo "ldapsearch failed ($RC)!"
104 test $KILLSERVERS != no && kill -HUP $KILLPIDS
108 echo "Using ldapadd to populate the producer directory..."
109 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
110 $LDIFORDEREDNOCP > /dev/null 2>&1
112 if test $RC != 0 ; then
113 echo "ldapadd failed ($RC)!"
114 test $KILLSERVERS != no && kill -HUP $KILLPIDS
118 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
121 echo "Using ldapsearch to read all the entries from the producer..."
122 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
123 '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
126 if test $RC != 0 ; then
127 echo "ldapsearch failed at producer ($RC)!"
128 test $KILLSERVERS != no && kill -HUP $KILLPIDS
132 echo "Using ldapsearch to read all the entries from the consumer..."
133 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
134 '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
137 if test $RC != 0 ; then
138 echo "ldapsearch failed at consumer ($RC)!"
139 test $KILLSERVERS != no && kill -HUP $KILLPIDS
143 echo "Filtering producer results..."
144 $LDIFFILTER < $MASTEROUT > $MASTERFLT
145 echo "Filtering consumer results..."
146 $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
148 echo "Comparing retrieved entries from producer and consumer..."
149 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
151 if test $? != 0 ; then
152 echo "test failed - producer and consumer databases differ"
153 test $KILLSERVERS != no && kill -HUP $KILLPIDS
157 echo "Stopping the provider, sleeping 10 seconds and restarting it..."
161 echo "RESTART" >> $LOG1
162 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
164 if test $WAIT != 0 ; then
168 KILLPIDS="$PID $SLAVEPID"
172 echo "Using ldapsearch to check that producer slapd is running..."
173 for i in 0 1 2 3 4 5; do
174 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
175 'objectclass=*' > /dev/null 2>&1
177 if test $RC = 0 ; then
180 echo "Waiting 5 seconds for slapd to start..."
184 echo "Waiting $SLEEP1 seconds for consumer to reconnect..."
187 if test $RC != 0 ; then
188 echo "ldapsearch failed ($RC)!"
189 test $KILLSERVERS != no && kill -HUP $KILLPIDS
193 echo "Using ldapmodify to modify producer directory..."
196 # Do some modifications
199 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
200 $TESTOUT 2>&1 << EOMODS
201 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
212 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
217 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
220 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
221 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
224 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
225 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
227 dn: cn=All Staff,ou=Groups,dc=example,dc=com
231 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
233 objectclass: OpenLDAPperson
237 title: Chief Investigator, ITD
238 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
239 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
241 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
242 description: Very odd
243 facsimiletelephonenumber: +1 313 555 7557
244 facsimiletelephonenumber: +1 313 555 9998
245 facsimiletelephonenumber: +1 313 555 9999
246 telephonenumber: +1 313 555 8343
247 mail: gjensen@mailgw.example.com
248 homephone: +1 313 555 8844
250 # modify attribute with no matching rule (ITS#6458)
251 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
253 replace: facsimiletelephonenumber
254 facsimiletelephonenumber: +1 313 555 9998
255 facsimiletelephonenumber: +1 313 555 9999
257 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
259 replace: facsimiletelephonenumber
260 facsimiletelephonenumber: +1 313 555 9998
261 facsimiletelephonenumber: +1 313 555 9999
262 facsimiletelephonenumber: +1 313 555 7557
264 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
266 replace: facsimiletelephonenumber
267 facsimiletelephonenumber: +1 313 555 9998
268 facsimiletelephonenumber: +1 313 555 9999
270 dn: ou=Retired, ou=People, dc=example,dc=com
272 objectclass: organizationalUnit
275 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
277 objectclass: OpenLDAPperson
278 cn: Rosco P. Coltrane
281 description: Fat tycoon
283 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
285 newrdn: cn=Rosco P. Coltrane
287 newsuperior: ou=Retired, ou=People, dc=example,dc=com
289 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
292 dn: dc=testdomain1,dc=example,dc=com
294 newrdn: dc=itsdomain1
297 dn: dc=itsdomain1,dc=example,dc=com
300 description: Example, Inc. ITS test domain
302 dn: dc=testdomain2,dc=example,dc=com
304 newrdn: dc=itsdomain2
310 if test $RC != 0 ; then
311 echo "ldapmodify failed ($RC)!"
312 test $KILLSERVERS != no && kill -HUP $KILLPIDS
316 echo "Using ldappasswd to change some passwords..."
317 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
318 'cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
321 if test $RC != 0 ; then
322 echo "ldapmodify failed ($RC)!"
323 test $KILLSERVERS != no && kill -HUP $KILLPIDS
327 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
330 echo "Using ldapsearch to read all the entries from the producer..."
331 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
332 '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
335 if test $RC != 0 ; then
336 echo "ldapsearch failed at producer ($RC)!"
337 test $KILLSERVERS != no && kill -HUP $KILLPIDS
341 echo "Using ldapsearch to read all the entries from the consumer..."
342 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
343 '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
346 if test $RC != 0 ; then
347 echo "ldapsearch failed at consumer ($RC)!"
348 test $KILLSERVERS != no && kill -HUP $KILLPIDS
352 echo "Filtering producer results..."
353 $LDIFFILTER < $MASTEROUT > $MASTERFLT
354 echo "Filtering consumer results..."
355 $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
357 echo "Comparing retrieved entries from producer and consumer..."
358 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
360 if test $? != 0 ; then
361 echo "test failed - producer and consumer databases differ"
362 test $KILLSERVERS != no && kill -HUP $KILLPIDS
366 echo "Stopping consumer to test recovery..."
370 echo "Modifying more entries on the producer..."
371 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
372 $TESTOUT 2>&1 << EOMODS
373 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
376 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
381 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
383 objectclass: OpenLDAPperson
386 cn: Rosco P. Coltrane
388 dn: dc=itsdomain2,dc=example,dc=com
391 description: Example, Inc. itsdomain2 test domain
396 if test $RC != 0 ; then
397 echo "ldapmodify failed ($RC)!"
398 test $KILLSERVERS != no && kill -HUP $KILLPIDS
402 echo "Restarting consumer..."
403 echo "RESTART" >> $LOG4
404 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
406 if test $WAIT != 0 ; then
407 echo SLAVEPID $SLAVEPID
410 KILLPIDS="$PID $SLAVEPID"
412 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
415 echo "Using ldapsearch to read all the entries from the producer..."
416 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
417 '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
420 if test $RC != 0 ; then
421 echo "ldapsearch failed at producer ($RC)!"
422 test $KILLSERVERS != no && kill -HUP $KILLPIDS
426 echo "Using ldapsearch to read all the entries from the consumer..."
427 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
428 '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
431 if test $RC != 0 ; then
432 echo "ldapsearch failed at consumer ($RC)!"
433 test $KILLSERVERS != no && kill -HUP $KILLPIDS
437 echo "Filtering producer results..."
438 $LDIFFILTER < $MASTEROUT > $MASTERFLT
439 echo "Filtering consumer results..."
440 $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
442 echo "Comparing retrieved entries from producer and consumer..."
443 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
445 if test $? != 0 ; then
446 echo "test failed - producer and consumer databases differ"
447 test $KILLSERVERS != no && kill -HUP $KILLPIDS
451 if test ! $BACKLDAP = "ldapno" ; then
452 echo "Try updating the consumer slapd..."
453 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD > \
454 $TESTOUT 2>&1 << EOMODS
455 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
458 description: This write must fail because directed to a shadow context,
459 description: unless the chain overlay is configured appropriately ;)
464 if test $RC != 0 ; then
465 echo "ldapmodify failed ($RC)!"
466 test $KILLSERVERS != no && kill -HUP $KILLPIDS
471 echo "Trying to change some passwords on the consumer..."
472 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD \
473 'cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
476 if test $RC != 0 ; then
477 echo "ldapmodify failed ($RC)!"
478 test $KILLSERVERS != no && kill -HUP $KILLPIDS
482 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
486 echo "Using ldapsearch to read all the entries from the producer..."
487 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
488 '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
491 if test $RC != 0 ; then
492 echo "ldapsearch failed at producer ($RC)!"
493 test $KILLSERVERS != no && kill -HUP $KILLPIDS
497 echo "Using ldapsearch to read all the entries from the consumer..."
498 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
499 '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
502 if test $RC != 0 ; then
503 echo "ldapsearch failed at consumer ($RC)!"
504 test $KILLSERVERS != no && kill -HUP $KILLPIDS
508 echo "Filtering producer results..."
509 $LDIFFILTER < $MASTEROUT > $MASTERFLT
510 echo "Filtering consumer results..."
511 $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
513 echo "Comparing retrieved entries from producer and consumer..."
514 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
516 if test $? != 0 ; then
517 echo "test failed - producer and consumer databases differ"
518 test $KILLSERVERS != no && kill -HUP $KILLPIDS
522 test $KILLSERVERS != no && kill -HUP $KILLPIDS
524 echo ">>>>> Test succeeded"
526 test $KILLSERVERS != no && wait