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 $SYNCPROV = syncprovno; then
20 echo "Syncrepl provider overlay not available, test skipped"
24 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
30 # - populate over ldap
31 # - perform some modifies and deleted
32 # - attempt to modify the slave (referral)
33 # - retrieve database over ldap and compare against expected results
36 echo "Starting master slapd on TCP/IP port $PORT1..."
37 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
38 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
40 if test $WAIT != 0 ; then
46 echo "Using ldapsearch to check that master slapd is running..."
47 for i in 0 1 2 3 4 5; do
48 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
49 'objectclass=*' > /dev/null 2>&1
51 if test $RC = 0 ; then
54 echo "Waiting 5 seconds for slapd to start..."
58 if test $RC != 0 ; then
59 echo "ldapsearch failed ($RC)!"
60 test $KILLSERVERS != no && kill -HUP $KILLPIDS
64 echo "Using ldapadd to create the context prefix entry in the master..."
65 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
66 $LDIFORDEREDCP > /dev/null 2>&1
68 if test $RC != 0 ; then
69 echo "ldapadd failed ($RC)!"
70 test $KILLSERVERS != no && kill -HUP $KILLPIDS
74 echo "Starting slave slapd on TCP/IP port $PORT2..."
75 . $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $CONF2
76 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
78 if test $WAIT != 0 ; then
79 echo SLAVEPID $SLAVEPID
82 KILLPIDS="$KILLPIDS $SLAVEPID"
84 echo "Using ldapsearch to check that slave slapd is running..."
85 for i in 0 1 2 3 4 5; do
86 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
87 'objectclass=*' > /dev/null 2>&1
89 if test $RC = 0 ; then
92 echo "Waiting 5 seconds for slapd to start..."
96 if test $RC != 0 ; then
97 echo "ldapsearch failed ($RC)!"
98 test $KILLSERVERS != no && kill -HUP $KILLPIDS
102 echo "Using ldapadd to populate the master directory..."
103 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
104 $LDIFORDEREDNOCP > /dev/null 2>&1
106 if test $RC != 0 ; then
107 echo "ldapadd failed ($RC)!"
108 test $KILLSERVERS != no && kill -HUP $KILLPIDS
112 echo "Waiting 15 seconds for syncrepl to receive changes..."
115 echo "Using ldapmodify to modify master directory..."
118 # Do some modifications
121 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
122 $TESTOUT 2>&1 << EOMODS
123 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
134 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
140 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
143 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
144 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
147 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
148 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
150 dn: cn=All Staff,ou=Groups,dc=example,dc=com
154 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
156 objectclass: OpenLDAPperson
160 title: Chief Investigator, ITD
161 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
162 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
164 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
165 description: Very odd
166 facsimiletelephonenumber: +1 313 555 7557
167 telephonenumber: +1 313 555 8343
168 mail: gjensen@mailgw.example.com
169 homephone: +1 313 555 8844
171 dn: ou=Retired, ou=People, dc=example,dc=com
173 objectclass: organizationalUnit
176 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
178 objectclass: OpenLDAPperson
179 cn: Rosco P. Coltrane
183 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
185 newrdn: cn=Rosco P. Coltrane
187 newsuperior: ou=Retired, ou=People, dc=example,dc=com
189 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
195 if test $RC != 0 ; then
196 echo "ldapmodify failed ($RC)!"
197 test $KILLSERVERS != no && kill -HUP $KILLPIDS
201 echo "Waiting 15 seconds for syncrepl to receive changes..."
204 echo "Try updating the slave slapd..."
205 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
206 $TESTOUT 2>&1 << EOMODS
207 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
210 description: This write must fail because directed to a shadow context,
211 description: unless the chain overlay is configured appropriately ;)
217 # expect 10 (LDAP_REFERRAL)...
218 if test $RC != 10 ; then
219 echo "ldapmodify should have failed ($RC)!"
220 test $KILLSERVERS != no && kill -HUP $KILLPIDS
224 echo "Using ldapsearch to read all the entries from the master..."
225 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
226 'objectclass=*' > $MASTEROUT 2>&1
229 if test $RC != 0 ; then
230 echo "ldapsearch failed at master ($RC)!"
231 test $KILLSERVERS != no && kill -HUP $KILLPIDS
235 echo "Using ldapsearch to read all the entries from the slave..."
236 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
237 'objectclass=*' > $SLAVEOUT 2>&1
240 if test $RC != 0 ; then
241 echo "ldapsearch failed at slave ($RC)!"
242 test $KILLSERVERS != no && kill -HUP $KILLPIDS
246 test $KILLSERVERS != no && kill -HUP $KILLPIDS
248 echo "Filtering master results..."
249 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
250 echo "Filtering slave results..."
251 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
253 echo "Comparing retrieved entries from master and slave..."
254 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
256 if test $? != 0 ; then
257 echo "test failed - master and slave databases differ"
261 echo ">>>>> Test succeeded"