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