]> git.ipfire.org Git - thirdparty/openldap.git/blob - tests/data/regressions/its8800/its8800
Happy New Year!
[thirdparty/openldap.git] / tests / data / regressions / its8800 / its8800
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2024 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 $PPOLICY = ppolicyno; then
20 echo "Password policy overlay not available, test skipped"
21 exit 0
22 fi
23
24 if test $SYNCPROV = syncprovno; then
25 echo "Syncrepl provider overlay not available, test skipped"
26 exit 0
27 fi
28 if test $ACCESSLOG = accesslogno; then
29 echo "Accesslog overlay not available, test skipped"
30 exit 0
31 fi
32 if test $BACKEND = ldif ; then
33 # Onelevel search does not return entries in order of creation or CSN.
34 echo "$BACKEND backend unsuitable for syncprov logdb, test skipped"
35 exit 0
36 fi
37
38 echo "This test tracks a case where changes are not refreshed when an old db is reloaded"
39 echo "See https://bugs.openldap.org/show_bug.cgi?id=8800 for more information."
40
41 MPR=4
42 XDIR=$TESTDIR/srv
43
44 mkdir -p $TESTDIR
45
46 $SLAPPASSWD -g -n >$CONFIGPWF
47
48 ITS=8800
49 ITSDIR=$DATADIR/regressions/its$ITS
50
51
52 n=1
53 while [ $n -le $MPR ]; do
54 echo "Initializing server configuration for MPR$n..."
55 DBDIR=${XDIR}$n/db
56 CFDIR=${XDIR}$n/slapd.d
57
58 mkdir -p ${XDIR}$n $DBDIR.1 $DBDIR.2 $CFDIR
59 . $CONFFILTER $BACKEND < $ITSDIR/slapd-provider${n}.ldif > $CONFLDIF
60 $SLAPADD -F $CFDIR -n 0 -l $CONFLDIF
61 $SLAPADD -F $CFDIR -q -b $BASEDN -l $ITSDIR/db.ldif
62 n=`expr $n + 1`
63 done
64
65 KILLPIDS=
66 n=1
67 while [ $n -le $MPR ]; do
68 MYURI=`eval echo '$URI'$n`
69 MYLOG=`eval echo '$LOG'$n`
70 CFDIR=${XDIR}$n/slapd.d
71
72 echo "Starting provider slapd on TCP/IP URI $MYURI"
73 $SLAPD -F $CFDIR -h $MYURI -d $LVL > $MYLOG 2>&1 &
74
75 PID=$!
76 if test $WAIT != 0 ; then
77 echo PID $PID
78 read foo
79 fi
80 KILLPIDS="$PID $KILLPIDS"
81 if [ $n = 1 ]; then
82 MPID="$PID"
83 fi
84 sleep 1
85
86 echo "Using ldapsearch to check that provider slapd is running..."
87 for i in 0 1 2 3 4 5; do
88 $LDAPSEARCH -s base -b "" -H $MYURI \
89 'objectclass=*' > /dev/null 2>&1
90 RC=$?
91 if test $RC = 0 ; then
92 break
93 fi
94 echo "Waiting 5 seconds for slapd to start..."
95 sleep 5
96 done
97
98 if test $RC != 0 ; then
99 echo "ldapsearch failed ($RC)!"
100 test $KILLSERVERS != no && kill -HUP $KILLPIDS
101 exit $RC
102 fi
103 n=`expr $n + 1`
104 done
105
106 echo "Sleeping 10 seconds to allow stabilization..."
107 sleep 10
108
109 echo "Looping failed authentications for 50 users 10 times each..."
110 user=250
111 while [ $user -le 300 ]; do
112 auths=1
113 echo -n "user $user..."
114 while [ $auths -le 10 ]; do
115 $LDAPSEARCH -x -H $URI1 -D uid=user.$user,ou=user,dc=example,dc=com -w wrongpass uid=fred >/dev/null 2>&1
116 RC=$?
117 if test $RC = 0 ; then
118 echo "ldapsearch succeeded when it should have failed"
119 exit 1
120 fi
121 auths=`expr $auths + 1`
122 done
123 echo "done"
124 user=`expr $user + 1`
125 done
126
127 echo -n "Sleeping 1 minute to ensure consumers catch up..."
128 sleep 60
129 echo "done"
130
131 echo -n "Stopping MPR1 slapd..."
132 kill -HUP $MPID
133 wait $MPID
134 KILLPIDS=`echo "$KILLPIDS " | sed -e "s/ $MPID / /"`;
135 sleep $SLEEP2
136 echo "done"
137
138 echo -n "Wiping primary and accesslog databases for MPR1..."
139 DBDIR="$TESTDIR/srv1/db"
140 CFDIR="$TESTDIR/srv1/slapd.d"
141 mv $DBDIR.1 $DBDIR.1.orig
142 mv $DBDIR.2 $DBDIR.2.orig
143 mkdir -p $DBDIR.1 $DBDIR.2
144 $SLAPADD -F $CFDIR -q -b $BASEDN -l $ITSDIR/db.ldif
145 echo "done"
146
147 echo "Starting provider1 slapd on TCP/IP URI $URI1"
148 CFDIR="$TESTDIR/srv1/slapd.d"
149 $SLAPD -F $CFDIR -h $URI1 -d $LVL >> $LOG1 2>&1 &
150
151 PID=$!
152 if test $WAIT != 0 ; then
153 echo PID $PID
154 read foo
155 fi
156 KILLPIDS="$PID $KILLPIDS"
157 sleep 1
158
159 echo "Using ldapsearch to check that provider slapd is running..."
160 for i in 0 1 2 3 4 5; do
161 $LDAPSEARCH -s base -b "" -H $URI1 \
162 'objectclass=*' > /dev/null 2>&1
163 RC=$?
164 if test $RC = 0 ; then
165 break
166 fi
167 echo "Waiting 5 seconds for slapd to start..."
168 sleep 5
169 done
170
171 if test $RC != 0 ; then
172 echo "ldapsearch failed ($RC)!"
173 test $KILLSERVERS != no && kill -HUP $KILLPIDS
174 exit $RC
175 fi
176 echo "done"
177
178 echo "Sleeping 5 minutes to allow databases to sync..."
179 sleep 300
180
181 echo "Comparing resulting databases..."
182
183 n=1
184 while [ $n -le 4 ]; do
185 CFDIR=${XDIR}$n/slapd.d
186 $SLAPCAT -F $CFDIR -b $BASEDN -l $TESTDIR/finaldb-$n.ldif
187 n=`expr $n + 1`
188 done
189
190 n=2
191 while [ $n -le 4 ]; do
192 diff $TESTDIR/finaldb-1.ldif $TESTDIR/finaldb-$n.ldif > /dev/null 2>&1
193 RC=$?
194 if test $RC != 0 ; then
195 echo "ERROR: Final LDIF files differ"
196 test $KILLSERVERS != no && kill -HUP $KILLPIDS
197 exit $RC
198 fi
199 n=`expr $n + 1`
200 done
201
202 test $KILLSERVERS != no && kill -HUP $KILLPIDS
203
204 echo ">>>>> Test succeeded"
205
206 test $KILLSERVERS != no && wait
207
208 exit 0