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