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