]> git.sur5r.net Git - openldap/blob - tests/data/regressions/its4326/its4326
Happy new year (belated)
[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-2014 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 "Starting proxy slapd on TCP/IP port $PORT2..."
68 . $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd.conf > $CONF2
69 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
70 PROXYPID=$!
71 if test $WAIT != 0 ; then
72     echo PROXYPID $PROXYPID
73     read foo
74 fi
75 KILLPIDS="$KILLPIDS $PROXYPID"
76
77 sleep 1
78
79 echo "Using ldapsearch to check that proxy slapd is running..."
80 for i in 0 1 2 3 4 5; do
81         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
82                 'objectclass=*' > /dev/null 2>&1
83         RC=$?
84         if test $RC = 0 ; then
85                 break
86         fi
87         echo "Waiting 5 seconds for slapd to start..."
88         sleep 5
89 done
90
91 if test $RC != 0 ; then
92         echo "ldapsearch failed ($RC)!"
93         test $KILLSERVERS != no && kill -HUP $KILLPIDS
94         exit $RC
95 fi
96
97 echo "Searching the proxy..."
98 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
99         '(objectClass=*)' > /dev/null 2>&1
100 RC=$?
101 if test $RC != 0 ; then
102         echo "ldapsearch failed ($RC)!"
103         test $KILLSERVERS != no && kill -HUP $KILLPIDS
104         exit $RC
105 fi
106
107 echo "Re-searching the proxy..."
108 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
109         '(objectClass=*)' > /dev/null 2>&1
110 RC=$?
111 if test $RC != 0 ; then
112         echo "ldapsearch failed ($RC)!"
113         test $KILLSERVERS != no && kill -HUP $KILLPIDS
114         exit $RC
115 fi
116
117 SLEEP=2
118 echo "Stopping the server and sleeping $SLEEP seconds..."
119 kill -HUP "$SERVERPID"
120 wait $SERVERPID
121 sleep $SLEEP
122 KILLPIDS="$PROXYPID"
123
124 echo "Searching the proxy..."
125 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
126         '(objectClass=*)' > /dev/null 2>&1
127 RC=$?
128 case $RC in
129 0)
130         echo "ldapsearch should have failed ($RC)!"
131         test $KILLSERVERS != no && kill -HUP $KILLPIDS
132         exit $RC
133         ;;
134 52)
135         echo "ldapsearch failed ($RC)"
136         ;;
137 *)
138         echo "ldapsearch failed ($RC)!"
139         test $KILLSERVERS != no && kill -HUP $KILLPIDS
140         exit $RC
141         ;;
142 esac
143
144 echo "Re-searching the proxy..."
145 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
146         '(objectClass=*)' > /dev/null 2>&1
147 RC=$?
148 case $RC in
149 0)
150         echo "ldapsearch should have failed ($RC)!"
151         test $KILLSERVERS != no && kill -HUP $KILLPIDS
152         exit $RC
153         ;;
154 52)
155         echo "ldapsearch failed ($RC)"
156         ;;
157 *)
158         echo "ldapsearch failed ($RC)!"
159         test $KILLSERVERS != no && kill -HUP $KILLPIDS
160         exit $RC
161         ;;
162 esac
163
164 echo "Restarting slapd on TCP/IP port $PORT1..."
165 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
166 SERVERPID=$!
167 if test $WAIT != 0 ; then
168     echo SERVERPID $SERVERPID
169     read foo
170 fi
171 KILLPIDS="$SERVERPID $PROXYPID"
172
173 sleep 1
174
175 echo "Using ldapsearch to check that slapd is running..."
176 for i in 0 1 2 3 4 5; do
177         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
178                 'objectclass=*' > /dev/null 2>&1
179         RC=$?
180         if test $RC = 0 ; then
181                 break
182         fi
183         echo "Waiting 5 seconds for slapd to start..."
184         sleep 5
185 done
186
187 if test $RC != 0 ; then
188         echo "ldapsearch failed ($RC)!"
189         test $KILLSERVERS != no && kill -HUP $KILLPIDS
190         exit $RC
191 fi
192
193 echo "Searching the proxy..."
194 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
195         '(objectClass=*)' > /dev/null 2>&1
196 RC=$?
197 if test $RC != 0 ; then
198         echo "ldapsearch failed ($RC)!"
199         test $KILLSERVERS != no && kill -HUP $KILLPIDS
200         exit $RC
201 fi
202
203 echo "Re-searching the proxy..."
204 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
205         '(objectClass=*)' > /dev/null 2>&1
206 RC=$?
207 if test $RC != 0 ; then
208         echo "ldapsearch failed ($RC)!"
209         test $KILLSERVERS != no && kill -HUP $KILLPIDS
210         exit $RC
211 fi
212
213 test $KILLSERVERS != no && kill -HUP $KILLPIDS
214
215 echo ">>>>> Test succeeded"
216
217 test $KILLSERVERS != no && wait
218
219 exit 0