xref: /netbsd-src/external/bsd/openldap/dist/tests/scripts/test053-syncprov-glue (revision e670fd5c413e99c2f6a37901bb21c537fcd322d2)
1*e670fd5cSchristos#! /bin/sh
2*e670fd5cSchristos# $OpenLDAP$
3*e670fd5cSchristos## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4*e670fd5cSchristos##
5*e670fd5cSchristos## Copyright 1998-2021 The OpenLDAP Foundation.
6*e670fd5cSchristos## All rights reserved.
7*e670fd5cSchristos##
8*e670fd5cSchristos## Redistribution and use in source and binary forms, with or without
9*e670fd5cSchristos## modification, are permitted only as authorized by the OpenLDAP
10*e670fd5cSchristos## Public License.
11*e670fd5cSchristos##
12*e670fd5cSchristos## A copy of this license is available in the file LICENSE in the
13*e670fd5cSchristos## top-level directory of the distribution or, alternatively, at
14*e670fd5cSchristos## <http://www.OpenLDAP.org/license.html>.
15*e670fd5cSchristos
16*e670fd5cSchristos# This script tests a bug where syncprov used on a glue database
17*e670fd5cSchristos# with a subordinate syncrepl consumer database looses a read-lock
18*e670fd5cSchristos# on the glue suffix entry when a modification is received on the
19*e670fd5cSchristos# syncrepl consumer.  The bug is only triggered when there is an
20*e670fd5cSchristos# active syncrepl consumers of the glue suffix entry.
21*e670fd5cSchristos
22*e670fd5cSchristosecho "running defines.sh"
23*e670fd5cSchristos. $SRCDIR/scripts/defines.sh
24*e670fd5cSchristos
25*e670fd5cSchristosif test $SYNCPROV = syncprovno; then
26*e670fd5cSchristos	echo "Syncrepl provider overlay not available, test skipped"
27*e670fd5cSchristos	exit 0
28*e670fd5cSchristosfi
29*e670fd5cSchristos
30*e670fd5cSchristosPRODDIR=$TESTDIR/prod
31*e670fd5cSchristosPRO2DIR=$TESTDIR/pro2
32*e670fd5cSchristosCONSDIR=$TESTDIR/cons
33*e670fd5cSchristosCFPROD=$PRODDIR/slapd.d
34*e670fd5cSchristosCFPRO2=$PRO2DIR/slapd.d
35*e670fd5cSchristosCFCONS=$CONSDIR/slapd.d
36*e670fd5cSchristos
37*e670fd5cSchristosmkdir -p $TESTDIR
38*e670fd5cSchristosmkdir -p $PRODDIR $CFPROD $PRODDIR/db $PRODDIR/ou1
39*e670fd5cSchristosmkdir -p $PRO2DIR $CFPRO2 $PRO2DIR/db
40*e670fd5cSchristosmkdir -p $CONSDIR $CFCONS $CONSDIR/db
41*e670fd5cSchristos
42*e670fd5cSchristoscd $TESTDIR
43*e670fd5cSchristos
44*e670fd5cSchristosKILLPIDS=
45*e670fd5cSchristos
46*e670fd5cSchristos$SLAPPASSWD -g -n >$CONFIGPWF
47*e670fd5cSchristos
48*e670fd5cSchristosif test x"$SYNCMODE" = x ; then
49*e670fd5cSchristos	SYNCMODE=rp
50*e670fd5cSchristosfi
51*e670fd5cSchristoscase "$SYNCMODE" in
52*e670fd5cSchristos	ro)
53*e670fd5cSchristos		SYNCTYPE="type=refreshOnly interval=00:00:00:03"
54*e670fd5cSchristos		;;
55*e670fd5cSchristos	rp)
56*e670fd5cSchristos		SYNCTYPE="type=refreshAndPersist"
57*e670fd5cSchristos		;;
58*e670fd5cSchristos	*)
59*e670fd5cSchristos		echo "unknown sync mode $SYNCMODE"
60*e670fd5cSchristos		exit 1;
61*e670fd5cSchristos		;;
62*e670fd5cSchristosesac
63*e670fd5cSchristos
64*e670fd5cSchristosecho "Initializing provider configurations..."
65*e670fd5cSchristos$SLAPADD -F $CFPROD -n 0 <<EOF
66*e670fd5cSchristosdn: cn=config
67*e670fd5cSchristosobjectClass: olcGlobal
68*e670fd5cSchristoscn: config
69*e670fd5cSchristosolcServerID: 1
70*e670fd5cSchristos
71*e670fd5cSchristosdn: olcDatabase={0}config,cn=config
72*e670fd5cSchristosobjectClass: olcDatabaseConfig
73*e670fd5cSchristosolcDatabase: {0}config
74*e670fd5cSchristosolcRootPW:< file://$CONFIGPWF
75*e670fd5cSchristos
76*e670fd5cSchristosEOF
77*e670fd5cSchristos
78*e670fd5cSchristosecho "Initializing provider2 configurations..."
79*e670fd5cSchristos$SLAPADD -F $CFPRO2 -n 0 <<EOF
80*e670fd5cSchristosdn: cn=config
81*e670fd5cSchristosobjectClass: olcGlobal
82*e670fd5cSchristoscn: config
83*e670fd5cSchristos
84*e670fd5cSchristosdn: olcDatabase={0}config,cn=config
85*e670fd5cSchristosobjectClass: olcDatabaseConfig
86*e670fd5cSchristosolcDatabase: {0}config
87*e670fd5cSchristosolcRootPW:< file://$CONFIGPWF
88*e670fd5cSchristos
89*e670fd5cSchristosEOF
90*e670fd5cSchristos
91*e670fd5cSchristos$SLAPADD -F $CFCONS -n 0 <<EOF
92*e670fd5cSchristosdn: cn=config
93*e670fd5cSchristosobjectClass: olcGlobal
94*e670fd5cSchristoscn: config
95*e670fd5cSchristos
96*e670fd5cSchristosdn: olcDatabase={0}config,cn=config
97*e670fd5cSchristosobjectClass: olcDatabaseConfig
98*e670fd5cSchristosolcDatabase: {0}config
99*e670fd5cSchristosolcRootPW:< file://$CONFIGPWF
100*e670fd5cSchristosEOF
101*e670fd5cSchristos
102*e670fd5cSchristosecho "Starting provider slapd on TCP/IP port $PORT1..."
103*e670fd5cSchristoscd $PRODDIR
104*e670fd5cSchristos$SLAPD -F slapd.d -h $URI1 -d $LVL > $LOG1 2>&1 &
105*e670fd5cSchristosPID=$!
106*e670fd5cSchristosif test $WAIT != 0 ; then
107*e670fd5cSchristos    echo PID $PID
108*e670fd5cSchristos    read foo
109*e670fd5cSchristosfi
110*e670fd5cSchristosKILLPIDS="$KILLPIDS $PID"
111*e670fd5cSchristoscd $TESTWD
112*e670fd5cSchristossleep 1
113*e670fd5cSchristosecho "Using ldapsearch to check that provider slapd is running..."
114*e670fd5cSchristosfor i in 0 1 2 3 4 5; do
115*e670fd5cSchristos	$LDAPSEARCH -s base -b "" -H $URI1 \
116*e670fd5cSchristos		'objectclass=*' > /dev/null 2>&1
117*e670fd5cSchristos	RC=$?
118*e670fd5cSchristos	if test $RC = 0 ; then
119*e670fd5cSchristos		break
120*e670fd5cSchristos	fi
121*e670fd5cSchristos	echo "Waiting 5 seconds for slapd to start..."
122*e670fd5cSchristos	sleep 5
123*e670fd5cSchristosdone
124*e670fd5cSchristosif test $RC != 0 ; then
125*e670fd5cSchristos	echo "ldapsearch failed ($RC)!"
126*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
127*e670fd5cSchristos	exit $RC
128*e670fd5cSchristosfi
129*e670fd5cSchristos
130*e670fd5cSchristosecho "Starting provider2 slapd on TCP/IP port $PORT2..."
131*e670fd5cSchristoscd $PRO2DIR
132*e670fd5cSchristos$SLAPD -F slapd.d -h $URI2 -d $LVL > $LOG2 2>&1 &
133*e670fd5cSchristosPID=$!
134*e670fd5cSchristosif test $WAIT != 0 ; then
135*e670fd5cSchristos    echo PID $PID
136*e670fd5cSchristos    read foo
137*e670fd5cSchristosfi
138*e670fd5cSchristosKILLPIDS="$KILLPIDS $PID"
139*e670fd5cSchristoscd $TESTWD
140*e670fd5cSchristossleep 1
141*e670fd5cSchristosecho "Using ldapsearch to check that provider slapd is running..."
142*e670fd5cSchristosfor i in 0 1 2 3 4 5; do
143*e670fd5cSchristos	$LDAPSEARCH -s base -b "" -H $URI2 \
144*e670fd5cSchristos		'objectclass=*' > /dev/null 2>&1
145*e670fd5cSchristos	RC=$?
146*e670fd5cSchristos	if test $RC = 0 ; then
147*e670fd5cSchristos		break
148*e670fd5cSchristos	fi
149*e670fd5cSchristos	echo "Waiting 5 seconds for slapd to start..."
150*e670fd5cSchristos	sleep 5
151*e670fd5cSchristosdone
152*e670fd5cSchristosif test $RC != 0 ; then
153*e670fd5cSchristos	echo "ldapsearch failed ($RC)!"
154*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
155*e670fd5cSchristos	exit $RC
156*e670fd5cSchristosfi
157*e670fd5cSchristos
158*e670fd5cSchristosecho "Starting consumer slapd on TCP/IP port $PORT3..."
159*e670fd5cSchristoscd $CONSDIR
160*e670fd5cSchristos$SLAPD -F slapd.d -h $URI3 -d $LVL > $LOG3 2>&1 &
161*e670fd5cSchristosPID=$!
162*e670fd5cSchristosif test $WAIT != 0 ; then
163*e670fd5cSchristos    echo PID $PID
164*e670fd5cSchristos    read foo
165*e670fd5cSchristosfi
166*e670fd5cSchristosKILLPIDS="$KILLPIDS $PID"
167*e670fd5cSchristoscd $TESTWD
168*e670fd5cSchristossleep 1
169*e670fd5cSchristosecho "Using ldapsearch to check that consumer slapd is running..."
170*e670fd5cSchristosfor i in 0 1 2 3 4 5; do
171*e670fd5cSchristos	$LDAPSEARCH -s base -b "" -H $URI3 \
172*e670fd5cSchristos		'objectclass=*' > /dev/null 2>&1
173*e670fd5cSchristos	RC=$?
174*e670fd5cSchristos	if test $RC = 0 ; then
175*e670fd5cSchristos		break
176*e670fd5cSchristos	fi
177*e670fd5cSchristos	echo "Waiting 5 seconds for slapd to start..."
178*e670fd5cSchristos	sleep 5
179*e670fd5cSchristosdone
180*e670fd5cSchristosif test $RC != 0 ; then
181*e670fd5cSchristos	echo "ldapsearch failed ($RC)!"
182*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
183*e670fd5cSchristos	exit $RC
184*e670fd5cSchristosfi
185*e670fd5cSchristos
186*e670fd5cSchristosfor uri in $URI1 $URI2 $URI3; do
187*e670fd5cSchristos	echo "Adding schema on $uri..."
188*e670fd5cSchristos	$LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
189*e670fd5cSchristosinclude: file://$ABS_SCHEMADIR/core.ldif
190*e670fd5cSchristos
191*e670fd5cSchristosinclude: file://$ABS_SCHEMADIR/cosine.ldif
192*e670fd5cSchristos
193*e670fd5cSchristosinclude: file://$ABS_SCHEMADIR/inetorgperson.ldif
194*e670fd5cSchristos
195*e670fd5cSchristosinclude: file://$ABS_SCHEMADIR/openldap.ldif
196*e670fd5cSchristos
197*e670fd5cSchristosinclude: file://$ABS_SCHEMADIR/nis.ldif
198*e670fd5cSchristosEOF
199*e670fd5cSchristos	RC=$?
200*e670fd5cSchristos	if test $RC != 0 ; then
201*e670fd5cSchristos		echo "ldapadd failed for schema config ($RC)!"
202*e670fd5cSchristos		test $KILLSERVERS != no && kill -HUP $KILLPIDS
203*e670fd5cSchristos		exit $RC
204*e670fd5cSchristos	fi
205*e670fd5cSchristos
206*e670fd5cSchristos	[ "$BACKENDTYPE" = mod ] || continue
207*e670fd5cSchristos
208*e670fd5cSchristos	echo "Adding backend module on $uri..."
209*e670fd5cSchristos	$LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
210*e670fd5cSchristosdn: cn=module,cn=config
211*e670fd5cSchristosobjectClass: olcModuleList
212*e670fd5cSchristoscn: module
213*e670fd5cSchristosolcModulePath: $TESTWD/../servers/slapd/back-$BACKEND
214*e670fd5cSchristosolcModuleLoad: back_$BACKEND.la
215*e670fd5cSchristosEOF
216*e670fd5cSchristos	RC=$?
217*e670fd5cSchristos	if test $RC != 0 ; then
218*e670fd5cSchristos		echo "ldapadd failed for backend module ($RC)!"
219*e670fd5cSchristos		test $KILLSERVERS != no && kill -HUP $KILLPIDS
220*e670fd5cSchristos		exit $RC
221*e670fd5cSchristos	fi
222*e670fd5cSchristosdone
223*e670fd5cSchristos
224*e670fd5cSchristosecho "Adding databases on provider..."
225*e670fd5cSchristosif [ "$SYNCPROV" = syncprovmod ]; then
226*e670fd5cSchristos	$LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
227*e670fd5cSchristosdn: cn=module,cn=config
228*e670fd5cSchristosobjectClass: olcModuleList
229*e670fd5cSchristoscn: module
230*e670fd5cSchristosolcModulePath: $TESTWD/../servers/slapd/overlays
231*e670fd5cSchristosolcModuleLoad: syncprov.la
232*e670fd5cSchristos
233*e670fd5cSchristosEOF
234*e670fd5cSchristos	RC=$?
235*e670fd5cSchristos	if test $RC != 0 ; then
236*e670fd5cSchristos		echo "ldapadd failed for moduleLoad ($RC)!"
237*e670fd5cSchristos		test $KILLSERVERS != no && kill -HUP $KILLPIDS
238*e670fd5cSchristos		exit $RC
239*e670fd5cSchristos	fi
240*e670fd5cSchristosfi
241*e670fd5cSchristos
242*e670fd5cSchristosnullExclude="" nullOK=""
243*e670fd5cSchristostest $BACKEND = null && nullExclude="# " nullOK="OK"
244*e670fd5cSchristos
245*e670fd5cSchristos$LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
246*e670fd5cSchristosdn: olcDatabase={1}$BACKEND,cn=config
247*e670fd5cSchristosobjectClass: olcDatabaseConfig
248*e670fd5cSchristos${nullExclude}objectClass: olc${BACKEND}Config
249*e670fd5cSchristosolcDatabase: {1}$BACKEND
250*e670fd5cSchristos${nullExclude}olcDbDirectory: $PRODDIR/db
251*e670fd5cSchristosolcSuffix: $BASEDN
252*e670fd5cSchristosolcRootDN: $MANAGERDN
253*e670fd5cSchristosolcRootPW: $PASSWD
254*e670fd5cSchristos
255*e670fd5cSchristosEOF
256*e670fd5cSchristosRC=$?
257*e670fd5cSchristosif test $RC != 0 ; then
258*e670fd5cSchristos	echo "ldapadd failed for provider database config1 ($RC)!"
259*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
260*e670fd5cSchristos	exit $RC
261*e670fd5cSchristosfi
262*e670fd5cSchristos
263*e670fd5cSchristos$LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
264*e670fd5cSchristosdn: olcOverlay={0}glue,olcDatabase={1}$BACKEND,cn=config
265*e670fd5cSchristosobjectClass: olcOverlayConfig
266*e670fd5cSchristosolcOverlay: {0}glue
267*e670fd5cSchristos
268*e670fd5cSchristosdn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
269*e670fd5cSchristosobjectClass: olcOverlayConfig
270*e670fd5cSchristosobjectClass: olcSyncProvConfig
271*e670fd5cSchristosolcOverlay: {1}syncprov
272*e670fd5cSchristos
273*e670fd5cSchristosdn: olcDatabase={1}$BACKEND,cn=config
274*e670fd5cSchristosobjectClass: olcDatabaseConfig
275*e670fd5cSchristos${nullExclude}objectClass: olc${BACKEND}Config
276*e670fd5cSchristosolcDatabase: {1}$BACKEND
277*e670fd5cSchristos${nullExclude}olcDbDirectory: $PRODDIR/ou1
278*e670fd5cSchristosolcSubordinate: TRUE
279*e670fd5cSchristosolcSuffix: ou=ou1,$BASEDN
280*e670fd5cSchristosolcRootDN: $MANAGERDN
281*e670fd5cSchristos
282*e670fd5cSchristosEOF
283*e670fd5cSchristosRC=$?
284*e670fd5cSchristosif test $RC != 0 ; then
285*e670fd5cSchristos	echo "ldapadd failed for provider database config ($RC)!"
286*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
287*e670fd5cSchristos	exit $RC
288*e670fd5cSchristosfi
289*e670fd5cSchristos
290*e670fd5cSchristosecho "Adding databases on provider2..."
291*e670fd5cSchristosif [ "$SYNCPROV" = syncprovmod ]; then
292*e670fd5cSchristos	$LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
293*e670fd5cSchristosdn: cn=module,cn=config
294*e670fd5cSchristosobjectClass: olcModuleList
295*e670fd5cSchristoscn: module
296*e670fd5cSchristosolcModulePath: $TESTWD/../servers/slapd/overlays
297*e670fd5cSchristosolcModuleLoad: syncprov.la
298*e670fd5cSchristos
299*e670fd5cSchristosEOF
300*e670fd5cSchristos	RC=$?
301*e670fd5cSchristos	if test $RC != 0 ; then
302*e670fd5cSchristos		echo "ldapadd failed for moduleLoad ($RC)!"
303*e670fd5cSchristos		test $KILLSERVERS != no && kill -HUP $KILLPIDS
304*e670fd5cSchristos		exit $RC
305*e670fd5cSchristos	fi
306*e670fd5cSchristosfi
307*e670fd5cSchristos
308*e670fd5cSchristos$LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
309*e670fd5cSchristosdn: olcDatabase={1}$BACKEND,cn=config
310*e670fd5cSchristosobjectClass: olcDatabaseConfig
311*e670fd5cSchristos${nullExclude}objectClass: olc${BACKEND}Config
312*e670fd5cSchristosolcDatabase: {1}$BACKEND
313*e670fd5cSchristos${nullExclude}olcDbDirectory: $PRO2DIR/db
314*e670fd5cSchristosolcSuffix: $BASEDN
315*e670fd5cSchristosolcRootDN: $MANAGERDN
316*e670fd5cSchristosolcRootPW: $PASSWD
317*e670fd5cSchristos
318*e670fd5cSchristosdn: olcOverlay={0}syncprov,olcDatabase={1}$BACKEND,cn=config
319*e670fd5cSchristosobjectClass: olcOverlayConfig
320*e670fd5cSchristosobjectClass: olcSyncProvConfig
321*e670fd5cSchristosolcOverlay: {0}syncprov
322*e670fd5cSchristos
323*e670fd5cSchristosEOF
324*e670fd5cSchristosRC=$?
325*e670fd5cSchristosif test $RC != 0 ; then
326*e670fd5cSchristos	echo "ldapadd failed for provider database config ($RC)!"
327*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
328*e670fd5cSchristos	exit $RC
329*e670fd5cSchristosfi
330*e670fd5cSchristos
331*e670fd5cSchristosecho "Adding databases on consumer..."
332*e670fd5cSchristos$LDAPADD -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
333*e670fd5cSchristosdn: olcDatabase={1}$BACKEND,cn=config
334*e670fd5cSchristosobjectClass: olcDatabaseConfig
335*e670fd5cSchristos${nullExclude}objectClass: olc${BACKEND}Config
336*e670fd5cSchristosolcDatabase: {1}$BACKEND
337*e670fd5cSchristos${nullExclude}olcDbDirectory: $CONSDIR/db
338*e670fd5cSchristosolcSuffix: $BASEDN
339*e670fd5cSchristosolcRootDN: $MANAGERDN
340*e670fd5cSchristos
341*e670fd5cSchristosEOF
342*e670fd5cSchristosRC=$?
343*e670fd5cSchristosif test $RC != 0 ; then
344*e670fd5cSchristos	echo "ldapadd failed for consumer database config ($RC)!"
345*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
346*e670fd5cSchristos	exit $RC
347*e670fd5cSchristosfi
348*e670fd5cSchristos
349*e670fd5cSchristosecho "Populating provider..."
350*e670fd5cSchristos$LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
351*e670fd5cSchristosdn: dc=example,dc=com
352*e670fd5cSchristosobjectClass: top
353*e670fd5cSchristosobjectClass: organization
354*e670fd5cSchristosobjectClass: dcObject
355*e670fd5cSchristosdc: example
356*e670fd5cSchristoso: Example, Inc
357*e670fd5cSchristos
358*e670fd5cSchristosdn: ou=ou1,dc=example,dc=com
359*e670fd5cSchristosobjectClass: top
360*e670fd5cSchristosobjectClass: organizationalUnit
361*e670fd5cSchristosou: ou1
362*e670fd5cSchristos
363*e670fd5cSchristosEOF
364*e670fd5cSchristosRC=$?
365*e670fd5cSchristosif test $RC != 0 ; then
366*e670fd5cSchristos	echo "ldapadd failed to populate provider entry ($RC)!"
367*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
368*e670fd5cSchristos	exit $RC
369*e670fd5cSchristosfi
370*e670fd5cSchristos
371*e670fd5cSchristosecho "Populating provider2..."
372*e670fd5cSchristos$LDAPADD -D "$MANAGERDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
373*e670fd5cSchristosdn: dc=example,dc=com
374*e670fd5cSchristosobjectClass: top
375*e670fd5cSchristosobjectClass: organization
376*e670fd5cSchristosobjectClass: dcObject
377*e670fd5cSchristosdc: example
378*e670fd5cSchristoso: Example, Inc
379*e670fd5cSchristos
380*e670fd5cSchristosdn: ou=ou1,dc=example,dc=com
381*e670fd5cSchristosobjectClass: top
382*e670fd5cSchristosobjectClass: organizationalUnit
383*e670fd5cSchristosou: ou1
384*e670fd5cSchristos
385*e670fd5cSchristosEOF
386*e670fd5cSchristosRC=$?
387*e670fd5cSchristosif test $RC != 0 ; then
388*e670fd5cSchristos	echo "ldapadd failed to populate provider entry ($RC)!"
389*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
390*e670fd5cSchristos	exit $RC
391*e670fd5cSchristosfi
392*e670fd5cSchristos
393*e670fd5cSchristosecho "Adding syncrepl on provider..."
394*e670fd5cSchristos$LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
395*e670fd5cSchristosdn: olcDatabase={1}$BACKEND,cn=config
396*e670fd5cSchristoschangetype: modify
397*e670fd5cSchristosadd: olcSyncRepl
398*e670fd5cSchristosolcSyncRepl: rid=1 provider=$URI2 searchbase="ou=ou1,$BASEDN"
399*e670fd5cSchristos  binddn="$MANAGERDN" bindmethod=simple credentials=$PASSWD
400*e670fd5cSchristos  $SYNCTYPE retry="3 5 300 5" timeout=1
401*e670fd5cSchristos
402*e670fd5cSchristosEOF
403*e670fd5cSchristosRC=$?
404*e670fd5cSchristosif test $RC != 0 ; then
405*e670fd5cSchristos	echo "ldapmodify failed to add syncrepl consumer ($RC)!"
406*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
407*e670fd5cSchristos	exit $RC
408*e670fd5cSchristosfi
409*e670fd5cSchristos
410*e670fd5cSchristosecho "Adding syncrepl consumer on consumer..."
411*e670fd5cSchristos$LDAPMODIFY -D cn=config -H $URI3 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
412*e670fd5cSchristosdn: olcDatabase={1}$BACKEND,cn=config
413*e670fd5cSchristoschangetype: modify
414*e670fd5cSchristosadd: olcSyncRepl
415*e670fd5cSchristosolcSyncRepl: rid=1 provider=$URI1 searchbase="$BASEDN"
416*e670fd5cSchristos  binddn="$MANAGERDN" bindmethod=simple credentials=$PASSWD
417*e670fd5cSchristos  $SYNCTYPE retry="3 5 300 5" timeout=1
418*e670fd5cSchristos
419*e670fd5cSchristosEOF
420*e670fd5cSchristosRC=$?
421*e670fd5cSchristosif test $RC != 0 ; then
422*e670fd5cSchristos	echo "ldapmodify failed to add syncrepl consumer ($RC)!"
423*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
424*e670fd5cSchristos	exit $RC
425*e670fd5cSchristosfi
426*e670fd5cSchristos
427*e670fd5cSchristosecho "Using ldapsearch to check that consumer received changes..."
428*e670fd5cSchristosRC=32
429*e670fd5cSchristosfor i in 0 1 2 3 4 5; do
430*e670fd5cSchristos	RESULT=`$LDAPSEARCH -H $URI3 \
431*e670fd5cSchristos		-s base -b "ou=ou1,$BASEDN" \
432*e670fd5cSchristos		'(objectClass=*)' 2>&1 | awk '/^dn:/ {print "OK"}'`
433*e670fd5cSchristos	if test "x$RESULT$nullOK" = "xOK" ; then
434*e670fd5cSchristos		RC=0
435*e670fd5cSchristos		break
436*e670fd5cSchristos	fi
437*e670fd5cSchristos	echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
438*e670fd5cSchristos	sleep $SLEEP1
439*e670fd5cSchristosdone
440*e670fd5cSchristosif test $RC != 0 ; then
441*e670fd5cSchristos	echo "ldapsearch failed ($RC)!"
442*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
443*e670fd5cSchristos	exit $RC
444*e670fd5cSchristosfi
445*e670fd5cSchristos
446*e670fd5cSchristosecho "Using ldapmodify to modify provider2..."
447*e670fd5cSchristos$LDAPADD -D "$MANAGERDN" -H $URI2 -w $PASSWD <<EOF >> $TESTOUT 2>&1
448*e670fd5cSchristosdn: ou=ou1,dc=example,dc=com
449*e670fd5cSchristoschangetype: modify
450*e670fd5cSchristosadd: description
451*e670fd5cSchristosdescription: Modify1
452*e670fd5cSchristos
453*e670fd5cSchristosEOF
454*e670fd5cSchristosRC=$?
455*e670fd5cSchristosif test $RC != 0 ; then
456*e670fd5cSchristos	echo "ldapmodify failed ($RC)!"
457*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
458*e670fd5cSchristos	exit $RC
459*e670fd5cSchristosfi
460*e670fd5cSchristos
461*e670fd5cSchristossleep 1
462*e670fd5cSchristos
463*e670fd5cSchristosecho "Using ldapsearch to check that consumer received changes..."
464*e670fd5cSchristosRC=32
465*e670fd5cSchristosfor i in 0 1 2 3 4 5; do
466*e670fd5cSchristos	RESULT=`$LDAPSEARCH -H $URI3 \
467*e670fd5cSchristos		-s base -b "ou=ou1,$BASEDN" \
468*e670fd5cSchristos		'(description=Modify1)' 2>&1 | awk '/^dn:/ {print "OK"}'`
469*e670fd5cSchristos	if test "x$RESULT$nullOK" = "xOK" ; then
470*e670fd5cSchristos		RC=0
471*e670fd5cSchristos		break
472*e670fd5cSchristos	fi
473*e670fd5cSchristos	echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
474*e670fd5cSchristos	sleep $SLEEP1
475*e670fd5cSchristosdone
476*e670fd5cSchristosif test $RC != 0 ; then
477*e670fd5cSchristos	echo "ldapsearch failed ($RC)!"
478*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
479*e670fd5cSchristos	exit $RC
480*e670fd5cSchristosfi
481*e670fd5cSchristos
482*e670fd5cSchristosecho "Using ldapmodify to modify glue suffix on provider..."
483*e670fd5cSchristos$LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF >> $TESTOUT 2>&1
484*e670fd5cSchristosdn: dc=example,dc=com
485*e670fd5cSchristoschangetype: modify
486*e670fd5cSchristosadd: description
487*e670fd5cSchristosdescription: Test1
488*e670fd5cSchristos
489*e670fd5cSchristosEOF
490*e670fd5cSchristosRC=$?
491*e670fd5cSchristosif test $RC != 0 ; then
492*e670fd5cSchristos	echo "ldapadd failed to modify suffix ($RC)!"
493*e670fd5cSchristos	test $KILLSERVERS != no && kill -HUP $KILLPIDS
494*e670fd5cSchristos	exit $RC
495*e670fd5cSchristosfi
496*e670fd5cSchristos
497*e670fd5cSchristostest $KILLSERVERS != no && kill -HUP $KILLPIDS
498*e670fd5cSchristostest "$lock_bug" = 2	&& exit 2
499*e670fd5cSchristos
500*e670fd5cSchristosecho ">>>>> Test succeeded"
501*e670fd5cSchristos
502*e670fd5cSchristosexit 0
503