]> git.sur5r.net Git - openldap/blob - tests/scripts/test012-glue
Sync with HEAD
[openldap] / tests / scripts / test012-glue
1 #! /bin/sh
2 # $OpenLDAP$
3
4 SRCDIR="."
5 if test $# -ge 1 ; then
6         SRCDIR=$1; shift
7 fi
8
9 . $SRCDIR/scripts/args.sh $*
10
11 echo "running defines.sh"
12 . $SRCDIR/scripts/defines.sh
13
14 echo "Cleaning up in $DBDIR..."
15
16 mkdir $DBDIR/C_db1 $DBDIR/C_db2 $DBDIR/C_db3
17
18 rm -f $DBDIR/[!C]* $DBDIR/C_db?/*
19
20 echo "Running slapadd to build glued slapd databases..."
21 . $CONFFILTER $BACKEND $MONITORDB < $GLUECONF > $DBCONF
22 $SLAPADD -d $LVL -f $DBCONF -l $LDIFORDERED > $DBDIR/slapadd.log 2>&1
23 RC=$?
24 if test $RC != 0 ; then
25         echo "slapadd failed ($RC)!"
26         exit $RC
27 fi
28
29 echo "Starting slapd on TCP/IP port $PORT..."
30 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
31 PID=$!
32 if test $WAIT != 0 ; then
33     echo PID $PID
34     read foo
35 fi
36
37 echo "Using ldapsearch to retrieve all the entries..."
38 cd test-db
39 for i in 0 1 2 3 4 5; do
40         ../$LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT > ../$SEARCHOUT 2>&1
41         RC=$?
42         if test $RC = 0 ; then
43                 break
44         fi
45         echo "Waiting 5 seconds for slapd to start..."
46         sleep 5
47 done
48 cd ..
49
50 kill -HUP $PID
51 echo "Sleeping for 5 seconds to let slapd exit..."
52 sleep 5
53
54 if test $RC != 0 ; then
55         echo "ldapsearch failed ($RC)!"
56         exit $RC
57 fi
58
59 echo "Filtering ldapsearch results..."
60 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
61 echo "Filtering original ldif used to create database..."
62 . $LDIFFILTER < $LDIFGLUED > $LDIFFLT
63 echo "Comparing filter output..."
64 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
65
66 if test $? != 0 ; then
67         echo "comparison failed - database was not created correctly"
68         echo $SEARCHFLT $LDIFFLT
69         $DIFF $SEARCHFLT $LDIFFLT
70         exit 1
71 fi
72
73 echo "OK...  Cleaning up in $DBDIR..."
74
75 rm -f $DBDIR/C_db?/*
76
77 echo "Starting slapd on TCP/IP port $PORT..."
78 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
79 PID=$!
80 if test $WAIT != 0 ; then
81     echo PID $PID
82     read foo
83 fi
84
85 echo "Using ldapsearch to check that slapd is running..."
86 for i in 0 1 2 3 4 5; do
87         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
88                 'objectclass=*' > /dev/null 2>&1
89         RC=$?
90         if test $RC = 0 ; then
91                 break
92         fi
93         echo "Waiting 5 seconds for slapd to start..."
94         sleep 5
95 done
96
97 echo "Using ldapadd to populate the glued database..."
98 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD < \
99         $LDIFORDERED > $TESTOUT 2>&1
100 RC=$?
101 if test $RC != 0 ; then
102         echo "ldapadd failed ($RC)!"
103         kill -HUP $PID
104         exit $RC
105 fi
106
107 echo "Using ldapsearch to read all the entries..."
108 $LDAPSEARCH -b "$BASEDN" -h $LOCALHOST -p $PORT \
109         'objectclass=*' > $SEARCHOUT 2>&1
110 RC=$?
111
112 kill -HUP $PID
113
114 if test $RC != 0 ; then
115         echo "ldapsearch failed ($RC)!"
116         exit $RC
117 fi
118
119 echo "Filtering ldapsearch results..."
120 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
121 echo "Filtering original ldif used to create database..."
122 . $LDIFFILTER < $LDIFGLUED > $LDIFFLT
123 echo "Comparing filter output..."
124 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
125
126 if test $? != 0 ; then
127         echo "comparison failed - database was not created correctly"
128         exit 1
129 fi
130
131 echo ">>>>> Test succeeded"
132
133
134 exit 0