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 if test $SYNCPROV = syncprovno; then
25 echo "Syncrepl provider overlay not available, test skipped"
29 mkdir -p $TESTDIR $DBDIR1 $DBDIR4
35 # - populate over ldap
36 # - perform some modifies and deleted
37 # - retrieve database over ldap and compare against expected results
40 echo "Starting master slapd on TCP/IP port $PORT1..."
41 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
42 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
44 if test $WAIT != 0 ; then
50 echo "Using ldapsearch to check that master slapd is running..."
51 for i in 0 1 2 3 4 5; do
52 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
53 'objectclass=*' > /dev/null 2>&1
55 if test $RC = 0 ; then
58 echo "Waiting 5 seconds for slapd to start..."
62 if test $RC != 0 ; then
63 echo "ldapsearch failed ($RC)!"
64 test $KILLSERVERS != no && kill -HUP $KILLPIDS
68 echo "Using ldapadd to create the context prefix entry in the master..."
69 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
70 $LDIFORDEREDCP > /dev/null 2>&1
72 if test $RC != 0 ; then
73 echo "ldapadd failed ($RC)!"
74 test $KILLSERVERS != no && kill -HUP $KILLPIDS
78 echo "Starting slave slapd on TCP/IP port $PORT4..."
79 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
80 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
82 if test $WAIT != 0 ; then
83 echo SLAVEPID $SLAVEPID
86 KILLPIDS="$KILLPIDS $SLAVEPID"
88 echo "Using ldapsearch to check that slave slapd is running..."
89 for i in 0 1 2 3 4 5; do
90 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT4 \
91 'objectclass=*' > /dev/null 2>&1
93 if test $RC = 0 ; then
96 echo "Waiting 5 seconds for slapd to start..."
100 if test $RC != 0 ; then
101 echo "ldapsearch failed ($RC)!"
102 test $KILLSERVERS != no && kill -HUP $KILLPIDS
106 echo "Using ldapadd to populate the master directory..."
107 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
108 $LDIFORDEREDNOCP > /dev/null 2>&1
110 if test $RC != 0 ; then
111 echo "ldapadd failed ($RC)!"
112 test $KILLSERVERS != no && kill -HUP $KILLPIDS
116 echo "Waiting 15 seconds for syncrepl to receive changes..."
119 echo "Using ldapmodify to modify master directory..."
122 # Do some modifications
125 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
126 $TESTOUT 2>&1 << EOMODS
127 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
138 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
143 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
146 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
147 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
150 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
151 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
153 dn: cn=All Staff,ou=Groups,dc=example,dc=com
157 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
159 objectclass: OpenLDAPperson
163 title: Chief Investigator, ITD
164 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
165 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
167 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
168 description: Very odd
169 facsimiletelephonenumber: +1 313 555 7557
170 telephonenumber: +1 313 555 8343
171 mail: gjensen@mailgw.example.com
172 homephone: +1 313 555 8844
174 dn: ou=Retired, ou=People, dc=example,dc=com
176 objectclass: organizationalUnit
179 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
181 objectclass: OpenLDAPperson
182 cn: Rosco P. Coltrane
185 description: Fat tycoon
187 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
189 newrdn: cn=Rosco P. Coltrane
191 newsuperior: ou=Retired, ou=People, dc=example,dc=com
193 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
199 if test $RC != 0 ; then
200 echo "ldapmodify failed ($RC)!"
201 test $KILLSERVERS != no && kill -HUP $KILLPIDS
205 echo "Waiting 15 seconds for syncrepl to receive changes..."
208 echo "Stopping consumer to test recovery..."
212 echo "Modifying more entries on the master..."
213 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
214 $TESTOUT 2>&1 << EOMODS
215 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
218 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
223 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
225 objectclass: OpenLDAPperson
228 cn: Rosco P. Coltrane
232 echo "Restarting consumer..."
233 echo "RESTART" >> $LOG4
234 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
236 if test $WAIT != 0 ; then
237 echo SLAVEPID $SLAVEPID
240 KILLPIDS="$PID $SLAVEPID"
242 echo "Waiting 25 seconds for syncrepl to receive changes..."
245 echo "Using ldapsearch to read all the entries from the master..."
246 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
247 'objectclass=*' > $MASTEROUT 2>&1
250 if test $RC != 0 ; then
251 echo "ldapsearch failed at master ($RC)!"
252 test $KILLSERVERS != no && kill -HUP $KILLPIDS
256 echo "Using ldapsearch to read all the entries from the slave..."
257 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
258 'objectclass=*' > $SLAVEOUT 2>&1
261 if test $RC != 0 ; then
262 echo "ldapsearch failed at slave ($RC)!"
263 test $KILLSERVERS != no && kill -HUP $KILLPIDS
267 test $KILLSERVERS != no && kill -HUP $KILLPIDS
269 echo "Filtering master results..."
270 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
271 echo "Filtering slave results..."
272 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
274 echo "Comparing retrieved entries from master and slave..."
275 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
277 if test $? != 0 ; then
278 echo "test failed - master and slave databases differ"
282 echo ">>>>> Test succeeded"