]> git.sur5r.net Git - openldap/blob - tests/data/regressions/its8800/its8800
Regression test for ITS8800
[openldap] / tests / data / regressions / its8800 / its8800
1 #! /bin/bash
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2016 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 http://www.openldap.org/its/index.cgi/?findid=8800 for more information."
40
41 MMR=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 $MMR ]; do
54         echo "Initializing server configuration for MMR$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 $MONITORDB < $ITSDIR/slapd-provider${n}.ldif > $CONFLDIF
60         $SLAPADD -F $CFDIR -n 0 -l $CONFLDIF
61         $SLAPADD -F $CFDIR -q -b $BASEDN -l $ITSDIR/its8800db.ldif
62         n=`expr $n + 1`
63 done
64
65 KILLPIDS=
66 n=1
67 while [ $n -le $MMR ]; 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 $TIMING > $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         PIDS[$n]="$PID"
82         sleep 1
83
84         echo "Using ldapsearch to check that provider slapd is running..."
85         for i in 0 1 2 3 4 5; do
86                 $LDAPSEARCH -s base -b "" -H $MYURI \
87                         'objectclass=*' > /dev/null 2>&1
88                 RC=$?
89                 if test $RC = 0 ; then
90                         break
91                 fi
92                 echo "Waiting 5 seconds for slapd to start..."
93                 sleep 5
94         done
95
96         if test $RC != 0 ; then
97                 echo "ldapsearch failed ($RC)!"
98                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
99                 exit $RC
100         fi
101         n=`expr $n + 1`
102 done
103
104 echo "Sleeping 10 seconds to allow stabalization..."
105 sleep 10
106
107 echo "Looping failed authentications for 50 users 10 times each..."
108 user=250
109 while [ $user -le 300 ]; do
110         auths=1
111         echo -n "user $user..."
112         while [ $auths -le 10 ]; do
113                 $LDAPSEARCH -x -H $URI1 -D uid=user.$user,ou=user,dc=example,dc=com -w wrongpass uid=fred >/dev/null 2>&1
114                 RC=$?
115                 if test $RC = 0 ; then
116                         echo "ldapsearch succeeded when it should have failed"
117                         exit 1
118                 fi
119                 auths=`expr $auths + 1`
120         done
121         echo "done"
122         user=`expr $user + 1`
123 done
124
125 echo -n "Sleeping 1 minute to ensure consumers catch up..."
126 sleep 60
127 echo "done"
128
129 echo -n "Stopping MMR1 slapd..."
130 kill -HUP "${PIDS[1]}"
131 wait ${PIDS[1]}
132 sleep $SLEEP2
133 echo "done"
134
135 echo -n "Wiping primary and accesslog databases for MMR1..."
136 DBDIR="$TESTDIR/srv1/db"
137 CFDIR="$TESTDIR/srv1/slapd.d"
138 mv $DBDIR.1 $DBDIR.1.orig
139 mv $DBDIR.2 $DBDIR.2.orig
140 mkdir -p $DBDIR.1 $DBDIR.2
141 $SLAPADD -F $CFDIR -q -b $BASEDN -l $ITSDIR/its8800db.ldif
142 echo "done"
143
144 echo "Starting provider1 slapd on TCP/IP URI $URI1"
145 CFDIR="$TESTDIR/srv1/slapd.d"
146 $SLAPD -F $CFDIR -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
147
148 PID=$!
149 if test $WAIT != 0 ; then
150         echo PID $PID
151         read foo
152 fi
153 PIDS[1]=$PID
154 sleep 1
155
156 echo "Using ldapsearch to check that provider slapd is running..."
157 for i in 0 1 2 3 4 5; do
158         $LDAPSEARCH -s base -b "" -H $URI1 \
159                 'objectclass=*' > /dev/null 2>&1
160         RC=$?
161         if test $RC = 0 ; then
162                 break
163         fi
164         echo "Waiting 5 seconds for slapd to start..."
165         sleep 5
166 done
167
168 n=1
169 KILLPIDS=
170 while [ $n -le 4 ]; do
171         KILLPIDS="${PIDS[$n]} $KILLPIDS"
172         n=`expr $n + 1`
173 done
174
175 if test $RC != 0 ; then
176         echo "ldapsearch failed ($RC)!"
177         test $KILLSERVERS != no && kill -HUP $KILLPIDS
178         exit $RC
179 fi
180 echo "done"
181
182 echo "Sleeping 5 minutes to allow databases to sync..."
183 sleep 300
184
185 echo "Comparing resulting databases..."
186
187 n=1
188 while [ $n -le 4 ]; do
189         CFDIR=${XDIR}$n/slapd.d
190         $SLAPCAT -F $CFDIR -b $BASEDN -l $TESTDIR/finaldb-$n.ldif
191         n=`expr $n + 1`
192 done
193
194 n=2
195 while [ $n -le 4 ]; do
196         diff $TESTDIR/finaldb-1.ldif $TESTDIR/finaldb-$n.ldif > /dev/null 2>&1
197         RC=$?
198         if test $RC != 0 ; then
199                 echo "ERROR: Final LDIF files differ"
200                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
201                 exit $RC
202         fi
203         n=`expr $n + 1`
204 done
205
206 test $KILLSERVERS != no && kill -HUP $KILLPIDS
207
208 echo ">>>>> Test succeeded"
209
210 test $KILLSERVERS != no && wait
211
212 exit 0