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 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test ! -x $SLURPD ; then
20 echo ">>>>> $SLURPD is not executable or do not exist."
21 echo ">>>>> Test skipped."
25 mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR2
29 # - start master (slapd1)
30 # - start slave (slapd2)
32 # - populate over ldap
33 # - perform some modifies and deleted
34 # - attempt to modify the slave (referral or chain)
35 # - retrieve database over ldap and compare against expected results
38 echo "Starting master slapd on TCP/IP port $PORT1..."
39 . $CONFFILTER $BACKEND $MONITORDB < $MASTERCONF > $CONF1
40 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
42 if test $WAIT != 0 ; then
48 echo "Starting slave slapd on TCP/IP port $PORT2..."
49 . $CONFFILTER $BACKEND $MONITORDB < $SLAVECONF > $CONF2
50 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
52 if test $WAIT != 0 ; then
53 echo SLAVEPID $SLAVEPID
56 KILLPIDS="$KILLPIDS $SLAVEPID"
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 $PORT1 \
61 'objectclass=*' > /dev/null 2>&1
63 if test $RC = 0 ; then
66 echo "Waiting 5 seconds for slapd to start..."
70 echo "Using ldapsearch to check that slave slapd is running..."
71 for i in 0 1 2 3 4 5; do
72 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
73 'objectclass=*' > /dev/null 2>&1
75 if test $RC = 0 ; then
78 echo "Waiting 5 seconds for slapd to start..."
82 echo "Starting slurpd..."
83 $SLURPD -f $CONF1 -d ${SLURPD_DEBUG-5} -t $DBDIR1B > $SLURPLOG 2>&1 &
85 if test $WAIT != 0 ; then
86 echo SLURPPID $SLURPPID
89 KILLPIDS="$KILLPIDS $SLURPPID"
91 echo "Using ldapadd to populate the master directory..."
92 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
93 $LDIFORDERED > /dev/null 2>&1
95 if test $RC != 0 ; then
96 echo "ldapadd failed ($RC)!"
97 test $KILLSERVERS != no && kill -HUP $KILLPIDS
101 echo "Waiting 15 seconds for slurpd to send changes..."
104 echo "Using ldapmodify to modify master directory..."
107 # Do some modifications
110 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
111 $TESTOUT 2>&1 << EOMODS
112 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
123 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example, dc=com
129 dn: cn=ITD Staff,ou=Groups,dc=example, dc=com
132 uniqueMember: cn=James A Jones 2, ou=Information Technology Division,
133 ou=People, dc=example, dc=com
134 uniqueMember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example, dc=com
137 uniqueMember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example, dc=com
138 uniqueMember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
140 dn: cn=All Staff,ou=Groups,dc=example, dc=com
144 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example, dc=com
146 objectclass: OpenLDAPperson
150 title: Chief Investigator, ITD
151 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
152 seealso: cn=All Staff, ou=Groups, dc=example, dc=com
154 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
155 description: Very odd
156 facsimiletelephonenumber: +1 313 555 7557
157 telephonenumber: +1 313 555 8343
158 mail: gjensen@mailgw.example.com
159 homephone: +1 313 555 8844
161 dn: ou=Retired, ou=People, dc=example, dc=com
163 objectclass: organizationalUnit
166 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example, dc=com
168 objectclass: OpenLDAPperson
169 cn: Rosco P. Coltrane
173 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example, dc=com
175 newrdn: cn=Rosco P. Coltrane
177 newsuperior: ou=Retired, ou=People, dc=example, dc=com
179 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example, dc=com
185 if test $RC != 0 ; then
186 echo "ldapmodify failed ($RC)!"
187 test $KILLSERVERS != no && kill -HUP $KILLPIDS
191 echo "Waiting 15 seconds for slurpd to send changes..."
194 echo "Try updating the slave slapd..."
195 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
196 $TESTOUT 2>&1 << EOMODS
197 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
200 description: This write must fail because directed to a shadow context,
201 description: unless the chain overlay is configured appropriately ;)
207 if test $BACKLDAP = "ldapno" ; then
208 # expect 10 (LDAP_REFERRAL)...
209 if test $RC != 10 ; then
210 echo "ldapmodify should have failed ($RC)!"
211 test $KILLSERVERS != no && kill -HUP $KILLPIDS
216 # expect 0 (LDAP_SUCCESS)...
217 if test $RC != 0 ; then
218 echo "ldapmodify failed ($RC)!"
219 test $KILLSERVERS != no && kill -HUP $KILLPIDS
223 echo "Waiting 5 seconds for slurpd to send changes..."
227 echo "Using ldapsearch to read all the entries from the master..."
228 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
229 'objectclass=*' > $MASTEROUT 2>&1
232 if test $RC != 0 ; then
233 echo "ldapsearch failed ($RC)!"
234 test $KILLSERVERS != no && kill -HUP $KILLPIDS
238 echo "Using ldapsearch to read all the entries from the slave..."
239 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
240 'objectclass=*' > $SLAVEOUT 2>&1
243 if test $RC != 0 ; then
244 echo "ldapsearch failed ($RC)!"
245 test $KILLSERVERS != no && kill -HUP $KILLPIDS
249 test $KILLSERVERS != no && kill -HUP $KILLPIDS
251 echo "Filtering master results..."
252 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
253 echo "Filtering slave results..."
254 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
256 echo "Comparing retrieved entries from master and slave..."
257 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
259 if test $? != 0 ; then
260 echo "test failed - master and slave databases differ"
264 echo ">>>>> Test succeeded"