3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2006 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
48 echo "Using ldapsearch to check that master slapd is running..."
49 for i in 0 1 2 3 4 5; do
50 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
51 'objectclass=*' > /dev/null 2>&1
53 if test $RC = 0 ; then
56 echo "Waiting 5 seconds for slapd to start..."
60 if test $RC != 0 ; then
61 echo "ldapsearch failed ($RC)!"
62 test $KILLSERVERS != no && kill -HUP $KILLPIDS
66 echo "Using ldapadd to create the context prefix entry in the master..."
67 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
68 $LDIFORDEREDCP > /dev/null 2>&1
70 if test $RC != 0 ; then
71 echo "ldapadd failed ($RC)!"
72 test $KILLSERVERS != no && kill -HUP $KILLPIDS
76 echo "Starting slave slapd on TCP/IP port $PORT2..."
77 . $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $CONF2
78 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
80 if test $WAIT != 0 ; then
81 echo SLAVEPID $SLAVEPID
84 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 $PORT2 \
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
144 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
147 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
148 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
151 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
152 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
154 dn: cn=All Staff,ou=Groups,dc=example,dc=com
158 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
160 objectclass: OpenLDAPperson
164 title: Chief Investigator, ITD
165 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
166 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
168 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
169 description: Very odd
170 facsimiletelephonenumber: +1 313 555 7557
171 telephonenumber: +1 313 555 8343
172 mail: gjensen@mailgw.example.com
173 homephone: +1 313 555 8844
175 dn: ou=Retired, ou=People, dc=example,dc=com
177 objectclass: organizationalUnit
180 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
182 objectclass: OpenLDAPperson
183 cn: Rosco P. Coltrane
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 "Try updating the slave slapd..."
209 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
210 $TESTOUT 2>&1 << EOMODS
211 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
214 description: This write must fail because directed to a shadow context,
215 description: unless the chain overlay is configured appropriately ;)
221 # expect 10 (LDAP_REFERRAL)...
222 if test $RC != 10 ; then
223 echo "ldapmodify should have failed ($RC)!"
224 test $KILLSERVERS != no && kill -HUP $KILLPIDS
228 echo "Using ldapsearch to read all the entries from the master..."
229 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
230 'objectclass=*' > $MASTEROUT 2>&1
233 if test $RC != 0 ; then
234 echo "ldapsearch failed at master ($RC)!"
235 test $KILLSERVERS != no && kill -HUP $KILLPIDS
239 echo "Using ldapsearch to read all the entries from the slave..."
240 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
241 'objectclass=*' > $SLAVEOUT 2>&1
244 if test $RC != 0 ; then
245 echo "ldapsearch failed at slave ($RC)!"
246 test $KILLSERVERS != no && kill -HUP $KILLPIDS
250 test $KILLSERVERS != no && kill -HUP $KILLPIDS
252 echo "Filtering master results..."
253 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
254 echo "Filtering slave results..."
255 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
257 echo "Comparing retrieved entries from master and slave..."
258 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
260 if test $? != 0 ; then
261 echo "test failed - master and slave databases differ"
265 echo ">>>>> Test succeeded"
267 test $KILLSERVERS != no && wait