Home | History | Annotate | Line # | Download | only in scripts
test036-meta-concurrency revision 1.1.1.5
      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.5   tron ## Copyright 1998-2014 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 # NOTE: this could be added to all tests...
     44      1.1  lukem if test "$BACKEND" = "bdb" || test "$BACKEND" = "hdb" ; then
     45      1.1  lukem 	if test "x$DB_CONFIG" != "x" ; then \
     46      1.1  lukem 		if test -f $DB_CONFIG ; then
     47      1.1  lukem 			echo "==> using DB_CONFIG \"$DB_CONFIG\""
     48      1.1  lukem 			cp $DB_CONFIG $DBDIR1
     49      1.1  lukem 			cp $DB_CONFIG $DBDIR2
     50      1.1  lukem 		else
     51      1.1  lukem 			echo "==> DB_CONFIG must point to a valid file (ignored)"
     52      1.1  lukem 		fi
     53      1.1  lukem 	else
     54      1.1  lukem 		echo "==> set \"DB_CONFIG\" to the DB_CONFIG file you want to use for the test."
     55      1.1  lukem 	fi
     56      1.1  lukem 	echo ""
     57      1.1  lukem fi
     58      1.1  lukem 
     59      1.1  lukem echo "Starting slapd on TCP/IP port $PORT1..."
     60      1.1  lukem . $CONFFILTER $BACKEND $MONITORDB < $METACONF1 > $CONF1
     61      1.1  lukem $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
     62      1.1  lukem PID=$!
     63      1.1  lukem if test $WAIT != 0 ; then
     64      1.1  lukem     echo PID $PID
     65      1.1  lukem     read foo
     66      1.1  lukem fi
     67      1.1  lukem KILLPIDS="$PID"
     68      1.1  lukem 
     69      1.1  lukem sleep 1
     70      1.1  lukem 
     71      1.1  lukem echo "Using ldapsearch to check that slapd is running..."
     72      1.1  lukem for i in 0 1 2 3 4 5; do
     73      1.1  lukem 	$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
     74      1.1  lukem 		'objectclass=*' > /dev/null 2>&1
     75      1.1  lukem 	RC=$?
     76      1.1  lukem 	if test $RC = 0 ; then
     77      1.1  lukem 		break
     78      1.1  lukem 	fi
     79      1.1  lukem 	echo "Waiting 5 seconds for slapd to start..."
     80      1.1  lukem 	sleep 5
     81      1.1  lukem done
     82      1.1  lukem if test $RC != 0 ; then
     83      1.1  lukem 	echo "ldapsearch failed ($RC)!"
     84      1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     85      1.1  lukem 	exit $RC
     86      1.1  lukem fi
     87      1.1  lukem 
     88      1.1  lukem echo "Using ldapadd to populate the database..."
     89      1.1  lukem $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
     90      1.1  lukem 	$LDIFORDERED > $TESTOUT 2>&1
     91      1.1  lukem RC=$?
     92      1.1  lukem if test $RC != 0 ; then
     93      1.1  lukem 	echo "ldapadd failed ($RC)!"
     94      1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     95      1.1  lukem 	exit $RC
     96      1.1  lukem fi
     97      1.1  lukem 
     98      1.1  lukem echo "Starting slapd on TCP/IP port $PORT2..."
     99      1.1  lukem . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
    100      1.1  lukem $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
    101      1.1  lukem PID=$!
    102      1.1  lukem if test $WAIT != 0 ; then
    103      1.1  lukem     echo PID $PID
    104      1.1  lukem     read foo
    105      1.1  lukem fi
    106      1.1  lukem KILLPIDS="$KILLPIDS $PID"
    107      1.1  lukem 
    108      1.1  lukem sleep 1
    109      1.1  lukem 
    110      1.1  lukem echo "Using ldapsearch to check that slapd is running..."
    111      1.1  lukem for i in 0 1 2 3 4 5; do
    112      1.1  lukem 	$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
    113      1.1  lukem 		'objectclass=*' > /dev/null 2>&1
    114      1.1  lukem 	RC=$?
    115      1.1  lukem 	if test $RC = 0 ; then
    116      1.1  lukem 		break
    117      1.1  lukem 	fi
    118      1.1  lukem 	echo "Waiting 5 seconds for slapd to start..."
    119      1.1  lukem 	sleep 5
    120      1.1  lukem done
    121      1.1  lukem if test $RC != 0 ; then
    122      1.1  lukem 	echo "ldapsearch failed ($RC)!"
    123      1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    124      1.1  lukem 	exit $RC
    125      1.1  lukem fi
    126      1.1  lukem 
    127      1.1  lukem echo "Using ldapadd to populate the database..."
    128      1.1  lukem $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
    129      1.1  lukem 	$LDIFMETA >> $TESTOUT 2>&1
    130      1.1  lukem RC=$?
    131      1.1  lukem if test $RC != 0 ; then
    132      1.1  lukem 	echo "ldapadd failed ($RC)!"
    133      1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    134      1.1  lukem 	exit $RC
    135      1.1  lukem fi
    136      1.1  lukem 
    137      1.1  lukem echo "Starting slapd on TCP/IP port $PORT3..."
    138      1.1  lukem . $CONFFILTER $BACKEND $MONITORDB < $METACONF > $CONF3
    139      1.1  lukem $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
    140      1.1  lukem PID=$!
    141      1.1  lukem if test $WAIT != 0 ; then
    142      1.1  lukem     echo PID $PID
    143      1.1  lukem     read foo
    144      1.1  lukem fi
    145      1.1  lukem KILLPIDS="$KILLPIDS $PID"
    146      1.1  lukem 
    147      1.1  lukem sleep 1
    148      1.1  lukem 
    149      1.1  lukem echo "Using ldapsearch to check that slapd is running..."
    150      1.1  lukem for i in 0 1 2 3 4 5; do
    151      1.1  lukem 	$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
    152      1.1  lukem 		'objectclass=*' > /dev/null 2>&1
    153      1.1  lukem 	RC=$?
    154      1.1  lukem 	if test $RC = 0 ; then
    155      1.1  lukem 		break
    156      1.1  lukem 	fi
    157      1.1  lukem 	echo "Waiting 5 seconds for slapd to start..."
    158      1.1  lukem 	sleep 5
    159      1.1  lukem done
    160      1.1  lukem if test $RC != 0 ; then
    161      1.1  lukem 	echo "ldapsearch failed ($RC)!"
    162      1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    163      1.1  lukem 	exit $RC
    164      1.1  lukem fi
    165      1.1  lukem 
    166      1.1  lukem cat /dev/null > $SEARCHOUT
    167      1.1  lukem 
    168      1.1  lukem mkdir -p $TESTDIR/$DATADIR
    169      1.1  lukem METABASEDN="o=Example,c=US"
    170      1.1  lukem for f in $DATADIR/do_* ; do
    171      1.1  lukem 	sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f
    172      1.1  lukem done
    173      1.1  lukem 
    174      1.1  lukem # add a read that matches only the local database, but selects 
    175      1.1  lukem # also the remote as candidate; this should be removed to compare
    176      1.1  lukem # execution times with test008...
    177      1.1  lukem for f in $TESTDIR/$DATADIR/do_read.* ; do
    178      1.1  lukem 	echo "ou=Meta,$METABASEDN" >> $f
    179      1.1  lukem done
    180      1.1  lukem 
    181      1.1  lukem # add a read that matches a referral in the local database only, 
    182      1.1  lukem # but selects also the remote as candidate; this should be removed 
    183      1.1  lukem # to compare execution times with test008...
    184      1.1  lukem for f in $TESTDIR/$DATADIR/do_read.* ; do
    185      1.1  lukem 	echo "cn=Somewhere,ou=Meta,$METABASEDN" >> $f
    186      1.1  lukem done
    187      1.1  lukem 
    188      1.1  lukem # add a bind that resolves to a referral
    189      1.1  lukem for f in $TESTDIR/$DATADIR/do_bind.* ; do
    190      1.1  lukem 	echo "cn=Foo,ou=Meta,$METABASEDN" >> $f
    191      1.1  lukem 	echo "bar" >> $f
    192      1.1  lukem 	echo "" >> $f
    193      1.1  lukem 	echo "" >> $f
    194      1.1  lukem done
    195      1.1  lukem 
    196  1.1.1.3  lukem # fix test data to include back-monitor, if available
    197  1.1.1.3  lukem # NOTE: copies do_* files from $TESTDIR/$DATADIR to $TESTDIR
    198  1.1.1.3  lukem $MONITORDATA "$MONITORDB" "$TESTDIR/$DATADIR" "$TESTDIR"
    199  1.1.1.3  lukem 
    200  1.1.1.5   tron BINDDN="cn=Manager,o=Local"
    201  1.1.1.5   tron PASSWD="secret"
    202      1.1  lukem echo "Using tester for concurrent server access..."
    203  1.1.1.3  lukem $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR" -h $LOCALHOST -p $PORT3 \
    204  1.1.1.5   tron 	-D "$BINDDN" -w $PASSWD -l $TESTLOOPS -j $TESTCHILDREN \
    205  1.1.1.5   tron 	-r 20 -i '!REFERRAL' -i '*INVALID_CREDENTIALS' -SS
    206      1.1  lukem RC=$?
    207      1.1  lukem 
    208      1.1  lukem if test $RC != 0 ; then
    209      1.1  lukem 	echo "slapd-tester failed ($RC)!"
    210      1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    211      1.1  lukem 	exit $RC
    212      1.1  lukem fi 
    213      1.1  lukem 
    214      1.1  lukem echo "Using ldapsearch to retrieve all the entries..."
    215      1.1  lukem $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \
    216      1.1  lukem 			'objectClass=*' > $SEARCHOUT 2>&1
    217      1.1  lukem RC=$?
    218      1.1  lukem 
    219      1.1  lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
    220      1.1  lukem 
    221      1.1  lukem if test $RC != 0 ; then
    222      1.1  lukem 	echo "ldapsearch failed ($RC)!"
    223      1.1  lukem 	exit $RC
    224      1.1  lukem fi
    225      1.1  lukem 
    226      1.1  lukem echo "Filtering ldapsearch results..."
    227  1.1.1.4   adam $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
    228      1.1  lukem echo "Filtering original ldif used to create database..."
    229  1.1.1.4   adam $LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT
    230      1.1  lukem echo "Comparing filter output..."
    231      1.1  lukem $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
    232      1.1  lukem 
    233      1.1  lukem if test $? != 0 ; then
    234      1.1  lukem 	echo "comparison failed - slapd-meta search/modification didn't succeed"
    235      1.1  lukem 	exit 1
    236      1.1  lukem fi
    237      1.1  lukem 
    238      1.1  lukem echo ">>>>> Test succeeded"
    239      1.1  lukem 
    240      1.1  lukem test $KILLSERVERS != no && wait
    241      1.1  lukem 
    242      1.1  lukem exit 0
    243