5 if test $# -ge 1 ; then
9 if test $# -ge 1 ; then
13 if test $# -ge 1 ; then
17 if test $# -ge 1 ; then
21 echo "running defines.sh"
22 . $SRCDIR/scripts/defines.sh
25 # Test default referral
29 echo "Cleaning up in $DBDIR and $REPLDIR ..."
34 echo "Running slapadd to build slapd database..."
35 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $DBCONF
36 $SLAPADD -f $DBCONF -l $LDIFORDERED
38 if test $RC != 0 ; then
39 echo "slapadd failed ($RC)!"
43 echo "Starting master slapd on TCP/IP port $PORT..."
44 $SLAPD -n master -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
46 if test $WAIT != 0 ; then
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 &
55 if test $WAIT != 0 ; then
56 echo SLAVEPID $SLAVEPID
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
65 if test $RC = 1 ; then
66 echo "Waiting 5 seconds for slapd to start..."
71 if test $RC != 0 ; then
72 echo "ldapsearch failed ($RC)!"
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
82 if test $RC = 1 ; then
83 echo "Waiting 5 seconds for slapd to start..."
88 cat /dev/null > $SEARCHOUT
90 echo "Testing exact searching..."
91 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
92 'sn=jensen' >> $SEARCHOUT 2>&1
94 if test $RC != 0 ; then
95 echo "ldapsearch failed ($RC)!"
96 kill -HUP $PID $SLAVEPID
100 echo "Testing OR searching..."
101 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
102 '(|(objectclass=groupofnames)(sn=jones))' >> $SEARCHOUT 2>&1
104 if test $RC != 0 ; then
105 echo "ldapsearch failed ($RC)!"
106 kill -HUP $PID $SLAVEPID
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
114 if test $RC != 0 ; then
115 echo "ldapsearch failed ($RC)!"
116 kill -HUP $PID $SLAVEPID
120 echo "Testing NOT searching..."
121 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
122 '(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1
124 if test $RC != 0 ; then
125 echo "ldapsearch failed ($RC)!"
126 kill -HUP $PID $SLAVEPID
130 kill -HUP $PID $SLAVEPID
132 LDIF=$SEARCHOUTMASTER
134 echo "Filtering ldapsearch results..."
135 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
136 echo "Filtering original ldif used to create database..."
137 . $LDIFFILTER < $LDIF > $LDIFFLT
138 echo "Comparing filter output..."
139 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
141 if test $? != 0 ; then
142 echo "Comparison failed"
146 echo ">>>>> Test succeeded"