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