]> git.sur5r.net Git - openldap/blob - tests/data/regressions/its8752/its8752
Wait for slapd to stop before proceeding. Otherwise this test may fail.
[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 wait $KILLPIDS
154
155 KILLPIDS=
156 n=1
157 while [ $n -le $MMR ]; do
158         MYURI=`eval echo '$URI'$n`
159         MYLOG=`eval echo '$LOG'$n`
160         MYCONF=`eval echo '$CONF'$n`
161         echo "Starting provider slapd on TCP/IP URI $MYURI"
162         . $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd.conf.mmr > $TESTDIR/slapd.conf
163         sed -e "s/MMR/$n/g" $TESTDIR/slapd.conf > $MYCONF
164         j=1
165         while [ $j -le $MMR ]; do
166                 MMCURI=`eval echo '$URI'$j`
167                 sed -e "s|MMC${j}|${MMCURI}|" $MYCONF > $TESTDIR/slapd.conf
168                 mv $TESTDIR/slapd.conf $MYCONF
169                 j=`expr $j + 1`
170         done
171         if [ -f $TESTDIR/slapd.conf ]; then
172                 rm -f $TESTDIR/slapd.conf
173         fi
174         $SLAPD -f $MYCONF -h $MYURI  -d $LVL $TIMING >> $MYLOG 2>&1 &
175         PID=$!
176         if test $WAIT != 0 ; then
177                 echo PID $PID
178                 read foo
179         fi
180         KILLPIDS="$PID $KILLPIDS"
181         sleep 1
182
183         echo "Using ldapsearch to check that provider slapd is running..."
184         for i in 0 1 2 3 4 5; do
185                 $LDAPSEARCH -s base -b "" -H $MYURI \
186                         'objectclass=*' > /dev/null 2>&1
187                 RC=$?
188                 if test $RC = 0 ; then
189                         break
190                 fi
191                 echo "Waiting 5 seconds for slapd to start..."
192                 sleep 5
193         done
194         
195         if test $RC != 0 ; then
196                 echo "ldapsearch failed ($RC)!"
197                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
198                 exit $RC
199         fi
200         n=`expr $n + 1`
201 done
202
203 echo "Setting up accesslog on each master..."
204 n=1
205 while [ $n -le $MMR ]; do
206         echo "Modifying dn: cn=Elmer_Fudd,ou=People,dc=example,dc=com on master $n"
207         MYURI=`eval echo '$URI'$n`
208         $LDAPMODIFY -v -D "$MANAGERDN" -H $MYURI -w $PASSWD > \
209                 $TESTOUT 2>&1 << EOMODS
210
211 dn: cn=Elmer_Fudd,ou=People,$BASEDN
212 changetype: modify
213 replace: sn
214 sn: Fudd
215 EOMODS
216         sleep 5
217         n=`expr $n + 1`
218 done
219
220 echo "Sleeping 30 seconds to ensure replication is reconciled between all nodes"
221 echo "The next step of the test will perform 20000 random write operations and may take some time."
222 echo "As this test is for a deadlock, it will take manual intervention to exit the test if one occurs."
223 sleep 30
224
225 echo "Starting random master/entry modifications..."
226 DN1="cn=Elmer_Fudd,ou=People,$BASEDN"
227 VAL1="Fudd"
228
229 DN2="cn=Jessica_Rabbit,ou=People,$BASEDN"
230 VAL2="Rabbit"
231
232 DN3="cn=Bugs_Bunny,ou=People,$BASEDN"
233 VAL3="Bunny"
234
235 DN4="cn=Daffy_Duck,ou=People,$BASEDN"
236 VAL4="Duck"
237
238 n=1
239 while [ $n -le 20000 ]; do
240         seed=`date +%N|sed s/...$//`
241         rvalue=`echo|awk "BEGIN {srand($seed)
242 {print int(1+rand()*4)}}"`
243         MYURI=`eval echo '$URI'$rvalue`
244         seed=`date +%N|sed s/...$//`
245         rvalue=`echo|awk "BEGIN {srand($seed)
246 {print int(1+rand()*4)}}"`
247         MYDN=`eval echo '$DN'$rvalue`
248         MYVAL=`eval echo '$VAL'$rvalue`
249         echo "Modifying $MYURI entry $MYDN with value $MYVAL iteration $n of 20000"
250         $LDAPMODIFY -v -D "$MANAGERDN" -H $MYURI -w $PASSWD > \
251                 $TESTOUT 2>&1 << EOMODS
252
253 dn: $MYDN
254 changetype: modify
255 replace: sn
256 sn: $MYVAL
257 EOMODS
258         n=`expr $n + 1`
259 done
260
261 test $KILLSERVERS != no && kill -HUP $KILLPIDS
262
263 echo ">>>>> Test succeeded"
264
265 test $KILLSERVERS != no && wait
266
267 exit 0