3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2004 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 mkdir $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
45 echo "Using ldapsearch to check that master slapd (pid=$PID) is running..."
46 for i in 0 1 2 3 4 5; do
47 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
48 'objectclass=*' > /dev/null 2>&1
50 if test $RC = 0 ; then
53 echo "Waiting 5 seconds for slapd to start..."
57 if test $RC != 0 ; then
58 echo "ldapsearch failed ($RC)!"
59 test $KILLSERVERS != no && kill -HUP $KILLPIDS
63 echo "Using ldapadd to create the context prefix entry in the master..."
64 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
65 $LDIFORDEREDCP > /dev/null 2>&1
67 if test $RC != 0 ; then
68 echo "ldapadd failed ($RC)!"
69 test $KILLSERVERS != no && kill -HUP $KILLPIDS
73 echo "Starting R1 slave slapd on TCP/IP port $PORT2..."
74 . $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $CONF2
75 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
77 if test $WAIT != 0 ; then
78 echo SLAVE R1 PID $SLAVEPID
81 KILLPIDS="$KILLPIDS $SLAVEPID"
83 echo "Using ldapsearch to check that R1 slave slapd (pid=$SLAVEPID) is running..."
84 for i in 0 1 2 3 4 5; do
85 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
86 'objectclass=*' > /dev/null 2>&1
88 if test $RC = 0 ; then
91 echo "Waiting 5 seconds for R1 slapd to start..."
95 if test $RC != 0 ; then
96 echo "ldapsearch failed ($RC)!"
97 test $KILLSERVERS != no && kill -HUP $KILLPIDS
101 echo "Starting R2 slave slapd on TCP/IP port $PORT3..."
102 . $CONFFILTER $BACKEND $MONITORDB < $R2SRSLAVECONF > $CONF3
103 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
105 if test $WAIT != 0 ; then
106 echo SLAVE R2 PID $SLAVEPID
109 KILLPIDS="$KILLPIDS $SLAVEPID"
111 echo "Using ldapsearch to check that R2 slave slapd (pid=$SLAVEPID) is running..."
112 for i in 0 1 2 3 4 5; do
113 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
114 'objectclass=*' > /dev/null 2>&1
116 if test $RC = 0 ; then
119 echo "Waiting 5 seconds for R2 slave slapd to start..."
123 if test $RC != 0 ; then
124 echo "ldapsearch failed ($RC)!"
125 test $KILLSERVERS != no && kill -HUP $KILLPIDS
129 echo "Starting P1 slave slapd on TCP/IP port $PORT4..."
130 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
131 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
133 if test $WAIT != 0 ; then
134 echo SLAVE P1 PID $SLAVEPID
137 KILLPIDS="$KILLPIDS $SLAVEPID"
139 echo "Using ldapsearch to check that P1 slave slapd (pid=$SLAVEPID) is running..."
140 for i in 0 1 2 3 4 5; do
141 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT4 \
142 'objectclass=*' > /dev/null 2>&1
144 if test $RC = 0 ; then
147 echo "Waiting 5 seconds for P1 slave slapd to start..."
151 if test $RC != 0 ; then
152 echo "ldapsearch failed ($RC)!"
153 test $KILLSERVERS != no && kill -HUP $KILLPIDS
157 echo "Starting P2 slave slapd on TCP/IP port $PORT5..."
158 . $CONFFILTER $BACKEND $MONITORDB < $P2SRSLAVECONF > $CONF5
159 $SLAPD -f $CONF5 -h $URI5 -d $LVL $TIMING > $LOG5 2>&1 &
161 if test $WAIT != 0 ; then
162 echo SLAVE P2 PID $SLAVEPID
165 KILLPIDS="$KILLPIDS $SLAVEPID"
167 echo "Using ldapsearch to check that P2 slave slapd (pid=$SLAVEPID) is running..."
168 for i in 0 1 2 3 4 5; do
169 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT5 \
170 'objectclass=*' > /dev/null 2>&1
172 if test $RC = 0 ; then
175 echo "Waiting 5 seconds for P2 slave slapd to start..."
179 if test $RC != 0 ; then
180 echo "ldapsearch failed ($RC)!"
181 test $KILLSERVERS != no && kill -HUP $KILLPIDS
185 echo "Starting P3 slave slapd on TCP/IP port $PORT6..."
186 . $CONFFILTER $BACKEND $MONITORDB < $P3SRSLAVECONF > $CONF6
187 $SLAPD -f $CONF6 -h $URI6 -d $LVL $TIMING > $LOG6 2>&1 &
189 if test $WAIT != 0 ; then
190 echo SLAVE P3 PID $SLAVEPID
193 KILLPIDS="$KILLPIDS $SLAVEPID"
195 echo "Using ldapsearch to check that P3 slave slapd (pid=$SLAVEPID) is running..."
196 for i in 0 1 2 3 4 5; do
197 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT6 \
198 'objectclass=*' > /dev/null 2>&1
200 if test $RC = 0 ; then
203 echo "Waiting 5 seconds for P3 slave slapd to start..."
207 if test $RC != 0 ; then
208 echo "ldapsearch failed ($RC)!"
209 test $KILLSERVERS != no && kill -HUP $KILLPIDS
213 echo "Using ldapadd to populate the master directory..."
214 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
215 $LDIFORDEREDNOCP > /dev/null 2>&1
217 if test $RC != 0 ; then
218 echo "ldapadd failed ($RC)!"
219 test $KILLSERVERS != no && kill -HUP $KILLPIDS
223 echo "Waiting 25 seconds for syncrepl to receive changes..."
226 echo "Using ldapmodify to modify master directory..."
229 # Do some modifications
232 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
233 $TESTOUT 2>&1 << EOMODS
234 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
245 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
251 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
254 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
255 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
258 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
259 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
261 dn: cn=All Staff,ou=Groups,dc=example,dc=com
265 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
267 objectclass: OpenLDAPperson
271 title: Chief Investigator, ITD
272 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
273 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
275 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
276 description: Very odd
277 facsimiletelephonenumber: +1 313 555 7557
278 telephonenumber: +1 313 555 8343
279 mail: gjensen@mailgw.example.com
280 homephone: +1 313 555 8844
282 dn: ou=Retired, ou=People, dc=example,dc=com
284 objectclass: organizationalUnit
287 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
289 objectclass: OpenLDAPperson
290 cn: Rosco P. Coltrane
294 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
296 newrdn: cn=Rosco P. Coltrane
298 newsuperior: ou=Retired, ou=People, dc=example,dc=com
300 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
306 if test $RC != 0 ; then
307 echo "ldapmodify failed ($RC)!"
308 test $KILLSERVERS != no && kill -HUP $KILLPIDS
312 echo "Waiting 25 seconds for syncrepl to receive changes..."
315 echo "Using ldapsearch to read all the entries from the master..."
316 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
317 'objectclass=*' > $MASTEROUT 2>&1
320 if test $RC != 0 ; then
321 echo "ldapsearch failed at master ($RC)!"
322 test $KILLSERVERS != no && kill -HUP $KILLPIDS
326 echo "Using ldapsearch to read all the entries from the R1 slave..."
327 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
328 'objectclass=*' > $SERVER2OUT 2>&1
331 if test $RC != 0 ; then
332 echo "ldapsearch failed at R1 slave ($RC)!"
333 test $KILLSERVERS != no && kill -HUP $KILLPIDS
337 echo "Using ldapsearch to read all the entries from the R2 slave..."
338 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT3 \
339 'objectclass=*' > $SERVER3OUT 2>&1
342 if test $RC != 0 ; then
343 echo "ldapsearch failed at R2 slave ($RC)!"
344 test $KILLSERVERS != no && kill -HUP $KILLPIDS
348 echo "Using ldapsearch to read all the entries from the P1 slave..."
349 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
350 'objectclass=*' > $SERVER4OUT 2>&1
353 if test $RC != 0 ; then
354 echo "ldapsearch failed at P1 slave ($RC)!"
355 test $KILLSERVERS != no && kill -HUP $KILLPIDS
359 echo "Using ldapsearch to read all the entries from the P2 slave..."
360 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT5 \
361 'objectclass=*' > $SERVER5OUT 2>&1
364 if test $RC != 0 ; then
365 echo "ldapsearch failed at P2 slave ($RC)!"
366 test $KILLSERVERS != no && kill -HUP $KILLPIDS
370 echo "Using ldapsearch to read all the entries from the P3 slave..."
371 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT6 \
372 'objectclass=*' > $SERVER6OUT 2>&1
375 if test $RC != 0 ; then
376 echo "ldapsearch failed at P3 slave ($RC)!"
377 test $KILLSERVERS != no && kill -HUP $KILLPIDS
381 test $KILLSERVERS != no && kill -HUP $KILLPIDS
383 echo "Filtering master ldapsearch results..."
384 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
385 echo "Filtering R1 slave ldapsearch results..."
386 . $LDIFFILTER < $SERVER2OUT > $SERVER2FLT
387 echo "Filtering R2 slave ldapsearch results..."
388 . $LDIFFILTER < $SERVER3OUT > $SERVER3FLT
389 echo "Filtering P1 slave ldapsearch results..."
390 . $LDIFFILTER < $SERVER4OUT > $SERVER4FLT
391 echo "Filtering P2 slave ldapsearch results..."
392 . $LDIFFILTER < $SERVER5OUT > $SERVER5FLT
393 echo "Filtering P3 slave ldapsearch results..."
394 . $LDIFFILTER < $SERVER6OUT > $SERVER6FLT
396 echo "Comparing retrieved entries from master and R1 slave..."
397 $CMP $MASTERFLT $SERVER2FLT > $CMPOUT
399 if test $? != 0 ; then
400 echo "test failed - master and R1 slave databases differ"
404 echo "Comparing retrieved entries from master and R2 slave..."
405 $CMP $MASTERFLT $SERVER3FLT > $CMPOUT
407 if test $? != 0 ; then
408 echo "test failed - master and R2 slave databases differ"
412 echo "Comparing retrieved entries from master and P1 slave..."
413 $CMP $MASTERFLT $SERVER4FLT > $CMPOUT
415 if test $? != 0 ; then
416 echo "test failed - master and P1 slave databases differ"
420 echo "Comparing retrieved entries from master and P2 slave..."
421 $CMP $MASTERFLT $SERVER5FLT > $CMPOUT
423 if test $? != 0 ; then
424 echo "test failed - master and P2 slave databases differ"
428 echo "Comparing retrieved entries from master and P3 slave..."
429 $CMP $MASTERFLT $SERVER6FLT > $CMPOUT
431 if test $? != 0 ; then
432 echo "test failed - master and P3 slave databases differ"
436 echo ">>>>> Test succeeded"