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