test086-delta-consumer-config revision 1.1.1.1 1 1.1 christos #! /bin/sh
2 1.1 christos # $OpenLDAP$
3 1.1 christos ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 1.1 christos ##
5 1.1 christos ## Copyright 1998-2021 The OpenLDAP Foundation.
6 1.1 christos ## All rights reserved.
7 1.1 christos ##
8 1.1 christos ## Redistribution and use in source and binary forms, with or without
9 1.1 christos ## modification, are permitted only as authorized by the OpenLDAP
10 1.1 christos ## Public License.
11 1.1 christos ##
12 1.1 christos ## A copy of this license is available in the file LICENSE in the
13 1.1 christos ## top-level directory of the distribution or, alternatively, at
14 1.1 christos ## <http://www.OpenLDAP.org/license.html>.
15 1.1 christos
16 1.1 christos echo "running defines.sh"
17 1.1 christos . $SRCDIR/scripts/defines.sh
18 1.1 christos
19 1.1 christos if test $SYNCPROV = syncprovno; then
20 1.1 christos echo "Syncrepl provider overlay not available, test skipped"
21 1.1 christos exit 0
22 1.1 christos fi
23 1.1 christos if test $ACCESSLOG = accesslogno; then
24 1.1 christos echo "Accesslog overlay not available, test skipped"
25 1.1 christos exit 0
26 1.1 christos fi
27 1.1 christos
28 1.1 christos CFPRO=$TESTDIR/cfpro.d
29 1.1 christos CFCON=$TESTDIR/cfcon.d
30 1.1 christos
31 1.1 christos mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C $DBDIR1D $DBDIR2A $CFPRO $CFCON
32 1.1 christos
33 1.1 christos $SLAPPASSWD -g -n >$CONFIGPWF
34 1.1 christos
35 1.1 christos if test x"$SYNCMODE" = x ; then
36 1.1 christos SYNCMODE=rp
37 1.1 christos fi
38 1.1 christos case "$SYNCMODE" in
39 1.1 christos ro)
40 1.1 christos SYNCTYPE="type=refreshOnly interval=00:00:00:03"
41 1.1 christos ;;
42 1.1 christos rp)
43 1.1 christos SYNCTYPE="type=refreshAndPersist"
44 1.1 christos ;;
45 1.1 christos *)
46 1.1 christos echo "unknown sync mode $SYNCMODE"
47 1.1 christos exit 1;
48 1.1 christos ;;
49 1.1 christos esac
50 1.1 christos
51 1.1 christos #
52 1.1 christos # Test replication of dynamic config with alternate consumer config:
53 1.1 christos # - start provider
54 1.1 christos # - start consumer
55 1.1 christos # - configure over ldap
56 1.1 christos # - populate over ldap
57 1.1 christos # - configure syncrepl over ldap
58 1.1 christos # - retrieve database over ldap and compare against expected results
59 1.1 christos #
60 1.1 christos
61 1.1 christos echo "Starting provider slapd on TCP/IP port $PORT1..."
62 1.1 christos . $CONFFILTER $BACKEND < $DYNAMICCONF > $CONFLDIF
63 1.1 christos $SLAPADD -F $CFPRO -n 0 -l $CONFLDIF
64 1.1 christos $SLAPD -F $CFPRO -h $URI1 -d $LVL > $LOG1 2>&1 &
65 1.1 christos PID=$!
66 1.1 christos if test $WAIT != 0 ; then
67 1.1 christos echo PID $PID
68 1.1 christos read foo
69 1.1 christos fi
70 1.1 christos KILLPIDS="$PID"
71 1.1 christos
72 1.1 christos sleep 1
73 1.1 christos
74 1.1 christos echo "Using ldapsearch to check that provider slapd is running..."
75 1.1 christos for i in 0 1 2 3 4 5; do
76 1.1 christos $LDAPSEARCH -s base -b "" -H $URI1 \
77 1.1 christos 'objectclass=*' > /dev/null 2>&1
78 1.1 christos RC=$?
79 1.1 christos if test $RC = 0 ; then
80 1.1 christos break
81 1.1 christos fi
82 1.1 christos echo "Waiting 5 seconds for slapd to start..."
83 1.1 christos sleep 5
84 1.1 christos done
85 1.1 christos
86 1.1 christos if test $RC != 0 ; then
87 1.1 christos echo "ldapsearch failed ($RC)!"
88 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
89 1.1 christos exit $RC
90 1.1 christos fi
91 1.1 christos
92 1.1 christos echo "Inserting syncprov and accesslog overlays on provider..."
93 1.1 christos if [ "$SYNCPROV" = syncprovmod -a "$ACCESSLOG" = accesslogmod ]; then
94 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
95 1.1 christos dn: cn=module,cn=config
96 1.1 christos objectClass: olcModuleList
97 1.1 christos cn: module
98 1.1 christos olcModulePath: ../servers/slapd/overlays
99 1.1 christos olcModuleLoad: syncprov.la
100 1.1 christos olcModuleLoad: accesslog.la
101 1.1 christos EOF
102 1.1 christos RC=$?
103 1.1 christos if test $RC != 0 ; then
104 1.1 christos echo "ldapadd failed for moduleLoad of syncprov and accesslog ($RC)!"
105 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
106 1.1 christos exit $RC
107 1.1 christos fi
108 1.1 christos elif [ "$SYNCPROV" = syncprovmod ]; then
109 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
110 1.1 christos dn: cn=module,cn=config
111 1.1 christos objectClass: olcModuleList
112 1.1 christos cn: module
113 1.1 christos olcModulePath: ../servers/slapd/overlays
114 1.1 christos olcModuleLoad: syncprov.la
115 1.1 christos EOF
116 1.1 christos RC=$?
117 1.1 christos if test $RC != 0 ; then
118 1.1 christos echo "ldapadd failed for moduleLoad of syncprov ($RC)!"
119 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
120 1.1 christos exit $RC
121 1.1 christos fi
122 1.1 christos elif [ "$ACCESSLOG" = accesslogmod ]; then
123 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
124 1.1 christos dn: cn=module,cn=config
125 1.1 christos objectClass: olcModuleList
126 1.1 christos cn: module
127 1.1 christos olcModulePath: ../servers/slapd/overlays
128 1.1 christos olcModuleLoad: accesslog.la
129 1.1 christos EOF
130 1.1 christos RC=$?
131 1.1 christos if test $RC != 0 ; then
132 1.1 christos echo "ldapadd failed for moduleLoad of accesslog ($RC)!"
133 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
134 1.1 christos exit $RC
135 1.1 christos fi
136 1.1 christos fi
137 1.1 christos
138 1.1 christos echo "Adding backend accesslog databases using $BACKEND..."
139 1.1 christos if [ "$BACKENDTYPE" = mod ]; then
140 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
141 1.1 christos dn: cn=module,cn=config
142 1.1 christos objectClass: olcModuleList
143 1.1 christos cn: module
144 1.1 christos olcModulePath: $TESTWD/../servers/slapd/back-$BACKEND
145 1.1 christos olcModuleLoad: back_$BACKEND.la
146 1.1 christos EOF
147 1.1 christos RC=$?
148 1.1 christos if test $RC != 0 ; then
149 1.1 christos echo "ldapadd failed for moduleLoad of $BACKEND ($RC)!"
150 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
151 1.1 christos exit $RC
152 1.1 christos fi
153 1.1 christos fi
154 1.1 christos
155 1.1 christos read CONFIGPW < $CONFIGPWF
156 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
157 1.1 christos dn: olcDatabase={1}$BACKEND,cn=config
158 1.1 christos objectClass: olcDatabaseConfig
159 1.1 christos objectClass: olc${BACKEND}Config
160 1.1 christos olcDatabase: {1}$BACKEND
161 1.1 christos olcSuffix: cn=accesslog
162 1.1 christos ${nullExclude}olcDbDirectory: $DBDIR1C
163 1.1 christos olcRootDN: cn=config
164 1.1 christos olcSizeLimit: unlimited
165 1.1 christos olcTimeLimit: unlimited
166 1.1 christos olcDbIndex: default eq
167 1.1 christos olcDbIndex: entryCSN,objectClass,reqEnd,reqResult,reqStart,reqDN
168 1.1 christos
169 1.1 christos dn: olcOverlay=syncprov,olcDatabase={1}${BACKEND},cn=config
170 1.1 christos changetype: add
171 1.1 christos objectClass: olcOverlayConfig
172 1.1 christos objectClass: olcSyncProvConfig
173 1.1 christos olcOverlay: syncprov
174 1.1 christos olcSpNoPresent: TRUE
175 1.1 christos olcSpReloadHint: TRUE
176 1.1 christos
177 1.1 christos dn: olcDatabase={2}$BACKEND,cn=config
178 1.1 christos objectClass: olcDatabaseConfig
179 1.1 christos objectClass: olc${BACKEND}Config
180 1.1 christos olcDatabase: {2}$BACKEND
181 1.1 christos olcSuffix: cn=consumer-accesslog
182 1.1 christos ${nullExclude}olcDbDirectory: $DBDIR1D
183 1.1 christos olcRootDN: cn=consumer,cn=config
184 1.1 christos olcSizeLimit: unlimited
185 1.1 christos olcTimeLimit: unlimited
186 1.1 christos olcDbIndex: default eq
187 1.1 christos olcDbIndex: entryCSN,objectClass,reqEnd,reqResult,reqStart,reqDN
188 1.1 christos
189 1.1 christos dn: olcOverlay=syncprov,olcDatabase={2}${BACKEND},cn=config
190 1.1 christos changetype: add
191 1.1 christos objectClass: olcOverlayConfig
192 1.1 christos objectClass: olcSyncProvConfig
193 1.1 christos olcOverlay: syncprov
194 1.1 christos olcSpNoPresent: TRUE
195 1.1 christos olcSpReloadHint: TRUE
196 1.1 christos EOF
197 1.1 christos
198 1.1 christos RC=$?
199 1.1 christos if test $RC != 0 ; then
200 1.1 christos echo "ldapadd failed for accesslog databases using $BACKEND ($RC)!"
201 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
202 1.1 christos exit $RC
203 1.1 christos fi
204 1.1 christos
205 1.1 christos $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
206 1.1 christos dn: olcOverlay=syncprov,olcDatabase={0}config,cn=config
207 1.1 christos changetype: add
208 1.1 christos objectClass: olcOverlayConfig
209 1.1 christos objectClass: olcSyncProvConfig
210 1.1 christos olcOverlay: syncprov
211 1.1 christos
212 1.1 christos dn: olcOverlay=accesslog,olcDatabase={0}config,cn=config
213 1.1 christos changetype: add
214 1.1 christos objectClass: olcOverlayConfig
215 1.1 christos objectClass: olcAccessLogConfig
216 1.1 christos olcOverlay: accesslog
217 1.1 christos olcAccessLogDB: cn=accesslog
218 1.1 christos olcAccessLogOps: writes
219 1.1 christos olcAccessLogPurge: 07+00:00 01+00:00
220 1.1 christos olcAccessLogSuccess: TRUE
221 1.1 christos EOF
222 1.1 christos
223 1.1 christos RC=$?
224 1.1 christos if test $RC != 0 ; then
225 1.1 christos echo "ldapmodify failed for syncprov and accesslog overlay config ($RC)!"
226 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
227 1.1 christos exit $RC
228 1.1 christos fi
229 1.1 christos
230 1.1 christos # Consumers will not replicate the provider's actual cn=config.
231 1.1 christos # Instead, they will use an alternate DB so that they may be
232 1.1 christos # configured differently from the provider. This alternate DB
233 1.1 christos # will also be a consumer for the real cn=schema,cn=config tree.
234 1.1 christos # It has multi-provider enabled so that it can be written directly
235 1.1 christos # while being a consumer of the main schema.
236 1.1 christos echo "Configuring consumer config DB on provider..."
237 1.1 christos $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
238 1.1 christos dn: cn=config
239 1.1 christos changetype: modify
240 1.1 christos add: olcServerID
241 1.1 christos olcServerID: 1
242 1.1 christos
243 1.1 christos dn: olcDatabase={1}ldif,cn=config
244 1.1 christos changetype: add
245 1.1 christos objectClass: olcDatabaseConfig
246 1.1 christos objectClass: olcLdifConfig
247 1.1 christos olcDatabase: {1}ldif
248 1.1 christos olcDbDirectory: $DBDIR1A
249 1.1 christos olcSuffix: cn=config,cn=consumer
250 1.1 christos olcRootDN: cn=config,cn=consumer
251 1.1 christos olcRootPW: repsecret
252 1.1 christos olcAccess: to * by dn.base="cn=config" write
253 1.1 christos
254 1.1 christos dn: olcOverlay=syncprov,olcDatabase={1}ldif,cn=config
255 1.1 christos changetype: add
256 1.1 christos objectClass: olcOverlayConfig
257 1.1 christos objectClass: olcSyncProvConfig
258 1.1 christos olcOverlay: syncprov
259 1.1 christos
260 1.1 christos dn: olcOverlay=accesslog,olcDatabase={1}ldif,cn=config
261 1.1 christos changetype: add
262 1.1 christos objectClass: olcOverlayConfig
263 1.1 christos objectClass: olcAccessLogConfig
264 1.1 christos olcOverlay: accesslog
265 1.1 christos olcAccessLogDB: cn=consumer-accesslog
266 1.1 christos olcAccessLogOps: writes
267 1.1 christos olcAccessLogPurge: 07+00:00 01+00:00
268 1.1 christos olcAccessLogSuccess: TRUE
269 1.1 christos
270 1.1 christos dn: cn=config,cn=consumer
271 1.1 christos changetype: add
272 1.1 christos objectClass: olcGlobal
273 1.1 christos cn: consumerconfig
274 1.1 christos
275 1.1 christos dn: olcDatabase={0}config,cn=config,cn=consumer
276 1.1 christos changetype: add
277 1.1 christos objectClass: olcDatabaseConfig
278 1.1 christos olcDatabase: {0}config
279 1.1 christos olcRootPW: topsecret
280 1.1 christos olcSyncrepl: {0}rid=001 provider=$URI1 binddn="cn=config,cn=consumer"
281 1.1 christos bindmethod=simple credentials=repsecret searchbase="cn=config,cn=consumer"
282 1.1 christos $SYNCTYPE retry="3 5 300 5" timeout=3 suffixmassage="cn=config"
283 1.1 christos olcUpdateRef: $URI1
284 1.1 christos
285 1.1 christos dn: olcDatabase={1}ldif,cn=config
286 1.1 christos changetype: modify
287 1.1 christos add: olcSyncrepl
288 1.1 christos olcSyncrepl: {0}rid=001 provider=$URI1 binddn="cn=config"
289 1.1 christos bindmethod=simple credentials=$CONFIGPW searchbase="cn=schema,cn=config"
290 1.1 christos $SYNCTYPE retry="3 5 300 5" timeout=3
291 1.1 christos suffixmassage="cn=schema,cn=config,cn=consumer"
292 1.1 christos -
293 1.1 christos add: olcMultiProvider
294 1.1 christos olcMultiProvider: TRUE
295 1.1 christos
296 1.1 christos EOF
297 1.1 christos RC=$?
298 1.1 christos if test $RC != 0 ; then
299 1.1 christos echo "ldapmodify failed for consumer DB config ($RC)!"
300 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
301 1.1 christos exit $RC
302 1.1 christos fi
303 1.1 christos
304 1.1 christos echo "Starting consumer slapd on TCP/IP port $PORT2..."
305 1.1 christos $SLAPADD -F $CFCON -n 0 -l $CONFLDIF
306 1.1 christos $SLAPD -F $CFCON -h $URI2 -d $LVL > $LOG2 2>&1 &
307 1.1 christos CONSUMERPID=$!
308 1.1 christos if test $WAIT != 0 ; then
309 1.1 christos echo CONSUMERPID $CONSUMERPID
310 1.1 christos read foo
311 1.1 christos fi
312 1.1 christos KILLPIDS="$KILLPIDS $CONSUMERPID"
313 1.1 christos
314 1.1 christos sleep 1
315 1.1 christos
316 1.1 christos echo "Using ldapsearch to check that consumer slapd is running..."
317 1.1 christos for i in 0 1 2 3 4 5; do
318 1.1 christos $LDAPSEARCH -s base -b "" -H $URI2 \
319 1.1 christos 'objectclass=*' > /dev/null 2>&1
320 1.1 christos RC=$?
321 1.1 christos if test $RC = 0 ; then
322 1.1 christos break
323 1.1 christos fi
324 1.1 christos echo "Waiting 5 seconds for slapd to start..."
325 1.1 christos sleep 5
326 1.1 christos done
327 1.1 christos
328 1.1 christos if test $RC != 0 ; then
329 1.1 christos echo "ldapsearch failed ($RC)!"
330 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
331 1.1 christos exit $RC
332 1.1 christos fi
333 1.1 christos
334 1.1 christos echo "Configuring syncrepl on consumer..."
335 1.1 christos $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
336 1.1 christos dn: olcDatabase={0}config,cn=config
337 1.1 christos changetype: modify
338 1.1 christos add: olcSyncRepl
339 1.1 christos olcSyncRepl: rid=001 provider=$URI1 binddn="cn=config,cn=consumer"
340 1.1 christos bindmethod=simple credentials=repsecret searchbase="cn=config,cn=consumer"
341 1.1 christos $SYNCTYPE retry="3 5 300 5" timeout=3 logbase="cn=consumer-accesslog"
342 1.1 christos logfilter="(&(objectclass=auditWriteObject)(reqresult=0))"
343 1.1 christos syncdata=accesslog suffixmassage="cn=config"
344 1.1 christos -
345 1.1 christos add: olcUpdateRef
346 1.1 christos olcUpdateRef: $URI1
347 1.1 christos EOF
348 1.1 christos
349 1.1 christos sleep 1
350 1.1 christos
351 1.1 christos echo "Using ldapsearch to check that syncrepl received config changes..."
352 1.1 christos RC=32
353 1.1 christos for i in 0 1 2 3 4 5; do
354 1.1 christos RESULT=`$LDAPSEARCH -H $URI2 -D cn=config -y $CONFIGPWF \
355 1.1 christos -s base -b "olcDatabase={0}config,cn=config" \
356 1.1 christos '(olcUpdateRef=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
357 1.1 christos if test "x$RESULT" = "xOK" ; then
358 1.1 christos RC=0
359 1.1 christos break
360 1.1 christos fi
361 1.1 christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
362 1.1 christos sleep $SLEEP1
363 1.1 christos done
364 1.1 christos
365 1.1 christos if test $RC != 0 ; then
366 1.1 christos echo "ldapsearch failed ($RC)!"
367 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
368 1.1 christos exit $RC
369 1.1 christos fi
370 1.1 christos
371 1.1 christos echo "Adding schema and databases on provider..."
372 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
373 1.1 christos include: file://$ABS_SCHEMADIR/core.ldif
374 1.1 christos
375 1.1 christos include: file://$ABS_SCHEMADIR/cosine.ldif
376 1.1 christos
377 1.1 christos include: file://$ABS_SCHEMADIR/inetorgperson.ldif
378 1.1 christos
379 1.1 christos include: file://$ABS_SCHEMADIR/openldap.ldif
380 1.1 christos
381 1.1 christos include: file://$ABS_SCHEMADIR/nis.ldif
382 1.1 christos EOF
383 1.1 christos RC=$?
384 1.1 christos if test $RC != 0 ; then
385 1.1 christos echo "ldapadd failed for schema config ($RC)!"
386 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
387 1.1 christos exit $RC
388 1.1 christos fi
389 1.1 christos
390 1.1 christos echo "Using ldapsearch to check that syncrepl received the schema changes..."
391 1.1 christos RC=32
392 1.1 christos for i in 0 1 2 3 4 5; do
393 1.1 christos RESULT=`$LDAPSEARCH -H $URI2 -D cn=config -y $CONFIGPWF \
394 1.1 christos -s sub -b "cn=schema,cn=config" \
395 1.1 christos '(cn=*openldap)' 2>&1 | awk '/^dn:/ {print "OK"}'`
396 1.1 christos if test "x$RESULT" = "xOK" ; then
397 1.1 christos RC=0
398 1.1 christos break
399 1.1 christos fi
400 1.1 christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
401 1.1 christos sleep $SLEEP1
402 1.1 christos done
403 1.1 christos
404 1.1 christos if test "x$RESULT" != "xOK" ; then
405 1.1 christos echo "consumer never received complete schema!"
406 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
407 1.1 christos exit 1
408 1.1 christos fi
409 1.1 christos
410 1.1 christos nullExclude="" nullOK=""
411 1.1 christos test $BACKEND = null && nullExclude="# " nullOK="OK"
412 1.1 christos
413 1.1 christos if [ "$BACKENDTYPE" = mod ]; then
414 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
415 1.1 christos dn: cn=module,cn=config,cn=consumer
416 1.1 christos objectClass: olcModuleList
417 1.1 christos cn: module
418 1.1 christos olcModulePath: ../servers/slapd/back-$BACKEND
419 1.1 christos olcModuleLoad: back_$BACKEND.la
420 1.1 christos EOF
421 1.1 christos RC=$?
422 1.1 christos if test $RC != 0 ; then
423 1.1 christos echo "ldapadd failed for backend config ($RC)!"
424 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
425 1.1 christos exit $RC
426 1.1 christos fi
427 1.1 christos fi
428 1.1 christos
429 1.1 christos $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
430 1.1 christos dn: olcDatabase={2}$BACKEND,cn=config
431 1.1 christos objectClass: olcDatabaseConfig
432 1.1 christos ${nullExclude}objectClass: olc${BACKEND}Config
433 1.1 christos olcDatabase: {2}$BACKEND
434 1.1 christos olcSuffix: $BASEDN
435 1.1 christos ${nullExclude}olcDbDirectory: $DBDIR1B
436 1.1 christos olcRootDN: $MANAGERDN
437 1.1 christos olcRootPW: $PASSWD
438 1.1 christos olcSyncRepl: rid=002 provider=$URI1 binddn="$MANAGERDN" bindmethod=simple
439 1.1 christos credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
440 1.1 christos retry="3 5 300 5" timeout=3
441 1.1 christos olcUpdateRef: $URI1
442 1.1 christos
443 1.1 christos dn: olcOverlay=syncprov,olcDatabase={2}${BACKEND},cn=config
444 1.1 christos changetype: add
445 1.1 christos objectClass: olcOverlayConfig
446 1.1 christos objectClass: olcSyncProvConfig
447 1.1 christos olcOverlay: syncprov
448 1.1 christos
449 1.1 christos dn: olcDatabase={1}$BACKEND,cn=config,cn=consumer
450 1.1 christos objectClass: olcDatabaseConfig
451 1.1 christos ${nullExclude}objectClass: olc${BACKEND}Config
452 1.1 christos olcDatabase: {1}$BACKEND
453 1.1 christos olcSuffix: $BASEDN
454 1.1 christos ${nullExclude}olcDbDirectory: $DBDIR2A
455 1.1 christos olcRootDN: $MANAGERDN
456 1.1 christos olcRootPW: $PASSWD
457 1.1 christos olcSyncRepl: rid=002 provider=$URI1 binddn="$MANAGERDN" bindmethod=simple
458 1.1 christos credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
459 1.1 christos retry="3 5 300 5" timeout=3
460 1.1 christos olcUpdateRef: $URI1
461 1.1 christos
462 1.1 christos EOF
463 1.1 christos RC=$?
464 1.1 christos if test $RC != 0 ; then
465 1.1 christos echo "ldapadd failed for database config ($RC)!"
466 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
467 1.1 christos exit $RC
468 1.1 christos fi
469 1.1 christos
470 1.1 christos if test $INDEXDB = indexdb ; then
471 1.1 christos $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
472 1.1 christos dn: olcDatabase={2}$BACKEND,cn=config
473 1.1 christos changetype: modify
474 1.1 christos add: olcDbIndex
475 1.1 christos olcDbIndex: objectClass,entryUUID,entryCSN eq
476 1.1 christos olcDbIndex: cn,uid pres,eq,sub
477 1.1 christos EOF
478 1.1 christos RC=$?
479 1.1 christos if test $RC != 0 ; then
480 1.1 christos echo "ldapadd modify for database config ($RC)!"
481 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
482 1.1 christos exit $RC
483 1.1 christos fi
484 1.1 christos fi
485 1.1 christos
486 1.1 christos echo "Using ldapadd to populate provider..."
487 1.1 christos $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDERED \
488 1.1 christos >> $TESTOUT 2>&1
489 1.1 christos RC=$?
490 1.1 christos if test $RC != 0 ; then
491 1.1 christos echo "ldapadd failed for database config ($RC)!"
492 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
493 1.1 christos exit $RC
494 1.1 christos fi
495 1.1 christos
496 1.1 christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
497 1.1 christos sleep $SLEEP1
498 1.1 christos
499 1.1 christos echo "Using ldapsearch to check that syncrepl received database changes..."
500 1.1 christos RC=32
501 1.1 christos for i in 0 1 2 3 4 5; do
502 1.1 christos RESULT=`$LDAPSEARCH -H $URI2 \
503 1.1 christos -s base -b "cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com" \
504 1.1 christos '(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
505 1.1 christos if test "x$RESULT$nullOK" = "xOK" ; then
506 1.1 christos RC=0
507 1.1 christos break
508 1.1 christos fi
509 1.1 christos echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
510 1.1 christos sleep $SLEEP1
511 1.1 christos done
512 1.1 christos
513 1.1 christos if test $RC != 0 ; then
514 1.1 christos echo "ldapsearch failed ($RC)!"
515 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
516 1.1 christos exit $RC
517 1.1 christos fi
518 1.1 christos
519 1.1 christos echo "Using ldapsearch to read all the entries from the provider..."
520 1.1 christos $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI1 -w $PASSWD \
521 1.1 christos 'objectclass=*' > $PROVIDEROUT 2>&1
522 1.1 christos RC=$?
523 1.1 christos
524 1.1 christos if test $RC != 0 ; then
525 1.1 christos echo "ldapsearch failed at provider ($RC)!"
526 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
527 1.1 christos exit $RC
528 1.1 christos fi
529 1.1 christos
530 1.1 christos echo "Using ldapsearch to read all the entries from the consumer..."
531 1.1 christos $LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI2 -w $PASSWD \
532 1.1 christos 'objectclass=*' > $CONSUMEROUT 2>&1
533 1.1 christos RC=$?
534 1.1 christos
535 1.1 christos if test $RC != 0 ; then
536 1.1 christos echo "ldapsearch failed at consumer ($RC)!"
537 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
538 1.1 christos exit $RC
539 1.1 christos fi
540 1.1 christos
541 1.1 christos test $KILLSERVERS != no && kill -HUP $KILLPIDS
542 1.1 christos
543 1.1 christos echo "Filtering provider results..."
544 1.1 christos $LDIFFILTER < $PROVIDEROUT > $PROVIDERFLT
545 1.1 christos echo "Filtering consumer results..."
546 1.1 christos $LDIFFILTER < $CONSUMEROUT > $CONSUMERFLT
547 1.1 christos
548 1.1 christos echo "Comparing retrieved entries from provider and consumer..."
549 1.1 christos $CMP $PROVIDERFLT $CONSUMERFLT > $CMPOUT
550 1.1 christos
551 1.1 christos if test $? != 0 ; then
552 1.1 christos echo "test failed - provider and consumer databases differ"
553 1.1 christos exit 1
554 1.1 christos fi
555 1.1 christos
556 1.1 christos echo ">>>>> Test succeeded"
557 1.1 christos
558 1.1 christos test $KILLSERVERS != no && wait
559 1.1 christos
560 1.1 christos exit 0
561