summaryrefslogtreecommitdiffstats
path: root/tests/scripts/test061-syncreplication-initiation
blob: a8ce51c1904372130bf5f8ed7600518d20418966 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
#! /bin/sh
# $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
##
## Copyright 1998-2022 The OpenLDAP Foundation.
## All rights reserved.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted only as authorized by the OpenLDAP
## Public License.
##
## A copy of this license is available in the file LICENSE in the
## top-level directory of the distribution or, alternatively, at
## <http://www.OpenLDAP.org/license.html>.

# This script tests race conditions related to setting up the syncrepl
# refresh phase, especially when the provider is itself a consumer
# refreshing from its provider again.

# The configuration used is a provider->forwarder->consumer chain, where
# the forwarder is restarted between add/delete of entries on the provider.

echo "Running defines.sh"
. $SRCDIR/scripts/defines.sh

test "x$INITIATION_RACE_TESTS" = "x" && INITIATION_RACE_TESTS=1

if test $SYNCPROV = syncprovno; then
	echo "Syncrepl provider overlay not available, test skipped"
	exit 0
fi

RETRY="1 +"

PROV_DIR=$TESTDIR/prov
CONS_DIR=$TESTDIR/cons
FWD1_DIR=$TESTDIR/fwd1
FWD2_DIR=$TESTDIR/fwd2

PROV_URI=$URI1
CONS_URI=$URI2
FWD1_URI=$URI3

PROV_LOG=$LOG1
CONS_LOG=$LOG2
FWD1_LOG=$LOG3

DIRS="$PROV_DIR $CONS_DIR $FWD1_DIR"
URIS="$PROV_URI $CONS_URI $FWD1_URI"

noObj=32
nullExclude="" nullOK=""
test $BACKEND = null && nullExclude="# " nullOK="OK" noObj=0

mkdir -p $TESTDIR

for dir in $DIRS; do
	mkdir -p $dir $dir/slapd.d $dir/db
done

KILLPIDS=

$SLAPPASSWD -g -n >$CONFIGPWF

case "$BACKEND" in
	*)		olcDbCheckpoint="# olcDbCheckpoint";;
esac

echo "Initializing server configurations"
for dir in $DIRS; do
	$SLAPADD -F $dir/slapd.d -n 0 <<EOF
dn: cn=config
objectClass: olcGlobal
cn: config
olcServerID: 1 $PROV_URI
olcServerID: 2 $CONS_URI
olcServerID: 3 $FWD1_URI

dn: olcDatabase={0}config,cn=config
objectClass: olcDatabaseConfig
olcDatabase: {0}config
olcRootPW:< file://$CONFIGPWF

EOF
done

echo "Starting provider slapd on $PROV_URI"
cd $PROV_DIR
$SLAPD -F slapd.d -h $PROV_URI -d $LVL >> $PROV_LOG 2>&1 &
PROV_PID=$!
if test $WAIT != 0 ; then
	echo PID $PROV_PID
	read foo
fi
KILLPIDS="$KILLPIDS $PROV_PID"
cd $TESTWD
sleep 1
for i in 1 2 3 4 5; do
	$LDAPSEARCH -s base -b "" -H $PROV_URI \
		'objectclass=*' > /dev/null 2>&1
	RC=$?
	test $RC = 0 && break
	echo "Waiting $i seconds for slapd to start..."
	sleep $i
done
if test $RC != 0 ; then
	echo "ldapsearch failed ($RC)!"
	test $KILLSERVERS != no && kill -HUP $KILLPIDS
	exit $RC
fi

echo "Starting forward1 slapd on $FWD1_URI"
cd $FWD1_DIR
$SLAPD -F slapd.d -h $FWD1_URI -d $LVL >> $FWD1_LOG 2>&1 &
FWD1_PID=$!
if test $WAIT != 0 ; then
	echo PID $FWD1_PID
	read foo
