]> git.sur5r.net Git - openldap/blob - tests/scripts/test002-populate
62d6923bbc1578ce438c278d2e01a5f9a32ab7d1
[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 "Comparing retrieved entries to LDIF file used to create database"
48 cmp $SEARCHOUT $LDIF
49 if [ $? != 0 ]; then
50         echo "comparison failed - database was not created correctly"
51         exit 1
52 fi
53
54 echo ">>>>> Test succeeded"
55
56
57 exit 0