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 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 provider 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 provider 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 provider..."
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 provider 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 provider..."
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 provider ($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 provider results..."
144 $LDIFFILTER < $MASTEROUT > $MASTERFLT
145 echo "Filtering consumer results..."
146 $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
148 echo "Comparing retrieved entries from provider and consumer..."
149 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
151 if test $? != 0 ; then
152 echo "test failed - provider 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 provider 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 provider 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 provider..."
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 provider ($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 provider results..."
353 $LDIFFILTER < $MASTEROUT > $MASTERFLT
354 echo "Filtering consumer results..."
355 $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
357 echo "Comparing retrieved entries from provider and consumer..."
358 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
360 if test $? != 0 ; then
361 echo "test failed - provider 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 provider..."
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
393 # rename with a newly added newSuperior while the consumer is down (ITS#6472)
394 dn: ou=New Branch,dc=example,dc=com
396 objectClass: organizationalUnit
399 dn: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
401 newrdn: cn=Dorothy Stevens
403 newsuperior: ou=New Branch,dc=example,dc=com
408 if test $RC != 0 ; then
409 echo "ldapmodify failed ($RC)!"
410 test $KILLSERVERS != no && kill -HUP $KILLPIDS
414 echo "Restarting consumer..."
415 echo "RESTART" >> $LOG4
416 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
418 if test $WAIT != 0 ; then
419 echo SLAVEPID $SLAVEPID
422 KILLPIDS="$PID $SLAVEPID"
424 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
427 echo "Using ldapsearch to read all the entries from the provider..."
428 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
429 '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
432 if test $RC != 0 ; then
433 echo "ldapsearch failed at provider ($RC)!"
434 test $KILLSERVERS != no && kill -HUP $KILLPIDS
438 echo "Using ldapsearch to read all the entries from the consumer..."
439 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
440 '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
443 if test $RC != 0 ; then
444 echo "ldapsearch failed at consumer ($RC)!"
445 test $KILLSERVERS != no && kill -HUP $KILLPIDS
449 echo "Filtering provider results..."
450 $LDIFFILTER < $MASTEROUT > $MASTERFLT
451 echo "Filtering consumer results..."
452 $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
454 echo "Comparing retrieved entries from provider and consumer..."
455 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
457 if test $? != 0 ; then
458 echo "test failed - provider and consumer databases differ"
459 test $KILLSERVERS != no && kill -HUP $KILLPIDS
463 if test ! $BACKLDAP = "ldapno" ; then
464 echo "Try updating the consumer slapd..."
465 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD > \
466 $TESTOUT 2>&1 << EOMODS
467 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
470 description: This write must fail because directed to a shadow context,
471 description: unless the chain overlay is configured appropriately ;)
476 if test $RC != 0 ; then
477 echo "ldapmodify failed ($RC)!"
478 test $KILLSERVERS != no && kill -HUP $KILLPIDS
483 echo "Trying to change some passwords on the consumer..."
484 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD \
485 'cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
488 if test $RC != 0 ; then
489 echo "ldapmodify failed ($RC)!"
490 test $KILLSERVERS != no && kill -HUP $KILLPIDS
494 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
498 echo "Using ldapsearch to read all the entries from the provider..."
499 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
500 '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
503 if test $RC != 0 ; then
504 echo "ldapsearch failed at provider ($RC)!"
505 test $KILLSERVERS != no && kill -HUP $KILLPIDS
509 echo "Using ldapsearch to read all the entries from the consumer..."
510 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
511 '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
514 if test $RC != 0 ; then
515 echo "ldapsearch failed at consumer ($RC)!"
516 test $KILLSERVERS != no && kill -HUP $KILLPIDS
520 echo "Filtering provider results..."
521 $LDIFFILTER < $MASTEROUT > $MASTERFLT
522 echo "Filtering consumer results..."
523 $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
525 echo "Comparing retrieved entries from provider and consumer..."
526 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
528 if test $? != 0 ; then
529 echo "test failed - provider and consumer databases differ"
530 test $KILLSERVERS != no && kill -HUP $KILLPIDS
534 test $KILLSERVERS != no && kill -HUP $KILLPIDS
536 echo ">>>>> Test succeeded"
538 test $KILLSERVERS != no && wait