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 if test $SYNCPROV = syncprovno; then
25 echo "Syncrepl provider overlay not available, test skipped"
29 mkdir -p $TESTDIR $DBDIR1 $DBDIR4
35 # - populate over ldap
36 # - perform some modifies and deleted
37 # - retrieve database over ldap and compare against expected results
40 echo "Starting master slapd on TCP/IP port $PORT1..."
41 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
42 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
44 if test $WAIT != 0 ; then
50 echo "Using ldapsearch to check that master slapd is running..."
51 for i in 0 1 2 3 4 5; do
52 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
53 'objectclass=*' > /dev/null 2>&1
55 if test $RC = 0 ; then
58 echo "Waiting 5 seconds for slapd to start..."
62 if test $RC != 0 ; then
63 echo "ldapsearch failed ($RC)!"
64 test $KILLSERVERS != no && kill -HUP $KILLPIDS
68 echo "Using ldapadd to create the context prefix entry in the master..."
69 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
70 $LDIFORDEREDCP > /dev/null 2>&1
72 if test $RC != 0 ; then
73 echo "ldapadd failed ($RC)!"
74 test $KILLSERVERS != no && kill -HUP $KILLPIDS
78 echo "Starting slave slapd on TCP/IP port $PORT4..."
79 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
80 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
82 if test $WAIT != 0 ; then
83 echo SLAVEPID $SLAVEPID
86 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 $PORT4 \
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 "Using ldapsearch to read all the entries from the master..."
209 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
210 'objectclass=*' > $MASTEROUT 2>&1
213 if test $RC != 0 ; then
214 echo "ldapsearch failed at master ($RC)!"
215 test $KILLSERVERS != no && kill -HUP $KILLPIDS
219 echo "Using ldapsearch to read all the entries from the slave..."
220 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
221 'objectclass=*' > $SLAVEOUT 2>&1
224 if test $RC != 0 ; then
225 echo "ldapsearch failed at slave ($RC)!"
226 test $KILLSERVERS != no && kill -HUP $KILLPIDS
230 test $KILLSERVERS != no && kill -HUP $KILLPIDS
232 echo "Filtering master results..."
233 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
234 echo "Filtering slave results..."
235 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
237 echo "Comparing retrieved entries from master and slave..."
238 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
240 if test $? != 0 ; then
241 echo "test failed - master and slave databases differ"
245 echo ">>>>> Test succeeded"