3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2003 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 mkdir $TESTDIR $DBDIR1 $DBDIR2 $DBDIR3 $DBDIR4 $DBDIR5 $DBDIR6
25 # - populate over ldap
26 # - perform some modifies and deleted
27 # - retrieve database over ldap and compare against expected results
30 echo "Starting master slapd on TCP/IP port $PORT1..."
31 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
32 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
34 if test $WAIT != 0 ; then
40 echo "Using ldapsearch to check that master slapd (pid=$PID) is running..."
41 for i in 0 1 2 3 4 5; do
42 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
43 'objectclass=*' > /dev/null 2>&1
45 if test $RC = 0 ; then
48 echo "Waiting 5 seconds for slapd to start..."
52 if test $RC != 0 ; then
53 echo "ldapsearch failed ($RC)!"
54 test $KILLSERVERS != no && kill -HUP $KILLPIDS
58 echo "Using ldapadd to create the context prefix entry in the master..."
59 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
60 $LDIFORDEREDCP > /dev/null 2>&1
62 if test $RC != 0 ; then
63 echo "ldapadd failed ($RC)!"
64 test $KILLSERVERS != no && kill -HUP $KILLPIDS
68 echo "Starting R1 slave slapd on TCP/IP port $PORT2..."
69 . $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $CONF2
70 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
72 if test $WAIT != 0 ; then
73 echo SLAVE R1 PID $SLAVEPID
76 KILLPIDS="$KILLPIDS $SLAVEPID"
78 echo "Using ldapsearch to check that R1 slave slapd(pid=$SLAVEPID) is running..."
79 for i in 0 1 2 3 4 5; do
80 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
81 'objectclass=*' > /dev/null 2>&1
83 if test $RC = 0 ; then
86 echo "Waiting 5 seconds for R1 slapd to start..."
90 if test $RC != 0 ; then
91 echo "ldapsearch failed ($RC)!"
92 test $KILLSERVERS != no && kill -HUP $KILLPIDS
96 echo "Starting R2 slave slapd on TCP/IP port $PORT3..."
97 . $CONFFILTER $BACKEND $MONITORDB < $R2SRSLAVECONF > $CONF3
98 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
100 if test $WAIT != 0 ; then
101 echo SLAVE R2 PID $SLAVEPID
104 KILLPIDS="$KILLPIDS $SLAVEPID"
106 echo "Using ldapsearch to check that R2 slave slapd(pid=$SLAVEPID) is running..."
107 for i in 0 1 2 3 4 5; do
108 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
109 'objectclass=*' > /dev/null 2>&1
111 if test $RC = 0 ; then
114 echo "Waiting 5 seconds for R2 slave slapd to start..."
118 if test $RC != 0 ; then
119 echo "ldapsearch failed ($RC)!"
120 test $KILLSERVERS != no && kill -HUP $KILLPIDS
124 echo "Starting P1 slave slapd on TCP/IP port $PORT4..."
125 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
126 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
128 if test $WAIT != 0 ; then
129 echo SLAVE P1 PID $SLAVEPID
132 KILLPIDS="$KILLPIDS $SLAVEPID"
134 echo "Using ldapsearch to check that P1 slave slapd(pid=$SLAVEPID) is running..."
135 for i in 0 1 2 3 4 5; do
136 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT4 \
137 'objectclass=*' > /dev/null 2>&1
139 if test $RC = 0 ; then
142 echo "Waiting 5 seconds for P1 slave slapd to start..."
146 if test $RC != 0 ; then
147 echo "ldapsearch failed ($RC)!"
148 test $KILLSERVERS != no && kill -HUP $KILLPIDS
152 echo "Starting P2 slave slapd on TCP/IP port $PORT5..."
153 . $CONFFILTER $BACKEND $MONITORDB < $P2SRSLAVECONF > $CONF5
154 $SLAPD -f $CONF5 -h $URI5 -d $LVL $TIMING > $LOG5 2>&1 &
156 if test $WAIT != 0 ; then
157 echo SLAVE P2 PID $SLAVEPID
160 KILLPIDS="$KILLPIDS $SLAVEPID"
162 echo "Using ldapsearch to check that P2 slave slapd(pid=$SLAVEPID) is running..."
163 for i in 0 1 2 3 4 5; do
164 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT5 \
165 'objectclass=*' > /dev/null 2>&1
167 if test $RC = 0 ; then
170 echo "Waiting 5 seconds for P2 slave slapd to start..."
174 if test $RC != 0 ; then
175 echo "ldapsearch failed ($RC)!"
176 test $KILLSERVERS != no && kill -HUP $KILLPIDS
180 echo "Starting P3 slave slapd on TCP/IP port $PORT6..."
181 . $CONFFILTER $BACKEND $MONITORDB < $P3SRSLAVECONF > $CONF6
182 $SLAPD -f $CONF6 -h $URI6 -d $LVL $TIMING > $LOG6 2>&1 &
184 if test $WAIT != 0 ; then
185 echo SLAVE P3 PID $SLAVEPID
188 KILLPIDS="$KILLPIDS $SLAVEPID"
190 echo "Using ldapsearch to check that P3 slave slapd(pid=$SLAVEPID) is running..."
191 for i in 0 1 2 3 4 5; do
192 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT6 \
193 'objectclass=*' > /dev/null 2>&1
195 if test $RC = 0 ; then
198 echo "Waiting 5 seconds for P3 slave slapd to start..."
202 if test $RC != 0 ; then
203 echo "ldapsearch failed ($RC)!"
204 test $KILLSERVERS != no && kill -HUP $KILLPIDS
208 echo "Using ldapadd to populate the master directory..."
209 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
210 $LDIFORDEREDNOCP > /dev/null 2>&1
212 if test $RC != 0 ; then
213 echo "ldapadd failed ($RC)!"
214 test $KILLSERVERS != no && kill -HUP $KILLPIDS
218 echo "Waiting 25 seconds for syncrepl to receive changes..."
221 echo "Using ldapmodify to modify master directory..."
224 # Do some modifications
227 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
228 $TESTOUT 2>&1 << EOMODS
229 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
240 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
246 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
249 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
250 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
253 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
254 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
256 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
260 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
262 objectclass: OpenLDAPperson
266 title: Chief Investigator, ITD
267 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
268 seealso: cn=All Staff, ou=Groups, o=University of Michigan, c=US
270 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
271 description: Very odd
272 facsimiletelephonenumber: +1 313 555 7557
273 telephonenumber: +1 313 555 8343
274 mail: gjensen@mailgw.example.com
275 homephone: +1 313 555 8844
277 dn: ou=Retired, ou=People, o=University of Michigan, c=US
279 objectclass: organizationalUnit
282 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
284 objectclass: OpenLDAPperson
285 cn: Rosco P. Coltrane
289 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
291 newrdn: cn=Rosco P. Coltrane
293 newsuperior: ou=Retired, ou=People, o=University of Michigan, c=US
295 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
301 if test $RC != 0 ; then
302 echo "ldapmodify failed ($RC)!"
303 test $KILLSERVERS != no && kill -HUP $KILLPIDS
307 echo "Waiting 25 seconds for syncrepl to receive changes..."
310 echo "Using ldapsearch to read all the entries from the master..."
311 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
312 'objectclass=*' > $MASTEROUT 2>&1
315 if test $RC != 0 ; then
316 echo "ldapsearch failed at master ($RC)!"
317 test $KILLSERVERS != no && kill -HUP $KILLPIDS
321 echo "Using ldapsearch to read all the entries from the R1 slave..."
322 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
323 'objectclass=*' > $SERVER2OUT 2>&1
326 if test $RC != 0 ; then
327 echo "ldapsearch failed at R1 slave ($RC)!"
328 test $KILLSERVERS != no && kill -HUP $KILLPIDS
332 echo "Using ldapsearch to read all the entries from the R2 slave..."
333 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT3 \
334 'objectclass=*' > $SERVER3OUT 2>&1
337 if test $RC != 0 ; then
338 echo "ldapsearch failed at R2 slave ($RC)!"
339 test $KILLSERVERS != no && kill -HUP $KILLPIDS
343 echo "Using ldapsearch to read all the entries from the P1 slave..."
344 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
345 'objectclass=*' > $SERVER4OUT 2>&1
348 if test $RC != 0 ; then
349 echo "ldapsearch failed at P1 slave ($RC)!"
350 test $KILLSERVERS != no && kill -HUP $KILLPIDS
354 echo "Using ldapsearch to read all the entries from the P2 slave..."
355 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT5 \
356 'objectclass=*' > $SERVER5OUT 2>&1
359 if test $RC != 0 ; then
360 echo "ldapsearch failed at P2 slave ($RC)!"
361 test $KILLSERVERS != no && kill -HUP $KILLPIDS
365 echo "Using ldapsearch to read all the entries from the P3 slave..."
366 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT6 \
367 'objectclass=*' > $SERVER6OUT 2>&1
370 if test $RC != 0 ; then
371 echo "ldapsearch failed at P3 slave ($RC)!"
372 test $KILLSERVERS != no && kill -HUP $KILLPIDS
376 test $KILLSERVERS != no && kill -HUP $KILLPIDS
378 echo "Filtering master ldapsearch results..."
379 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
380 echo "Filtering R1 slave ldapsearch results..."
381 . $LDIFFILTER < $SERVER2OUT > $SERVER2FLT
382 echo "Filtering R2 slave ldapsearch results..."
383 . $LDIFFILTER < $SERVER3OUT > $SERVER3FLT
384 echo "Filtering P1 slave ldapsearch results..."
385 . $LDIFFILTER < $SERVER4OUT > $SERVER4FLT
386 echo "Filtering P2 slave ldapsearch results..."
387 . $LDIFFILTER < $SERVER5OUT > $SERVER5FLT
388 echo "Filtering P3 slave ldapsearch results..."
389 . $LDIFFILTER < $SERVER6OUT > $SERVER6FLT
391 echo "Comparing retrieved entries from master and R1 slave..."
392 $CMP $MASTERFLT $SERVER2FLT > $CMPOUT
394 if test $? != 0 ; then
395 echo "test failed - master and R1 slave databases differ"
399 echo "Comparing retrieved entries from master and R2 slave..."
400 $CMP $MASTERFLT $SERVER3FLT > $CMPOUT
402 if test $? != 0 ; then
403 echo "test failed - master and R2 slave databases differ"
407 echo "Comparing retrieved entries from master and P1 slave..."
408 $CMP $MASTERFLT $SERVER4FLT > $CMPOUT
410 if test $? != 0 ; then
411 echo "test failed - master and P1 slave databases differ"
415 echo "Comparing retrieved entries from master and P2 slave..."
416 $CMP $MASTERFLT $SERVER5FLT > $CMPOUT
418 if test $? != 0 ; then
419 echo "test failed - master and P2 slave databases differ"
423 echo "Comparing retrieved entries from master and P3 slave..."
424 $CMP $MASTERFLT $SERVER6FLT > $CMPOUT
426 if test $? != 0 ; then
427 echo "test failed - master and P3 slave databases differ"
431 echo ">>>>> Test succeeded"