3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2016 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
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>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test $SYNCPROV = syncprovno; then
20 echo "Syncrepl provider overlay not available, test skipped"
24 echo "This test tracks a case where a consumer fails to replicate from the provider"
25 echo "when the provider is dynamically configured for replication."
26 echo "See http://www.openldap.org/its/index.cgi/?findid=8521 for more information."
33 mkdir -p $TESTDIR $DBDIR1 $DBDIR2 $PRODIR $CONDIR $CFPRO $CFCON
35 $SLAPPASSWD -g -n >$CONFIGPWF
38 ITSDIR=$DATADIR/regressions/its$ITS
40 echo "Starting provider slapd on TCP/IP port $PORT1..."
41 . $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd-provider.ldif > $CONFLDIF
42 $SLAPADD -F $CFPRO -n 0 -l $CONFLDIF
43 $SLAPD -F $CFPRO -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
45 if test $WAIT != 0 ; then
53 echo "Using ldapsearch to check that provider slapd is running..."
54 for i in 0 1 2 3 4 5; do
55 $LDAPSEARCH -s base -b "" -H $URI1 \
56 'objectclass=*' > /dev/null 2>&1
58 if test $RC = 0 ; then
61 echo "Waiting 5 seconds for slapd to start..."
65 if test $RC != 0 ; then
66 echo "ldapsearch failed ($RC)!"
67 test $KILLSERVERS != no && kill -HUP $KILLPIDS
71 echo "Starting consumer slapd on TCP/IP port $PORT2..."
72 . $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd-consumer.ldif > $CONFLDIF
73 $SLAPADD -F $CFCON -n 0 -l $CONFLDIF
74 $SLAPD -F $CFCON -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
76 if test $WAIT != 0 ; then
77 echo SLAVEPID $SLAVEPID
80 KILLPIDS="$KILLPIDS $SLAVEPID"
84 echo "Using ldapsearch to check that consumer slapd is running..."
85 for i in 0 1 2 3 4 5; do
86 $LDAPSEARCH -s base -b "" -H $URI2 \
87 'objectclass=*' > /dev/null 2>&1
89 if test $RC = 0 ; then
92 echo "Waiting 5 seconds for slapd to start..."
96 if test $RC != 0 ; then
97 echo "ldapsearch failed ($RC)!"
98 test $KILLSERVERS != no && kill -HUP $KILLPIDS
102 echo "Setting serverID on provider..."
103 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
111 if test $RC != 0 ; then
112 echo "ldapmodify failed ($RC)!"
113 test $KILLSERVERS != no && kill -HUP $KILLPIDS
117 echo "Populating database on provider..."
118 $LDAPADD -D $MANAGERDN -H $URI1 -w $PASSWD << EOMODS >> $TESTOUT 2>&1
119 dn: dc=example,dc=com
125 dn: ou=LDAPRoles,dc=example,dc=com
127 objectClass: organizationalUnit
130 dn: dc=users,dc=example,dc=com
136 dn: cn=Johndoe,dc=users,dc=example,dc=com
143 dn: cn=replicator,ou=LDAPRoles,dc=example,dc=com
145 objectClass: simpleSecurityObject
146 objectClass: organizationalRole
152 if test $RC != 0 ; then
153 echo "ldapadd failed ($RC)!"
154 test $KILLSERVERS != no && kill -HUP $KILLPIDS
158 if [ "$SYNCPROV" = syncprovmod ]; then
159 echo "Configuring syncprov module on the provider..."
160 $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
161 dn: cn=module,cn=config
162 objectClass: olcModuleList
164 olcModulePath: $TESTWD/../servers/slapd/overlays
165 olcModuleLoad: syncprov.la
168 if test $RC != 0 ; then
169 echo "ldapadd failed for moduleLoad ($RC)!"
170 test $KILLSERVERS != no && kill -HUP $KILLPIDS
175 echo "Configuring replication on the provider..."
176 $LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
177 dn: olcOverlay=syncprov,olcDatabase={1}$BACKEND,cn=config
179 objectClass: olcOverlayConfig
180 objectClass: olcConfig
182 objectClass: olcSyncprovConfig
184 olcSpSessionLog: 10000
185 olcSpCheckpoint: 100 10
187 dn: olcDatabase={1}$BACKEND,cn=config
190 olcLimits: dn.exact="cn=replicator,ou=LDAPRoles,dc=example,dc=com"
191 time.soft=unlimited time.hard=unlimited size.soft=unlimited
194 dn: olcDatabase={1}$BACKEND,cn=config
197 olcAccess: {0}to dn.subtree="dc=example,dc=com" by self write
198 by dn.exact="cn=replicator,ou=LDAPRoles,dc=example,dc=com" read
199 by anonymous auth by * read
203 if test $RC != 0 ; then
204 echo "ldapmodify failed ($RC)!"
205 test $KILLSERVERS != no && kill -HUP $KILLPIDS
209 echo "Configuring replication on the consumer..."
210 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1
211 dn: olcDatabase={1}$BACKEND,cn=config
214 olcSyncrepl: rid=100 provider=$URI1 bindmethod=simple
215 binddn="cn=replicator,ou=LDAPRoles,dc=example,dc=com" credentials=secret
216 type=refreshOnly searchbase="dc=example,dc=com" filter="(objectclass=*)"
217 scope=sub schemachecking=on retry="5 10 60 +" sizeLimit=unlimited
223 if test $RC != 0 ; then
224 echo "ldapmodify failed for olcSyncrepl configuration ($RC)!"
225 test $KILLSERVERS != no && kill -HUP $KILLPIDS
229 #### See if restarting provider makes any differnce (It doesn't) ####
230 echo "Stopping provider to test recovery..."
234 echo "Restarting provider..."
235 echo "RESTART" >> $LOG1
236 $SLAPD -F $CFPRO -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
238 if test $WAIT != 0 ; then
242 KILLPIDS="$PID $SLAVEPID"
246 echo "Using ldapsearch to check that provider slapd is running..."
247 for i in 0 1 2 3 4 5; do
248 $LDAPSEARCH -s base -b "" -H $URI1 \
249 'objectclass=*' > /dev/null 2>&1
251 if test $RC = 0 ; then
254 echo "Waiting 5 seconds for slapd to start..."
258 if test $RC != 0 ; then
259 echo "ldapsearch failed ($RC)!"
260 test $KILLSERVERS != no && kill -HUP $KILLPIDS
264 #### END TEST LINES ####
266 #### See if restarting consumer makes any differnce (It doesn't) ####
267 echo "Stopping consumer to test recovery..."
271 echo "Restarting consumer..."
272 echo "RESTART" >> $LOG2
273 $SLAPD -F $CFCON -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
275 if test $WAIT != 0 ; then
276 echo SLAVEPID $SLAVEPID
279 KILLPIDS="$PID $SLAVEPID"
283 echo "Using ldapsearch to check that consumer slapd is running..."
284 for i in 0 1 2 3 4 5; do
285 $LDAPSEARCH -s base -b "" -H $URI2 \
286 'objectclass=*' > /dev/null 2>&1
288 if test $RC = 0 ; then
291 echo "Waiting 5 seconds for slapd to start..."
295 if test $RC != 0 ; then
296 echo "ldapsearch failed ($RC)!"
297 test $KILLSERVERS != no && kill -HUP $KILLPIDS
301 echo "Sleeping 30 seconds to allow replication to initiate..."
303 #### END TEST LINES ####
305 echo "Using ldapsearch to read all the entries from the provider..."
306 $LDAPSEARCH -S "" -D $MANAGERDN -w $PASSWD -b "$BASEDN" -H $URI1 \
307 '(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1
310 if test $RC != 0 ; then
311 echo "ldapsearch failed at provider ($RC)!"
312 test $KILLSERVERS != no && kill -HUP $KILLPIDS
316 echo "Using ldapsearch to read all the entries from the consumer..."
317 $LDAPSEARCH -S "" -D $MANAGERDN -w $PASSWD -b "$BASEDN" -H $URI2 \
318 '(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1
321 if test $RC != 0 ; then
322 echo "ldapsearch failed at consumer ($RC)!"
323 test $KILLSERVERS != no && kill -HUP $KILLPIDS
327 test $KILLSERVERS != no && kill -HUP $KILLPIDS
329 echo "Filtering provider results..."
330 $LDIFFILTER < $MASTEROUT > $MASTERFLT
331 echo "Filtering consumer results..."
332 $LDIFFILTER < $SLAVEOUT > $SLAVEFLT
334 echo "Comparing retrieved entries from provider and consumer..."
335 $CMP $MASTERFLT $SLAVEFLT > $CMPOUT
337 if test $? != 0 ; then
338 echo "test failed - provider and consumer databases differ"
343 echo ">>>>> Test succeeded"
345 test $KILLSERVERS != no && wait