3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2017 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"
23 if test $ACCESSLOG = accesslogno; then
24 echo "Accesslog overlay not available, test skipped"
27 if test $BACKEND = ldif ; then
28 echo "$BACKEND backend unsuitable, test skipped"
32 dtest=`date +%N|sed s/...$//`
34 if test $dtest = N; then
35 echo "nanosecond date values not supported, test skipped"
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."
48 ITSDIR=$DATADIR/regressions/its$ITS
51 while [ $n -le $MMR ]; do
53 mkdir -p ${XDIR}$n $DBDIR.1 $DBDIR.2
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 &
63 if test $WAIT != 0 ; then
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
76 if test $RC = 0 ; then
79 echo "Waiting 5 seconds for slapd to start..."
83 if test $RC != 0 ; then
84 echo "ldapsearch failed ($RC)!"
85 test $KILLSERVERS != no && kill -HUP $KILLPIDS
89 echo "Populating database on first provider..."
90 $LDAPADD -D $MANAGERDN -H $URI1 -w $PASSWD << EOMODS >> $TESTOUT 2>&1
92 objectClass: organization
98 objectClass: organizationalUnit
101 dn: ou=Groups,$BASEDN
102 objectClass: organizationalUnit
105 dn: cn=Roger Rabbit,ou=People,$BASEDN
106 objectClass: inetOrgPerson
110 dn: cn=Baby Herman,ou=People,$BASEDN
111 objectClass: inetOrgPerson
115 dn: cn=Jessica_Rabbit,ou=People,$BASEDN
116 objectClass: inetOrgPerson
120 dn: cn=Bugs_Bunny,ou=People,$BASEDN
121 objectClass: inetOrgPerson
125 dn: cn=Daffy_Duck,ou=People,$BASEDN
126 objectClass: inetOrgPerson
130 dn: cn=Elmer_Fudd,ou=People,$BASEDN
131 objectClass: inetOrgPerson
135 dn: cn=Cartoonia,ou=Groups,$BASEDN
136 objectClass: groupOfNames
138 member: cn=Roger Rabbit,ou=People,$BASEDN
139 member: cn=Baby Herman,ou=People,$BASEDN
144 if test $RC != 0 ; then
145 echo "ldapadd failed ($RC)!"
146 test $KILLSERVERS != no && kill -HUP $KILLPIDS
150 echo "Stopping slapd and reworking configuration for MMR..."
152 test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
164 while [ $j -le $MMR ]; do
165 MMCURI=`eval echo '$URI'$j`
166 sed -e "s|MMC${j}|${MMCURI}|" $MYCONF > $CONF
170 if [ -f $CONF ]; then
173 $SLAPD -f $MYCONF -h $MYURI -d $LVL $TIMING > $MYLOG 2>&1 &
175 if test $WAIT != 0 ; then
179 KILLPIDS="$PID $KILLPIDS"
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
187 if test $RC = 0 ; then
190 echo "Waiting 5 seconds for slapd to start..."
194 if test $RC != 0 ; then
195 echo "ldapsearch failed ($RC)!"
196 test $KILLSERVERS != no && kill -HUP $KILLPIDS
202 echo "Setting up accesslog on each master..."
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
210 dn: cn=Elmer_Fudd,ou=People,$BASEDN
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."
224 echo "Starting random master/entry modifications..."
225 DN1="cn=Elmer_Fudd,ou=People,$BASEDN"
228 DN2="cn=Jessica_Rabbit,ou=People,$BASEDN"
231 DN3="cn=Bugs_Bunny,ou=People,$BASEDN"
234 DN4="cn=Daffy_Duck,ou=People,$BASEDN"
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
260 test $KILLSERVERS != no && kill -HUP $KILLPIDS
262 echo ">>>>> Test succeeded"
264 test $KILLSERVERS != no && wait