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