test054-syncreplication-parallel-load revision 1.1.1.7 1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2020 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.
11 ##
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>.
15
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 if test $SYNCPROV = syncprovno; then
20 echo "Syncrepl provider overlay not available, test skipped"
21 exit 0
22 fi
23
24 mkdir -p $TESTDIR $DBDIR1 $DBDIR4
25
26 #
27 # Test replication:
28 # - start provider
29 # - start consumer
30 # - populate over ldap
31 # - perform some modifies and deleted
32 # - attempt to modify the consumer (referral or chain)
33 # - retrieve database over ldap and compare against expected results
34 #
35
36 echo "Starting provider 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
43 fi
44 KILLPIDS="$PID"
45
46 sleep 1
47
48 echo "Using ldapsearch to check that provider 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
55 fi
56 echo "Waiting 5 seconds for slapd to start..."
57 sleep 5
58 done
59
60 if test $RC != 0 ; then
61 echo "ldapsearch failed ($RC)!"
62 test $KILLSERVERS != no && kill -HUP $KILLPIDS
63 exit $RC
64 fi
65
66 echo "Using ldapadd to create the context prefix entry in the provider..."
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
74 fi
75
76 echo "Starting consumer slapd on TCP/IP port $PORT4..."
77 . $CONFFILTER $BACKEND $MONITORDB < $P1SRSLAVECONF > $CONF4
78 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING > $LOG4 2>&1 &
79 SLAVEPID=$!
80 if test $WAIT != 0 ; then
81 echo SLAVEPID $SLAVEPID
82 read foo
83 fi
84 KILLPIDS="$KILLPIDS $SLAVEPID"
85
86 sleep 1
87
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 $PORT4 \
91 'objectclass=*' > /dev/null 2>&1
92 RC=$?
93 if test $RC = 0 ; then
94 break
95 fi
96 echo "Waiting 5 seconds for slapd to start..."
97 sleep 5
98 done
99
100 if test $RC != 0 ; then
101 echo "ldapsearch failed ($RC)!"
102 test $KILLSERVERS != no && kill -HUP $KILLPIDS
103 exit $RC
104 fi
105
106 MORELDIF=$TESTDIR/more.ldif
107 TESTOUT1=$TESTDIR/testout1.out
108 TESTOUT2=$TESTDIR/testout2.out
109 sed -e 's/[Oo][Uu]=/ou=More /g' -e 's/^[Oo][Uu]: /ou: More /' \
110 -e 's/cn=Manager/cn=More Manager/g' \
111 -e 's/^cn: Manager/cn: More Manager/' \
112 $LDIFORDEREDNOCP > $MORELDIF
113
114 echo "Using ldapadd to populate the provider directory..."
115 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
116 $LDIFORDEREDNOCP > $TESTOUT1 2>&1 &
117 C1PID=$!
118 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
119 $MORELDIF > $TESTOUT2 2>&1 &
120 C2PID=$!
121 wait $C1PID $C2PID
122
123 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
124 sleep $SLEEP1
125
126 echo "Stopping the provider, sleeping 10 seconds and restarting it..."
127 kill -HUP "$PID"
128 wait $PID
129 sleep 10
130 echo "RESTART" >> $LOG1
131 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
132 PID=$!
133 if test $WAIT != 0 ; then
134 echo PID $PID
135 read foo
136 fi
137 KILLPIDS="$PID $SLAVEPID"
138
139 sleep 1
140
141 echo "Using ldapsearch to check that provider slapd is running..."
142 for i in 0 1 2 3 4 5; do
143 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
144 'objectclass=*' > /dev/null 2>&1
145 RC=$?
146 if test $RC = 0 ; then
147 break
148 fi
149 echo "Waiting 5 seconds for slapd to start..."
150 sleep 5
151 done
152
153 if test $RC != 0 ; then
154 echo "ldapsearch failed ($RC)!"
155 test $KILLSERVERS != no && kill -HUP $KILLPIDS
156 exit $RC
157 fi
158
159 echo "Waiting 10 seconds to let the system catch up"
160 sleep 10
161
162 echo "Using ldapmodify to modify provider directory..."
163
164 #
165 # Do some modifications
166 #
167
168 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
169 $TESTOUT 2>&1 << EOMODS
170 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
171 changetype: modify
172 add: drink
173 drink: Orange Juice
174 -
175 delete: sn
176 sn: Jones
177 -
178 add: sn
179 sn: Jones
180
181 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
182 changetype: modify
183 replace: drink
184 drink: Iced Tea
185
186 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
187 changetype: modify
188 delete: uniquemember
189 uniquemember: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
190 uniquemember: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
191 -
192 add: uniquemember
193 uniquemember: cn=Dorothy Stevens, ou=Alumni Association, ou=People, dc=example,dc=com
194 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example,dc=com
195
196 dn: cn=All Staff,ou=Groups,dc=example,dc=com
197 changetype: modify
198 delete: description
199
200 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
201 changetype: add
202 objectclass: OpenLDAPperson
203 cn: Gern Jensen
204 sn: Jensen
205 uid: gjensen
206 title: Chief Investigator, ITD
207 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
208 seealso: cn=All Staff, ou=Groups, dc=example,dc=com
209 drink: Coffee
210 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
211 description: Very odd
212 facsimiletelephonenumber: +1 313 555 7557
213 telephonenumber: +1 313 555 8343
214 mail: gjensen@mailgw.example.com
215 homephone: +1 313 555 8844
216
217 dn: ou=Retired, ou=People, dc=example,dc=com
218 changetype: add
219 objectclass: organizationalUnit
220 ou: Retired
221
222 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
223 changetype: add
224 objectclass: OpenLDAPperson
225 cn: Rosco P. Coltrane
226 sn: Coltrane
227 uid: rosco
228 description: Fat tycoon
229
230 dn: cn=Rosco P. Coltrane, ou=Information Technology Division, ou=People, dc=example,dc=com
231 changetype: modrdn
232 newrdn: cn=Rosco P. Coltrane
233 deleteoldrdn: 1
234 newsuperior: ou=Retired, ou=People, dc=example,dc=com
235
236 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example,dc=com
237 changetype: delete
238
239 EOMODS
240
241 RC=$?
242 if test $RC != 0 ; then
243 echo "ldapmodify failed ($RC)!"
244 test $KILLSERVERS != no && kill -HUP $KILLPIDS
245 exit $RC
246 fi
247
248 echo "Using ldappasswd to change some passwords..."
249 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
250 'cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
251 > $TESTOUT 2>&1
252 RC=$?
253 if test $RC != 0 ; then
254 echo "ldapmodify failed ($RC)!"
255 test $KILLSERVERS != no && kill -HUP $KILLPIDS
256 exit $RC
257 fi
258
259 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
260 sleep $SLEEP1
261
262 echo "Stopping consumer to test recovery..."
263 kill -HUP $SLAVEPID
264 wait $SLAVEPID
265
266 echo "Modifying more entries on the provider..."
267 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
268 $TESTOUT 2>&1 << EOMODS
269 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
270 changetype: delete
271
272 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, dc=example,dc=com
273 changetype: modify
274 add: drink
275 drink: Mad Dog 20/20
276
277 dn: cn=Rosco P. Coltrane, ou=Retired, ou=People, dc=example,dc=com
278 changetype: add
279 objectclass: OpenLDAPperson
280 sn: Coltrane
281 uid: rosco
282 cn: Rosco P. Coltrane
283
284 EOMODS
285
286 echo "Restarting consumer..."
287 echo "RESTART" >> $LOG4
288 $SLAPD -f $CONF4 -h $URI4 -d $LVL $TIMING >> $LOG4 2>&1 &
289 SLAVEPID=$!
290 if test $WAIT != 0 ; then
291 echo SLAVEPID $SLAVEPID
292 read foo
293 fi
294 KILLPIDS="$PID $SLAVEPID"
295
296 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
297 sleep $SLEEP1
298
299 if test ! $BACKLDAP = "ldapno" ; then
300 echo "Try updating the consumer slapd..."
301 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD > \
302 $TESTOUT 2>&1 << EOMODS
303 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
304 changetype: modify
305 add: description
306 description: This write must fail because directed to a shadow context,
307 description: unless the chain overlay is configured appropriately ;)
308
309 EOMODS
310
311 RC=$?
312 if test $RC != 0 ; then
313 echo "ldapmodify failed ($RC)!"
314 test $KILLSERVERS != no && kill -HUP $KILLPIDS
315 exit $RC
316 fi
317
318 # ITS#4964
319 echo "Trying to change some passwords on the consumer..."
320 $LDAPPASSWD -D "$MANAGERDN" -h $LOCALHOST -p $PORT4 -w $PASSWD \
321 'cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com' \
322 > $TESTOUT 2>&1
323 RC=$?
324 if test $RC != 0 ; then
325 echo "ldapmodify failed ($RC)!"
326 test $KILLSERVERS != no && kill -HUP $KILLPIDS
327 exit $RC
328 fi
329
330 echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
331 sleep $SLEEP1
332 fi
333
334 OPATTRS="entryUUID creatorsName createTimestamp modifiersName modifyTimestamp"
335
336 echo "Using ldapsearch to read all the entries from the provider..."
337 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
338 '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
339 RC=$?
340
341 if test $RC != 0 ; then
342 echo "ldapsearch failed at provider ($RC)!"
343 test $KILLSERVERS != no && kill -HUP $KILLPIDS
344 exit $RC
345 fi
346
347 echo "Using ldapsearch to read all the entries from the consumer..."
348 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT4 \
349 '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
350 RC=$?
351
352 if test $RC != 0 ; then
353 echo "ldapsearch failed at consumer ($RC)!"
354 test $KILLSERVERS != no && kill -HUP $KILLPIDS
355 exit $RC
356 fi
357
358 test $KILLSERVERS != no && kill -HUP $KILLPIDS
359
360 echo "Filtering provider results..."
361 $LDIFFILTER < $MASTEROUT > $MASTERFLT
362 echo "Filtering consumer results..."
363 $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
364
365 echo "Comparing retrieved entries from provider and consumer..."
366 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
367
368 if test $? != 0 ; then
369 echo "test failed - provider and consumer databases differ"
370 exit 1
371 fi
372
373 echo ">>>>> Test succeeded"
374
375 test $KILLSERVERS != no && wait
376
377 exit 0
378