fi
KILLPIDS="$KILLPIDS $FWD1_PID"
cd $TESTWD
sleep 1
for i in 1 2 3 4 5; do
	$LDAPSEARCH -s base -b "" -H $FWD1_URI \
		'objectclass=*' > /dev/null 2>&1
	RC=$?
	test $RC = 0 && break
	echo "Waiting $i seconds for slapd to start..."
	sleep $i
done
if test $RC != 0 ; then
	echo "ldapsearch failed ($RC)!"
	test $KILLSERVERS != no && kill -HUP $KILLPIDS
	exit $RC
fi

echo "Starting consumer slapd on $CONS_URI"
cd $CONS_DIR
$SLAPD -F slapd.d -h $CONS_URI -d $LVL >> $CONS_LOG 2>&1 &
CONS_PID=$!
if test $WAIT != 0 ; then
	echo PID $CONS_PID
	read foo
fi
KILLPIDS="$KILLPIDS $CONS_PID"
cd $TESTWD
sleep 1
for i in 1 2 3 4 5; do
	$LDAPSEARCH -s base -b "" -H $CONS_URI \
		'objectclass=*' > /dev/null 2>&1
	RC=$?
	test $RC = 0 && break
	echo "Waiting $i seconds for slapd to start..."
	sleep $i
done
if test $RC != 0 ; then
	echo "ldapsearch failed ($RC)!"
	test $KILLSERVERS != no && kill -HUP $KILLPIDS
	exit $RC
fi

for uri in $URIS; do
	echo "Adding schema on $uri"
	$LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
include: file://$ABS_SCHEMADIR/core.ldif

include: file://$ABS_SCHEMADIR/cosine.ldif

include: file://$ABS_SCHEMADIR/inetorgperson.ldif

include: file://$ABS_SCHEMADIR/openldap.ldif

include: file://$ABS_SCHEMADIR/nis.ldif

EOF
	RC=$?
	if test $RC != 0 ; then
		echo "ldapadd failed ($RC)!"
		test $KILLSERVERS != no && kill -HUP $KILLPIDS
		exit $RC
	fi

	[ "$BACKENDTYPE" = mod ] || continue

	echo "Adding backend module on $uri..."
	$LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
dn: cn=module,cn=config
objectClass: olcModuleList
cn: module
olcModulePath: $TESTWD/../servers/slapd/back-$BACKEND
olcModuleLoad: back_$BACKEND.la

EOF
	RC=$?
	if test $RC != 0 ; then
		echo "ldapadd failed for backend module ($RC)!"
		test $KILLSERVERS != no && kill -HUP $KILLPIDS
		exit $RC
	fi
done

syncprov_module=''
[ "$AC_syncprov" = syncprovmod ] && syncprov_module="
dn: cn=module,cn=config
objectClass: olcModuleList
cn: module
olcModulePath: $TESTWD/../servers/slapd/overlays
olcModuleLoad: syncprov.la"

for uri in $PROV_URI; do
	echo "Adding database configuration on $uri"
	$LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
dn: olcDatabase={1}$BACKEND,cn=config
objectClass: olcDatabaseConfig
objectClass: olc${BACKEND}Config
olcDatabase: {1}$BACKEND
${nullExclude}olcDbDirectory: ./db
$olcDbCheckpoint: 1024 5
olcSuffix: $BASEDN
olcRootDN: $MANAGERDN
olcRootPW: $PASSWD

$syncprov_module

dn: olcOverlay={0}syncprov,olcDatabase={1}$BACKEND,cn=config
objectClass: olcOverlayConfig
objectClass: olcSyncProvConfig
olcOverlay: {0}syncprov
olcSpCheckpoint: 1 1

EOF
	RC=$?
	if test $RC != 0 ; then
		echo "ldapadd failed ($RC)!"
		test $KILLSERVERS != no && kill -HUP $KILLPIDS
		exit $RC
	fi

	echo "Populating provider on $uri"
	$LDAPADD -D "$MANAGERDN" -H $PROV_URI -w $PASSWD <<EOF >> $TESTOUT 2>&1
