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 $DBDIR2 $DBDIR3 $DBDIR4 $DBDIR5 $DBDIR6
30 # - populate over ldap
31 # - perform some modifies and deleted
32 # - retrieve database over ldap and compare against expected results
35 echo "Starting master slapd on TCP/IP port $PORT1..."
36 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
37 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
39 if test $WAIT != 0 ; then
47 echo "Using ldapsearch to check that master slapd (pid=$PID) is running..."
48 for i in 0 1 2 3 4 5; do
49 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
50 'objectclass=*' > /dev/null 2>&1
52 if test $RC = 0 ; then
55 echo "Waiting 5 seconds for slapd to start..."
59 if test $RC != 0 ; then
60 echo "ldapsearch failed ($RC)!"
61 test $KILLSERVERS != no && kill -HUP $KILLPIDS
65 echo "Using ldapadd to create the context prefix entry in the master..."
66 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
67 $LDIFORDEREDCP > /dev/null 2>&1
69 if test $RC != 0 ; then
70 echo "ldapadd failed ($RC)!"
71 test $KILLSERVERS != no && kill -HUP $KILLPIDS
75 echo "Starting R1 slave slapd on TCP/IP port $PORT2..."
76 . $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $CONF2
77 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
79 if test $WAIT != 0 ; then
80 echo SLAVE R1 PID $SLAVEPID
83 KILLPIDS="$KILLPIDS $SLAVEPID"
87 echo "Using ldapsearch to check that R1 slave slapd (pid=$SLAVEPID) is running..."
88 for i in 0 1 2 3 4 5; do
89 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
90 'objectclass=*' > /dev/null 2>&1
92 if test $RC = 0 ; then
95 echo "Waiting 5 seconds for R1 slapd to start..."
99 if test $RC != 0 ; then
100 echo "ldapsearch failed ($RC)!"
101 test $KILLSERVERS != no && kill -HUP $KILLPIDS
105 echo "Starting R2 slave slapd on TCP/IP port $PORT3..."
106 . $CONFFILTER $BACKEND $MONITORDB < $R2SRSLAVECONF > $CONF3
107 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
109 if test $WAIT != 0 ; then
110 echo SLAVE R2 PID $SLAVEPID
113 KILLPIDS="$KILLPIDS $SLAVEPID"
117 echo "Using ldapsearch to check that R2 slave slapd (pid=$SLAVEPID) is running..."
118 for i in 0 1 2 3 4 5; do
119 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
120 'objectclass=*' > /dev/null 2>&1
122 if test $RC = 0 ; then
125 echo "Waiting 5 seconds for R2 slave slapd to start..."
129 if test $RC != 0 ; then
130 echo "ldapsearch failed ($RC)!"
131 test $KILLSERVERS != no && kill -HUP $KILLPIDS
135 echo "Starting P1 slave slapd on TCP/IP port $PORT4..."
136 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
137 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
139 if test $WAIT != 0 ; then
140 echo SLAVE P1 PID $SLAVEPID
143 KILLPIDS="$KILLPIDS $SLAVEPID"
147 echo "Using ldapsearch to check that P1 slave slapd (pid=$SLAVEPID) is running..."
148 for i in 0 1 2 3 4 5; do
149 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT4 \
150 'objectclass=*' > /dev/null 2>&1
152 if test $RC = 0 ; then
155 echo "Waiting 5 seconds for P1 slave slapd to start..."
159 if test $RC != 0 ; then
160 echo "ldapsearch failed ($RC)!"
161 test $KILLSERVERS != no && kill -HUP $KILLPIDS
165 echo "Starting P2 slave slapd on TCP/IP port $PORT5..."
166 . $CONFFILTER $BACKEND $MONITORDB < $P2SRSLAVECONF > $CONF5
167 $SLAPD -f $CONF5 -h $URI5 -d $LVL $TIMING > $LOG5 2>&1 &
169 if test $WAIT != 0 ; then
170 echo SLAVE P2 PID $SLAVEPID
173 KILLPIDS="$KILLPIDS $SLAVEPID"
177 echo "Using ldapsearch to check that P2 slave slapd (pid=$SLAVEPID) is running..."
178 for i in 0 1 2 3 4 5; do
179 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT5 \
180 'objectclass=*' > /dev/null 2>&1
182 if test $RC = 0 ; then
185 echo "Waiting 5 seconds for P2 slave slapd to start..."
189 if test $RC != 0 ; then
190 echo "ldapsearch failed ($RC)!"
191 test $KILLSERVERS != no && kill -HUP $KILLPIDS
195 echo "Starting P3 slave slapd on TCP/IP port $PORT6..."
196 . $CONFFILTER $BACKEND $MONITORDB < $P3SRSLAVECONF > $CONF6
197 $SLAPD -f $CONF6 -h $URI6 -d $LVL $TIMING > $LOG6 2>&1 &
199 if test $WAIT != 0 ; then
200 echo SLAVE P3 PID $SLAVEPID
203 KILLPIDS="$KILLPIDS $SLAVEPID"
207 echo "Using ldapsearch to check that P3 slave slapd (pid=$SLAVEPID) is running..."
208 for i in 0 1 2 3 4 5; do
209 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT6 \
210 'objectclass=*' > /dev/null 2>&1
212 if test $RC = 0 ; then
215 echo "Waiting 5 seconds for P3 slave slapd to start..."
219 if test $RC != 0 ; then
220 echo "ldapsearch failed ($RC)!"
221 test $KILLSERVERS != no && kill -HUP $KILLPIDS
225 echo "Using ldapadd to populate the master directory..."
226 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
227 $LDIFORDEREDNOCP > /dev/null 2>&1
229 if test $RC != 0 ; then
230 echo "ldapadd failed ($RC)!"
231 test $KILLSERVERS != no && kill -HUP $KILLPIDS
235 echo "Waiting $SLEEP2 seconds for syncrepl to receive changes..."
238 echo "Using ldapmodify to modify master directory..."
241 # Do some modifications
244 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
245 $TESTOUT 2>&1 << EOMODS
246 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
257 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
263 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
266 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
267 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
270 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
271 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
273 dn: cn=All Staff,ou=Groups,dc=example,dc=com
277 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
279 objectclass: OpenLDAPperson
283 title: Chief Investigator, ITD
284 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
285 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
287 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
288 description: Very odd
289 facsimiletelephonenumber: +1 313 555 7557
290 telephonenumber: +1 313 555 8343
291 mail: gjensen@mailgw.example.com
292 homephone: +1 313 555 8844
294 dn: ou=Retired, ou=People, dc=example,dc=com
296 objectclass: organizationalUnit
299 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
301 objectclass: OpenLDAPperson
302 cn: Rosco P. Coltrane
306 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
308 newrdn: cn=Rosco P. Coltrane
310 newsuperior: ou=Retired, ou=People, dc=example,dc=com
312 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
315 dn: dc=testdomain1,dc=example,dc=com
317 newrdn: dc=itsdomain1
320 dn: dc=itsdomain1,dc=example,dc=com
323 description: Example, Inc. ITS test domain
325 dn: dc=testdomain2,dc=example,dc=com
327 newrdn: dc=itsdomain2
333 if test $RC != 0 ; then
334 echo "ldapmodify failed ($RC)!"
335 test $KILLSERVERS != no && kill -HUP $KILLPIDS
339 echo "Waiting $SLEEP2 seconds for syncrepl to receive changes..."
342 echo "Performing modify alone on provider..."
343 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
344 $TESTOUT 2>&1 << EOMODS
345 dn: dc=itsdomain2,dc=example,dc=com
348 description: Example, Inc. itsdomain2 test domain
353 if test $RC != 0 ; then
354 echo "ldapmodify failed ($RC)!"
355 test $KILLSERVERS != no && kill -HUP $KILLPIDS
359 echo "Waiting $SLEEP2 seconds for syncrepl to receive changes..."
362 echo "Using ldapsearch to read all the entries from the master..."
363 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
364 '(objectClass=*)' '*' entryCSN > $MASTEROUT 2>&1
367 if test $RC != 0 ; then
368 echo "ldapsearch failed at master ($RC)!"
369 test $KILLSERVERS != no && kill -HUP $KILLPIDS
373 echo "Using ldapsearch to read all the entries from the R1 slave..."
374 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
375 '(objectClass=*)' '*' entryCSN > $SERVER2OUT 2>&1
378 if test $RC != 0 ; then
379 echo "ldapsearch failed at R1 slave ($RC)!"
380 test $KILLSERVERS != no && kill -HUP $KILLPIDS
384 echo "Using ldapsearch to read all the entries from the R2 slave..."
385 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT3 \
386 '(objectClass=*)' '*' entryCSN > $SERVER3OUT 2>&1
389 if test $RC != 0 ; then
390 echo "ldapsearch failed at R2 slave ($RC)!"
391 test $KILLSERVERS != no && kill -HUP $KILLPIDS
395 echo "Using ldapsearch to read all the entries from the P1 slave..."
396 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
397 '(objectClass=*)' '*' entryCSN > $SERVER4OUT 2>&1
400 if test $RC != 0 ; then
401 echo "ldapsearch failed at P1 slave ($RC)!"
402 test $KILLSERVERS != no && kill -HUP $KILLPIDS
406 echo "Using ldapsearch to read all the entries from the P2 slave..."
407 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT5 \
408 '(objectClass=*)' '*' entryCSN > $SERVER5OUT 2>&1
411 if test $RC != 0 ; then
412 echo "ldapsearch failed at P2 slave ($RC)!"
413 test $KILLSERVERS != no && kill -HUP $KILLPIDS
417 echo "Using ldapsearch to read all the entries from the P3 slave..."
418 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT6 \
419 '(objectClass=*)' '*' entryCSN > $SERVER6OUT 2>&1
422 if test $RC != 0 ; then
423 echo "ldapsearch failed at P3 slave ($RC)!"
424 test $KILLSERVERS != no && kill -HUP $KILLPIDS
428 test $KILLSERVERS != no && kill -HUP $KILLPIDS
430 echo "Filtering master ldapsearch results..."
431 $LDIFFILTER < $MASTEROUT > $MASTERFLT
432 echo "Filtering R1 slave ldapsearch results..."
433 $LDIFFILTER < $SERVER2OUT > $SERVER2FLT
434 echo "Filtering R2 slave ldapsearch results..."
435 $LDIFFILTER < $SERVER3OUT > $SERVER3FLT
436 echo "Filtering P1 slave ldapsearch results..."
437 $LDIFFILTER < $SERVER4OUT > $SERVER4FLT
438 echo "Filtering P2 slave ldapsearch results..."
439 $LDIFFILTER < $SERVER5OUT > $SERVER5FLT
440 echo "Filtering P3 slave ldapsearch results..."
441 $LDIFFILTER < $SERVER6OUT > $SERVER6FLT
443 echo "Comparing retrieved entries from master and R1 slave..."
444 $CMP $MASTERFLT $SERVER2FLT > $CMPOUT
446 if test $? != 0 ; then
447 echo "test failed - master and R1 slave databases differ"
451 echo "Comparing retrieved entries from master and R2 slave..."
452 $CMP $MASTERFLT $SERVER3FLT > $CMPOUT
454 if test $? != 0 ; then
455 echo "test failed - master and R2 slave databases differ"
459 echo "Comparing retrieved entries from master and P1 slave..."
460 $CMP $MASTERFLT $SERVER4FLT > $CMPOUT
462 if test $? != 0 ; then
463 echo "test failed - master and P1 slave databases differ"
467 echo "Comparing retrieved entries from master and P2 slave..."
468 $CMP $MASTERFLT $SERVER5FLT > $CMPOUT
470 if test $? != 0 ; then
471 echo "test failed - master and P2 slave databases differ"
475 echo "Comparing retrieved entries from master and P3 slave..."
476 $CMP $MASTERFLT $SERVER6FLT > $CMPOUT
478 if test $? != 0 ; then
479 echo "test failed - master and P3 slave databases differ"
483 echo ">>>>> Test succeeded"
485 test $KILLSERVERS != no && wait