3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2005 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" -a "$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 $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
50 echo "Using ldapsearch to check that master slapd (pid=$PID) 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 master..."
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 R1 slave slapd on TCP/IP port $PORT2..."
79 . $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $CONF2
80 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
82 if test $WAIT != 0 ; then
83 echo SLAVE R1 PID $SLAVEPID
86 KILLPIDS="$KILLPIDS $SLAVEPID"
88 echo "Using ldapsearch to check that R1 slave slapd (pid=$SLAVEPID) is running..."
89 for i in 0 1 2 3 4 5; do
90 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
91 'objectclass=*' > /dev/null 2>&1
93 if test $RC = 0 ; then
96 echo "Waiting 5 seconds for R1 slapd to start..."
100 if test $RC != 0 ; then
101 echo "ldapsearch failed ($RC)!"
102 test $KILLSERVERS != no && kill -HUP $KILLPIDS
106 echo "Starting R2 slave slapd on TCP/IP port $PORT3..."
107 . $CONFFILTER $BACKEND $MONITORDB < $R2SRSLAVECONF > $CONF3
108 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
110 if test $WAIT != 0 ; then
111 echo SLAVE R2 PID $SLAVEPID
114 KILLPIDS="$KILLPIDS $SLAVEPID"
116 echo "Using ldapsearch to check that R2 slave slapd (pid=$SLAVEPID) is running..."
117 for i in 0 1 2 3 4 5; do
118 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
119 'objectclass=*' > /dev/null 2>&1
121 if test $RC = 0 ; then
124 echo "Waiting 5 seconds for R2 slave slapd to start..."
128 if test $RC != 0 ; then
129 echo "ldapsearch failed ($RC)!"
130 test $KILLSERVERS != no && kill -HUP $KILLPIDS
134 echo "Starting P1 slave slapd on TCP/IP port $PORT4..."
135 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
136 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
138 if test $WAIT != 0 ; then
139 echo SLAVE P1 PID $SLAVEPID
142 KILLPIDS="$KILLPIDS $SLAVEPID"
144 echo "Using ldapsearch to check that P1 slave slapd (pid=$SLAVEPID) is running..."
145 for i in 0 1 2 3 4 5; do
146 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT4 \
147 'objectclass=*' > /dev/null 2>&1
149 if test $RC = 0 ; then
152 echo "Waiting 5 seconds for P1 slave slapd to start..."
156 if test $RC != 0 ; then
157 echo "ldapsearch failed ($RC)!"
158 test $KILLSERVERS != no && kill -HUP $KILLPIDS
162 echo "Starting P2 slave slapd on TCP/IP port $PORT5..."
163 . $CONFFILTER $BACKEND $MONITORDB < $P2SRSLAVECONF > $CONF5
164 $SLAPD -f $CONF5 -h $URI5 -d $LVL $TIMING > $LOG5 2>&1 &
166 if test $WAIT != 0 ; then
167 echo SLAVE P2 PID $SLAVEPID
170 KILLPIDS="$KILLPIDS $SLAVEPID"
172 echo "Using ldapsearch to check that P2 slave slapd (pid=$SLAVEPID) is running..."
173 for i in 0 1 2 3 4 5; do
174 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT5 \
175 'objectclass=*' > /dev/null 2>&1
177 if test $RC = 0 ; then
180 echo "Waiting 5 seconds for P2 slave slapd to start..."
184 if test $RC != 0 ; then
185 echo "ldapsearch failed ($RC)!"
186 test $KILLSERVERS != no && kill -HUP $KILLPIDS
190 echo "Starting P3 slave slapd on TCP/IP port $PORT6..."
191 . $CONFFILTER $BACKEND $MONITORDB < $P3SRSLAVECONF > $CONF6
192 $SLAPD -f $CONF6 -h $URI6 -d $LVL $TIMING > $LOG6 2>&1 &
194 if test $WAIT != 0 ; then
195 echo SLAVE P3 PID $SLAVEPID
198 KILLPIDS="$KILLPIDS $SLAVEPID"
200 echo "Using ldapsearch to check that P3 slave slapd (pid=$SLAVEPID) is running..."
201 for i in 0 1 2 3 4 5; do
202 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT6 \
203 'objectclass=*' > /dev/null 2>&1
205 if test $RC = 0 ; then
208 echo "Waiting 5 seconds for P3 slave slapd to start..."
212 if test $RC != 0 ; then
213 echo "ldapsearch failed ($RC)!"
214 test $KILLSERVERS != no && kill -HUP $KILLPIDS
218 echo "Using ldapadd to populate the master directory..."
219 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
220 $LDIFORDEREDNOCP > /dev/null 2>&1
222 if test $RC != 0 ; then
223 echo "ldapadd failed ($RC)!"
224 test $KILLSERVERS != no && kill -HUP $KILLPIDS
228 echo "Waiting 25 seconds for syncrepl to receive changes..."
231 echo "Using ldapmodify to modify master directory..."
234 # Do some modifications
237 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
238 $TESTOUT 2>&1 << EOMODS
239 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
250 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
256 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
259 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
260 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
263 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
264 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
266 dn: cn=All Staff,ou=Groups,dc=example,dc=com
270 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
272 objectclass: OpenLDAPperson
276 title: Chief Investigator, ITD
277 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
278 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
280 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
281 description: Very odd
282 facsimiletelephonenumber: +1 313 555 7557
283 telephonenumber: +1 313 555 8343
284 mail: gjensen@mailgw.example.com
285 homephone: +1 313 555 8844
287 dn: ou=Retired, ou=People, dc=example,dc=com
289 objectclass: organizationalUnit
292 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
294 objectclass: OpenLDAPperson
295 cn: Rosco P. Coltrane
299 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
301 newrdn: cn=Rosco P. Coltrane
303 newsuperior: ou=Retired, ou=People, dc=example,dc=com
305 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
311 if test $RC != 0 ; then
312 echo "ldapmodify failed ($RC)!"
313 test $KILLSERVERS != no && kill -HUP $KILLPIDS
317 echo "Waiting 25 seconds for syncrepl to receive changes..."
320 echo "Using ldapsearch to read all the entries from the master..."
321 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
322 'objectclass=*' > $MASTEROUT 2>&1
325 if test $RC != 0 ; then
326 echo "ldapsearch failed at master ($RC)!"
327 test $KILLSERVERS != no && kill -HUP $KILLPIDS
331 echo "Using ldapsearch to read all the entries from the R1 slave..."
332 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
333 'objectclass=*' > $SERVER2OUT 2>&1
336 if test $RC != 0 ; then
337 echo "ldapsearch failed at R1 slave ($RC)!"
338 test $KILLSERVERS != no && kill -HUP $KILLPIDS
342 echo "Using ldapsearch to read all the entries from the R2 slave..."
343 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT3 \
344 'objectclass=*' > $SERVER3OUT 2>&1
347 if test $RC != 0 ; then
348 echo "ldapsearch failed at R2 slave ($RC)!"
349 test $KILLSERVERS != no && kill -HUP $KILLPIDS
353 echo "Using ldapsearch to read all the entries from the P1 slave..."
354 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
355 'objectclass=*' > $SERVER4OUT 2>&1
358 if test $RC != 0 ; then
359 echo "ldapsearch failed at P1 slave ($RC)!"
360 test $KILLSERVERS != no && kill -HUP $KILLPIDS
364 echo "Using ldapsearch to read all the entries from the P2 slave..."
365 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT5 \
366 'objectclass=*' > $SERVER5OUT 2>&1
369 if test $RC != 0 ; then
370 echo "ldapsearch failed at P2 slave ($RC)!"
371 test $KILLSERVERS != no && kill -HUP $KILLPIDS
375 echo "Using ldapsearch to read all the entries from the P3 slave..."
376 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT6 \
377 'objectclass=*' > $SERVER6OUT 2>&1
380 if test $RC != 0 ; then
381 echo "ldapsearch failed at P3 slave ($RC)!"
382 test $KILLSERVERS != no && kill -HUP $KILLPIDS
386 test $KILLSERVERS != no && kill -HUP $KILLPIDS
388 echo "Filtering master ldapsearch results..."
389 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
390 echo "Filtering R1 slave ldapsearch results..."
391 . $LDIFFILTER < $SERVER2OUT > $SERVER2FLT
392 echo "Filtering R2 slave ldapsearch results..."
393 . $LDIFFILTER < $SERVER3OUT > $SERVER3FLT
394 echo "Filtering P1 slave ldapsearch results..."
395 . $LDIFFILTER < $SERVER4OUT > $SERVER4FLT
396 echo "Filtering P2 slave ldapsearch results..."
397 . $LDIFFILTER < $SERVER5OUT > $SERVER5FLT
398 echo "Filtering P3 slave ldapsearch results..."
399 . $LDIFFILTER < $SERVER6OUT > $SERVER6FLT
401 echo "Comparing retrieved entries from master and R1 slave..."
402 $CMP $MASTERFLT $SERVER2FLT > $CMPOUT
404 if test $? != 0 ; then
405 echo "test failed - master and R1 slave databases differ"
409 echo "Comparing retrieved entries from master and R2 slave..."
410 $CMP $MASTERFLT $SERVER3FLT > $CMPOUT
412 if test $? != 0 ; then
413 echo "test failed - master and R2 slave databases differ"
417 echo "Comparing retrieved entries from master and P1 slave..."
418 $CMP $MASTERFLT $SERVER4FLT > $CMPOUT
420 if test $? != 0 ; then
421 echo "test failed - master and P1 slave databases differ"
425 echo "Comparing retrieved entries from master and P2 slave..."
426 $CMP $MASTERFLT $SERVER5FLT > $CMPOUT
428 if test $? != 0 ; then
429 echo "test failed - master and P2 slave databases differ"
433 echo "Comparing retrieved entries from master and P3 slave..."
434 $CMP $MASTERFLT $SERVER6FLT > $CMPOUT
436 if test $? != 0 ; then
437 echo "test failed - master and P3 slave databases differ"
441 echo ">>>>> Test succeeded"