3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2007 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 if test "$BACKEND" != "bdb" && test "$BACKEND" != "hdb" ; then
17 echo "Test does not support $BACKEND"
21 echo "running defines.sh"
22 . $SRCDIR/scripts/defines.sh
24 if test $SYNCPROV = syncprovno; then
25 echo "Syncrepl provider overlay not available, test skipped"
29 mkdir -p $TESTDIR $DBDIR1 $DBDIR2 $DBDIR3 $DBDIR4 $DBDIR5 $DBDIR6
35 # - populate over ldap
36 # - perform some modifies and deleted
37 # - retrieve database over ldap and compare against expected results
40 echo "Starting master slapd on TCP/IP port $PORT1..."
41 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
42 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
44 if test $WAIT != 0 ; then
52 echo "Using ldapsearch to check that master slapd (pid=$PID) is running..."
53 for i in 0 1 2 3 4 5; do
54 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
55 'objectclass=*' > /dev/null 2>&1
57 if test $RC = 0 ; then
60 echo "Waiting 5 seconds for slapd to start..."
64 if test $RC != 0 ; then
65 echo "ldapsearch failed ($RC)!"
66 test $KILLSERVERS != no && kill -HUP $KILLPIDS
70 echo "Using ldapadd to create the context prefix entry in the master..."
71 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
72 $LDIFORDEREDCP > /dev/null 2>&1
74 if test $RC != 0 ; then
75 echo "ldapadd failed ($RC)!"
76 test $KILLSERVERS != no && kill -HUP $KILLPIDS
80 echo "Starting R1 slave slapd on TCP/IP port $PORT2..."
81 . $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $CONF2
82 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
84 if test $WAIT != 0 ; then
85 echo SLAVE R1 PID $SLAVEPID
88 KILLPIDS="$KILLPIDS $SLAVEPID"
92 echo "Using ldapsearch to check that R1 slave slapd (pid=$SLAVEPID) is running..."
93 for i in 0 1 2 3 4 5; do
94 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
95 'objectclass=*' > /dev/null 2>&1
97 if test $RC = 0 ; then
100 echo "Waiting 5 seconds for R1 slapd to start..."
104 if test $RC != 0 ; then
105 echo "ldapsearch failed ($RC)!"
106 test $KILLSERVERS != no && kill -HUP $KILLPIDS
110 echo "Starting R2 slave slapd on TCP/IP port $PORT3..."
111 . $CONFFILTER $BACKEND $MONITORDB < $R2SRSLAVECONF > $CONF3
112 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
114 if test $WAIT != 0 ; then
115 echo SLAVE R2 PID $SLAVEPID
118 KILLPIDS="$KILLPIDS $SLAVEPID"
122 echo "Using ldapsearch to check that R2 slave slapd (pid=$SLAVEPID) is running..."
123 for i in 0 1 2 3 4 5; do
124 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
125 'objectclass=*' > /dev/null 2>&1
127 if test $RC = 0 ; then
130 echo "Waiting 5 seconds for R2 slave slapd to start..."
134 if test $RC != 0 ; then
135 echo "ldapsearch failed ($RC)!"
136 test $KILLSERVERS != no && kill -HUP $KILLPIDS
140 echo "Starting P1 slave slapd on TCP/IP port $PORT4..."
141 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
142 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
144 if test $WAIT != 0 ; then
145 echo SLAVE P1 PID $SLAVEPID
148 KILLPIDS="$KILLPIDS $SLAVEPID"
152 echo "Using ldapsearch to check that P1 slave slapd (pid=$SLAVEPID) is running..."
153 for i in 0 1 2 3 4 5; do
154 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT4 \
155 'objectclass=*' > /dev/null 2>&1
157 if test $RC = 0 ; then
160 echo "Waiting 5 seconds for P1 slave slapd to start..."
164 if test $RC != 0 ; then
165 echo "ldapsearch failed ($RC)!"
166 test $KILLSERVERS != no && kill -HUP $KILLPIDS
170 echo "Starting P2 slave slapd on TCP/IP port $PORT5..."
171 . $CONFFILTER $BACKEND $MONITORDB < $P2SRSLAVECONF > $CONF5
172 $SLAPD -f $CONF5 -h $URI5 -d $LVL $TIMING > $LOG5 2>&1 &
174 if test $WAIT != 0 ; then
175 echo SLAVE P2 PID $SLAVEPID
178 KILLPIDS="$KILLPIDS $SLAVEPID"
182 echo "Using ldapsearch to check that P2 slave slapd (pid=$SLAVEPID) is running..."
183 for i in 0 1 2 3 4 5; do
184 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT5 \
185 'objectclass=*' > /dev/null 2>&1
187 if test $RC = 0 ; then
190 echo "Waiting 5 seconds for P2 slave slapd to start..."
194 if test $RC != 0 ; then
195 echo "ldapsearch failed ($RC)!"
196 test $KILLSERVERS != no && kill -HUP $KILLPIDS
200 echo "Starting P3 slave slapd on TCP/IP port $PORT6..."
201 . $CONFFILTER $BACKEND $MONITORDB < $P3SRSLAVECONF > $CONF6
202 $SLAPD -f $CONF6 -h $URI6 -d $LVL $TIMING > $LOG6 2>&1 &
204 if test $WAIT != 0 ; then
205 echo SLAVE P3 PID $SLAVEPID
208 KILLPIDS="$KILLPIDS $SLAVEPID"
212 echo "Using ldapsearch to check that P3 slave slapd (pid=$SLAVEPID) is running..."
213 for i in 0 1 2 3 4 5; do
214 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT6 \
215 'objectclass=*' > /dev/null 2>&1
217 if test $RC = 0 ; then
220 echo "Waiting 5 seconds for P3 slave slapd to start..."
224 if test $RC != 0 ; then
225 echo "ldapsearch failed ($RC)!"
226 test $KILLSERVERS != no && kill -HUP $KILLPIDS
230 echo "Using ldapadd to populate the master directory..."
231 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
232 $LDIFORDEREDNOCP > /dev/null 2>&1
234 if test $RC != 0 ; then
235 echo "ldapadd failed ($RC)!"
236 test $KILLSERVERS != no && kill -HUP $KILLPIDS
240 echo "Waiting 25 seconds for syncrepl to receive changes..."
243 echo "Using ldapmodify to modify master directory..."
246 # Do some modifications
249 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
250 $TESTOUT 2>&1 << EOMODS
251 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
262 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
268 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
271 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
272 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
275 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
276 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
278 dn: cn=All Staff,ou=Groups,dc=example,dc=com
282 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
284 objectclass: OpenLDAPperson
288 title: Chief Investigator, ITD
289 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
290 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
292 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
293 description: Very odd
294 facsimiletelephonenumber: +1 313 555 7557
295 telephonenumber: +1 313 555 8343
296 mail: gjensen@mailgw.example.com
297 homephone: +1 313 555 8844
299 dn: ou=Retired, ou=People, dc=example,dc=com
301 objectclass: organizationalUnit
304 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
306 objectclass: OpenLDAPperson
307 cn: Rosco P. Coltrane
311 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
313 newrdn: cn=Rosco P. Coltrane
315 newsuperior: ou=Retired, ou=People, dc=example,dc=com
317 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
323 if test $RC != 0 ; then
324 echo "ldapmodify failed ($RC)!"
325 test $KILLSERVERS != no && kill -HUP $KILLPIDS
329 echo "Waiting 25 seconds for syncrepl to receive changes..."
332 echo "Using ldapsearch to read all the entries from the master..."
333 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
334 'objectclass=*' > $MASTEROUT 2>&1
337 if test $RC != 0 ; then
338 echo "ldapsearch failed at master ($RC)!"
339 test $KILLSERVERS != no && kill -HUP $KILLPIDS
343 echo "Using ldapsearch to read all the entries from the R1 slave..."
344 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
345 'objectclass=*' > $SERVER2OUT 2>&1
348 if test $RC != 0 ; then
349 echo "ldapsearch failed at R1 slave ($RC)!"
350 test $KILLSERVERS != no && kill -HUP $KILLPIDS
354 echo "Using ldapsearch to read all the entries from the R2 slave..."
355 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT3 \
356 'objectclass=*' > $SERVER3OUT 2>&1
359 if test $RC != 0 ; then
360 echo "ldapsearch failed at R2 slave ($RC)!"
361 test $KILLSERVERS != no && kill -HUP $KILLPIDS
365 echo "Using ldapsearch to read all the entries from the P1 slave..."
366 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
367 'objectclass=*' > $SERVER4OUT 2>&1
370 if test $RC != 0 ; then
371 echo "ldapsearch failed at P1 slave ($RC)!"
372 test $KILLSERVERS != no && kill -HUP $KILLPIDS
376 echo "Using ldapsearch to read all the entries from the P2 slave..."
377 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT5 \
378 'objectclass=*' > $SERVER5OUT 2>&1
381 if test $RC != 0 ; then
382 echo "ldapsearch failed at P2 slave ($RC)!"
383 test $KILLSERVERS != no && kill -HUP $KILLPIDS
387 echo "Using ldapsearch to read all the entries from the P3 slave..."
388 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT6 \
389 'objectclass=*' > $SERVER6OUT 2>&1
392 if test $RC != 0 ; then
393 echo "ldapsearch failed at P3 slave ($RC)!"
394 test $KILLSERVERS != no && kill -HUP $KILLPIDS
398 test $KILLSERVERS != no && kill -HUP $KILLPIDS
400 echo "Filtering master ldapsearch results..."
401 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
402 echo "Filtering R1 slave ldapsearch results..."
403 . $LDIFFILTER < $SERVER2OUT > $SERVER2FLT
404 echo "Filtering R2 slave ldapsearch results..."
405 . $LDIFFILTER < $SERVER3OUT > $SERVER3FLT
406 echo "Filtering P1 slave ldapsearch results..."
407 . $LDIFFILTER < $SERVER4OUT > $SERVER4FLT
408 echo "Filtering P2 slave ldapsearch results..."
409 . $LDIFFILTER < $SERVER5OUT > $SERVER5FLT
410 echo "Filtering P3 slave ldapsearch results..."
411 . $LDIFFILTER < $SERVER6OUT > $SERVER6FLT
413 echo "Comparing retrieved entries from master and R1 slave..."
414 $CMP $MASTERFLT $SERVER2FLT > $CMPOUT
416 if test $? != 0 ; then
417 echo "test failed - master and R1 slave databases differ"
421 echo "Comparing retrieved entries from master and R2 slave..."
422 $CMP $MASTERFLT $SERVER3FLT > $CMPOUT
424 if test $? != 0 ; then
425 echo "test failed - master and R2 slave databases differ"
429 echo "Comparing retrieved entries from master and P1 slave..."
430 $CMP $MASTERFLT $SERVER4FLT > $CMPOUT
432 if test $? != 0 ; then
433 echo "test failed - master and P1 slave databases differ"
437 echo "Comparing retrieved entries from master and P2 slave..."
438 $CMP $MASTERFLT $SERVER5FLT > $CMPOUT
440 if test $? != 0 ; then
441 echo "test failed - master and P2 slave databases differ"
445 echo "Comparing retrieved entries from master and P3 slave..."
446 $CMP $MASTERFLT $SERVER6FLT > $CMPOUT
448 if test $? != 0 ; then
449 echo "test failed - master and P3 slave databases differ"
453 echo ">>>>> Test succeeded"
455 test $KILLSERVERS != no && wait