3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 2004-2006 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test $VALSORT = valsortno; then
20 echo "Valsort overlay not available, test skipped"
24 mkdir -p $TESTDIR $DBDIR1
26 echo "Running slapadd to build slapd database..."
27 . $CONFFILTER $BACKEND $MONITORDB < $VALSORTCONF > $CONF1
28 $SLAPADD -f $CONF1 -l $LDIFVALSORT
30 if test $RC != 0 ; then
31 echo "slapadd failed ($RC)!"
35 echo "Starting slapd on TCP/IP port $PORT1..."
36 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
38 if test $WAIT != 0 ; then
46 echo "Testing slapd sorted values operations..."
47 for i in 0 1 2 3 4 5; do
48 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
49 'objectclass=*' > /dev/null 2>&1
51 if test $RC = 0 ; then
54 echo "Waiting 5 seconds for slapd to start..."
58 if test $RC != 0 ; then
59 echo "ldapsearch failed ($RC)!"
60 test $KILLSERVERS != no && kill -HUP $KILLPIDS
64 echo "Testing ascending and weighted sort"
66 FILTER="objectClass=*"
67 $LDAPSEARCH -b "$VALSORTBASEDN" -h $LOCALHOST -p $PORT1 \
68 "$FILTER" > $SEARCHOUT 2>&1
71 if test $RC != 0 ; then
72 echo "ldapsearch failed ($RC)!"
73 test $KILLSERVERS != no && kill -HUP $KILLPIDS
77 echo "Filtering ldapsearch results..."
78 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
79 echo "Comparing filter output..."
80 $CMP $SEARCHFLT $VALSORTOUT1 > $CMPOUT
82 if test $? != 0 ; then
83 echo "Comparison failed"
84 test $KILLSERVERS != no && kill -HUP $KILLPIDS
88 echo "Reconfiguring slapd to test valsort descending"
90 $LDAPMODIFY -x -D cn=config -h $LOCALHOST -p $PORT1 -w $PASSWD > \
91 $TESTOUT 2>&1 << EOMODS
93 dn: olcOverlay={0}valsort,olcDatabase={1}$BACKEND,cn=config
95 replace: olcValSortAttr
96 olcValSortAttr: employeeType "ou=users,o=valsort" weighted alpha-descend
97 olcValSortAttr: ou "ou=users,o=valsort" weighted
98 olcValSortAttr: mailPreferenceOption "ou=users,o=valsort" numeric-descend
99 olcValSortAttr: departmentNumber "ou=users,o=valsort" alpha-descend
100 olcValSortAttr: sn "ou=users,o=valsort" alpha-descend
105 if test $RC != 0 ; then
106 echo "ldapmodify failed ($RC)!"
107 test $KILLSERVERS != no && kill -HUP $KILLPIDS
111 echo "Testing descending and weighted sort"
113 $LDAPSEARCH -b "$VALSORTBASEDN" -h $LOCALHOST -p $PORT1 \
114 "$FILTER" > $SEARCHOUT 2>&1
117 if test $RC != 0 ; then
118 echo "ldapsearch failed ($RC)!"
119 test $KILLSERVERS != no && kill -HUP $KILLPIDS
123 echo "Filtering ldapsearch results..."
124 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
125 echo "Comparing filter output..."
126 $CMP $SEARCHFLT $VALSORTOUT2 > $CMPOUT
128 if test $? != 0 ; then
129 echo "Comparison failed"
130 test $KILLSERVERS != no && kill -HUP $KILLPIDS
134 echo "Adding a valsort record with weighted ou..."
136 $LDAPADD -D "$VALSORTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
137 > /dev/null << EOTVALSORT1
138 dn: uid=dave,ou=users,o=valsort
139 objectClass: OpenLDAPperson
143 businessCategory: otest
148 employeeType: {1}contractor
156 if test $RC != 0 ; then
157 echo "ldapadd failed ($RC)!"
158 test $KILLSERVERS != no && kill -HUP $KILLPIDS
162 #echo ----------------------
163 #$LDAPSEARCH -b "o=valsort" -h $LOCALHOST -p $PORT1
165 echo "Adding a non-weighted valsort record with ou..."
167 $LDAPADD -D "$VALSORTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
168 $TESTOUT 2>&1 << EOTVALSORT2
169 dn: uid=bill,ou=users,o=valsort
170 objectClass: OpenLDAPperson
174 businessCategory: rtest
179 employeeType: {1}contractor
187 if test $RC != 19 ; then
188 echo "valsort check failed ($RC)!"
189 test $KILLSERVERS != no && kill -HUP $KILLPIDS
193 $LDAPSEARCH -b "$VALSORTBASEDN" -h $LOCALHOST -p $PORT1 \
194 "$FILTER" > $SEARCHOUT 2>&1
197 if test $RC != 0 ; then
198 echo "ldapsearch failed ($RC)!"
199 test $KILLSERVERS != no && kill -HUP $KILLPIDS
203 echo "Filtering ldapsearch results..."
204 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
205 echo "Comparing filter output..."
206 $CMP $SEARCHFLT $VALSORTOUT3 > $CMPOUT
208 if test $? != 0 ; then
209 echo "Comparison failed"
210 test $KILLSERVERS != no && kill -HUP $KILLPIDS
214 test $KILLSERVERS != no && kill -HUP $KILLPIDS
216 test $KILLSERVERS != no && wait
218 echo ">>>>> Test succeeded"