dn: $BASEDN
objectClass: top
objectClass: organization
objectClass: dcObject
dc: example
o: Example, Inc

EOF
	RC=$?
	if test $RC != 0 ; then
		echo "ldapadd failed ($RC)!"
		test $KILLSERVERS != no && kill -HUP $KILLPIDS
		exit $RC
	fi
done

for uri in $FWD1_URI; do
	echo "Adding database configuration on $uri"
	$LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
dn: olcDatabase={1}$BACKEND,cn=config
objectClass: olcDatabaseConfig
objectClass: olc${BACKEND}Config
olcDatabase: {1}$BACKEND
${nullExclude}olcDbDirectory: ./db
$olcDbCheckpoint: 1024 5
olcSuffix: $BASEDN
olcRootDN: $MANAGERDN
olcRootPW: $PASSWD
olcSyncRepl: rid=1 provider=$PROV_URI searchbase="$BASEDN"
  binddn="$MANAGERDN" bindmethod=simple credentials=$PASSWD
  type=refreshAndPersist retry="$RETRY" timeout=1

$syncprov_module

dn: olcOverlay={0}syncprov,olcDatabase={1}$BACKEND,cn=config
objectClass: olcOverlayConfig
objectClass: olcSyncProvConfig
olcOverlay: {0}syncprov
olcSpCheckpoint: 1 1

EOF
	RC=$?
	if test $RC != 0 ; then
		echo "ldapadd failed ($RC)!"
		test $KILLSERVERS != no && kill -HUP $KILLPIDS
		exit $RC
	fi
done

for uri in $CONS_URI; do
	echo "Adding database configuration on $uri"
	$LDAPADD -D cn=config -H $uri -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
dn: olcDatabase={1}$BACKEND,cn=config
objectClass: olcDatabaseConfig
objectClass: olc${BACKEND}Config
olcDatabase: {1}$BACKEND
${nullExclude}olcDbDirectory: ./db
$olcDbCheckpoint: 1024 5
olcSuffix: $BASEDN
olcRootDN: $MANAGERDN
olcRootPW: $PASSWD
olcSyncRepl: rid=1 provider=$FWD1_URI searchbase="$BASEDN"
  binddn="$MANAGERDN" bindmethod=simple credentials=$PASSWD
  type=refreshAndPersist retry="$RETRY" timeout=1

EOF
	RC=$?
	if test $RC != 0 ; then
		echo "ldapadd failed ($RC)!"
		test $KILLSERVERS != no && kill -HUP $KILLPIDS
		exit $RC
	fi
done

for uri in $FWD1_URI $CONS_URI; do
	echo "Using ldapsearch to check that $uri received database..."
	for i in 1 2 3 4 5; do
		$LDAPSEARCH -s base -b "$BASEDN" -H $uri \
			'objectclass=*' > /dev/null 2>&1
		RC=$?
		test $RC = 0 && break
		echo "Waiting $i seconds for slapd to receive database..."
		sleep $i
	done
	if test $RC != 0 ; then
		echo "ldapsearch failed ($RC)!"
		test $KILLSERVERS != no && kill -HUP $KILLPIDS
		exit $RC
	fi
done

RACE_NUM=0
ERROR=0

nEntries=10

addEnd=1
delEnd=1

addIdx=1
delIdx=1

while test $ERROR -eq 0 -a $RACE_NUM -lt $INITIATION_RACE_TESTS ; do
	RACE_NUM=`expr $RACE_NUM + 1`
	echo "Running $RACE_NUM of $INITIATION_RACE_TESTS syncrepl initiation race tests..."

	echo "Stopping forwarders for add test"
	for pid in $FWD1_PID; do
		kill -HUP $pid
		wait $pid
		KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $pid / /"`;
	done

	addStart=$addEnd
	addEnd=`expr $addEnd + $nEntries`

	echo "Using ldapadd to add $nEntries entries on provider"
	while test $addIdx -lt $addEnd; do
		$LDAPADD -D "$MANAGERDN" -H $PROV_URI -w $PASSWD <<EOF >> $TESTOUT 2>&1
