its8521 8.63 KB
Newer Older
1
2
3
4
#! /bin/sh
# $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
##
Quanah Gibson-Mount's avatar
Quanah Gibson-Mount committed
5
## Copyright 1998-2020 The OpenLDAP Foundation.
6
7
8
9
10
11
12
13
14
15
## 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>.

16
echo "This test is no longer valid after the fixes in ITS#9015"
17
echo "https://bugs.openldap.org/show_bug.cgi?id=9015"
18
19
exit 0

20
21
22
23
24
25
26
27
echo "running defines.sh"
. $SRCDIR/scripts/defines.sh

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

28
29
30
echo ""
echo "  This test tracks a case where a consumer fails to replicate from the provider"
echo "  when the provider is dynamically configured for replication."
31
32
echo "  See https://bugs.openldap.org/show_bug.cgi?id=8521 and"
echo "  See https://bugs.openldap.org/show_bug.cgi?id=8281 for more information."
33
echo ""
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

PRODIR=$TESTDIR/pro
CONDIR=$TESTDIR/con1
CFPRO=$PRODIR/slapd.d
CFCON=$CONDIR/slapd.d

mkdir -p $TESTDIR $DBDIR1 $DBDIR2 $PRODIR $CONDIR $CFPRO $CFCON

$SLAPPASSWD -g -n >$CONFIGPWF

ITS=8521
ITSDIR=$DATADIR/regressions/its$ITS

echo "Starting provider slapd on TCP/IP port $PORT1..."
. $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd-provider.ldif > $CONFLDIF
$SLAPADD -F $CFPRO -n 0 -l $CONFLDIF
$SLAPD -F $CFPRO -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
PID=$!
if test $WAIT != 0 ; then
	echo PID $PID
	read foo
fi
KILLPIDS="$PID"

sleep 1

echo "Using ldapsearch to check that provider slapd is running..."
for i in 0 1 2 3 4 5; do
	$LDAPSEARCH -s base -b "" -H $URI1 \
		'objectclass=*' > /dev/null 2>&1
	RC=$?
	if test $RC = 0 ; then
		break
	fi
	echo "Waiting 5 seconds for slapd to start..."
	sleep 5
done

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

echo "Starting consumer slapd on TCP/IP port $PORT2..."
. $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd-consumer.ldif > $CONFLDIF
$SLAPADD -F $CFCON -n 0 -l $CONFLDIF
$SLAPD -F $CFCON -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
SLAVEPID=$!
if test $WAIT != 0 ; then
	echo SLAVEPID $SLAVEPID
	read foo
fi
KILLPIDS="$KILLPIDS $SLAVEPID"

sleep 1

echo "Using ldapsearch to check that consumer slapd is running..."
for i in 0 1 2 3 4 5; do
	$LDAPSEARCH -s base -b "" -H $URI2 \
		'objectclass=*' > /dev/null 2>&1
	RC=$?
	if test $RC = 0 ; then
		break
	fi
	echo "Waiting 5 seconds for slapd to start..."
	sleep 5
done

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

echo "Setting serverID on provider..."
$LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
dn: cn=config
changetype: modify
add: olcServerId
olcServerId: 1
EOF
RC=$?

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

echo "Populating database on provider..."
$LDAPADD -D $MANAGERDN -H $URI1 -w $PASSWD << EOMODS >> $TESTOUT 2>&1
dn: dc=example,dc=com
changetype: add
objectClass: domain
objectClass: top
dc: example

dn: ou=LDAPRoles,dc=example,dc=com
objectClass: top
objectClass: organizationalUnit
ou: LDAPRoles

dn: dc=users,dc=example,dc=com
changetype: add
dc: users
objectClass: domain
objectClass: top

143
dn: uid=johndoe,dc=users,dc=example,dc=com
144
changetype: add
145
objectClass: inetOrgPerson
146
objectClass: top
147
sn: Doe
148
cn: Johndoe
149
uid: johndoe
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

dn: cn=replicator,ou=LDAPRoles,dc=example,dc=com
objectClass: top
objectClass: simpleSecurityObject
objectClass: organizationalRole
userPassword: secret
cn: replicator
EOMODS

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

if [ "$SYNCPROV" = syncprovmod ]; then
	echo "Configuring syncprov module on the provider..."
	$LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
dn: cn=module,cn=config
objectClass: olcModuleList
cn: module
olcModulePath: $TESTWD/../servers/slapd/overlays
olcModuleLoad: syncprov.la
EOF
	RC=$?
	if test $RC != 0 ; then
		echo "ldapadd failed for moduleLoad ($RC)!"
		test $KILLSERVERS != no && kill -HUP $KILLPIDS
		exit $RC
	fi
fi

