Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / openldap / dist / tests / scripts / test017-syncreplication-refresh
blob31045a875c7f82715ffd8626f1704b4a788ff7df
1 #! /bin/sh
2 # $OpenLDAP: pkg/ldap/tests/scripts/test017-syncreplication-refresh,v 1.33.2.3 2008/02/11 23:26:51 kurt Exp $
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2008 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
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"
21 exit 0
22 fi
24 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
27 # Test replication:
28 # - start producer
29 # - start consumer
30 # - populate over ldap
31 # - perform some modifies and deleted
32 # - attempt to modify the consumer (referral)
33 # - retrieve database over ldap and compare against expected results
36 echo "Starting producer slapd on TCP/IP port $PORT1..."
37 . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
38 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
39 PID=$!
40 if test $WAIT != 0 ; then
41 echo PID $PID
42 read foo
44 KILLPIDS="$PID"
46 sleep 1
48 echo "Using ldapsearch to check that producer 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
52 RC=$?
53 if test $RC = 0 ; then
54 break
56 echo "Waiting 5 seconds for slapd to start..."
57 sleep 5
58 done
60 if test $RC != 0 ; then
61 echo "ldapsearch failed ($RC)!"
62 test $KILLSERVERS != no && kill -HUP $KILLPIDS
63 exit $RC
66 echo "Using ldapadd to create the context prefix entry in the producer..."
67 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
68 $LDIFORDEREDCP > /dev/null 2>&1
69 RC=$?
70 if test $RC != 0 ; then
71 echo "ldapadd failed ($RC)!"
72 test $KILLSERVERS != no && kill -HUP $KILLPIDS
73 exit $RC
76 echo "Starting consumer slapd on TCP/IP port $PORT2..."
77 . $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $CONF2
78 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
79 SLAVEPID=$!
80 if test $WAIT != 0 ; then
81 echo SLAVEPID $SLAVEPID
82 read foo
84 KILLPIDS="$KILLPIDS $SLAVEPID"
86 sleep 1
88 echo "Using ldapsearch to check that consumer 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
92 RC=$?
93 if test $RC = 0 ; then
94 break
96 echo "Waiting 5 seconds for slapd to start..."
97 sleep 5
98 done
100 if test $RC != 0 ; then
101 echo "ldapsearch failed ($RC)!"
102 test $KILLSERVERS != no && kill -HUP $KILLPIDS
103 exit $RC
106 echo "Using ldapadd to populate the producer directory..."
107 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
108 $LDIFORDEREDNOCP > /dev/null 2>&1
109 RC=$?
110 if test $RC != 0 ; then
111 echo "ldapadd failed ($RC)!"
112 test $KILLSERVERS != no && kill -HUP $KILLPIDS
113 exit $RC
116 echo "Waiting 15 seconds for syncrepl to receive changes..."
117 sleep 15
119 echo "Using ldapmodify to modify producer 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
128 changetype: modify
129 add: drink
130 drink: Orange Juice
132 delete: sn
133 sn: Jones
135 add: sn
136 sn: Jones
138 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
139 changetype: modify
140 replace: drink
141 drink: Iced Tea
142 drink: Mad Dog 20/20
144 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
145 changetype: modify
146 delete: uniquemember
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
150 add: uniquemember
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
155 changetype: modify
156 delete: description
158 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
159 changetype: add
160 objectclass: OpenLDAPperson
161 cn: Gern Jensen
162 sn: Jensen
163 uid: gjensen
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
167 drink: Coffee
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
176 changetype: add
177 objectclass: organizationalUnit
178 ou: Retired
180 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
181 changetype: add
182 objectclass: OpenLDAPperson
183 cn: Rosco P. Coltrane
184 sn: Coltrane
185 uid: rosco
187 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
188 changetype: modrdn
189 newrdn: cn=Rosco P. Coltrane
190 deleteoldrdn: 1
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
194 changetype: delete
196 EOMODS
198 RC=$?
199 if test $RC != 0 ; then
200 echo "ldapmodify failed ($RC)!"
201 test $KILLSERVERS != no && kill -HUP $KILLPIDS
202 exit $RC
205 echo "Waiting 15 seconds for syncrepl to receive changes..."
206 sleep 15
208 echo "Try updating the consumer 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
212 changetype: modify
213 add: description
214 description: This write must fail because directed to a shadow context,
215 description: unless the chain overlay is configured appropriately ;)
217 EOMODS
219 RC=$?
221 # expect 10 (LDAP_REFERRAL)...
222 if test $RC != 10 ; then
223 echo "ldapmodify should have returned referral ($RC)!"
224 test $KILLSERVERS != no && kill -HUP $KILLPIDS
225 exit $RC
228 OPATTRS="entryUUID creatorsName createTimestamp modifiersName modifyTimestamp"
230 echo "Using ldapsearch to read all the entries from the producer..."
231 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
232 '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
233 RC=$?
235 if test $RC != 0 ; then
236 echo "ldapsearch failed at producer ($RC)!"
237 test $KILLSERVERS != no && kill -HUP $KILLPIDS
238 exit $RC
241 echo "Using ldapsearch to read all the entries from the consumer..."
242 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
243 '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
244 RC=$?
246 if test $RC != 0 ; then
247 echo "ldapsearch failed at consumer ($RC)!"
248 test $KILLSERVERS != no && kill -HUP $KILLPIDS
249 exit $RC
252 test $KILLSERVERS != no && kill -HUP $KILLPIDS
254 echo "Filtering producer results..."
255 . $LDIFFILTER < $MASTEROUT > $MASTERFLT
256 echo "Filtering consumer results..."
257 . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
259 echo "Comparing retrieved entries from producer and consumer..."
260 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
262 if test $? != 0 ; then
263 echo "test failed - producer and consumer databases differ"
264 exit 1
267 echo ">>>>> Test succeeded"
269 test $KILLSERVERS != no && wait
271 exit 0