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