dn: ou=$addIdx,$BASEDN
objectClass: top
objectClass: organizationalUnit
ou: $addIdx

EOF
		RC=$?
		if test $RC != 0 ; then
			echo "ldapadd failed for entry $addIdx ($RC)!"
			test $KILLSERVERS != no && kill -HUP $KILLPIDS
			exit $RC
		fi
		addIdx=`expr $addIdx + 1`
	done

	echo "Starting forwarders again"
	cd $FWD1_DIR
	$SLAPD -F slapd.d -h $FWD1_URI -d $LVL >> $FWD1_LOG 2>&1 &
	FWD1_PID=$!
	KILLPIDS="$KILLPIDS $FWD1_PID"
	cd $TESTWD

	addEnd=`expr $addEnd + $nEntries`

	echo "Using ldapadd to add $nEntries more entries on provider"
	while test $addIdx -lt $addEnd; do
		$LDAPADD -D "$MANAGERDN" -H $PROV_URI -w $PASSWD <<EOF >> $TESTOUT 2>&1
dn: ou=$addIdx,$BASEDN
objectClass: top
objectClass: organizationalUnit
ou: $addIdx

EOF
		RC=$?
		if test $RC != 0 ; then
			echo "ldapadd failed for entry $addIdx ($RC)!"
			test $KILLSERVERS != no && kill -HUP $KILLPIDS
			exit $RC
		fi
		addIdx=`expr $addIdx + 1`
	done

	for uri in $FWD1_URI $CONS_URI; do
		echo "Checking replication to $uri"
		RC=32
		i=$addStart
		while test $i -lt $addEnd; do
			for j in 1 2 3 4 5; do
				RESULT=`$LDAPSEARCH -H $uri -s base -b "ou=$i,$BASEDN" 2>&1 \
					| awk '/^dn:/ {print "OK"}'`
				if test "x$RESULT$nullOK" = "xOK" ; then
					RC=0
					break
				fi
				echo "Waiting $j seconds for $uri to receive entry $i..."
				sleep $j
			done
			if test $RC != 0 ; then
				echo "ERROR: Entry $i not replicated to $uri! ($RC)!"
				ERROR=1
				break
			fi
			i=`expr $i + 1`
		done
		if test $ERROR != 0; then break; fi
	done
	if test $ERROR != 0; then break; fi

	echo "Stopping forwarders for add/delete test"
	for pid in $FWD1_PID; do
		kill -HUP $pid
		wait $pid
		KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $pid / /"`;
	done

	addStart=$addEnd
	addEnd=`expr $addEnd + $nEntries`

	echo "Using ldapadd to add $nEntries entries on provider"
	while test $addIdx -lt $addEnd; do
		$LDAPADD -D "$MANAGERDN" -H $PROV_URI -w $PASSWD <<EOF >> $TESTOUT 2>&1
dn: ou=$addIdx,$BASEDN
objectClass: top
objectClass: organizationalUnit
ou: $addIdx