echo "Configuring replication on the provider..."
$LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
dn: olcOverlay=syncprov,olcDatabase={1}$BACKEND,cn=config
changetype: add
objectClass: olcOverlayConfig
objectClass: olcConfig
objectClass: top
objectClass: olcSyncprovConfig
olcOverlay: syncprov
olcSpSessionLog: 10000
olcSpCheckpoint: 100 10

dn: olcDatabase={1}$BACKEND,cn=config
changetype: modify
add: olcLimits
olcLimits: dn.exact="cn=replicator,ou=LDAPRoles,dc=example,dc=com"
  time.soft=unlimited time.hard=unlimited size.soft=unlimited
  size.hard=unlimited

dn: olcDatabase={1}$BACKEND,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to dn.subtree="dc=example,dc=com"  by self write
  by dn.exact="cn=replicator,ou=LDAPRoles,dc=example,dc=com" read
  by anonymous auth by * read
EOF

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

echo "Configuring replication on the consumer..."
$LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
dn: olcDatabase={1}$BACKEND,cn=config
changetype: modify
add: olcSyncrepl
olcSyncrepl: rid=100 provider=$URI1 bindmethod=simple
  binddn="cn=replicator,ou=LDAPRoles,dc=example,dc=com" credentials=secret
224
225
  type=refreshAndPersist searchbase="dc=example,dc=com" filter="(objectclass=*)"
  scope=sub schemachecking=on interval=5 retry="5 +" sizeLimit=unlimited
226
227
228
229
230
231
232
233
234
235
236
  timelimit=unlimited
-

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

237
echo "Sleeping 10 seconds to allow replication to initiate..."
238
239
sleep 10

240
241
242
243
echo "Using ldapsearch to read all the entries from the provider..."
$LDAPSEARCH -S "" -D $MANAGERDN -w $PASSWD -b "$BASEDN" -H $URI1 \
        '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
RC=$?
244
245

if test $RC != 0 ; then
246
247
248
        echo "ldapsearch failed at provider ($RC)!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
        exit $RC
249
250
fi

251
252
253
254
echo "Using ldapsearch to read all the entries from the consumer..."
$LDAPSEARCH -S "" -D $MANAGERDN -w $PASSWD -b "$BASEDN" -H $URI2 \
        '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
RC=$?
255

256
257
if test $RC != 32 ; then
        echo "ldapsearch should have failed with error 32.  Got $RC instead!"
258
259
260
	echo "This is a regression of ITS8281"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
        exit $RC
261
262
263
fi


264
265
266
267
echo "Filtering provider results..."
$LDIFFILTER < $MASTEROUT > $MASTERFLT
echo "Filtering consumer results..."
$LDIFFILTER < $SLAVEOUT > $SLAVEFLT
268

269
270
271
echo "Comparing retrieved entries from provider and consumer..."
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT

Quanah Gibson-Mount's avatar
Quanah Gibson-Mount committed
272
if test $? = 0 ; then
273
274
        echo "test failed - provider and consumer databases match"
	echo "This is a regression of ITS8281"
275
	test $KILLSERVERS != no && kill -HUP $KILLPIDS
276
        exit 1
277
278
fi

279
280
281
282
283
284
285
286
287
288
echo "Modifying provider to force generation of a contextCSN"
$LDAPMODIFY -v -D "$MANAGERDN" -H $URI1 -w $PASSWD > \
        $TESTOUT 2>&1 << EOMODS
dn: uid=Johndoe,dc=users,dc=example,dc=com
changetype: modify
replace: cn
cn: John Doe
EOMODS

echo "Sleeping 30 seconds to allow consumer to reconnect and replicate..."
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
sleep 30

echo "Using ldapsearch to read all the entries from the provider..."
$LDAPSEARCH -S "" -D $MANAGERDN -w $PASSWD -b "$BASEDN" -H $URI1 \
        '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
RC=$?

if test $RC != 0 ; then
        echo "ldapsearch failed at provider ($RC)!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
        exit $RC
fi

echo "Using ldapsearch to read all the entries from the consumer..."
$LDAPSEARCH -S "" -D $MANAGERDN -w $PASSWD -b "$BASEDN" -H $URI2 \
        '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
RC=$?

if test $RC != 0 ; then
        echo "ldapsearch failed at consumer ($RC)!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
        exit $RC
fi


echo "Filtering provider results..."
$LDIFFILTER < $MASTEROUT > $MASTERFLT
echo "Filtering consumer results..."
$LDIFFILTER < $SLAVEOUT > $SLAVEFLT

echo "Comparing retrieved entries from provider and consumer..."
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT

if test $? != 0 ; then
        echo "test failed - provider and consumer databases differ"
324
	test $KILLSERVERS != no && kill -HUP $KILLPIDS
325
326
327
        exit 1
fi

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

330
331
332
333
334
335
echo
echo ">>>>> Test succeeded"

test $KILLSERVERS != no && wait

exit 0