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