3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2018 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 if test $BACKEND = "ldap" ; then
25 echo "LDAP backend not valid, test skipped"
29 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
32 ITSDIR=$DATADIR/regressions/its$ITS
34 echo "Running slapadd to build slapd database..."
35 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
36 $SLAPADD -f $CONF1 -l $LDIFORDERED
38 if test $RC != 0 ; then
39 echo "slapadd failed ($RC)!"
43 echo "Starting slapd on TCP/IP port $PORT1..."
44 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
46 if test $WAIT != 0 ; then
47 echo SERVERPID $SERVERPID
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
59 if test $RC = 0 ; then
62 echo "Waiting 5 seconds for slapd to start..."
66 if test $RC != 0 ; then
67 echo "ldapsearch failed ($RC)!"
68 test $KILLSERVERS != no && kill -HUP $KILLPIDS
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 &
76 if test $WAIT != 0 ; then
77 echo PROXYPID $PROXYPID
80 KILLPIDS="$KILLPIDS $PROXYPID"
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
89 if test $RC = 0 ; then
92 echo "Waiting 5 seconds for slapd to start..."
96 if test $RC != 0 ; then
97 echo "ldapsearch failed ($RC)!"
98 test $KILLSERVERS != no && kill -HUP $KILLPIDS
102 echo "Searching the proxy..."
103 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
104 '(objectClass=*)' > /dev/null 2>&1
106 if test $RC != 0 ; then
107 echo "ldapsearch failed ($RC)!"
108 test $KILLSERVERS != no && kill -HUP $KILLPIDS
112 echo "Re-searching the proxy..."
113 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
114 '(objectClass=*)' > /dev/null 2>&1
116 if test $RC != 0 ; then
117 echo "ldapsearch failed ($RC)!"
118 test $KILLSERVERS != no && kill -HUP $KILLPIDS
123 echo "Stopping the server and sleeping $SLEEP seconds..."
124 kill -HUP "$SERVERPID"
129 echo "Searching the proxy..."
130 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
131 '(objectClass=*)' > /dev/null 2>&1
135 echo "ldapsearch should have failed ($RC)!"
136 test $KILLSERVERS != no && kill -HUP $KILLPIDS
140 echo "ldapsearch failed ($RC)"
143 echo "ldapsearch failed ($RC)!"
144 test $KILLSERVERS != no && kill -HUP $KILLPIDS
149 echo "Re-searching the proxy..."
150 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
151 '(objectClass=*)' > /dev/null 2>&1
155 echo "ldapsearch should have failed ($RC)!"
156 test $KILLSERVERS != no && kill -HUP $KILLPIDS
160 echo "ldapsearch failed ($RC)"
163 echo "ldapsearch failed ($RC)!"
164 test $KILLSERVERS != no && kill -HUP $KILLPIDS
169 echo "Restarting slapd on TCP/IP port $PORT1..."
170 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
172 if test $WAIT != 0 ; then
173 echo SERVERPID $SERVERPID
176 KILLPIDS="$SERVERPID $PROXYPID"
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
185 if test $RC = 0 ; then
188 echo "Waiting 5 seconds for slapd to start..."
192 if test $RC != 0 ; then
193 echo "ldapsearch failed ($RC)!"
194 test $KILLSERVERS != no && kill -HUP $KILLPIDS
198 echo "Searching the proxy..."
199 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
200 '(objectClass=*)' > /dev/null 2>&1
202 if test $RC != 0 ; then
203 echo "ldapsearch failed ($RC)!"
204 test $KILLSERVERS != no && kill -HUP $KILLPIDS
208 echo "Re-searching the proxy..."
209 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
210 '(objectClass=*)' > /dev/null 2>&1
212 if test $RC != 0 ; then
213 echo "ldapsearch failed ($RC)!"
214 test $KILLSERVERS != no && kill -HUP $KILLPIDS
218 test $KILLSERVERS != no && kill -HUP $KILLPIDS
220 echo ">>>>> Test succeeded"
222 test $KILLSERVERS != no && wait