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