]> git.sur5r.net Git - openldap/blob - tests/scripts/test009-referral
aab5a45356f3bd90a1b18d6f25c7550006e81547
[openldap] / tests / scripts / test009-referral
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 #
25 # Test default referral
26 #
27
28
29 echo "Cleaning up in $DBDIR and $REPLDIR ..."
30
31 rm -f $DBDIR/[!C]*
32 rm -f $REPLDIR/[!C]*
33
34 echo "Running slapadd to build slapd database..."
35 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $DBCONF
36 $SLAPADD -f $DBCONF -l $LDIFORDERED
37 RC=$?
38 if test $RC != 0 ; then
39         echo "slapadd failed ($RC)!"
40         exit $RC
41 fi
42
43 echo "Starting master slapd on TCP/IP port $PORT..."
44 $SLAPD -n master -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
45 PID=$!
46 if test $WAIT != 0 ; then
47     echo PID $PID
48     read foo
49 fi
50
51 echo "Starting slave slapd on TCP/IP port $SLAVEPORT..."
52 . $CONFFILTER $BACKEND $MONITORDB < $REFSLAVECONF > $REPLCONF
53 $SLAPD -n slave -f $REPLCONF -h $SLAVEURI -d $LVL $TIMING > $SLAVELOG 2>&1 &
54 SLAVEPID=$!
55 if test $WAIT != 0 ; then
56     echo SLAVEPID $SLAVEPID
57     read foo
58 fi
59
60 echo "Testing for master slapd..."
61 for i in 0 1 2 3 4 5; do
62         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
63                 'objectclass=*' > /dev/null 2>&1
64         RC=$?
65         if test $RC = 1 ; then
66                 echo "Waiting 5 seconds for slapd to start..."
67                 sleep 5
68         fi
69 done
70
71 if test $RC != 0 ; then
72         echo "ldapsearch failed ($RC)!"
73         kill -HUP $PID
74         exit $RC
75 fi
76
77 echo "Testing for slave slapd..."
78 for i in 0 1 2 3 4 5; do
79         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $SLAVEPORT \
80                 'objectclass=*' > /dev/null 2>&1
81         RC=$?
82         if test $RC = 1 ; then
83                 echo "Waiting 5 seconds for slapd to start..."
84                 sleep 5
85         fi
86 done
87
88 cat /dev/null > $SEARCHOUT
89
90 echo "Testing exact searching..."
91 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
92         'sn=jensen' >> $SEARCHOUT 2>&1
93 RC=$?
94 if test $RC != 0 ; then
95         echo "ldapsearch failed ($RC)!"
96         kill -HUP $PID $SLAVEPID
97         exit $RC
98 fi
99
100 echo "Testing OR searching..."
101 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
102         '(|(objectclass=groupofnames)(sn=jones))' >> $SEARCHOUT 2>&1
103 RC=$?
104 if test $RC != 0 ; then
105         echo "ldapsearch failed ($RC)!"
106         kill -HUP $PID $SLAVEPID
107         exit $RC
108 fi
109
110 echo "Testing AND matching and ends-with searching..."
111 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
112         '(&(objectclass=groupofnames)(cn=A*))' >> $SEARCHOUT 2>&1
113 RC=$?
114 if test $RC != 0 ; then
115         echo "ldapsearch failed ($RC)!"
116         kill -HUP $PID $SLAVEPID
117         exit $RC
118 fi
119
120 echo "Testing NOT searching..."
121 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
122         '(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1
123 RC=$?
124 if test $RC != 0 ; then
125         echo "ldapsearch failed ($RC)!"
126         kill -HUP $PID $SLAVEPID
127         exit $RC
128 fi
129
130 echo "Testing objectClass/attributeType inheritance ..."
131 $LDAPSEARCH -M -a never -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
132         '(&(objectClass=inetorgperson)(userid=uham))' \
133         "2.5.4.0" "userid" >> $SEARCHOUT 2>&1
134 RC=$?
135 if test $RC != 0 ; then
136         echo "ldapsearch failed ($RC)!"
137         kill -HUP $PID
138         exit $RC
139 fi
140
141
142 kill -HUP $PID $SLAVEPID
143
144 LDIF=$SEARCHOUTMASTER
145
146 echo "Filtering ldapsearch results..."
147 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
148 echo "Filtering original ldif used to create database..."
149 . $LDIFFILTER < $LDIF > $LDIFFLT
150 echo "Comparing filter output..."
151 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
152
153 if test $? != 0 ; then
154         echo "Comparison failed"
155         exit 1
156 fi
157
158 echo ">>>>> Test succeeded"
159
160
161 exit 0