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