3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2016 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
35 SPEC="mdb=a,bdb=a,hdb=a"
41 # - populate over ldap
42 # - perform some modifies and deleted
43 # - attempt to modify the consumer (referral or chain)
44 # - retrieve database over ldap and compare against expected results
47 echo "Starting provider slapd on TCP/IP port $PORT1..."
48 . $CONFFILTER $BACKEND $MONITORDB < $DSRMASTERCONF > $CONF1
49 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
51 if test $WAIT != 0 ; then
59 echo "Using ldapsearch to check that provider slapd is running..."
60 for i in 0 1 2 3 4 5; do
61 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
62 'objectclass=*' > /dev/null 2>&1
64 if test $RC = 0 ; then
67 echo "Waiting 5 seconds for slapd to start..."
71 if test $RC != 0 ; then
72 echo "ldapsearch failed ($RC)!"
73 test $KILLSERVERS != no && kill -HUP $KILLPIDS
77 echo "Using ldapadd to create the context prefix entries in the provider..."
78 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
79 $LDIFORDEREDCP > /dev/null 2>&1
81 if test $RC != 0 ; then
82 echo "ldapadd failed ($RC)!"
83 test $KILLSERVERS != no && kill -HUP $KILLPIDS
87 echo "Starting consumer slapd on TCP/IP port $PORT2..."
88 . $CONFFILTER $BACKEND $MONITORDB < $DSRSLAVECONF > $CONF2
89 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
91 if test $WAIT != 0 ; then
92 echo SLAVEPID $SLAVEPID
95 KILLPIDS="$KILLPIDS $SLAVEPID"
99 echo "Using ldapsearch to check that consumer slapd is running..."
100 for i in 0 1 2 3 4 5; do
101 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
102 'objectclass=*' > /dev/null 2>&1
104 if test $RC = 0 ; then
107 echo "Waiting 5 seconds for slapd to start..."
111 if test $RC != 0 ; then
112 echo "ldapsearch failed ($RC)!"
113 test $KILLSERVERS != no && kill -HUP $KILLPIDS
117 echo "Using ldapadd to populate the provider directory..."
118 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
119 $LDIFORDEREDNOCP > /dev/null 2>&1
121 if test $RC != 0 ; then
122 echo "ldapadd failed ($RC)!"
123 test $KILLSERVERS != no && kill -HUP $KILLPIDS
127 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
130 echo "Stopping the provider, sleeping 10 seconds and restarting it..."
133 echo "RESTART" >> $LOG1
134 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
136 if test $WAIT != 0 ; then
140 KILLPIDS="$PID $SLAVEPID"
144 echo "Using ldapsearch to check that provider slapd is running..."
145 for i in 0 1 2 3 4 5; do
146 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
147 'objectclass=*' > /dev/null 2>&1
149 if test $RC = 0 ; then
152 echo "Waiting 5 seconds for slapd to start..."
156 if test $RC != 0 ; then
157 echo "ldapsearch failed ($RC)!"
158 test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
241 if test $RC != 0 ; then
242 echo "ldapmodify failed ($RC)!"
243 test $KILLSERVERS != no && kill -HUP $KILLPIDS
247 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
250 echo "Using ldapsearch to read all the entries from the provider..."
251 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
252 'objectclass=*' \* + > $MASTEROUT 2>&1
255 if test $RC != 0 ; then
256 echo "ldapsearch failed at provider ($RC)!"
257 test $KILLSERVERS != no && kill -HUP $KILLPIDS
261 echo "Using ldapsearch to read all the entries from the consumer..."
262 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
263 'objectclass=*' \* + > $SLAVEOUT 2>&1
266 if test $RC != 0 ; then
267 echo "ldapsearch failed at consumer ($RC)!"
268 test $KILLSERVERS != no && kill -HUP $KILLPIDS
272 echo "Filtering provider results..."
273 $LDIFFILTER -b $BACKEND -s $SPEC < $MASTEROUT | grep -iv "^auditcontext:" > $MASTERFLT
274 echo "Filtering consumer results..."
275 $LDIFFILTER -b $BACKEND -s $SPEC < $SLAVEOUT | grep -iv "^auditcontext:" > $SLAVEFLT
277 echo "Comparing retrieved entries from provider and consumer..."
278 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
280 if test $? != 0 ; then
281 echo "test failed - provider and consumer databases differ"
282 test $KILLSERVERS != no && kill -HUP $KILLPIDS
286 echo "Stopping consumer to test recovery..."
290 echo "Modifying more entries on the provider..."
291 $LDAPMODIFY -v -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
292 $TESTOUT 2>&1 << EOMODS
293 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
296 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
301 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
303 objectclass: OpenLDAPperson
306 cn: Rosco P. Coltrane
308 dn: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com
312 dn: cn=All Staff,ou=Groups,dc=example,dc=com
314 newrdn: cn=Some Staff
319 echo "Restarting consumer..."
320 echo "RESTART" >> $LOG2
321 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
323 if test $WAIT != 0 ; then
324 echo SLAVEPID $SLAVEPID
327 KILLPIDS="$PID $SLAVEPID"
329 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
332 if test ! $BACKLDAP = "ldapno" ; then
333 echo "Try updating the consumer slapd..."
334 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
335 $TESTOUT 2>&1 << EOMODS
336 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
339 description: This write must fail because directed to a shadow context,
340 description: unless the chain overlay is configured appropriately ;)
345 if test $RC != 0 ; then
346 echo "ldapmodify failed ($RC)!"
347 test $KILLSERVERS != no && kill -HUP $KILLPIDS
351 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
355 echo "Using ldapsearch to read all the entries from the provider..."
356 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
357 'objectclass=*' \* + > $MASTEROUT 2>&1
360 if test $RC != 0 ; then
361 echo "ldapsearch failed at provider ($RC)!"
362 test $KILLSERVERS != no && kill -HUP $KILLPIDS
366 echo "Using ldapsearch to read all the entries from the consumer..."
367 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
368 'objectclass=*' \* + > $SLAVEOUT 2>&1
371 if test $RC != 0 ; then
372 echo "ldapsearch failed at consumer ($RC)!"
373 test $KILLSERVERS != no && kill -HUP $KILLPIDS
377 test $KILLSERVERS != no && kill -HUP $KILLPIDS
379 echo "Filtering provider results..."
380 $LDIFFILTER -b $BACKEND -s $SPEC < $MASTEROUT | grep -iv "^auditcontext:" > $MASTERFLT
381 echo "Filtering consumer results..."
382 $LDIFFILTER -b $BACKEND -s $SPEC < $SLAVEOUT | grep -iv "^auditcontext:" > $SLAVEFLT
384 echo "Comparing retrieved entries from provider and consumer..."
385 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
387 if test $? != 0 ; then
388 echo "test failed - provider and consumer databases differ"
392 echo ">>>>> Test succeeded"
394 test $KILLSERVERS != no && wait