5 if test $# -ge 1 ; then
9 if test $# -ge 1 ; then
13 if test $# -ge 1 ; then
17 echo "running defines.sh"
18 . $SRCDIR/scripts/defines.sh
21 # Test default referral
25 echo "Cleaning up in $DBDIR and $REPLDIR ..."
30 echo "Running slapadd to build slapd database..."
31 . $CONFFILTER $BACKEND < $CONF > $DBCONF
32 $SLAPADD -f $DBCONF -l $LDIFORDERED
34 if test $RC != 0 ; then
35 echo "slapadd failed ($RC)!"
39 echo "Starting master slapd on TCP/IP port $PORT..."
40 $SLAPD -n master -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
42 if test $WAIT != 0 ; then
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 &
51 if test $WAIT != 0 ; then
52 echo SLAVEPID $SLAVEPID
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
61 if test $RC = 1 ; then
62 echo "Waiting 5 seconds for slapd to start..."
67 if test $RC != 0 ; then
68 echo "ldapsearch failed ($RC)!"
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
78 if test $RC = 1 ; then
79 echo "Waiting 5 seconds for slapd to start..."
84 cat /dev/null > $SEARCHOUT
86 echo "Testing exact searching..."
87 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
88 'sn=jensen' >> $SEARCHOUT 2>&1
89 if test $RC != 0 ; then
90 echo "ldapsearch failed ($RC)!"
91 kill -HUP $PID $SLAVEPID
95 echo "Testing OR searching..."
96 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
97 '(|(objectclass=groupofnames)(sn=jones))' >> $SEARCHOUT 2>&1
98 if test $RC != 0 ; then
99 echo "ldapsearch failed ($RC)!"
100 kill -HUP $PID $SLAVEPID
104 echo "Testing AND matching and ends-with searching..."
105 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
106 '(&(objectclass=groupofnames)(cn=A*))' >> $SEARCHOUT 2>&1
107 if test $RC != 0 ; then
108 echo "ldapsearch failed ($RC)!"
109 kill -HUP $PID $SLAVEPID
113 echo "Testing NOT searching..."
114 $LDAPSEARCH -C -S "" -b "$BASEDN" -h $LOCALHOST -p $SLAVEPORT \
115 '(!(objectclass=person))' >> $SEARCHOUT 2>&1
116 if test $RC != 0 ; then
117 echo "ldapsearch failed ($RC)!"
118 kill -HUP $PID $SLAVEPID
122 kill -HUP $PID $SLAVEPID
124 LDIF=$SEARCHOUTMASTER
126 echo "Filtering ldapsearch results..."
127 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
128 echo "Filtering original ldif used to create database..."
129 . $LDIFFILTER < $LDIF > $LDIFFLT
130 echo "Comparing filter output..."
131 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
133 if test $? != 0 ; then
134 echo "Comparison failed"
138 echo ">>>>> Test succeeded"