3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 2004-2005 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
44 echo "Testing slapd sorted values operations..."
45 for i in 0 1 2 3 4 5; do
46 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
47 'objectclass=*' > /dev/null 2>&1
49 if test $RC = 0 ; then
52 echo "Waiting 5 seconds for slapd to start..."
56 if test $RC != 0 ; then
57 echo "ldapsearch failed ($RC)!"
58 test $KILLSERVERS != no && kill -HUP $KILLPIDS
62 echo "Testing ascending and weighted sort"
64 FILTER="objectClass=*"
65 $LDAPSEARCH -b "$VALSORTBASEDN" -h $LOCALHOST -p $PORT1 \
66 "$FILTER" > $SEARCHOUT 2>&1
69 if test $RC != 0 ; then
70 echo "ldapsearch failed ($RC)!"
71 test $KILLSERVERS != no && kill -HUP $KILLPIDS
75 echo "Filtering ldapsearch results..."
76 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
77 echo "Comparing filter output..."
78 $CMP $SEARCHFLT $VALSORTOUT1 > $CMPOUT
80 if test $? != 0 ; then
81 echo "Comparison failed"
82 test $KILLSERVERS != no && kill -HUP $KILLPIDS
86 echo ">>>>> Test succeeded"
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 ">>>>> Test succeeded"
136 echo "Adding a valsort record with weighted ou..."
138 $LDAPADD -D "$VALSORTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
139 > /dev/null << EOTVALSORT1
140 dn: uid=dave,ou=users,o=valsort
141 objectClass: OpenLDAPperson
145 businessCategory: otest
150 employeeType: {1}contractor
158 if test $RC != 0 ; then
159 echo "ldapadd failed ($RC)!"
160 test $KILLSERVERS != no && kill -HUP $KILLPIDS
164 #echo ----------------------
165 #$LDAPSEARCH -b "o=valsort" -h $LOCALHOST -p $PORT1
167 echo "Adding a non-weighted valsort record with ou..."
169 $LDAPADD -D "$VALSORTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
170 $TESTOUT 2>&1 << EOTVALSORT2
171 dn: uid=bill,ou=users,o=valsort
172 objectClass: OpenLDAPperson
176 businessCategory: rtest
181 employeeType: {1}contractor
189 if test $RC != 19 ; then
190 echo "valsort check failed ($RC)!"
191 test $KILLSERVERS != no && kill -HUP $KILLPIDS
195 $LDAPSEARCH -b "$VALSORTBASEDN" -h $LOCALHOST -p $PORT1 \
196 "$FILTER" > $SEARCHOUT 2>&1
199 if test $RC != 0 ; then
200 echo "ldapsearch failed ($RC)!"
201 test $KILLSERVERS != no && kill -HUP $KILLPIDS
205 echo "Filtering ldapsearch results..."
206 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
207 echo "Comparing filter output..."
208 $CMP $SEARCHFLT $VALSORTOUT3 > $CMPOUT
210 if test $? != 0 ; then
211 echo "Comparison failed"
212 test $KILLSERVERS != no && kill -HUP $KILLPIDS
216 test $KILLSERVERS != no && kill -HUP $KILLPIDS
218 echo ">>>>> Test succeeded"