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 ">>>>> Test succeeded"
90 echo "Reconfiguring slapd to test valsort descending"
92 $LDAPMODIFY -x -D cn=config -h $LOCALHOST -p $PORT1 -w $PASSWD > \
93 $TESTOUT 2>&1 << EOMODS
95 dn: olcOverlay={0}valsort,olcDatabase={1}$BACKEND,cn=config
97 replace: olcValSortAttr
98 olcValSortAttr: employeeType "ou=users,o=valsort" weighted alpha-descend
99 olcValSortAttr: ou "ou=users,o=valsort" weighted
100 olcValSortAttr: mailPreferenceOption "ou=users,o=valsort" numeric-descend
101 olcValSortAttr: departmentNumber "ou=users,o=valsort" alpha-descend
102 olcValSortAttr: sn "ou=users,o=valsort" alpha-descend
107 if test $RC != 0 ; then
108 echo "ldapmodify failed ($RC)!"
109 test $KILLSERVERS != no && kill -HUP $KILLPIDS
113 echo "Testing descending and weighted sort"
115 $LDAPSEARCH -b "$VALSORTBASEDN" -h $LOCALHOST -p $PORT1 \
116 "$FILTER" > $SEARCHOUT 2>&1
119 if test $RC != 0 ; then
120 echo "ldapsearch failed ($RC)!"
121 test $KILLSERVERS != no && kill -HUP $KILLPIDS
125 echo "Filtering ldapsearch results..."
126 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
127 echo "Comparing filter output..."
128 $CMP $SEARCHFLT $VALSORTOUT2 > $CMPOUT
130 if test $? != 0 ; then
131 echo "Comparison failed"
132 test $KILLSERVERS != no && kill -HUP $KILLPIDS
136 echo ">>>>> Test succeeded"
138 echo "Adding a valsort record with weighted ou..."
140 $LDAPADD -D "$VALSORTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
141 > /dev/null << EOTVALSORT1
142 dn: uid=dave,ou=users,o=valsort
143 objectClass: OpenLDAPperson
147 businessCategory: otest
152 employeeType: {1}contractor
160 if test $RC != 0 ; then
161 echo "ldapadd failed ($RC)!"
162 test $KILLSERVERS != no && kill -HUP $KILLPIDS
166 #echo ----------------------
167 #$LDAPSEARCH -b "o=valsort" -h $LOCALHOST -p $PORT1
169 echo "Adding a non-weighted valsort record with ou..."
171 $LDAPADD -D "$VALSORTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
172 $TESTOUT 2>&1 << EOTVALSORT2
173 dn: uid=bill,ou=users,o=valsort
174 objectClass: OpenLDAPperson
178 businessCategory: rtest
183 employeeType: {1}contractor
191 if test $RC != 19 ; then
192 echo "valsort check failed ($RC)!"
193 test $KILLSERVERS != no && kill -HUP $KILLPIDS
197 $LDAPSEARCH -b "$VALSORTBASEDN" -h $LOCALHOST -p $PORT1 \
198 "$FILTER" > $SEARCHOUT 2>&1
201 if test $RC != 0 ; then
202 echo "ldapsearch failed ($RC)!"
203 test $KILLSERVERS != no && kill -HUP $KILLPIDS
207 echo "Filtering ldapsearch results..."
208 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
209 echo "Comparing filter output..."
210 $CMP $SEARCHFLT $VALSORTOUT3 > $CMPOUT
212 if test $? != 0 ; then
213 echo "Comparison failed"
214 test $KILLSERVERS != no && kill -HUP $KILLPIDS
218 test $KILLSERVERS != no && kill -HUP $KILLPIDS
220 echo ">>>>> Test succeeded"
222 test $KILLSERVERS != no && wait