5 if test $# -ge 1 ; then
9 . $SRCDIR/scripts/args.sh $*
11 echo "running defines.sh"
12 . $SRCDIR/scripts/defines.sh
18 # - populate over ldap
19 # - perform some modifies and deleted
20 # - retrieve database over ldap and compare against expected results
23 echo "Cleaning up in $DBDIR..."
25 echo "Resetting $R1REPLDIR..."
28 echo "Resetting $R2REPLDIR..."
31 echo "Resetting $P1REPLDIR..."
34 echo "Resetting $P2REPLDIR..."
37 echo "Resetting $P3REPLDIR..."
42 if test $SYNCREPL = no; then
43 if test $BACKEND = ldbm; then
44 echo "Sync replication requires back-bdb or back-hdb"
50 echo "Starting master slapd on TCP/IP port $PORT..."
51 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $DBCONF
52 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
54 if test $WAIT != 0 ; then
59 echo "Using ldapsearch to check that master slapd PID $PID is running..."
60 for i in 0 1 2 3 4 5; do
61 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
62 'objectclass=*' > /dev/null 2>&1
64 if test $RC = 0 ; then
67 echo "Waiting 5 seconds for slapd to start..."
71 if test $RC != 0 ; then
72 echo "ldapsearch failed ($RC)!"
77 echo "Using ldapadd to create the context prefix entry in the master..."
78 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
79 $LDIFORDEREDCP > /dev/null 2>&1
81 if test $RC != 0 ; then
82 echo "ldapadd failed ($RC)!"
87 echo "Starting R1 slave slapd on TCP/IP port $R1SLAVEPORT..."
88 . $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $R1REPLCONF
89 $SLAPD -f $R1REPLCONF -h $R1SLAVEURI -d $LVL $TIMING > $R1SLAVELOG 2>&1 &
91 if test $WAIT != 0 ; then
92 echo SLAVE R1 PID $R1SLAVEPID
96 echo "Using ldapsearch to check that R1 slave slapd PID $R1SLAVEPID is running..."
97 for i in 0 1 2 3 4 5; do
98 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $R1SLAVEPORT \
99 'objectclass=*' > /dev/null 2>&1
101 if test $RC = 0 ; then
104 echo "Waiting 5 seconds for R1 slapd to start..."
108 if test $RC != 0 ; then
109 echo "ldapsearch failed ($RC)!"
110 kill -HUP $PID $R1SLAVEPID
115 echo "Starting R2 slave slapd on TCP/IP port $R2SLAVEPORT..."
116 . $CONFFILTER $BACKEND $MONITORDB < $R2SRSLAVECONF > $R2REPLCONF
117 $SLAPD -f $R2REPLCONF -h $R2SLAVEURI -d $LVL $TIMING > $R2SLAVELOG 2>&1 &
119 if test $WAIT != 0 ; then
120 echo SLAVE R2 PID $R2SLAVEPID
124 echo "Using ldapsearch to check that the R2 slave slapd PID $R2SLAVEPID is running..."
125 for i in 0 1 2 3 4 5; do
126 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $R2SLAVEPORT \
127 'objectclass=*' > /dev/null 2>&1
129 if test $RC = 0 ; then
132 echo "Waiting 5 seconds for R2 slave slapd to start..."
136 if test $RC != 0 ; then
137 echo "ldapsearch failed ($RC)!"
138 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID
143 echo "Starting P1 slave slapd on TCP/IP port $P1SLAVEPORT..."
144 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $P1REPLCONF
145 $SLAPD -f $P1REPLCONF -h $P1SLAVEURI -d $LVL $TIMING > $P1SLAVELOG 2>&1 &
147 if test $WAIT != 0 ; then
148 echo SLAVE P1 PID $P1SLAVEPID
152 echo "Using ldapsearch to check that the P1 slave slapd PID $P1SLAVEPID is running..."
153 for i in 0 1 2 3 4 5; do
154 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $P1SLAVEPORT \
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 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID
171 echo "Starting P2 slave slapd on TCP/IP port $P2SLAVEPORT..."
172 . $CONFFILTER $BACKEND $MONITORDB < $P2SRSLAVECONF > $P2REPLCONF
173 $SLAPD -f $P2REPLCONF -h $P2SLAVEURI -d $LVL $TIMING > $P2SLAVELOG 2>&1 &
175 if test $WAIT != 0 ; then
176 echo SLAVE P2 PID $P2SLAVEPID
180 echo "Using ldapsearch to check that the P2 slave slapd PID $P2SLAVEPID is running..."
181 for i in 0 1 2 3 4 5; do
182 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $P2SLAVEPORT \
183 'objectclass=*' > /dev/null 2>&1
185 if test $RC = 0 ; then
188 echo "Waiting 5 seconds for P2 slave slapd to start..."
192 if test $RC != 0 ; then
193 echo "ldapsearch failed ($RC)!"
194 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID
198 echo "Starting P3 slave slapd on TCP/IP port $P3SLAVEPORT..."
199 . $CONFFILTER $BACKEND $MONITORDB < $P3SRSLAVECONF > $P3REPLCONF
200 $SLAPD -f $P3REPLCONF -h $P3SLAVEURI -d $LVL $TIMING > $P3SLAVELOG 2>&1 &
202 if test $WAIT != 0 ; then
203 echo SLAVE P3 PID $P3SLAVEPID
207 echo "Using ldapsearch to check that the P3 slave slapd PID $P3SLAVEPID is running..."
208 for i in 0 1 2 3 4 5; do
209 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $P3SLAVEPORT \
210 'objectclass=*' > /dev/null 2>&1
212 if test $RC = 0 ; then
215 echo "Waiting 5 seconds for P3 slave slapd to start..."
219 if test $RC != 0 ; then
220 echo "ldapsearch failed ($RC)!"
221 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
225 echo "Using ldapadd to populate the master directory..."
226 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
227 $LDIFORDEREDNOCP > /dev/null 2>&1
229 if test $RC != 0 ; then
230 echo "ldapadd failed ($RC)!"
231 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
235 echo "Waiting 90 seconds for syncrepl to receive changes..."
238 echo "Using ldapmodify to modify master directory..."
241 # Do some modifications
244 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD > \
245 $TESTOUT 2>&1 << EOMODS
246 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
257 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
263 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
266 member: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
267 member: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
270 member: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
271 member: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
273 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
277 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
279 objectclass: OpenLDAPperson
283 title: Chief Investigator, ITD
284 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
285 seealso: cn=All Staff, ou=Groups, o=University of Michigan, c=US
287 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
288 description: Very odd
289 facsimiletelephonenumber: +1 313 555 7557
290 telephonenumber: +1 313 555 8343
291 mail: gjensen@mailgw.example.com
292 homephone: +1 313 555 8844
294 dn: ou=Retired, ou=People, o=University of Michigan, c=US
296 objectclass: organizationalUnit
299 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
301 objectclass: OpenLDAPperson
302 cn: Rosco P. Coltrane
306 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
308 newrdn: cn=Rosco P. Coltrane
310 newsuperior: ou=Retired, ou=People, o=University of Michigan, c=US
312 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
317 echo "Waiting 90 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 $PORT \
322 'objectclass=*' > $MASTEROUT 2>&1
325 if test $RC != 0 ; then
326 echo "ldapsearch failed at master ($RC)!"
327 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
331 echo "Using ldapsearch to read all the entries from the R1 slave..."
332 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $R1SLAVEPORT \
333 'objectclass=*' > $R1SLAVEOUT 2>&1
336 if test $RC != 0 ; then
337 echo "ldapsearch failed at R1 slave ($RC)!"
338 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
342 echo "Using ldapsearch to read all the entries from the R2 slave..."
343 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $R2SLAVEPORT \
344 'objectclass=*' > $R2SLAVEOUT 2>&1
347 if test $RC != 0 ; then
348 echo "ldapsearch failed at R2 slave ($RC)!"
349 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
353 echo "Using ldapsearch to read all the entries from the P1 slave..."
354 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $P1SLAVEPORT \
355 'objectclass=*' > $P1SLAVEOUT 2>&1
358 if test $RC != 0 ; then
359 echo "ldapsearch failed at R1 slave ($RC)!"
360 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
364 echo "Using ldapsearch to read all the entries from the P2 slave..."
365 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $P2SLAVEPORT \
366 'objectclass=*' > $P2SLAVEOUT 2>&1
369 if test $RC != 0 ; then
370 echo "ldapsearch failed at R2 slave ($RC)!"
371 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
375 echo "Using ldapsearch to read all the entries from the P3 slave..."
376 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $P3SLAVEPORT \
377 'objectclass=*' > $P3SLAVEOUT 2>&1
380 if test $RC != 0 ; then
381 echo "ldapsearch failed at R2 slave ($RC)!"
382 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
386 kill -HUP $PID $R1SLAVEPID $R2SLAVEPID $P1SLAVEPID $P2SLAVEPID $P3SLAVEPID
395 echo "Filtering master ldapsearch results..."
396 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
397 echo "Filtering R1 slave ldapsearch results..."
398 . $LDIFFILTER < $R1LDIF > $R1LDIFFLT
399 echo "Filtering R2 slave ldapsearch results..."
400 . $LDIFFILTER < $R2LDIF > $R2LDIFFLT
401 echo "Filtering P1 slave ldapsearch results..."
402 . $LDIFFILTER < $P1LDIF > $P1LDIFFLT
403 echo "Filtering P2 slave ldapsearch results..."
404 . $LDIFFILTER < $P2LDIF > $P2LDIFFLT
405 echo "Filtering P3 slave ldapsearch results..."
406 . $LDIFFILTER < $P3LDIF > $P3LDIFFLT
408 echo "Comparing retrieved entries from master and R1 slave..."
409 $CMP $SEARCHFLT $R1LDIFFLT > $CMPOUT
411 if test $? != 0 ; then
412 echo "test failed - master and R1 slave databases differ"
416 echo "Comparing retrieved entries from master and R2 slave..."
417 $CMP $SEARCHFLT $R2LDIFFLT > $CMPOUT
419 if test $? != 0 ; then
420 echo "test failed - master and R2 slave databases differ"
424 echo "Comparing retrieved entries from master and P1 slave..."
425 $CMP $SEARCHFLT $P1LDIFFLT > $CMPOUT
427 if test $? != 0 ; then
428 echo "test failed - master and P1 slave databases differ"
432 echo "Comparing retrieved entries from master and P2 slave..."
433 $CMP $SEARCHFLT $P2LDIFFLT > $CMPOUT
435 if test $? != 0 ; then
436 echo "test failed - master and P2 slave databases differ"
440 echo "Comparing retrieved entries from master and P3 slave..."
441 $CMP $SEARCHFLT $P3LDIFFLT > $CMPOUT
443 if test $? != 0 ; then
444 echo "test failed - master and P3 slave databases differ"
448 echo ">>>>> Test succeeded"