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 mkdir -p $TESTDIR $DBDIR1 $DBDIR4
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 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 slave slapd on TCP/IP port $PORT4..."
74 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
75 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
77 if test $WAIT != 0 ; then
78 echo SLAVEPID $SLAVEPID
81 KILLPIDS="$KILLPIDS $SLAVEPID"
83 echo "Using ldapsearch to check that slave slapd is running..."
84 for i in 0 1 2 3 4 5; do
85 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT4 \
86 'objectclass=*' > /dev/null 2>&1
88 if test $RC = 0 ; then
91 echo "Waiting 5 seconds for slapd to start..."
95 if test $RC != 0 ; then
96 echo "ldapsearch failed ($RC)!"
97 test $KILLSERVERS != no && kill -HUP $KILLPIDS
101 echo "Using ldapadd to populate the master directory..."
102 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
103 $LDIFORDEREDNOCP > /dev/null 2>&1
105 if test $RC != 0 ; then
106 echo "ldapadd failed ($RC)!"
107 test $KILLSERVERS != no && kill -HUP $KILLPIDS
111 echo "Waiting 15 seconds for syncrepl to receive changes..."
114 echo "Using ldapmodify to modify master directory..."
117 # Do some modifications
120 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
121 $TESTOUT 2>&1 << EOMODS
122 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
133 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
138 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
141 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
142 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
145 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
146 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
148 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
152 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
154 objectclass: OpenLDAPperson
158 title: Chief Investigator, ITD
159 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
160 seealso: cn=All Staff, ou=Groups, o=University of Michigan, c=US
162 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
163 description: Very odd
164 facsimiletelephonenumber: +1 313 555 7557
165 telephonenumber: +1 313 555 8343
166 mail: gjensen@mailgw.example.com
167 homephone: +1 313 555 8844
169 dn: ou=Retired, ou=People, o=University of Michigan, c=US
171 objectclass: organizationalUnit
174 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
176 objectclass: OpenLDAPperson
177 cn: Rosco P. Coltrane
180 description: Fat tycoon
182 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
184 newrdn: cn=Rosco P. Coltrane
186 newsuperior: ou=Retired, ou=People, o=University of Michigan, c=US
188 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
194 if test $RC != 0 ; then
195 echo "ldapmodify failed ($RC)!"
196 test $KILLSERVERS != no && kill -HUP $KILLPIDS
200 echo "Waiting 15 seconds for syncrepl to receive changes..."
203 echo "Stopping consumer to test recovery..."
207 echo "Modifying more entries on the master..."
208 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
209 $TESTOUT 2>&1 << EOMODS
210 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, o=University of Michigan, c=US
213 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
218 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, o=University of Michigan, c=US
220 objectclass: OpenLDAPperson
223 cn: Rosco P. Coltrane
227 echo "Restarting consumer..."
228 echo "RESTART" >> $LOG4
229 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
231 if test $WAIT != 0 ; then
232 echo SLAVEPID $SLAVEPID
235 KILLPIDS="$PID $SLAVEPID"
237 echo "Waiting 25 seconds for syncrepl to receive changes..."
240 echo "Using ldapsearch to read all the entries from the master..."
241 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
242 'objectclass=*' > $MASTEROUT 2>&1
245 if test $RC != 0 ; then
246 echo "ldapsearch failed at master ($RC)!"
247 test $KILLSERVERS != no && kill -HUP $KILLPIDS
251 echo "Using ldapsearch to read all the entries from the slave..."
252 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
253 'objectclass=*' > $SLAVEOUT 2>&1
256 if test $RC != 0 ; then
257 echo "ldapsearch failed at slave ($RC)!"
258 test $KILLSERVERS != no && kill -HUP $KILLPIDS
262 test $KILLSERVERS != no && kill -HUP $KILLPIDS
264 echo "Filtering master results..."
265 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
266 echo "Filtering slave results..."
267 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
269 echo "Comparing retrieved entries from master and slave..."
270 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
272 if test $? != 0 ; then
273 echo "test failed - master and slave databases differ"
277 echo ">>>>> Test succeeded"