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 mkdir -p $TESTDIR $DBDIR1 $DBDIR4
30 # - populate over ldap
31 # - perform some modifies and deleted
32 # - retrieve database over ldap and compare against expected results
35 echo "Starting master slapd on TCP/IP port $PORT1..."
36 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
37 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
39 if test $WAIT != 0 ; then
45 echo "Using ldapsearch to check that master slapd is running..."
46 for i in 0 1 2 3 4 5; do
47 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
48 'objectclass=*' > /dev/null 2>&1
50 if test $RC = 0 ; then
53 echo "Waiting 5 seconds for slapd to start..."
57 if test $RC != 0 ; then
58 echo "ldapsearch failed ($RC)!"
59 test $KILLSERVERS != no && kill -HUP $KILLPIDS
63 echo "Using ldapadd to create the context prefix entry in the master..."
64 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
65 $LDIFORDEREDCP > /dev/null 2>&1
67 if test $RC != 0 ; then
68 echo "ldapadd failed ($RC)!"
69 test $KILLSERVERS != no && kill -HUP $KILLPIDS
73 echo "Starting slave slapd on TCP/IP port $PORT4..."
74 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
75 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
77 if test $WAIT != 0 ; then
78 echo SLAVEPID $SLAVEPID
81 KILLPIDS="$KILLPIDS $SLAVEPID"
83 echo "Using ldapsearch to check that slave slapd is running..."
84 for i in 0 1 2 3 4 5; do
85 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT4 \
86 'objectclass=*' > /dev/null 2>&1
88 if test $RC = 0 ; then
91 echo "Waiting 5 seconds for slapd to start..."
95 if test $RC != 0 ; then
96 echo "ldapsearch failed ($RC)!"
97 test $KILLSERVERS != no && kill -HUP $KILLPIDS
101 echo "Using ldapadd to populate the master directory..."
102 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
103 $LDIFORDEREDNOCP > /dev/null 2>&1
105 if test $RC != 0 ; then
106 echo "ldapadd failed ($RC)!"
107 test $KILLSERVERS != no && kill -HUP $KILLPIDS
111 echo "Waiting 15 seconds for syncrepl to receive changes..."
114 echo "Using ldapmodify to modify master directory..."
117 # Do some modifications
120 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
121 $TESTOUT 2>&1 << EOMODS
122 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
133 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
139 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
142 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
143 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
146 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
147 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
149 dn: cn=All Staff,ou=Groups,dc=example,dc=com
153 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
155 objectclass: OpenLDAPperson
159 title: Chief Investigator, ITD
160 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
161 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
163 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
164 description: Very odd
165 facsimiletelephonenumber: +1 313 555 7557
166 telephonenumber: +1 313 555 8343
167 mail: gjensen@mailgw.example.com
168 homephone: +1 313 555 8844
170 dn: ou=Retired, ou=People, dc=example,dc=com
172 objectclass: organizationalUnit
175 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
177 objectclass: OpenLDAPperson
178 cn: Rosco P. Coltrane
182 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
184 newrdn: cn=Rosco P. Coltrane
186 newsuperior: ou=Retired, ou=People, dc=example,dc=com
188 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
194 if test $RC != 0 ; then
195 echo "ldapmodify failed ($RC)!"
196 test $KILLSERVERS != no && kill -HUP $KILLPIDS
200 echo "Waiting 15 seconds for syncrepl to receive changes..."
203 echo "Using ldapsearch to read all the entries from the master..."
204 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
205 'objectclass=*' > $MASTEROUT 2>&1
208 if test $RC != 0 ; then
209 echo "ldapsearch failed at master ($RC)!"
210 test $KILLSERVERS != no && kill -HUP $KILLPIDS
214 echo "Using ldapsearch to read all the entries from the slave..."
215 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
216 'objectclass=*' > $SLAVEOUT 2>&1
219 if test $RC != 0 ; then
220 echo "ldapsearch failed at slave ($RC)!"
221 test $KILLSERVERS != no && kill -HUP $KILLPIDS
225 test $KILLSERVERS != no && kill -HUP $KILLPIDS
227 echo "Filtering master results..."
228 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
229 echo "Filtering slave results..."
230 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
232 echo "Comparing retrieved entries from master and slave..."
233 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
235 if test $? != 0 ; then
236 echo "test failed - master and slave databases differ"
240 echo ">>>>> Test succeeded"