]> git.sur5r.net Git - openldap/blob - tests/data/regressions/its4326/its4326
check regression of ITS#4326
[openldap] / tests / data / regressions / its4326 / its4326
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2006 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 $BACKLDAP = "ldapno" ; then 
20         echo "LDAP backend not available, test skipped"
21         exit 0
22 fi 
23
24 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
25
26 ITS=4326
27 ITSDIR=$DATADIR/regressions/its$ITS
28
29 echo "Running slapadd to build slapd database..."
30 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
31 $SLAPADD -f $CONF1 -l $LDIFORDERED
32 RC=$?
33 if test $RC != 0 ; then
34         echo "slapadd failed ($RC)!"
35         exit $RC
36 fi
37
38 echo "Starting slapd on TCP/IP port $PORT1..."
39 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
40 SERVERPID=$!
41 if test $WAIT != 0 ; then
42     echo SERVERPID $SERVERPID
43     read foo
44 fi
45 KILLPIDS="$SERVERPID"
46
47 sleep 1
48
49 echo "Using ldapsearch to check that slapd is running..."
50 for i in 0 1 2 3 4 5; do
51         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
52                 'objectclass=*' > /dev/null 2>&1
53         RC=$?
54         if test $RC = 0 ; then
55                 break
56         fi
57         echo "Waiting 5 seconds for slapd to start..."
58         sleep 5
59 done
60
61 if test $RC != 0 ; then
62         echo "ldapsearch failed ($RC)!"
63         test $KILLSERVERS != no && kill -HUP $KILLPIDS
64         exit $RC
65 fi
66
67 echo "Running slapadd to create glue entry..."
68 . $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd.conf > $CONF2
69 #$SLAPADD -f $CONF2 << EODATA
70 #dn: dc=example,dc=com
71 #objectClass: domain
72 #dc: example
73 #EODATA
74 #RC=$?
75 #if test $RC != 0 ; then
76 #       echo "slapadd failed ($RC)!"
77 #       test $KILLSERVERS != no && kill -HUP $KILLPIDS
78 #       exit $RC
79 #fi
80
81 echo "Starting proxy slapd on TCP/IP port $PORT2..."
82 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
83 PROXYPID=$!
84 if test $WAIT != 0 ; then
85     echo PROXYPID $PROXYPID
86     read foo
87 fi
88 KILLPIDS="$KILLPIDS $PROXYPID"
89
90 sleep 1
91
92 echo "Using ldapsearch to check that proxy slapd is running..."
93 for i in 0 1 2 3 4 5; do
94         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
95                 'objectclass=*' > /dev/null 2>&1
96         RC=$?
97         if test $RC = 0 ; then
98                 break
99         fi
100         echo "Waiting 5 seconds for slapd to start..."
101         sleep 5
102 done
103
104 if test $RC != 0 ; then
105         echo "ldapsearch failed ($RC)!"
106         test $KILLSERVERS != no && kill -HUP $KILLPIDS
107         exit $RC
108 fi
109
110 echo "Searching the proxy..."
111 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
112         '(objectClass=*)' > /dev/null 2>&1
113 RC=$?
114 if test $RC != 0 ; then
115         echo "ldapsearch failed ($RC)!"
116         test $KILLSERVERS != no && kill -HUP $KILLPIDS
117         exit $RC
118 fi
119
120 echo "Re-searching the proxy..."
121 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
122         '(objectClass=*)' > /dev/null 2>&1
123 RC=$?
124 if test $RC != 0 ; then
125         echo "ldapsearch failed ($RC)!"
126         test $KILLSERVERS != no && kill -HUP $KILLPIDS
127         exit $RC
128 fi
129
130 SLEEP=2
131 echo "Stopping the provider and sleeping $SLEEP seconds..."
132 kill -HUP "$SERVERPID"
133 wait $SERVERPID
134 sleep $SLEEP
135 KILLPIDS="$PROXYPID"
136
137 echo "Searching the proxy..."
138 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
139         '(objectClass=*)' > /dev/null 2>&1
140 RC=$?
141 case $RC in
142 0)
143         echo "ldapsearch should have failed ($RC)!"
144         test $KILLSERVERS != no && kill -HUP $KILLPIDS
145         exit $RC
146         ;;
147 52)
148         echo "ldapsearch failed ($RC)"
149         ;;
150 *)
151         echo "ldapsearch failed ($RC)!"
152         test $KILLSERVERS != no && kill -HUP $KILLPIDS
153         exit $RC
154         ;;
155 esac
156
157 echo "Re-searching the proxy..."
158 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
159         '(objectClass=*)' > /dev/null 2>&1
160 RC=$?
161 case $RC in
162 0)
163         echo "ldapsearch should have failed ($RC)!"
164         test $KILLSERVERS != no && kill -HUP $KILLPIDS
165         exit $RC
166         ;;
167 52)
168         echo "ldapsearch failed ($RC)"
169         ;;
170 *)
171         echo "ldapsearch failed ($RC)!"
172         test $KILLSERVERS != no && kill -HUP $KILLPIDS
173         exit $RC
174         ;;
175 esac
176
177 echo "Restarting slapd on TCP/IP port $PORT1..."
178 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
179 SERVERPID=$!
180 if test $WAIT != 0 ; then
181     echo SERVERPID $SERVERPID
182     read foo
183 fi
184 KILLPIDS="$SERVERPID $PROXYPID"
185
186 sleep 1
187
188 echo "Using ldapsearch to check that slapd is running..."
189 for i in 0 1 2 3 4 5; do
190         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
191                 'objectclass=*' > /dev/null 2>&1
192         RC=$?
193         if test $RC = 0 ; then
194                 break
195         fi
196         echo "Waiting 5 seconds for slapd to start..."
197         sleep 5
198 done
199
200 if test $RC != 0 ; then
201         echo "ldapsearch failed ($RC)!"
202         test $KILLSERVERS != no && kill -HUP $KILLPIDS
203         exit $RC
204 fi
205
206 echo "Searching the proxy..."
207 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
208         '(objectClass=*)' > /dev/null 2>&1
209 RC=$?
210 if test $RC != 0 ; then
211         echo "ldapsearch failed ($RC)!"
212         test $KILLSERVERS != no && kill -HUP $KILLPIDS
213         exit $RC
214 fi
215
216 echo "Re-searching the proxy..."
217 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
218         '(objectClass=*)' > /dev/null 2>&1
219 RC=$?
220 if test $RC != 0 ; then
221         echo "ldapsearch failed ($RC)!"
222         test $KILLSERVERS != no && kill -HUP $KILLPIDS
223         exit $RC
224 fi
225
226 test $KILLSERVERS != no && kill -HUP $KILLPIDS
227
228 echo ">>>>> Test succeeded"
229
230 test $KILLSERVERS != no && wait
231
232 exit 0