EOF
		RC=$?
		if test $RC != 0 ; then
			echo "ldapadd failed for entry $addIdx ($RC)!"
			test $KILLSERVERS != no && kill -HUP $KILLPIDS
			exit $RC
		fi
		addIdx=`expr $addIdx + 1`
	done

	delStart=$delEnd
	delEnd=`expr $delEnd + $nEntries`

	echo "Using ldapdelete to delete $nEntries entries on provider"
	while test $delIdx -lt $delEnd; do
		$LDAPDELETE -D "$MANAGERDN" -H $PROV_URI -w $PASSWD "ou=$delIdx,$BASEDN"
		RC=$?
		if test $RC != 0 ; then
			echo "ldapdelete failed ($RC)!"
			test $KILLSERVERS != no && kill -HUP $KILLPIDS
			exit 1
		fi
		delIdx=`expr $delIdx + 1`
	done

	echo "Starting forwarders again"
	cd $FWD1_DIR
	$SLAPD -F slapd.d -h $FWD1_URI -d $LVL >> $FWD1_LOG 2>&1 &
	FWD1_PID=$!
	KILLPIDS="$KILLPIDS $FWD1_PID"
	cd $TESTWD

	addEnd=`expr $addEnd + $nEntries`
	delEnd=`expr $delEnd + $nEntries`

	echo "Using ldapadd to add $nEntries more entries on provider"
	while test $addIdx -lt $addEnd; do
		$LDAPADD -D "$MANAGERDN" -H $PROV_URI -w $PASSWD <<EOF >> $TESTOUT 2>&1
dn: ou=$addIdx,$BASEDN
objectClass: top
objectClass: organizationalUnit
ou: $addIdx

