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
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
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
171 if [ -f $TESTDIR/slapd.conf ]; then
172 rm -f $TESTDIR/slapd.conf
174 $SLAPD -f $MYCONF -h $MYURI -d $LVL $TIMING >> $MYLOG 2>&1 &
176 if test $WAIT != 0 ; then
180 KILLPIDS="$PID $KILLPIDS"
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
188 if test $RC = 0 ; then
191 echo "Waiting 5 seconds for slapd to start..."
195 if test $RC != 0 ; then
196 echo "ldapsearch failed ($RC)!"
197 test $KILLSERVERS != no && kill -HUP $KILLPIDS
203 echo "Setting up accesslog on each master..."
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
211 dn: cn=Elmer_Fudd,ou=People,$BASEDN
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."
225 echo "Starting random master/entry modifications..."
226 DN1="cn=Elmer_Fudd,ou=People,$BASEDN"
229 DN2="cn=Jessica_Rabbit,ou=People,$BASEDN"
232 DN3="cn=Bugs_Bunny,ou=People,$BASEDN"
235 DN4="cn=Daffy_Duck,ou=People,$BASEDN"
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
261 test $KILLSERVERS != no && kill -HUP $KILLPIDS
263 echo ">>>>> Test succeeded"
265 test $KILLSERVERS != no && wait