Home | History | Annotate | Line # | Download | only in scripts
test002-populate revision 1.1.1.3
      1      1.1  lukem #! /bin/sh
      2  1.1.1.3   adam # OpenLDAP: pkg/ldap/tests/scripts/test002-populate,v 1.41.2.6 2010/04/19 19:14:32 quanah Exp
      3      1.1  lukem ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
      4      1.1  lukem ##
      5  1.1.1.3   adam ## Copyright 1998-2010 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 mkdir -p $TESTDIR $DBDIR1 
     20      1.1  lukem 
     21      1.1  lukem echo "Starting slapd on TCP/IP port $PORT1..."
     22      1.1  lukem . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
     23      1.1  lukem $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
     24      1.1  lukem PID=$!
     25      1.1  lukem if test $WAIT != 0 ; then
     26      1.1  lukem     echo PID $PID
     27      1.1  lukem     read foo
     28      1.1  lukem fi
     29      1.1  lukem KILLPIDS="$PID"
     30      1.1  lukem 
     31      1.1  lukem sleep 1
     32      1.1  lukem 
     33      1.1  lukem echo "Using ldapsearch to check that slapd is running..."
     34      1.1  lukem for i in 0 1 2 3 4 5; do
     35      1.1  lukem 	$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
     36      1.1  lukem 		'objectclass=*' > /dev/null 2>&1
     37      1.1  lukem 	RC=$?
     38      1.1  lukem 	if test $RC = 0 ; then
     39      1.1  lukem 		break
     40      1.1  lukem 	fi
     41      1.1  lukem 	echo "Waiting 5 seconds for slapd to start..."
     42      1.1  lukem 	sleep 5
     43      1.1  lukem done
     44      1.1  lukem 
     45      1.1  lukem echo "Using ldapadd to populate the database..."
     46      1.1  lukem $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
     47      1.1  lukem 	$LDIFORDERED > $TESTOUT 2>&1
     48      1.1  lukem RC=$?
     49      1.1  lukem if test $RC != 0 ; then
     50      1.1  lukem 	echo "ldapadd failed ($RC)!"
     51      1.1  lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     52      1.1  lukem 	exit $RC
     53      1.1  lukem fi
     54      1.1  lukem 
     55      1.1  lukem echo "Using ldapsearch to read all the entries..."
     56      1.1  lukem $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
     57      1.1  lukem 	'objectclass=*' > $SEARCHOUT 2>&1
     58      1.1  lukem RC=$?
     59      1.1  lukem 
     60      1.1  lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
     61      1.1  lukem 
     62      1.1  lukem if test $RC != 0 ; then
     63      1.1  lukem 	echo "ldapsearch failed ($RC)!"
     64      1.1  lukem 	exit $RC
     65      1.1  lukem fi
     66      1.1  lukem 
     67      1.1  lukem echo "Filtering ldapsearch results..."
     68  1.1.1.3   adam $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
     69      1.1  lukem echo "Filtering original ldif used to create database..."
     70  1.1.1.3   adam $LDIFFILTER < $LDIF > $LDIFFLT
     71      1.1  lukem echo "Comparing filter output..."
     72      1.1  lukem $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
     73      1.1  lukem 
     74      1.1  lukem if test $? != 0 ; then
     75      1.1  lukem 	echo "comparison failed - database was not created correctly"
     76      1.1  lukem 	exit 1
     77      1.1  lukem fi
     78      1.1  lukem 
     79      1.1  lukem echo ">>>>> Test succeeded"
     80      1.1  lukem 
     81      1.1  lukem test $KILLSERVERS != no && wait
     82      1.1  lukem 
     83      1.1  lukem exit 0
     84