EOF
		RC=$?
		if test $RC != 0 ; then
			echo "ldapadd failed for entry $addIdx ($RC)!"
			test $KILLSERVERS != no && kill -HUP $KILLPIDS
			exit $RC
		fi
		addIdx=`expr $addIdx + 1`
	done

	echo "Using ldapdelete to delete $nEntries more entries on provider"
	while test $delIdx -lt $delEnd; do
		$LDAPDELETE -D "$MANAGERDN" -H $PROV_URI -w $PASSWD "ou=$delIdx,$BASEDN"
		RC=$?
		if test $RC != 0 ; then
			echo "ldapdelete failed ($RC)!"
			test $KILLSERVERS != no && kill -HUP $KILLPIDS
			exit 1
		fi
		delIdx=`expr $delIdx + 1`
	done

	for uri in $FWD1_URI $CONS_URI; do
		echo "Checking replication to $uri"
		RC=32
		i=$addStart
		while test $i -lt $addEnd; do
			for j in 1 2 3 4 5; do
				RESULT=`$LDAPSEARCH -H $uri -s base -b "ou=$i,$BASEDN" 2>&1 \
					| awk '/^dn:/ {print "OK"}'`
				if test "x$RESULT$nullOK" = "xOK" ; then
					RC=0
					break
				fi
				echo "Waiting $j seconds for $uri to receive entry $i..."
				sleep $j
			done
			if test $RC != 0 ; then
				echo "ERROR: Entry $i not replicated to $uri! ($RC)!"
				ERROR=1
				break
			fi
			i=`expr $i + 1`
		done
		if test $ERROR != 0; then break; fi

		i=$delStart
		while test $i -lt $delEnd; do
			for j in 1 2 3 4 5; do
				$LDAPSEARCH -s base -b "ou=$i,$BASEDN" -H $uri > /dev/null 2>&1
				RC=$?
				if test $RC = $noObj; then break; fi
				echo "Waiting $j seconds for $uri to delete entry $i..."
				sleep $j
			done
			if test $RC != $noObj; then
				echo "ERROR: Entry $i not removed on $uri! (RC=$RC)"
				ERROR=1
				break
			fi
			i=`expr $i + 1`
		done	
		if test $ERROR != 0; then break; fi
	done
	if test $ERROR != 0; then break; fi

	echo "Stopping forwarders for delete test"
	for pid in $FWD1_PID; do
		kill -HUP $pid
		wait $pid
		KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $pid / /"`;
	done

	delStart=$delEnd
	delEnd=`expr $delEnd + $nEntries`

	echo "Using ldapdelete to delete entries on provider"
	while test $delIdx -lt $delEnd; do
		$LDAPDELETE -D "$MANAGERDN" -H $PROV_URI -w $PASSWD "ou=$delIdx,$BASEDN"
		RC=$?
		if test $RC != 0 ; then
			echo "ldapdelete failed ($RC)!"
			test $KILLSERVERS != no && kill -HUP $KILLPIDS
			exit 1
		fi
		delIdx=`expr $delIdx + 1`
	done

	echo "Starting forwarders again"
	cd $FWD1_DIR
	$SLAPD -F slapd.d -h $FWD1_URI -d $LVL >> $FWD1_LOG 2>&1 &
	FWD1_PID=$!
	KILLPIDS="$KILLPIDS $FWD1_PID"
	cd $TESTWD

	delEnd=`expr $delEnd + $nEntries`

	echo "Using ldapdelete to delete $nEntries more entries on provider"
	while test $delIdx -lt $delEnd; do
		$LDAPDELETE -D "$MANAGERDN" -H $PROV_URI -w $PASSWD "ou=$delIdx,$BASEDN"
		RC=$?
		if test $RC != 0 ; then
			echo "ldapdelete failed ($RC)!"
			test $KILLSERVERS != no && kill -HUP $KILLPIDS
			exit 1
		fi
		delIdx=`expr $delIdx + 1`
	done

	for uri in $FWD1_URI $CONS_URI; do
		echo "Checking replication to $uri"
		RC=0
		i=$delStart
		while test $i -lt $delEnd; do
			for j in 1 2 3 4 5; do
				$LDAPSEARCH -s base -b "ou=$i,$BASEDN" -H $uri > /dev/null 2>&1
				RC=$?
				if test $RC = $noObj; then break; fi
				echo "Waiting $j seconds for $uri to delete entry $i..."
				sleep $j
			done
			if test $RC != $noObj; then
				echo "ERROR: Entry $i not removed on $uri! (RC=$RC)"
				ERROR=1
				break
			fi
			i=`expr $i + 1`
		done	
		if test $ERROR != 0; then break; fi
	done
	if test $ERROR != 0; then break; fi

	sleep 1
	echo "Checking contextCSN"
	CSN_ERRORS=0
	CSN1=`$LDAPSEARCH -H $URI1 -b $BASEDN -s base contextCSN | grep contextCSN`
	CSN2=`$LDAPSEARCH -H $URI2 -b $BASEDN -s base contextCSN | grep contextCSN`
	CSN3=`$LDAPSEARCH -H $URI3 -b $BASEDN -s base contextCSN | grep contextCSN`

	if test -z "$CSN1" ; then
		test $BACKEND = null && break
		echo "ERROR: contextCSN empty on provider"
		ERROR=1
		break
	fi
	nCSN=`echo "$CSN1" | wc -l`
	if test "$nCSN" -ne 1 ; then
		echo "ERROR: Wrong contextCSN count on provider, should be 1"
		echo "$CSN1"
		test $KILLSERVERS != no && kill -HUP $KILLPIDS
		exit 1
	fi
	if  test -z "$CSN2" -o "$CSN1" != "$CSN2" ; then
		echo "ERROR: contextCSN mismatch between provider and consumer"
		echo "contextCSN on provider: $CSN1"
		echo "contextCSN on consumer: $CSN2"
		ERROR=1
		break
	fi
	if  test -z "$CSN3" -o "$CSN1" != "$CSN3" ; then
		echo "ERROR: contextCSN mismatch between provider and forward1"
		echo "contextCSN on provider: $CSN1"
		echo "contextCSN on forward1: $CSN3"
		ERROR=1
		break
	fi
done

test $KILLSERVERS != no && kill -HUP $KILLPIDS

if test $ERROR != 0; then
	echo "Error found after $RACE_NUM of $INITIATION_RACE_TESTS iterations"
	exit 1
else
	echo "No race errors found after $INITIATION_RACE_TESTS iterations"
fi

echo ">>>>> Test succeeded"

exit 0