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