Debian Codegraph @

tests/scripts/lloadd/test001-backend-issues

raw
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2024 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 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
20
21 $SLAPPASSWD -g -n >$CONFIGPWF
22 echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
23
24 echo "Starting an empty slapd on TCP/IP port $PORT2..."
25 . $CONFFILTER $BACKEND < $SCHEMACONF > $CONF2
26 $SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
27 PID=$!
28 if test $WAIT != 0 ; then
29 echo PID $PID
30 read foo
31 fi
32 PID2="$PID"
33 KILLPIDS="$PID"
34
35 echo "Testing slapd searching..."
36 for i in 0 1 2 3 4 5; do
37 $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
38 '(objectclass=*)' > /dev/null 2>&1
39 RC=$?
40 if test $RC = 0 ; then
41 break
42 fi
43 echo "Waiting $SLEEP1 seconds for slapd to start..."
44 sleep $SLEEP1
45 done
46 if test $RC != 0 ; then
47 echo "ldapsearch failed ($RC)!"
48 test $KILLSERVERS != no && kill -HUP $KILLPIDS
49 exit $RC
50 fi
51
52 echo "Running slapadd to build slapd database..."
53 . $CONFFILTER $BACKEND < $CONFTWO > $CONF3
54 $SLAPADD -f $CONF3 -l $LDIFORDERED
55 RC=$?
56 if test $RC != 0 ; then
57 echo "slapadd failed ($RC)!"
58 test $KILLSERVERS != no && kill -HUP $KILLPIDS
59 exit $RC
60 fi
61
62 echo "Running slapindex to index slapd database..."
63 $SLAPINDEX -f $CONF3
64 RC=$?
65 if test $RC != 0 ; then
66 echo "warning: slapindex failed ($RC)"
67 echo " assuming no indexing support"
68 fi
69
70 echo "Starting second slapd on TCP/IP port $PORT3..."
71 $SLAPD -f $CONF3 -h $URI3 -d $LVL > $LOG3 2>&1 &
72 PID=$!
73 if test $WAIT != 0 ; then
74 echo PID $PID
75 read foo
76 fi
77 PID3="$PID"
78 KILLPIDS="$KILLPIDS $PID"
79
80 sleep $SLEEP0
81
82 echo "Testing slapd searching..."
83 for i in 0 1 2 3 4 5; do
84 $LDAPSEARCH -s base -b "$MONITOR" -H $URI3 \
85 '(objectclass=*)' > /dev/null 2>&1
86 RC=$?
87 if test $RC = 0 ; then
88 break
89 fi
90 echo "Waiting $SLEEP1 seconds for slapd to start..."
91 sleep $SLEEP1
92 done
93 if test $RC != 0 ; then
94 echo "ldapsearch failed ($RC)!"
95 test $KILLSERVERS != no && kill -HUP $KILLPIDS
96 exit $RC
97 fi
98
99 echo "Starting lloadd on TCP/IP port $PORT1..."
100 . $CONFFILTER $BACKEND < $LLOADDUNREACHABLECONF > $CONF1.lloadd
101 if test $AC_lloadd = lloaddyes; then
102 $LLOADD -f $CONF1.lloadd -h $URI1 -d $LVL > $LOG1 2>&1 &
103 else
104 . $CONFFILTER $BACKEND < $SLAPDLLOADCONF > $CONF1.slapd
105 $SLAPD -f $CONF1.slapd -h $URI6 -d $LVL > $LOG1 2>&1 &
106 fi
107 PID=$!
108 if test $WAIT != 0 ; then
109 echo PID $PID
110 read foo
111 fi
112 KILLPIDS="$KILLPIDS $PID"
113
114 echo "Testing slapd searching..."
115 for i in 0 1 2 3 4 5; do
116 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
117 '(objectclass=*)' > /dev/null 2>&1
118 RC=$?
119 if test $RC = 0 ; then
120 break
121 fi
122 echo "Waiting $SLEEP1 seconds for lloadd to start..."
123 sleep $SLEEP1
124 done
125
126 if test $RC != 0 ; then
127 echo "ldapsearch failed ($RC)!"
128 test $KILLSERVERS != no && kill -HUP $KILLPIDS
129 exit $RC
130 fi
131
132 echo "Testing exact searching..."
133 echo "# Testing exact searching..." > $SEARCHOUT
134 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
135 '(sn=jENSEN)' >> $SEARCHOUT 2>&1
136 RC=$?
137 if test $RC != 0 ; then
138 echo "ldapsearch failed ($RC)!"
139 test $KILLSERVERS != no && kill -HUP $KILLPIDS
140 exit $RC
141 fi
142
143 echo "Testing approximate searching..."
144 echo "# Testing approximate searching..." >> $SEARCHOUT
145 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
146 '(sn~=jENSEN)' name >> $SEARCHOUT 2>&1
147 RC=$?
148 if test $RC != 0 ; then
149 echo "ldapsearch failed ($RC)!"
150 test $KILLSERVERS != no && kill -HUP $KILLPIDS
151 exit $RC
152 fi
153
154 echo "Testing OR searching..."
155 echo "# Testing OR searching..." >> $SEARCHOUT
156 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
157 '(|(givenname=Xx*yY*Z)(cn=)(undef=*)(objectclass=groupofnames)(sn=jones)(member=cn=Manager,dc=example,dc=com)(uniqueMember=cn=Manager,dc=example,dc=com))' >> $SEARCHOUT 2>&1
158 RC=$?
159 if test $RC != 0 ; then
160 echo "ldapsearch failed ($RC)!"
161 test $KILLSERVERS != no && kill -HUP $KILLPIDS
162 exit $RC
163 fi
164
165 echo "Testing AND matching and ends-with searching..."
166 echo "# Testing AND matching and ends-with searching..." >> $SEARCHOUT
167 $LDAPSEARCH -S "" -b "ou=groups,$BASEDN" -s one -H $URI1 \
168 '(&(objectclass=groupofnames)(cn=A*)(member=cn=Mark Elliot,ou=Alumni Association,ou=People,dc=example,dc=com))' >> $SEARCHOUT 2>&1
169 RC=$?
170 if test $RC != 0 ; then
171 echo "ldapsearch failed ($RC)!"
172 test $KILLSERVERS != no && kill -HUP $KILLPIDS
173 exit $RC
174 fi
175
176 echo "Testing NOT searching..."
177 echo "# Testing NOT searching..." >> $SEARCHOUT
178 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
179 '(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1
180 RC=$?
181 if test $RC != 0 ; then
182 echo "ldapsearch failed ($RC)!"
183 test $KILLSERVERS != no && kill -HUP $KILLPIDS
184 exit $RC
185 fi
186
187 echo "Testing objectClass/attributeType inheritance ..."
188 echo "# Testing objectClass/attributeType inheritance ..." >> $SEARCHOUT
189 $LDAPSEARCH -M -a never -S "" -b "$BASEDN" -H $URI1 \
190 '(&(objectClass=inetorgperson)(userid=uham))' \
191 "2.5.4.0" "userid" >> $SEARCHOUT 2>&1
192 RC=$?
193 if test $RC != 0 ; then
194 echo "ldapsearch failed ($RC)!"
195 test $KILLSERVERS != no && kill -HUP $KILLPIDS
196 exit $RC
197 fi
198
199 test $KILLSERVERS != no && kill -HUP $KILLPIDS
200
201 LDIF=$SEARCHOUTPROVIDER
202
203 echo "Filtering ldapsearch results..."
204 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
205 echo "Filtering original ldif used to create database..."
206 $LDIFFILTER < $LDIF > $LDIFFLT
207 echo "Comparing filter output..."
208 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
209
210 if test $? != 0 ; then
211 echo "Comparison failed"
212 exit 1
213 fi
214
215 echo ">>>>> Test succeeded"
216
217 test $KILLSERVERS != no && wait
218
219 exit 0