]> git.sur5r.net Git - openldap/blob - tests/data/regressions/its8444/its8444
Happy New Year
[openldap] / tests / data / regressions / its8444 / its8444
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2018 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
11 ##
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>.
15
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 if test $SYNCPROV = syncprovno; then
20         echo "Syncrepl provider overlay not available, test skipped"
21         exit 0
22 fi
23 if test $ACCESSLOG = accesslogno; then
24         echo "Accesslog overlay not available, test skipped"
25         exit 0
26 fi
27 if test $DYNLIST = dynlistno; then
28         echo "Accesslog overlay not available, test skipped"
29         exit 0
30 fi
31 if test $MEMBEROF = memberofno; then
32         echo "Memberof overlay not available, test skipped"
33         exit 0
34 fi
35 if test $BACKEND = ldif ; then
36         # Onelevel search does not return entries in order of creation or CSN.
37         echo "$BACKEND backend unsuitable for syncprov logdb, test skipped"
38         exit 0
39 fi
40
41 echo "This test tracks a case where changes are incorrectly skipped"
42 echo "See http://www.openldap.org/its/index.cgi/?findid=8444 for more information."
43
44 MMR=4
45 XDIR=$TESTDIR/srv
46
47 mkdir -p $TESTDIR
48
49 $SLAPPASSWD -g -n >$CONFIGPWF
50
51 ITS=8444
52 ITSDIR=$DATADIR/regressions/its$ITS
53
54 echo "Initializing server configurations..."
55
56 n=1
57 while [ $n -le $MMR ]; do
58         DBDIR=${XDIR}$n/db
59         CFDIR=${XDIR}$n/slapd.d
60
61         mkdir -p ${XDIR}$n $DBDIR.1 $DBDIR.2 $CFDIR
62         . $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd-provider${n}.ldif > $CONFLDIF
63         $SLAPADD -F $CFDIR -n 0 -l $CONFLDIF
64         n=`expr $n + 1`
65 done
66
67 KILLPIDS=
68 n=1
69 while [ $n -le $MMR ]; do
70         MYURI=`eval echo '$URI'$n`
71         MYLOG=`eval echo '$LOG'$n`
72         CFDIR=${XDIR}$n/slapd.d
73
74         echo "Starting provider slapd on TCP/IP URI $MYURI"
75         $SLAPD -F $CFDIR -h $MYURI -d $LVL $TIMING > $MYLOG 2>&1 &
76
77         PID=$!
78         if test $WAIT != 0 ; then
79                 echo PID $PID
80                 read foo
81         fi
82         KILLPIDS="$PID $KILLPIDS"
83         sleep 1
84
85         echo "Using ldapsearch to check that provider slapd is running..."
86         for i in 0 1 2 3 4 5; do
87                 $LDAPSEARCH -s base -b "" -H $MYURI \
88                         'objectclass=*' > /dev/null 2>&1
89                 RC=$?
90                 if test $RC = 0 ; then
91                         break
92                 fi
93                 echo "Waiting 5 seconds for slapd to start..."
94                 sleep 5
95         done
96
97         if test $RC != 0 ; then
98                 echo "ldapsearch failed ($RC)!"
99                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
100                 exit $RC
101         fi
102         n=`expr $n + 1`
103 done
104
105 echo "Populating database on first provider..."
106 $LDAPADD -D $MANAGERDN -H $URI1 -w $PASSWD << EOMODS >> $TESTOUT 2>&1
107 dn: $BASEDN
108 objectClass: organization
109 objectClass: dcObject
110 o: Example, Inc.
111 dc: example
112
113 dn: ou=People,$BASEDN
114 objectClass: organizationalUnit
115 ou: People
116
117 dn: ou=Groups,$BASEDN
118 objectClass: organizationalUnit
119 ou: Groups
120
121 dn: cn=Roger Rabbit,ou=People,$BASEDN
122 objectClass: inetOrgPerson
123 cn: Roger Rabbit
124 sn: Rabbit
125
126 dn: cn=Baby Herman,ou=People,$BASEDN
127 objectClass: inetOrgPerson
128 cn: Baby Herman
129 sn: Herman
130
131 dn: cn=Jessica_Rabbit,ou=People,$BASEDN
132 objectClass: inetOrgPerson
133 cn: Jessica_Rabbit
134 sn: Rabbit
135
136 dn: cn=Bugs_Bunny,ou=People,$BASEDN
137 objectClass: inetOrgPerson
138 cn: Bugs_Bunny
139 sn: Bunny
140
141 dn: cn=Daffy_Duck,ou=People,$BASEDN
142 objectClass: inetOrgPerson
143 cn: Daffy_Duck
144 sn: Duck
145
146 dn: cn=Elmer_Fudd,ou=People,$BASEDN
147 objectClass: inetOrgPerson
148 cn: Elmer_Fudd
149 sn: Fudd
150
151 dn: cn=Cartoonia,ou=Groups,$BASEDN
152 objectClass: groupOfNames
153 cn: Cartoonia
154 member: cn=Roger Rabbit,ou=People,$BASEDN
155 member: cn=Baby Herman,ou=People,$BASEDN
156 EOMODS
157
158 RC=$?
159 if test $RC != 0 ; then
160         echo "ldapadd failed ($RC)!"
161         test $KILLSERVERS != no && kill -HUP $KILLPIDS
162         exit $RC
163 fi
164
165 echo "Sleeping 10 seconds to allow replication to initiate..."
166 sleep 10
167
168 echo "Looping 50 times adding and deleting members to the Cartoonia group..."
169 modloop=1
170 while [ $modloop -le 50 ]; do
171         echo "Adding new members to the group (${modloop}/50)..."
172         $LDAPMODIFY -H $URI1 \
173                 -D "cn=Manager,$BASEDN" -w $PASSWD \
174                 >> $TESTOUT 2>&1 << EOF
175 dn: cn=Cartoonia,ou=Groups,$BASEDN
176 changetype: modify
177 add: member
178 member: cn=Jessica_Rabbit,ou=People,$BASEDN
179 member: cn=Elmer_Fudd,ou=People,$BASEDN
180 member: cn=Daffy_Duck,ou=People,$BASEDN
181 member: cn=Bugs_Bunny,ou=People,$BASEDN
182 EOF
183
184         sleep 3
185         
186         echo "Deleting new members from the group..."
187         $LDAPMODIFY -H $URI1 \
188                 -D "cn=Manager,$BASEDN" -w $PASSWD \
189                 >> $TESTOUT 2>&1 << EOF
190 dn: cn=Cartoonia,ou=Groups,$BASEDN
191 changetype: modify
192 delete: member
193 member: cn=Jessica_Rabbit,ou=People,$BASEDN
194 member: cn=Elmer_Fudd,ou=People,$BASEDN
195 member: cn=Daffy_Duck,ou=People,$BASEDN
196 member: cn=Bugs_Bunny,ou=People,$BASEDN
197 EOF
198         sleep 3
199
200         echo "Searching new members to see if they still have memberOf present..."
201         TOON1="cn=Jessica_Rabbit,ou=People,$BASEDN"
202         TOON2="cn=Elmer_Fudd,ou=People,$BASEDN"
203         TOON3="cn=Daffy_Duck,ou=People,$BASEDN"
204         TOON4="cn=Bugs_Bunny,ou=People,$BASEDN"
205         for member in $TOON1 $TOON2 $TOON3 $TOON4; do
206                 n=1
207                 while [ $n -le $MMR ]; do
208                         >$SEARCHOUT
209                         echo "# Searching member $member after removal from Cartoonia group, provider $n" >> $SEARCHOUT
210                         MYURI=`eval echo '$URI'$n`
211                         $LDAPSEARCH -S "" -b "$member" -s base -H $MYURI -D "cn=manager,$BASEDN" -w $PASSWD \
212                                 '(objectClass=*)' 'memberOf' >> $SEARCHOUT 2>&1
213                         RC=$?
214                         if test $RC != 0 ; then
215                                 echo "ldapsearch failed ($RC)!"
216                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
217                                 exit $RC
218                         fi
219                         grep "memberOf:" $SEARCHOUT >/dev/null 2>&1
220                         RC=$?
221                         
222                         if test $RC != 1 ; then
223                                 echo "User delete failed on one or more consumer."
224                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
225                                 exit $RC
226                         fi
227                         n=`expr $n + 1`
228                 done
229         done
230         modloop=`expr $modloop + 1`
231 done
232
233 echo "Looping 50 times deleting and adding Cartoonia group..."
234 modloop=1
235 while [ $modloop -le 50 ]; do
236         >$SEARCHOUT
237         echo "Running ldapdelete to remove a group (${modloop}/50)..."
238         $LDAPMODIFY -H $URI1 \
239                 -D "cn=Manager,$BASEDN" -w $PASSWD \
240                 >> $TESTOUT 2>&1 << EOF
241 dn: cn=Cartoonia,ou=Groups,$BASEDN
242 changetype: delete
243 EOF
244
245         sleep 3
246
247         echo "Searching entire database on each provider after deleting Cartoonia group"
248
249         n=1
250         while [ $n -le $MMR ]; do
251                 echo "# Searching the entire database after deleting Cartoonia, provider $n" >> $SEARCHOUT
252                 MYURI=`eval echo '$URI'$n`
253                 $LDAPSEARCH -S "" -b "$BASEDN" -H $MYURI -D "cn=manager,$BASEDN" -w $PASSWD \
254                         '(objectClass=*)' '*' >> $SEARCHOUT 2>&1
255                 RC=$?
256                 if test $RC != 0 ; then
257                         echo "ldapsearch failed ($RC)!"
258                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
259                         exit $RC
260                 fi
261                 n=`expr $n + 1`
262         done
263
264         grep "cn=Cartoonia" $SEARCHOUT >/dev/null 2>&1
265         RC=$?
266
267         if test $RC != 1 ; then
268                 echo "Group delete failed on one or more consumer."
269                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
270                 exit $RC
271         fi
272
273         echo "Running ldapmodify to add the group back..."
274         $LDAPMODIFY -H $URI1 \
275                 -D "cn=Manager,$BASEDN" -w $PASSWD \
276                 >> $TESTOUT 2>&1 <<EOF
277 dn: cn=Cartoonia,ou=Groups,$BASEDN
278 changetype: add
279 objectClass: groupOfNames
280 cn: Cartoonia
281 member: cn=Roger Rabbit,ou=People,$BASEDN
282 member: cn=Baby Herman,ou=People,$BASEDN
283 EOF
284
285         sleep 3
286
287         echo "Searching entire database on each provider after re-adding Cartoonia group"
288
289         n=1
290         while [ $n -le $MMR ]; do
291                 >$SEARCHOUT
292                 echo "# Searching the entire database after re-adding Cartoonia, provider $n" >> $SEARCHOUT
293                 MYURI=`eval echo '$URI'$n`
294                 $LDAPSEARCH -S "" -b "$BASEDN" -H $MYURI -D "cn=manager,$BASEDN" -w $PASSWD \
295                         '(objectClass=*)' '*' memberOf>> $SEARCHOUT 2>&1
296                 RC=$?
297                 if test $RC != 0 ; then
298                         echo "ldapsearch failed ($RC)!"
299                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
300                         exit $RC
301                 fi
302                 grep "memberOf:" $SEARCHOUT >/dev/null 2>&1
303                 RC=$?
304                 
305                 if test $RC != 0 ; then
306                         echo "Group add failed on one or more consumer."
307                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
308                         exit $RC
309                 fi
310
311                 n=`expr $n + 1`
312         done
313         modloop=`expr $modloop + 1`
314 done
315
316 test $KILLSERVERS != no && kill -HUP $KILLPIDS
317
318 echo ">>>>> Test succeeded"
319
320 test $KILLSERVERS != no && wait
321
322 exit 0