5 if test $# -ge 1 ; then
9 . $SRCDIR/scripts/args.sh $*
11 if test "$BACKEND" != "bdb" -a "$BACKEND" != "hdb"; then
12 echo "Test only valid for back-bdb"
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
23 # - populate over ldap
24 # - perform some modifies and deleted
25 # - retrieve database over ldap and compare against expected results
28 echo "Cleaning up in $DBDIR..."
30 echo "Resetting $R1REPLDIR..."
33 echo "Resetting $R2REPLDIR..."
36 echo "Resetting $P1REPLDIR..."
39 echo "Resetting $P2REPLDIR..."
42 echo "Resetting $P3REPLDIR..."
46 echo "Starting master slapd on TCP/IP port $PORT..."
47 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $DBCONF
48 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
50 if test $WAIT != 0 ; then
55 echo "Waiting 5 seconds to wait for master to start..."
58 echo "Using ldapsearch to check that master slapd is running..."
59 for i in 0 1 2 3 4 5; do
60 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
61 'objectclass=*' > /dev/null 2>&1
63 if test $RC = 0 ; then
66 echo "Waiting 5 seconds for slapd to start..."
70 echo "Using ldapadd to create the context prefix entry in the master..."
71 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
72 $LDIFORDEREDCP > /dev/null 2>&1
74 if test $RC != 0 ; then
75 echo "ldapadd failed ($RC)!"
80 echo "Starting R1 slave slapd on TCP/IP port $R1SLAVEPORT..."
81 . $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $R1REPLCONF
82 $SLAPD -f $R1REPLCONF -h $R1SLAVEURI -d $LVL $TIMING > $R1SLAVELOG 2>&1 &
84 if test $WAIT != 0 ; then
85 echo SLAVE R1 PID $R1SLAVEPID
89 echo "Using ldapsearch to check that R1 slave slapd is running..."
90 for i in 0 1 2 3 4 5; do
91 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $R1SLAVEPORT \
92 'objectclass=*' > /dev/null 2>&1
94 if test $RC = 0 ; then
97 echo "Waiting 5 seconds for R1 slapd to start..."
101 echo "Waiting for the R1 slave to replicate..."
104 echo "Starting R2 slave slapd on TCP/IP port $R2SLAVEPORT..."
105 . $CONFFILTER $BACKEND $MONITORDB < $R2SRSLAVECONF > $R2REPLCONF
106 $SLAPD -f $R2REPLCONF -h $R2SLAVEURI -d $LVL $TIMING > $R2SLAVELOG 2>&1 &
108 if test $WAIT != 0 ; then
109 echo SLAVE R2 PID $R2SLAVEPID
113 echo "Using ldapsearch to check that the R2 slave slapd is running..."
114 for i in 0 1 2 3 4 5; do
115 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $R2SLAVEPORT \
116 'objectclass=*' > /dev/null 2>&1
118 if test $RC = 0 ; then
121 echo "Waiting 5 seconds for R2 slave slapd to start..."
125 echo "Waiting for the R2 slave to replicate..."
128 echo "Starting P1 slave slapd on TCP/IP port $P1SLAVEPORT..."
129 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $P1REPLCONF
130 $SLAPD -f $P1REPLCONF -h $P1SLAVEURI -d $LVL $TIMING > $P1SLAVELOG 2>&1 &
132 if test $WAIT != 0 ; then
133 echo SLAVE P1 PID $P1SLAVEPID
137 echo "Using ldapsearch to check that the P1 slave slapd is running..."
138 for i in 0 1 2 3 4 5; do
139 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $P1SLAVEPORT \
140 'objectclass=*' > /dev/null 2>&1
142 if test $RC = 0 ; then
145 echo "Waiting 5 seconds for P1 slave slapd to start..."
149 echo "Waiting for the P1 slave to replicate..."
152 echo "Starting P2 slave slapd on TCP/IP port $P2SLAVEPORT..."
153 . $CONFFILTER $BACKEND $MONITORDB < $P2SRSLAVECONF > $P2REPLCONF
154 $SLAPD -f $P2REPLCONF -h $P2SLAVEURI -d $LVL $TIMING > $P2SLAVELOG 2>&1 &
156 if test $WAIT != 0 ; then
157 echo SLAVE P2 PID $P2SLAVEPID
161 echo "Using ldapsearch to check that the P2 slave slapd is running..."
162 for i in 0 1 2 3 4 5; do
163 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $P2SLAVEPORT \
164 'objectclass=*' > /dev/null 2>&1
166 if test $RC = 0 ; then
169 echo "Waiting 5 seconds for P2 slave slapd to start..."
173 echo "Starting P3 slave slapd on TCP/IP port $P3SLAVEPORT..."
174 . $CONFFILTER $BACKEND $MONITORDB < $P3SRSLAVECONF > $P3REPLCONF
175 $SLAPD -f $P3REPLCONF -h $P3SLAVEURI -d $LVL $TIMING > $P3SLAVELOG 2>&1 &
177 if test $WAIT != 0 ; then
178 echo SLAVE P3 PID $P3SLAVEPID
182 echo "Using ldapsearch to check that the P3 slave slapd is running..."
183 for i in 0 1 2 3 4 5; do
184 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $P3SLAVEPORT \
185 'objectclass=*' > /dev/null 2>&1
187 if test $RC = 0 ; then
190 echo "Waiting 5 seconds for P3 slave slapd to start..."
194 echo "Using ldapadd to populate the master directory..."
195 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
196 $LDIFORDEREDNOCP > /dev/null 2>&1
198 if test $RC != 0 ; then
199 echo "ldapadd failed ($RC)!"
200 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
204 echo "Waiting 30 seconds for syncrepl to receive changes..."
207 echo "Using ldapmodify to modify master directory..."
210 # Do some modifications
213 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD > \
214 $TESTOUT 2>&1 << EOMODS
215 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
226 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
232 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
235 member: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
236 member: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
239 member: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
240 member: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
242 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
246 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
248 objectclass: OpenLDAPperson
252 title: Chief Investigator, ITD
253 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
254 seealso: cn=All Staff, ou=Groups, o=University of Michigan, c=US
256 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
257 description: Very odd
258 facsimiletelephonenumber: +1 313 555 7557
259 telephonenumber: +1 313 555 8343
260 mail: gjensen@mailgw.example.com
261 homephone: +1 313 555 8844
263 dn: ou=Retired, ou=People, o=University of Michigan, c=US
265 objectclass: organizationalUnit
268 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
270 objectclass: OpenLDAPperson
271 cn: Rosco P. Coltrane
275 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
277 newrdn: cn=Rosco P. Coltrane
279 newsuperior: ou=Retired, ou=People, o=University of Michigan, c=US
281 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
286 echo "Waiting 30 seconds for syncrepl to receive changes..."
289 echo "Using ldapsearch to read all the entries from the master..."
290 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
291 'objectclass=*' > $MASTEROUT 2>&1
294 if test $RC != 0 ; then
295 echo "ldapsearch failed at master ($RC)!"
296 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
300 echo "Using ldapsearch to read all the entries from the R1 slave..."
301 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $R1SLAVEPORT \
302 'objectclass=*' > $R1SLAVEOUT 2>&1
305 if test $RC != 0 ; then
306 echo "ldapsearch failed at R1 slave ($RC)!"
307 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
311 echo "Using ldapsearch to read all the entries from the R2 slave..."
312 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $R2SLAVEPORT \
313 'objectclass=*' > $R2SLAVEOUT 2>&1
316 if test $RC != 0 ; then
317 echo "ldapsearch failed at R2 slave ($RC)!"
318 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
322 echo "Using ldapsearch to read all the entries from the P1 slave..."
323 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $P1SLAVEPORT \
324 'objectclass=*' > $P1SLAVEOUT 2>&1
327 if test $RC != 0 ; then
328 echo "ldapsearch failed at R1 slave ($RC)!"
329 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
333 echo "Using ldapsearch to read all the entries from the P2 slave..."
334 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $P2SLAVEPORT \
335 'objectclass=*' > $P2SLAVEOUT 2>&1
338 if test $RC != 0 ; then
339 echo "ldapsearch failed at R2 slave ($RC)!"
340 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
344 echo "Using ldapsearch to read all the entries from the P3 slave..."
345 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $P3SLAVEPORT \
346 'objectclass=*' > $P3SLAVEOUT 2>&1
349 if test $RC != 0 ; then
350 echo "ldapsearch failed at R2 slave ($RC)!"
351 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
355 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
364 echo "Filtering master ldapsearch results..."
365 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
366 echo "Filtering R1 slave ldapsearch results..."
367 . $LDIFFILTER < $R1LDIF > $R1LDIFFLT
368 echo "Filtering R2 slave ldapsearch results..."
369 . $LDIFFILTER < $R2LDIF > $R2LDIFFLT
370 echo "Filtering P1 slave ldapsearch results..."
371 . $LDIFFILTER < $P1LDIF > $P1LDIFFLT
372 echo "Filtering P2 slave ldapsearch results..."
373 . $LDIFFILTER < $P2LDIF > $P2LDIFFLT
374 echo "Filtering P3 slave ldapsearch results..."
375 . $LDIFFILTER < $P3LDIF > $P3LDIFFLT
377 echo "Comparing retrieved entries from master and R1 slave..."
378 $CMP $SEARCHFLT $R1LDIFFLT > $CMPOUT
380 if test $? != 0 ; then
381 echo "test failed - master and R1 slave databases differ"
385 echo "Comparing retrieved entries from master and R2 slave..."
386 $CMP $SEARCHFLT $R2LDIFFLT > $CMPOUT
388 if test $? != 0 ; then
389 echo "test failed - master and R2 slave databases differ"
393 echo "Comparing retrieved entries from master and P1 slave..."
394 $CMP $SEARCHFLT $P1LDIFFLT > $CMPOUT
396 if test $? != 0 ; then
397 echo "test failed - master and P1 slave databases differ"
401 echo "Comparing retrieved entries from master and P2 slave..."
402 $CMP $SEARCHFLT $P2LDIFFLT > $CMPOUT
404 if test $? != 0 ; then
405 echo "test failed - master and P2 slave databases differ"
409 echo "Comparing retrieved entries from master and P3 slave..."
410 $CMP $SEARCHFLT $P3LDIFFLT > $CMPOUT
412 if test $? != 0 ; then
413 echo "test failed - master and P3 slave databases differ"
417 echo ">>>>> Test succeeded"