]> git.sur5r.net Git - openldap/blobdiff - tests/scripts/test030-relay
ITS#7455
[openldap] / tests / scripts / test030-relay
index bcca7cd500f5a9017412ca085fe7115ca1e081ec..72594760d832b673cf7180dc1ff25ab9bf937a90 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2004 The OpenLDAP Foundation.
+## Copyright 1998-2012 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
 echo "running defines.sh"
 . $SRCDIR/scripts/defines.sh
 
-if test $BACKRELAY = relayno ; then 
-       echo "relay backend not available, test skipped"
-       exit 0
-fi 
-
 if test $RWM = rwmno ; then 
-       echo "Rewrite/remap overlay not available, test skipped"
+       echo "rwm (Rewrite/remap) overlay not available, test skipped"
        exit 0
 fi 
 
-mkdir -p $TESTDIR $DBDIR1
+echo ""
 
-echo "Starting slapd on TCP/IP port $PORT1..."
-. $CONFFILTER $BACKEND $MONITORDB < $RWMCONF > $CONF1
-$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
-PID=$!
-if test $WAIT != 0 ; then
-    echo PID $PID
-    read foo
-fi
-KILLPIDS="$PID"
+if test "x$RELAYS" = "x" ; then
+       RELAYS=
+       # back-relay
+       if test $BACKRELAY = relayno ; then 
+               echo "relay backend not available, test skipped"
+       else
+               if test "x$RELAYS" != "x" ; then
+                       RELAYS="${RELAYS} "
+               fi
+               RELAYS="${RELAYS}relay"
+       fi
 
-echo "Using ldapsearch to check that slapd is running..."
-for i in 0 1 2 3 4 5; do
-       $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
-               'objectclass=*' > /dev/null 2>&1
-       RC=$?
-       if test $RC = 0 ; then
-               break
+       # back-ldap
+       if test $BACKLDAP = ldapno ; then 
+               echo "ldap backend not available, test skipped"
+       else
+               if test $THREADS = "threadsno" ; then
+                       echo "Need threads support, test skipped"
+               else
+                       if test "x$RELAYS" != "x" ; then
+                               RELAYS="${RELAYS} "
+                       fi
+                       RELAYS="${RELAYS}ldap"
+               fi 
        fi
-       echo "Waiting 5 seconds for slapd to start..."
-       sleep 5
-done
-if test $RC != 0 ; then
-       echo "ldapsearch failed $(RC)!"
-       test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       exit $RC
-fi
 
-echo "Using ldapadd to populate the database..."
-$LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
-       $LDIFORDERED > $TESTOUT 2>&1
-RC=$?
-if test $RC != 0 ; then
-       echo "ldapadd failed ($RC)!"
-       test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       exit $RC
+       # back-meta
+       if test $BACKMETA = metano ; then 
+               echo "meta backend not available, test skipped"
+       else
+               if test $THREADS = "threadsno" ; then
+                       echo "Need threads support, test skipped"
+               else
+                       if test "x$RELAYS" != "x" ; then
+                               RELAYS="${RELAYS} "
+                       fi
+                       RELAYS="${RELAYS}meta"
+               fi
+       fi 
 fi
 
-cat /dev/null > $SEARCHOUT
-
-BASEDN="dc=example,dc=com"
-echo "searching base=\"$BASEDN\"..."
-$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
-RC=$?
-if test $RC != 0 ; then
-       echo "Search failed ($RC)!"
-       test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       exit $RC
+if test "x$RELAYS" = "x" ; then
+       echo "no relaying capable backend is available"
+       echo ">>>>> Test succeeded"
+       exit 0
 fi
 
-BASEDN="o=Example,c=US"
-echo "searching base=\"$BASEDN\"..."
-$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
-RC=$?
-if test $RC != 0 ; then
-       echo "Search failed ($RC)!"
-       test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       exit $RC
-fi
+echo "Testing virtual naming context mapping with $RELAYS backend(s)..."
+echo ""
 
-BASEDN="o=Esempio,c=IT"
-echo "searching base=\"$BASEDN\"..."
-$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
-RC=$?
-if test $RC != 0 ; then
-       echo "Search failed ($RC)!"
-       test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       exit $RC
+tmpfile=savelog.log
+if test -f $tmpfile ; then
+       rm -f $tmpfile
 fi
+first=1
+for RELAY in $RELAYS ; do
+       RUNIT=yes
+       if test $THREADS = "threadsno" ; then
+               case $RELAY in
+               ldap|meta)
+                       echo "Need threads support, test skipped"
+                       RUNIT=no
+                       ;;
+               esac
+       fi
+       
+       if test $RUNIT = yes ; then             
+               if test $first = 1 ; then
+                       first=0
+               else
+                       echo ">>>>> waiting for things to exit"
+                       test $KILLSERVERS != no && wait
+                       echo ""
 
-BASEDN="o=Beispiel,c=DE"
-echo "searching base=\"$BASEDN\"..."
-$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
-RC=$?
-if test $RC != 0 ; then
-       echo "Search failed ($RC)!"
-       test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       exit $RC
-fi
+                       mv -f $LOG1 $tmpfile
+                       rm -rf $TESTDIR
+               fi
+
+               mkdir -p $TESTDIR $DBDIR1
 
-test $KILLSERVERS != no && kill -HUP $KILLPIDS
+               if test -f $tmpfile ; then
+                       mv $tmpfile $LOG1
+               fi
+       
+               . $SRCDIR/scripts/relay
+       fi
+done
 
 echo ">>>>> Test succeeded"
+
+test $KILLSERVERS != no && wait
+
 exit 0