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