]> git.sur5r.net Git - openldap/blob - tests/data/regressions/its4336/its4336
62ee53b77bc8a9eae4924b97fbcfadf854122148
[openldap] / tests / data / regressions / its4336 / its4336
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 $RETCODE = retcodeno; then 
25         echo "Retcode overlay not available, test skipped"
26         exit 0
27 fi
28
29 if test "$BACKEND" = "ldap"; then
30         echo "LDAP backend not valid, test skipped"
31         exit 0
32 fi
33
34 mkdir -p $TESTDIR $DBDIR1
35
36 ITS=4336
37 ITSDIR=$DATADIR/regressions/its$ITS
38
39 echo "Running slapadd to build slapd database..."
40 . $CONFFILTER $BACKEND $MONITORDB < $RETCODECONF > $CONF1
41 $SLAPADD -f $CONF1 -l $LDIFORDERED
42 RC=$?
43 if test $RC != 0 ; then
44         echo "slapadd failed ($RC)!"
45         exit $RC
46 fi
47
48 echo "Starting slapd on TCP/IP port $PORT1..."
49 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
50 SERVERPID=$!
51 if test $WAIT != 0 ; then
52     echo SERVERPID $SERVERPID
53     read foo
54 fi
55 KILLPIDS="$SERVERPID"
56
57 sleep 1
58
59 echo "Using ldapsearch to check that slapd is running..."
60 for i in 0 1 2 3 4 5; do
61         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
62                 'objectclass=*' > /dev/null 2>&1
63         RC=$?
64         if test $RC = 0 ; then
65                 break
66         fi
67         echo "Waiting 5 seconds for slapd to start..."
68         sleep 5
69 done
70
71 if test $RC != 0 ; then
72         echo "ldapsearch failed ($RC)!"
73         test $KILLSERVERS != no && kill -HUP $KILLPIDS
74         exit $RC
75 fi
76
77 echo "Starting chain slapd on TCP/IP port $PORT2..."
78 . $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd.conf > $CONF2
79 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
80 PROXYPID=$!
81 if test $WAIT != 0 ; then
82     echo PROXYPID $PROXYPID
83     read foo
84 fi
85 KILLPIDS="$KILLPIDS $PROXYPID"
86
87 sleep 1
88
89 echo "Using ldapsearch to check that chain slapd is running..."
90 for i in 0 1 2 3 4 5; do
91         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
92                 'objectclass=*' > /dev/null 2>&1
93         RC=$?
94         if test $RC = 0 ; then
95                 break
96         fi
97         echo "Waiting 5 seconds for slapd to start..."
98         sleep 5
99 done
100
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 "Searching the chain..."
108 echo "
109         Search an entry that causes a successful result to be returned
110         with a 2 second delay; since size/time limits were erroneously
111         set to 0/0, which internally means 0 instead of unlimited, the
112         underlying back-ldap search timed out.
113 "
114 $LDAPSEARCH -b "cn=success w/ delay,ou=RetCodes,$BASEDN" -h $LOCALHOST -p $PORT2 \
115         '(objectClass=*)' > /dev/null 2>&1
116 RC=$?
117 if test $RC != 0 ; then
118         echo "ldapsearch failed ($RC)!"
119         test $KILLSERVERS != no && kill -HUP $KILLPIDS
120         exit $RC
121 fi
122
123 echo "Re-searching the chain..."
124 $LDAPSEARCH -b "cn=success w/ delay,ou=RetCodes,$BASEDN" -h $LOCALHOST -p $PORT2 \
125         '(objectClass=*)' > /dev/null 2>&1
126 RC=$?
127 if test $RC != 0 ; then
128         echo "ldapsearch failed ($RC)!"
129         test $KILLSERVERS != no && kill -HUP $KILLPIDS
130         exit $RC
131 fi
132
133 test $KILLSERVERS != no && kill -HUP $KILLPIDS
134
135 echo ">>>>> Test succeeded"
136
137 test $KILLSERVERS != no && wait
138
139 exit 0