| 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 |
echo "" |
| 20 |
|
| 21 |
if test $BACKMETA = metano ; then |
| 22 |
echo "meta backend not available, test skipped" |
| 23 |
exit 0 |
| 24 |
fi |
| 25 |
|
| 26 |
if test $BACKLDAP = ldapno ; then |
| 27 |
echo "ldap backend not available, test skipped" |
| 28 |
exit 0 |
| 29 |
fi |
| 30 |
|
| 31 |
if test x$TESTLOOPS = x ; then |
| 32 |
TESTLOOPS=50 |
| 33 |
fi |
| 34 |
|
| 35 |
if test x$TESTCHILDREN = x ; then |
| 36 |
TESTCHILDREN=20 |
| 37 |
fi |
| 38 |
|
| 39 |
rm -rf $TESTDIR |
| 40 |
|
| 41 |
mkdir -p $TESTDIR $DBDIR1 $DBDIR2 |
| 42 |
|
| 43 |
echo "Starting slapd on TCP/IP port $PORT1..." |
| 44 |
. $CONFFILTER $BACKEND < $METACONF1 > $CONF1 |
| 45 |
$SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 & |
| 46 |
PID=$! |
| 47 |
if test $WAIT != 0 ; then |
| 48 |
echo PID $PID |
| 49 |
read foo |
| 50 |
fi |
| 51 |
KILLPIDS="$PID" |
| 52 |
|
| 53 |
sleep 1 |
| 54 |
|
| 55 |
echo "Using ldapsearch to check that slapd is running..." |
| 56 |
for i in 0 1 2 3 4 5; do |
| 57 |
$LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \ |
| 58 |
'objectclass=*' > /dev/null 2>&1 |
| 59 |
RC=$? |
| 60 |
if test $RC = 0 ; then |
| 61 |
break |
| 62 |
fi |
| 63 |
echo "Waiting 5 seconds for slapd to start..." |
| 64 |
sleep 5 |
| 65 |
done |
| 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 "Using ldapadd to populate the database..." |
| 73 |
$LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD < \ |
| 74 |
$LDIFORDERED > $TESTOUT 2>&1 |
| 75 |
RC=$? |
| 76 |
if test $RC != 0 ; then |
| 77 |
echo "ldapadd failed ($RC)!" |
| 78 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 79 |
exit $RC |
| 80 |
fi |
| 81 |
|
| 82 |
echo "Starting slapd on TCP/IP port $PORT2..." |
| 83 |
. $CONFFILTER $BACKEND < $METACONF2 > $CONF2 |
| 84 |
$SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 & |
| 85 |
PID=$! |
| 86 |
if test $WAIT != 0 ; then |
| 87 |
echo PID $PID |
| 88 |
read foo |
| 89 |
fi |
| 90 |
KILLPIDS="$KILLPIDS $PID" |
| 91 |
|
| 92 |
sleep 1 |
| 93 |
|
| 94 |
echo "Using ldapsearch to check that slapd is running..." |
| 95 |
for i in 0 1 2 3 4 5; do |
| 96 |
$LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \ |
| 97 |
'objectclass=*' > /dev/null 2>&1 |
| 98 |
RC=$? |
| 99 |
if test $RC = 0 ; then |
| 100 |
break |
| 101 |
fi |
| 102 |
echo "Waiting 5 seconds for slapd to start..." |
| 103 |
sleep 5 |
| 104 |
done |
| 105 |
if test $RC != 0 ; then |
| 106 |
echo "ldapsearch failed ($RC)!" |
| 107 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 108 |
exit $RC |
| 109 |
fi |
| 110 |
|
| 111 |
echo "Using ldapadd to populate the database..." |
| 112 |
$LDAPADD -D "$METAMANAGERDN" -H $URI2 -w $PASSWD < \ |
| 113 |
$LDIFMETA >> $TESTOUT 2>&1 |
| 114 |
RC=$? |
| 115 |
if test $RC != 0 ; then |
| 116 |
echo "ldapadd failed ($RC)!" |
| 117 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 118 |
exit $RC |
| 119 |
fi |
| 120 |
|
| 121 |
echo "Starting slapd on TCP/IP port $PORT3..." |
| 122 |
. $CONFFILTER $BACKEND < $METACONF > $CONF3 |
| 123 |
$SLAPD -f $CONF3 -h $URI3 -d $LVL > $LOG3 2>&1 & |
| 124 |
PID=$! |
| 125 |
if test $WAIT != 0 ; then |
| 126 |
echo PID $PID |
| 127 |
read foo |
| 128 |
fi |
| 129 |
KILLPIDS="$KILLPIDS $PID" |
| 130 |
|
| 131 |
sleep 1 |
| 132 |
|
| 133 |
echo "Using ldapsearch to check that slapd is running..." |
| 134 |
for i in 0 1 2 3 4 5; do |
| 135 |
$LDAPSEARCH -s base -b "$MONITOR" -H $URI3 \ |
| 136 |
'objectclass=*' > /dev/null 2>&1 |
| 137 |
RC=$? |
| 138 |
if test $RC = 0 ; then |
| 139 |
break |
| 140 |
fi |
| 141 |
echo "Waiting 5 seconds for slapd to start..." |
| 142 |
sleep 5 |
| 143 |
done |
| 144 |
if test $RC != 0 ; then |
| 145 |
echo "ldapsearch failed ($RC)!" |
| 146 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 147 |
exit $RC |
| 148 |
fi |
| 149 |
|
| 150 |
cat /dev/null > $SEARCHOUT |
| 151 |
|
| 152 |
mkdir -p $TESTDIR/$DATADIR |
| 153 |
METABASEDN="o=Example,c=US" |
| 154 |
for f in $DATADIR/do_* ; do |
| 155 |
sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f |
| 156 |
done |
| 157 |
|
| 158 |
# add a read that matches only the local database, but selects |
| 159 |
# also the remote as candidate; this should be removed to compare |
| 160 |
# execution times with test008... |
| 161 |
for f in $TESTDIR/$DATADIR/do_read.* ; do |
| 162 |
echo "ou=Meta,$METABASEDN" >> $f |
| 163 |
done |
| 164 |
|
| 165 |
# add a read that matches a referral in the local database only, |
| 166 |
# but selects also the remote as candidate; this should be removed |
| 167 |
# to compare execution times with test008... |
| 168 |
for f in $TESTDIR/$DATADIR/do_read.* ; do |
| 169 |
echo "cn=Somewhere,ou=Meta,$METABASEDN" >> $f |
| 170 |
done |
| 171 |
|
| 172 |
# add a bind that resolves to a referral |
| 173 |
for f in $TESTDIR/$DATADIR/do_bind.* ; do |
| 174 |
echo "cn=Foo,ou=Meta,$METABASEDN" >> $f |
| 175 |
echo "bar" >> $f |
| 176 |
echo "" >> $f |
| 177 |
echo "" >> $f |
| 178 |
done |
| 179 |
|
| 180 |
# NOTE: copies do_* files from $TESTDIR/$DATADIR to $TESTDIR |
| 181 |
$MONITORDATA "$TESTDIR/$DATADIR" "$TESTDIR" |
| 182 |
|
| 183 |
BINDDN="cn=Manager,o=Local" |
| 184 |
PASSWD="secret" |
| 185 |
echo "Using tester for concurrent server access..." |
| 186 |
$SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR" -H $URI3 \ |
| 187 |
-D "$BINDDN" -w $PASSWD -l $TESTLOOPS -j $TESTCHILDREN \ |
| 188 |
-r 20 -i '!REFERRAL' -i '*INVALID_CREDENTIALS' -SS |
| 189 |
RC=$? |
| 190 |
|
| 191 |
if test $RC != 0 ; then |
| 192 |
echo "slapd-tester failed ($RC)!" |
| 193 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 194 |
exit $RC |
| 195 |
fi |
| 196 |
|
| 197 |
echo "Using ldapsearch to retrieve all the entries..." |
| 198 |
$LDAPSEARCH -S "" -b "$METABASEDN" -H $URI3 \ |
| 199 |
'objectClass=*' > $SEARCHOUT 2>&1 |
| 200 |
RC=$? |
| 201 |
|
| 202 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 203 |
|
| 204 |
if test $RC != 0 ; then |
| 205 |
echo "ldapsearch failed ($RC)!" |
| 206 |
exit $RC |
| 207 |
fi |
| 208 |
|
| 209 |
echo "Filtering ldapsearch results..." |
| 210 |
$LDIFFILTER < $SEARCHOUT > $SEARCHFLT |
| 211 |
echo "Filtering original ldif used to create database..." |
| 212 |
$LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT |
| 213 |
echo "Comparing filter output..." |
| 214 |
$CMP $SEARCHFLT $LDIFFLT > $CMPOUT |
| 215 |
|
| 216 |
if test $? != 0 ; then |
| 217 |
echo "comparison failed - slapd-meta search/modification didn't succeed" |
| 218 |
exit 1 |
| 219 |
fi |
| 220 |
|
| 221 |
echo ">>>>> Test succeeded" |
| 222 |
|
| 223 |
test $KILLSERVERS != no && wait |
| 224 |
|
| 225 |
exit 0 |