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