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 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 # - retrieve database over ldap and compare against expected results
37 echo "Starting master slapd on TCP/IP port $PORT1..."
38 . $CONFFILTER $BACKEND $MONITORDB < $MASTERCONF > $CONF1
39 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
41 if test $WAIT != 0 ; then
47 echo "Starting slave slapd on TCP/IP port $PORT2..."
48 . $CONFFILTER $BACKEND $MONITORDB < $SLAVECONF > $CONF2
49 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
51 if test $WAIT != 0 ; then
52 echo SLAVEPID $SLAVEPID
55 KILLPIDS="$KILLPIDS $SLAVEPID"
57 echo "Using ldapsearch to check that master slapd is running..."
58 for i in 0 1 2 3 4 5; do
59 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
60 'objectclass=*' > /dev/null 2>&1
62 if test $RC = 0 ; then
65 echo "Waiting 5 seconds for slapd to start..."
69 echo "Using ldapsearch to check that slave slapd is running..."
70 for i in 0 1 2 3 4 5; do
71 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
72 'objectclass=*' > /dev/null 2>&1
74 if test $RC = 0 ; then
77 echo "Waiting 5 seconds for slapd to start..."
81 echo "Starting slurpd..."
82 $SLURPD -f $CONF1 -d ${SLURPD_DEBUG-5} -t $DBDIR1B > $SLURPLOG 2>&1 &
84 if test $WAIT != 0 ; then
85 echo SLURPPID $SLURPPID
88 KILLPIDS="$KILLPIDS $SLURPPID"
90 echo "Using ldapadd to populate the master directory..."
91 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
92 $LDIFORDERED > /dev/null 2>&1
94 if test $RC != 0 ; then
95 echo "ldapadd failed ($RC)!"
96 test $KILLSERVERS != no && kill -HUP $KILLPIDS
100 echo "Waiting 15 seconds for slurpd to send changes..."
103 echo "Using ldapmodify to modify master directory..."
106 # Do some modifications
109 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
110 $TESTOUT 2>&1 << EOMODS
111 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
122 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example, dc=com
128 dn: cn=ITD Staff,ou=Groups,dc=example, dc=com
131 uniqueMember: cn=James A Jones 2, ou=Information Technology Division,
132 ou=People, dc=example, dc=com
133 uniqueMember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example, dc=com
136 uniqueMember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example, dc=com
137 uniqueMember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
139 dn: cn=All Staff,ou=Groups,dc=example, dc=com
143 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example, dc=com
145 objectclass: OpenLDAPperson
149 title: Chief Investigator, ITD
150 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
151 seealso: cn=All Staff, ou=Groups, dc=example, dc=com
153 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
154 description: Very odd
155 facsimiletelephonenumber: +1 313 555 7557
156 telephonenumber: +1 313 555 8343
157 mail: gjensen@mailgw.example.com
158 homephone: +1 313 555 8844
160 dn: ou=Retired, ou=People, dc=example, dc=com
162 objectclass: organizationalUnit
165 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example, dc=com
167 objectclass: OpenLDAPperson
168 cn: Rosco P. Coltrane
172 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example, dc=com
174 newrdn: cn=Rosco P. Coltrane
176 newsuperior: ou=Retired, ou=People, dc=example, dc=com
178 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example, dc=com
184 if test $RC != 0 ; then
185 echo "ldapmodify failed ($RC)!"
186 test $KILLSERVERS != no && kill -HUP $KILLPIDS
190 echo "Waiting 15 seconds for slurpd to send changes..."
193 echo "Using ldapsearch to read all the entries from the master..."
194 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
195 'objectclass=*' > $MASTEROUT 2>&1
198 if test $RC != 0 ; then
199 echo "ldapsearch failed ($RC)!"
200 test $KILLSERVERS != no && kill -HUP $KILLPIDS
204 echo "Using ldapsearch to read all the entries from the slave..."
205 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
206 'objectclass=*' > $SLAVEOUT 2>&1
209 if test $RC != 0 ; then
210 echo "ldapsearch failed ($RC)!"
211 test $KILLSERVERS != no && kill -HUP $KILLPIDS
215 test $KILLSERVERS != no && kill -HUP $KILLPIDS
217 echo "Filtering master results..."
218 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
219 echo "Filtering slave results..."
220 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
222 echo "Comparing retrieved entries from master and slave..."
223 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
225 if test $? != 0 ; then
226 echo "test failed - master and slave databases differ"
230 echo ">>>>> Test succeeded"