test017-syncreplication-refresh revision 1.1.1.2 1 1.1 lukem #! /bin/sh
2 1.1.1.2 lukem # OpenLDAP: pkg/ldap/tests/scripts/test017-syncreplication-refresh,v 1.33.2.9 2009/11/18 01:29:50 quanah Exp
3 1.1 lukem ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 1.1 lukem ##
5 1.1.1.2 lukem ## Copyright 1998-2009 The OpenLDAP Foundation.
6 1.1 lukem ## All rights reserved.
7 1.1 lukem ##
8 1.1 lukem ## Redistribution and use in source and binary forms, with or without
9 1.1 lukem ## modification, are permitted only as authorized by the OpenLDAP
10 1.1 lukem ## Public License.
11 1.1 lukem ##
12 1.1 lukem ## A copy of this license is available in the file LICENSE in the
13 1.1 lukem ## top-level directory of the distribution or, alternatively, at
14 1.1 lukem ## <http://www.OpenLDAP.org/license.html>.
15 1.1 lukem
16 1.1 lukem echo "running defines.sh"
17 1.1 lukem . $SRCDIR/scripts/defines.sh
18 1.1 lukem
19 1.1 lukem if test $SYNCPROV = syncprovno; then
20 1.1 lukem echo "Syncrepl provider overlay not available, test skipped"
21 1.1 lukem exit 0
22 1.1 lukem fi
23 1.1 lukem
24 1.1 lukem mkdir -p $TESTDIR $DBDIR1 $DBDIR2
25 1.1 lukem
26 1.1 lukem #
27 1.1 lukem # Test replication:
28 1.1 lukem # - start producer
29 1.1 lukem # - start consumer
30 1.1 lukem # - populate over ldap
31 1.1 lukem # - perform some modifies and deleted
32 1.1 lukem # - attempt to modify the consumer (referral)
33 1.1 lukem # - retrieve database over ldap and compare against expected results
34 1.1 lukem #
35 1.1 lukem
36 1.1 lukem echo "Starting producer slapd on TCP/IP port $PORT1..."
37 1.1 lukem . $CONFFILTER $BACKEND $MONITORDB < $SRMASTERCONF > $CONF1
38 1.1 lukem $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
39 1.1 lukem PID=$!
40 1.1 lukem if test $WAIT != 0 ; then
41 1.1 lukem echo PID $PID
42 1.1 lukem read foo
43 1.1 lukem fi
44 1.1 lukem KILLPIDS="$PID"
45 1.1 lukem
46 1.1 lukem sleep 1
47 1.1 lukem
48 1.1 lukem echo "Using ldapsearch to check that producer slapd is running..."
49 1.1 lukem for i in 0 1 2 3 4 5; do
50 1.1 lukem $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
51 1.1 lukem 'objectclass=*' > /dev/null 2>&1
52 1.1 lukem RC=$?
53 1.1 lukem if test $RC = 0 ; then
54 1.1 lukem break
55 1.1 lukem fi
56 1.1 lukem echo "Waiting 5 seconds for slapd to start..."
57 1.1 lukem sleep 5
58 1.1 lukem done
59 1.1 lukem
60 1.1 lukem if test $RC != 0 ; then
61 1.1 lukem echo "ldapsearch failed ($RC)!"
62 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
63 1.1 lukem exit $RC
64 1.1 lukem fi
65 1.1 lukem
66 1.1 lukem echo "Using ldapadd to create the context prefix entry in the producer..."
67 1.1 lukem $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
68 1.1 lukem $LDIFORDEREDCP > /dev/null 2>&1
69 1.1 lukem RC=$?
70 1.1 lukem if test $RC != 0 ; then
71 1.1 lukem echo "ldapadd failed ($RC)!"
72 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
73 1.1 lukem exit $RC
74 1.1 lukem fi
75 1.1 lukem
76 1.1 lukem echo "Starting consumer slapd on TCP/IP port $PORT2..."
77 1.1 lukem . $CONFFILTER $BACKEND $MONITORDB < $R1SRSLAVECONF > $CONF2
78 1.1 lukem $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
79 1.1 lukem SLAVEPID=$!
80 1.1 lukem if test $WAIT != 0 ; then
81 1.1 lukem echo SLAVEPID $SLAVEPID
82 1.1 lukem read foo
83 1.1 lukem fi
84 1.1 lukem KILLPIDS="$KILLPIDS $SLAVEPID"
85 1.1 lukem
86 1.1 lukem sleep 1
87 1.1 lukem
88 1.1 lukem echo "Using ldapsearch to check that consumer slapd is running..."
89 1.1 lukem for i in 0 1 2 3 4 5; do
90 1.1 lukem $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
91 1.1 lukem 'objectclass=*' > /dev/null 2>&1
92 1.1 lukem RC=$?
93 1.1 lukem if test $RC = 0 ; then
94 1.1 lukem break
95 1.1 lukem fi
96 1.1 lukem echo "Waiting 5 seconds for slapd to start..."
97 1.1 lukem sleep 5
98 1.1 lukem done
99 1.1 lukem
100 1.1 lukem if test $RC != 0 ; then
101 1.1 lukem echo "ldapsearch failed ($RC)!"
102 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
103 1.1 lukem exit $RC
104 1.1 lukem fi
105 1.1 lukem
106 1.1 lukem echo "Using ldapadd to populate the producer directory..."
107 1.1 lukem $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
108 1.1 lukem $LDIFORDEREDNOCP > /dev/null 2>&1
109 1.1 lukem RC=$?
110 1.1 lukem if test $RC != 0 ; then
111 1.1 lukem echo "ldapadd failed ($RC)!"
112 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
113 1.1 lukem exit $RC
114 1.1 lukem fi
115 1.1 lukem
116 1.1.1.2 lukem echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
117 1.1.1.2 lukem sleep $SLEEP1
118 1.1 lukem
119 1.1 lukem echo "Using ldapmodify to modify producer directory..."
120 1.1 lukem
121 1.1 lukem #
122 1.1 lukem # Do some modifications
123 1.1 lukem #
124 1.1 lukem
125 1.1 lukem $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
126 1.1 lukem $TESTOUT 2>&1 << EOMODS
127 1.1 lukem dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
128 1.1 lukem changetype: modify
129 1.1 lukem add: drink
130 1.1 lukem drink: Orange Juice
131 1.1 lukem -
132 1.1 lukem delete: sn
133 1.1 lukem sn: Jones
134 1.1 lukem -
135 1.1 lukem add: sn
136 1.1 lukem sn: Jones
137 1.1 lukem
138 1.1 lukem dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
139 1.1 lukem changetype: modify
140 1.1 lukem replace: drink
141 1.1 lukem drink: Iced Tea
142 1.1 lukem drink: Mad Dog 20/20
143 1.1 lukem
144 1.1 lukem dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
145 1.1 lukem changetype: modify
146 1.1 lukem delete: uniquemember
147 1.1 lukem uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
148 1.1 lukem uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
149 1.1 lukem -
150 1.1 lukem add: uniquemember
151 1.1 lukem uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
152 1.1 lukem uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
153 1.1 lukem
154 1.1 lukem dn: cn=All Staff,ou=Groups,dc=example,dc=com
155 1.1 lukem changetype: modify
156 1.1 lukem delete: description
157 1.1 lukem
158 1.1 lukem dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
159 1.1 lukem changetype: add
160 1.1 lukem objectclass: OpenLDAPperson
161 1.1 lukem cn: Gern Jensen
162 1.1 lukem sn: Jensen
163 1.1 lukem uid: gjensen
164 1.1 lukem title: Chief Investigator, ITD
165 1.1 lukem postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
166 1.1 lukem seealso: cn=All Staff, ou=Groups, dc=example,dc=com
167 1.1 lukem drink: Coffee
168 1.1 lukem homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
169 1.1 lukem description: Very odd
170 1.1 lukem facsimiletelephonenumber: +1 313 555 7557
171 1.1 lukem telephonenumber: +1 313 555 8343
172 1.1 lukem mail: gjensen@mailgw.example.com
173 1.1 lukem homephone: +1 313 555 8844
174 1.1 lukem
175 1.1 lukem dn: ou=Retired, ou=People, dc=example,dc=com
176 1.1 lukem changetype: add
177 1.1 lukem objectclass: organizationalUnit
178 1.1 lukem ou: Retired
179 1.1 lukem
180 1.1 lukem dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
181 1.1 lukem changetype: add
182 1.1 lukem objectclass: OpenLDAPperson
183 1.1 lukem cn: Rosco P. Coltrane
184 1.1 lukem sn: Coltrane
185 1.1 lukem uid: rosco
186 1.1 lukem
187 1.1 lukem dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
188 1.1 lukem changetype: modrdn
189 1.1 lukem newrdn: cn=Rosco P. Coltrane
190 1.1 lukem deleteoldrdn: 1
191 1.1 lukem newsuperior: ou=Retired, ou=People, dc=example,dc=com
192 1.1 lukem
193 1.1 lukem dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
194 1.1 lukem changetype: delete
195 1.1 lukem
196 1.1.1.2 lukem dn: dc=testdomain1,dc=example,dc=com
197 1.1.1.2 lukem changetype: modrdn
198 1.1.1.2 lukem newrdn: dc=itsdomain1
199 1.1.1.2 lukem deleteoldrdn: 1
200 1.1.1.2 lukem
201 1.1.1.2 lukem dn: dc=itsdomain1,dc=example,dc=com
202 1.1.1.2 lukem changetype: modify
203 1.1.1.2 lukem replace: description
204 1.1.1.2 lukem description: Example, Inc. ITS test domain
205 1.1.1.2 lukem
206 1.1.1.2 lukem EOMODS
207 1.1.1.2 lukem
208 1.1.1.2 lukem RC=$?
209 1.1.1.2 lukem if test $RC != 0 ; then
210 1.1.1.2 lukem echo "ldapmodify failed ($RC)!"
211 1.1.1.2 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
212 1.1.1.2 lukem exit $RC
213 1.1.1.2 lukem fi
214 1.1.1.2 lukem
215 1.1.1.2 lukem echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
216 1.1.1.2 lukem sleep $SLEEP1
217 1.1.1.2 lukem
218 1.1.1.2 lukem echo "Performing modrdn alone on the producer..."
219 1.1.1.2 lukem $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
220 1.1.1.2 lukem $TESTOUT 2>&1 << EOMODS
221 1.1.1.2 lukem dn: dc=testdomain2,dc=example,dc=com
222 1.1.1.2 lukem changetype: modrdn
223 1.1.1.2 lukem newrdn: dc=itsdomain2
224 1.1.1.2 lukem deleteoldrdn: 1
225 1.1.1.2 lukem
226 1.1.1.2 lukem EOMODS
227 1.1.1.2 lukem
228 1.1.1.2 lukem RC=$?
229 1.1.1.2 lukem if test $RC != 0 ; then
230 1.1.1.2 lukem echo "ldapmodify failed ($RC)!"
231 1.1.1.2 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
232 1.1.1.2 lukem exit $RC
233 1.1.1.2 lukem fi
234 1.1.1.2 lukem
235 1.1.1.2 lukem echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
236 1.1.1.2 lukem sleep $SLEEP1
237 1.1.1.2 lukem
238 1.1.1.2 lukem echo "Performing modify alone on the producer..."
239 1.1.1.2 lukem $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
240 1.1.1.2 lukem $TESTOUT 2>&1 << EOMODS
241 1.1.1.2 lukem dn: dc=itsdomain2,dc=example,dc=com
242 1.1.1.2 lukem changetype: modify
243 1.1.1.2 lukem replace: description
244 1.1.1.2 lukem description: Example, Inc. itsdomain2 test domain
245 1.1.1.2 lukem
246 1.1.1.2 lukem EOMODS
247 1.1.1.2 lukem
248 1.1.1.2 lukem RC=$?
249 1.1.1.2 lukem if test $RC != 0 ; then
250 1.1.1.2 lukem echo "ldapmodify failed ($RC)!"
251 1.1.1.2 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
252 1.1.1.2 lukem exit $RC
253 1.1.1.2 lukem fi
254 1.1.1.2 lukem
255 1.1.1.2 lukem echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
256 1.1.1.2 lukem sleep $SLEEP1
257 1.1.1.2 lukem
258 1.1.1.2 lukem echo "Performing larger modify on the producer..."
259 1.1.1.2 lukem $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
260 1.1.1.2 lukem $TESTOUT 2>&1 << EOMODS
261 1.1.1.2 lukem dn: cn=Alumni Assoc Staff,ou=Groups,dc=example,dc=com
262 1.1.1.2 lukem changetype: modify
263 1.1.1.2 lukem replace: objectClass
264 1.1.1.2 lukem objectClass: groupOfNames
265 1.1.1.2 lukem -
266 1.1.1.2 lukem replace: cn
267 1.1.1.2 lukem cn: Alumni Assoc Staff
268 1.1.1.2 lukem -
269 1.1.1.2 lukem replace: description
270 1.1.1.2 lukem description: blablabla
271 1.1.1.2 lukem -
272 1.1.1.2 lukem replace: member
273 1.1.1.2 lukem member: cn=Manager,dc=example,dc=com
274 1.1.1.2 lukem member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
275 1.1.1.2 lukem member: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
276 1.1.1.2 lukem member: cn=Jane Doe,ou=Alumni Association,ou=People,dc=example,dc=com
277 1.1.1.2 lukem member: cn=Jennifer Smith,ou=Alumni Association,ou=People,dc=example,dc=com
278 1.1.1.2 lukem member: cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com
279 1.1.1.2 lukem member: cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com
280 1.1.1.2 lukem
281 1.1 lukem EOMODS
282 1.1 lukem
283 1.1 lukem RC=$?
284 1.1 lukem if test $RC != 0 ; then
285 1.1 lukem echo "ldapmodify failed ($RC)!"
286 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
287 1.1 lukem exit $RC
288 1.1 lukem fi
289 1.1 lukem
290 1.1.1.2 lukem echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
291 1.1.1.2 lukem sleep $SLEEP1
292 1.1 lukem
293 1.1 lukem echo "Try updating the consumer slapd..."
294 1.1 lukem $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
295 1.1 lukem $TESTOUT 2>&1 << EOMODS
296 1.1 lukem dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
297 1.1 lukem changetype: modify
298 1.1 lukem add: description
299 1.1 lukem description: This write must fail because directed to a shadow context,
300 1.1 lukem description: unless the chain overlay is configured appropriately ;)
301 1.1 lukem
302 1.1 lukem EOMODS
303 1.1 lukem
304 1.1 lukem RC=$?
305 1.1 lukem
306 1.1 lukem # expect 10 (LDAP_REFERRAL)...
307 1.1 lukem if test $RC != 10 ; then
308 1.1 lukem echo "ldapmodify should have returned referral ($RC)!"
309 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
310 1.1 lukem exit $RC
311 1.1 lukem fi
312 1.1 lukem
313 1.1 lukem OPATTRS="entryUUID creatorsName createTimestamp modifiersName modifyTimestamp"
314 1.1 lukem
315 1.1 lukem echo "Using ldapsearch to read all the entries from the producer..."
316 1.1 lukem $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
317 1.1 lukem '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
318 1.1 lukem RC=$?
319 1.1 lukem
320 1.1 lukem if test $RC != 0 ; then
321 1.1 lukem echo "ldapsearch failed at producer ($RC)!"
322 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
323 1.1 lukem exit $RC
324 1.1 lukem fi
325 1.1 lukem
326 1.1 lukem echo "Using ldapsearch to read all the entries from the consumer..."
327 1.1 lukem $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
328 1.1 lukem '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
329 1.1 lukem RC=$?
330 1.1 lukem
331 1.1 lukem if test $RC != 0 ; then
332 1.1 lukem echo "ldapsearch failed at consumer ($RC)!"
333 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
334 1.1 lukem exit $RC
335 1.1 lukem fi
336 1.1 lukem
337 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
338 1.1 lukem
339 1.1 lukem echo "Filtering producer results..."
340 1.1 lukem . $LDIFFILTER < $MASTEROUT > $MASTERFLT
341 1.1 lukem echo "Filtering consumer results..."
342 1.1 lukem . $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
343 1.1 lukem
344 1.1 lukem echo "Comparing retrieved entries from producer and consumer..."
345 1.1 lukem $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
346 1.1 lukem
347 1.1 lukem if test $? != 0 ; then
348 1.1 lukem echo "test failed - producer and consumer databases differ"
349 1.1 lukem exit 1
350 1.1 lukem fi
351 1.1 lukem
352 1.1 lukem echo ">>>>> Test succeeded"
353 1.1 lukem
354 1.1 lukem test $KILLSERVERS != no && wait
355 1.1 lukem
356 1.1 lukem exit 0
357