]> git.sur5r.net Git - openldap/blob - tests/scripts/test002-populate
ITS#2401 support tests for dynamically loaded backends
[openldap] / tests / scripts / test002-populate
1 #! /bin/sh
2 # $OpenLDAP$
3
4 SRCDIR="."
5 if test $# -ge 1 ; then
6         SRCDIR=$1; shift
7 fi
8
9 . $SRCDIR/scripts/args.sh
10
11 echo "running defines.sh"
12 . $SRCDIR/scripts/defines.sh
13
14 echo "Cleaning up in $DBDIR..."
15
16 rm -f $DBDIR/[!C]*
17
18 echo "Starting slapd on TCP/IP port $PORT..."
19 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $DBCONF
20 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
21 PID=$!
22 if test $WAIT != 0 ; then
23     echo PID $PID
24     read foo
25 fi
26
27 echo "Using ldapsearch to check that slapd is running..."
28 for i in 0 1 2 3 4 5; do
29         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
30                 'objectclass=*' > /dev/null 2>&1
31         RC=$?
32         if test $RC = 0 ; then
33                 break
34         fi
35         echo "Waiting 5 seconds for slapd to start..."
36         sleep 5
37 done
38
39 echo "Using ldapadd to populate the database..."
40 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
41         $LDIFORDERED > $TESTOUT 2>&1
42 RC=$?
43 if test $RC != 0 ; then
44         echo "ldapadd failed ($RC)!"
45         kill -HUP $PID
46         exit $RC
47 fi
48
49 echo "Using ldapsearch to read all the entries..."
50 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
51         'objectclass=*' > $SEARCHOUT 2>&1
52 RC=$?
53
54 kill -HUP $PID
55
56 if test $RC != 0 ; then
57         echo "ldapsearch failed ($RC)!"
58         exit $RC
59 fi
60
61 echo "Filtering ldapsearch results..."
62 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
63 echo "Filtering original ldif used to create database..."
64 . $LDIFFILTER < $LDIF > $LDIFFLT
65 echo "Comparing filter output..."
66 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
67
68 if test $? != 0 ; then
69         echo "comparison failed - database was not created correctly"
70         exit 1
71 fi
72
73 echo ">>>>> Test succeeded"
74
75
76 exit 0