Home | History | Annotate | Line # | Download | only in scripts
test002-populate revision 1.1.1.1.8.2
      1  1.1.1.1.8.2  lukem #! /bin/sh
      2  1.1.1.1.8.2  lukem # $OpenLDAP: pkg/ldap/tests/scripts/test002-populate,v 1.41.2.3 2008/02/11 23:26:50 kurt Exp $
      3  1.1.1.1.8.2  lukem ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
      4  1.1.1.1.8.2  lukem ##
      5  1.1.1.1.8.2  lukem ## Copyright 1998-2008 The OpenLDAP Foundation.
      6  1.1.1.1.8.2  lukem ## All rights reserved.
      7  1.1.1.1.8.2  lukem ##
      8  1.1.1.1.8.2  lukem ## Redistribution and use in source and binary forms, with or without
      9  1.1.1.1.8.2  lukem ## modification, are permitted only as authorized by the OpenLDAP
     10  1.1.1.1.8.2  lukem ## Public License.
     11  1.1.1.1.8.2  lukem ##
     12  1.1.1.1.8.2  lukem ## A copy of this license is available in the file LICENSE in the
     13  1.1.1.1.8.2  lukem ## top-level directory of the distribution or, alternatively, at
     14  1.1.1.1.8.2  lukem ## <http://www.OpenLDAP.org/license.html>.
     15  1.1.1.1.8.2  lukem 
     16  1.1.1.1.8.2  lukem echo "running defines.sh"
     17  1.1.1.1.8.2  lukem . $SRCDIR/scripts/defines.sh
     18  1.1.1.1.8.2  lukem 
     19  1.1.1.1.8.2  lukem mkdir -p $TESTDIR $DBDIR1 
     20  1.1.1.1.8.2  lukem 
     21  1.1.1.1.8.2  lukem echo "Starting slapd on TCP/IP port $PORT1..."
     22  1.1.1.1.8.2  lukem . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
     23  1.1.1.1.8.2  lukem $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
     24  1.1.1.1.8.2  lukem PID=$!
     25  1.1.1.1.8.2  lukem if test $WAIT != 0 ; then
     26  1.1.1.1.8.2  lukem     echo PID $PID
     27  1.1.1.1.8.2  lukem     read foo
     28  1.1.1.1.8.2  lukem fi
     29  1.1.1.1.8.2  lukem KILLPIDS="$PID"
     30  1.1.1.1.8.2  lukem 
     31  1.1.1.1.8.2  lukem sleep 1
     32  1.1.1.1.8.2  lukem 
     33  1.1.1.1.8.2  lukem echo "Using ldapsearch to check that slapd is running..."
     34  1.1.1.1.8.2  lukem for i in 0 1 2 3 4 5; do
     35  1.1.1.1.8.2  lukem 	$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
     36  1.1.1.1.8.2  lukem 		'objectclass=*' > /dev/null 2>&1
     37  1.1.1.1.8.2  lukem 	RC=$?
     38  1.1.1.1.8.2  lukem 	if test $RC = 0 ; then
     39  1.1.1.1.8.2  lukem 		break
     40  1.1.1.1.8.2  lukem 	fi
     41  1.1.1.1.8.2  lukem 	echo "Waiting 5 seconds for slapd to start..."
     42  1.1.1.1.8.2  lukem 	sleep 5
     43  1.1.1.1.8.2  lukem done
     44  1.1.1.1.8.2  lukem 
     45  1.1.1.1.8.2  lukem echo "Using ldapadd to populate the database..."
     46  1.1.1.1.8.2  lukem $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
     47  1.1.1.1.8.2  lukem 	$LDIFORDERED > $TESTOUT 2>&1
     48  1.1.1.1.8.2  lukem RC=$?
     49  1.1.1.1.8.2  lukem if test $RC != 0 ; then
     50  1.1.1.1.8.2  lukem 	echo "ldapadd failed ($RC)!"
     51  1.1.1.1.8.2  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     52  1.1.1.1.8.2  lukem 	exit $RC
     53  1.1.1.1.8.2  lukem fi
     54  1.1.1.1.8.2  lukem 
     55  1.1.1.1.8.2  lukem echo "Using ldapsearch to read all the entries..."
     56  1.1.1.1.8.2  lukem $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
     57  1.1.1.1.8.2  lukem 	'objectclass=*' > $SEARCHOUT 2>&1
     58  1.1.1.1.8.2  lukem RC=$?
     59  1.1.1.1.8.2  lukem 
     60  1.1.1.1.8.2  lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
     61  1.1.1.1.8.2  lukem 
     62  1.1.1.1.8.2  lukem if test $RC != 0 ; then
     63  1.1.1.1.8.2  lukem 	echo "ldapsearch failed ($RC)!"
     64  1.1.1.1.8.2  lukem 	exit $RC
     65  1.1.1.1.8.2  lukem fi
     66  1.1.1.1.8.2  lukem 
     67  1.1.1.1.8.2  lukem echo "Filtering ldapsearch results..."
     68  1.1.1.1.8.2  lukem . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
     69  1.1.1.1.8.2  lukem echo "Filtering original ldif used to create database..."
     70  1.1.1.1.8.2  lukem . $LDIFFILTER < $LDIF > $LDIFFLT
     71  1.1.1.1.8.2  lukem echo "Comparing filter output..."
     72  1.1.1.1.8.2  lukem $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
     73  1.1.1.1.8.2  lukem 
     74  1.1.1.1.8.2  lukem if test $? != 0 ; then
     75  1.1.1.1.8.2  lukem 	echo "comparison failed - database was not created correctly"
     76  1.1.1.1.8.2  lukem 	exit 1
     77  1.1.1.1.8.2  lukem fi
     78  1.1.1.1.8.2  lukem 
     79  1.1.1.1.8.2  lukem echo ">>>>> Test succeeded"
     80  1.1.1.1.8.2  lukem 
     81  1.1.1.1.8.2  lukem test $KILLSERVERS != no && wait
     82  1.1.1.1.8.2  lukem 
     83  1.1.1.1.8.2  lukem exit 0
     84