]> git.sur5r.net Git - openldap/blob - tests/data/regressions/its8752/its8752
c851f561c1e642724ceb359a99f22390cd91b5f5
[openldap] / tests / data / regressions / its8752 / its8752
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2017 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 $BACKEND = ldif ; then
28         echo "$BACKEND backend unsuitable, test skipped"
29         exit 0
30 fi
31
32 dtest=`date +%N|sed s/...$//`
33
34 if test $dtest = N; then
35         echo "nanosecond date values not supported, test skipped"
36         exit 0
37 fi
38
39 echo "This test tracks a case where slapd deadlocks during a significant write load"
40 echo "See http://www.openldap.org/its/index.cgi/?findid=8752 for more information."
41
42 MMR=4
43 XDIR=$TESTDIR/srv
44
45 mkdir -p $TESTDIR
46
47 ITS=8752
48 ITSDIR=$DATADIR/regressions/its$ITS
49
50 n=1
51 while [ $n -le $MMR ]; do
52         DBDIR=${XDIR}$n/db
53         mkdir -p ${XDIR}$n $DBDIR.1 $DBDIR.2
54         n=`expr $n + 1`
55 done
56
57 KILLPIDS=
58
59 echo "Starting slapd on TCP/IP port $PORT1..."
60 . $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd.conf > $CONF1
61 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
62 PID=$!
63 if test $WAIT != 0 ; then
64         echo PID $PID
65         read foo
66 fi
67 KILLPIDS="$PID"
68
69 sleep 1
70
71 echo "Using ldapsearch to check that slapd is running..."
72 for i in 0 1 2 3 4 5; do
73         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
74                 'objectclass=*' > /dev/null 2>&1
75         RC=$?
76         if test $RC = 0 ; then
77                 break
78         fi
79         echo "Waiting 5 seconds for slapd to start..."
80         sleep 5
81 done
82
83 if test $RC != 0 ; then
84         echo "ldapsearch failed ($RC)!"
85         test $KILLSERVERS != no && kill -HUP $KILLPIDS
86         exit $RC
87 fi
88
89 echo "Populating database on first provider..."
90 $LDAPADD -D $MANAGERDN -H $URI1 -w $PASSWD << EOMODS >> $TESTOUT 2>&1
91 dn: $BASEDN
92 objectClass: organization
93 objectClass: dcObject
94 o: Example, Inc.
95 dc: example
96
97 dn: ou=People,$BASEDN
98 objectClass: organizationalUnit
99 ou: People
100
101 dn: ou=Groups,$BASEDN
102 objectClass: organizationalUnit
103 ou: Groups
104
105 dn: cn=Roger Rabbit,ou=People,$BASEDN
106 objectClass: inetOrgPerson
107 cn: Roger Rabbit
108 sn: Rabbit
109
110 dn: cn=Baby Herman,ou=People,$BASEDN
111 objectClass: inetOrgPerson
112 cn: Baby Herman
113 sn: Herman
114
115 dn: cn=Jessica_Rabbit,ou=People,$BASEDN
116 objectClass: inetOrgPerson
117 cn: Jessica_Rabbit
118 sn: Rabbit
119
120 dn: cn=Bugs_Bunny,ou=People,$BASEDN
121 objectClass: inetOrgPerson
122 cn: Bugs_Bunny
123 sn: Bunny
124
125 dn: cn=Daffy_Duck,ou=People,$BASEDN
126 objectClass: inetOrgPerson
127 cn: Daffy_Duck
128 sn: Duck
129
130 dn: cn=Elmer_Fudd,ou=People,$BASEDN
131 objectClass: inetOrgPerson
132 cn: Elmer_Fudd
133 sn: Fudd
134
135 dn: cn=Cartoonia,ou=Groups,$BASEDN
136 objectClass: groupOfNames
137 cn: Cartoonia
138 member: cn=Roger Rabbit,ou=People,$BASEDN
139 member: cn=Baby Herman,ou=People,$BASEDN
140 EOMODS
141
142 RC=$?
143
144 if test $RC != 0 ; then
145         echo "ldapadd failed ($RC)!"
146         test $KILLSERVERS != no && kill -HUP $KILLPIDS
147         exit $RC
148 fi
149
150 echo "Stopping slapd and reworking configuration for MMR..."
151
152 test $KILLSERVERS != no && kill -HUP $KILLPIDS
153
154 KILLPIDS=
155 n=1
156 while [ $n -le $MMR ]; do
157         MYURI=`eval echo '$URI'$n`
158         MYLOG=`eval echo '$LOG'$n`
159         MYCONF=`eval echo '$CONF'$n`
160         echo "Starting provider slapd on TCP/IP URI $MYURI"
161         . $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd.conf.mmr > $CONF
162         sed -e "s/MMR/$n/g" $CONF > $MYCONF
163         j=1
164         while [ $j -le $MMR ]; do
165                 MMCURI=`eval echo '$URI'$j`
166                 sed -e "s|MMC${j}|${MMCURI}|" $MYCONF > $CONF
167                 mv $CONF $MYCONF
168                 j=`expr $j + 1`
169         done
170         if [ -f $CONF ]; then
171                 rm -f $CONF
172         fi
173         $SLAPD -f $MYCONF -h $MYURI  -d $LVL $TIMING > $MYLOG 2>&1 &
174         PID=$!
175         if test $WAIT != 0 ; then
176                 echo PID $PID
177                 read foo
178         fi
179         KILLPIDS="$PID $KILLPIDS"
180         sleep 1
181
182         echo "Using ldapsearch to check that provider slapd is running..."
183         for i in 0 1 2 3 4 5; do
184                 $LDAPSEARCH -s base -b "" -H $MYURI \
185                         'objectclass=*' > /dev/null 2>&1
186                 RC=$?
187                 if test $RC = 0 ; then
188                         break
189                 fi
190                 echo "Waiting 5 seconds for slapd to start..."
191                 sleep 5
192         done
193         
194         if test $RC != 0 ; then
195                 echo "ldapsearch failed ($RC)!"
196                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
197                 exit $RC
198         fi
199         n=`expr $n + 1`
200 done
201
202 echo "Setting up accesslog on each master..."
203 n=1
204 while [ $n -le $MMR ]; do
205         echo "Modifying dn: cn=Elmer_Fudd,ou=People,dc=example,dc=com on master $n"
206         MYURI=`eval echo '$URI'$n`
207         $LDAPMODIFY -v -D "$MANAGERDN" -H $MYURI -w $PASSWD > \
208                 $TESTOUT 2>&1 << EOMODS
209
210 dn: cn=Elmer_Fudd,ou=People,$BASEDN
211 changetype: modify
212 replace: sn
213 sn: Fudd
214 EOMODS
215         sleep 5
216         n=`expr $n + 1`
217 done
218
219 echo "Sleeping 30 seconds to ensure replication is reconciled between all nodes"
220 echo "The next step of the test will perform 20000 random write operations and may take some time."
221 echo "As this test is for a deadlock, it will take manual intervention to exit the test if one occurs."
222 sleep 30
223
224 echo "Starting random master/entry modifications..."
225 DN1="cn=Elmer_Fudd,ou=People,$BASEDN"
226 VAL1="Fudd"
227
228 DN2="cn=Jessica_Rabbit,ou=People,$BASEDN"
229 VAL2="Rabbit"
230
231 DN3="cn=Bugs_Bunny,ou=People,$BASEDN"
232 VAL3="Bunny"
233
234 DN4="cn=Daffy_Duck,ou=People,$BASEDN"
235 VAL4="Duck"
236
237 n=1
238 while [ $n -le 20000 ]; do
239         seed=`date +%N|sed s/...$//`
240         rvalue=`echo|awk "BEGIN {srand($seed)
241 {print int(1+rand()*4)}}"`
242         MYURI=`eval echo '$URI'$rvalue`
243         seed=`date +%N|sed s/...$//`
244         rvalue=`echo|awk "BEGIN {srand($seed)
245 {print int(1+rand()*4)}}"`
246         MYDN=`eval echo '$DN'$rvalue`
247         MYVAL=`eval echo '$VAL'$rvalue`
248         echo "Modifying $MYURI entry $MYDN with value $MYVAL iteration $n of 20000"
249         $LDAPMODIFY -v -D "$MANAGERDN" -H $MYURI -w $PASSWD > \
250                 $TESTOUT 2>&1 << EOMODS
251
252 dn: $MYDN
253 changetype: modify
254 replace: sn
255 sn: $MYVAL
256 EOMODS
257         n=`expr $n + 1`
258 done
259
260 test $KILLSERVERS != no && kill -HUP $KILLPIDS
261
262 echo ">>>>> Test succeeded"
263
264 test $KILLSERVERS != no && wait
265
266 exit 0