3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2012 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
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>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test $BACKLDAP = "ldapno" ; then
20 echo "LDAP backend not available, test skipped"
24 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
27 ITSDIR=$DATADIR/regressions/its$ITS
29 echo "Running slapadd to build slapd database..."
30 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
31 $SLAPADD -f $CONF1 -l $LDIFORDERED
33 if test $RC != 0 ; then
34 echo "slapadd failed ($RC)!"
38 echo "Starting slapd on TCP/IP port $PORT1..."
39 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
41 if test $WAIT != 0 ; then
42 echo SERVERPID $SERVERPID
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
54 if test $RC = 0 ; then
57 echo "Waiting 5 seconds for slapd to start..."
61 if test $RC != 0 ; then
62 echo "ldapsearch failed ($RC)!"
63 test $KILLSERVERS != no && kill -HUP $KILLPIDS
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 &
71 if test $WAIT != 0 ; then
72 echo PROXYPID $PROXYPID
75 KILLPIDS="$KILLPIDS $PROXYPID"
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
84 if test $RC = 0 ; then
87 echo "Waiting 5 seconds for slapd to start..."
91 if test $RC != 0 ; then
92 echo "ldapsearch failed ($RC)!"
93 test $KILLSERVERS != no && kill -HUP $KILLPIDS
97 echo "Searching the proxy..."
98 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
99 '(objectClass=*)' > /dev/null 2>&1
101 if test $RC != 0 ; then
102 echo "ldapsearch failed ($RC)!"
103 test $KILLSERVERS != no && kill -HUP $KILLPIDS
107 echo "Re-searching the proxy..."
108 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
109 '(objectClass=*)' > /dev/null 2>&1
111 if test $RC != 0 ; then
112 echo "ldapsearch failed ($RC)!"
113 test $KILLSERVERS != no && kill -HUP $KILLPIDS
118 echo "Stopping the server and sleeping $SLEEP seconds..."
119 kill -HUP "$SERVERPID"
124 echo "Searching the proxy..."
125 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
126 '(objectClass=*)' > /dev/null 2>&1
130 echo "ldapsearch should have failed ($RC)!"
131 test $KILLSERVERS != no && kill -HUP $KILLPIDS
135 echo "ldapsearch failed ($RC)"
138 echo "ldapsearch failed ($RC)!"
139 test $KILLSERVERS != no && kill -HUP $KILLPIDS
144 echo "Re-searching the proxy..."
145 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
146 '(objectClass=*)' > /dev/null 2>&1
150 echo "ldapsearch should have failed ($RC)!"
151 test $KILLSERVERS != no && kill -HUP $KILLPIDS
155 echo "ldapsearch failed ($RC)"
158 echo "ldapsearch failed ($RC)!"
159 test $KILLSERVERS != no && kill -HUP $KILLPIDS
164 echo "Restarting slapd on TCP/IP port $PORT1..."
165 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
167 if test $WAIT != 0 ; then
168 echo SERVERPID $SERVERPID
171 KILLPIDS="$SERVERPID $PROXYPID"
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
180 if test $RC = 0 ; then
183 echo "Waiting 5 seconds for slapd to start..."
187 if test $RC != 0 ; then
188 echo "ldapsearch failed ($RC)!"
189 test $KILLSERVERS != no && kill -HUP $KILLPIDS
193 echo "Searching the proxy..."
194 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
195 '(objectClass=*)' > /dev/null 2>&1
197 if test $RC != 0 ; then
198 echo "ldapsearch failed ($RC)!"
199 test $KILLSERVERS != no && kill -HUP $KILLPIDS
203 echo "Re-searching the proxy..."
204 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
205 '(objectClass=*)' > /dev/null 2>&1
207 if test $RC != 0 ; then
208 echo "ldapsearch failed ($RC)!"
209 test $KILLSERVERS != no && kill -HUP $KILLPIDS
213 test $KILLSERVERS != no && kill -HUP $KILLPIDS
215 echo ">>>>> Test succeeded"
217 test $KILLSERVERS != no && wait