2 # $OpenLDAP: pkg/ldap/tests/scripts/test042-valsort,v 1.4.2.5 2008/02/11 23:26:51 kurt Exp $
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 2004-2008 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 $SLAPPASSWD -g -n >$CONFIGPWF
27 echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
29 echo "Running slapadd to build slapd database..."
30 .
$CONFFILTER $BACKEND $MONITORDB < $VALSORTCONF > $CONF1
31 $SLAPADD -f $CONF1 -l $LDIFVALSORT
33 if test $RC != 0 ; then
34 echo "slapadd failed ($RC)!"
38 echo "Starting slapd on TCP/IP port $PORT1..."
39 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
41 if test $WAIT != 0 ; then
49 echo "Testing slapd sorted values operations..."
50 for i
in 0 1 2 3 4 5; do
51 $LDAPSEARCH -s base
-b "$MONITOR" -h $LOCALHOST -p $PORT1 \
52 'objectclass=*' > /dev
/null
2>&1
54 if test $RC = 0 ; then
57 echo "Waiting 5 seconds for slapd to start..."
61 if test $RC != 0 ; then
62 echo "ldapsearch failed ($RC)!"
63 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
67 echo "Testing ascending and weighted sort"
69 FILTER
="objectClass=*"
70 $LDAPSEARCH -b "$VALSORTBASEDN" -h $LOCALHOST -p $PORT1 \
71 "$FILTER" > $SEARCHOUT 2>&1
74 if test $RC != 0 ; then
75 echo "ldapsearch failed ($RC)!"
76 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
80 echo "Filtering ldapsearch results..."
81 .
$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
82 echo "Comparing filter output..."
83 $CMP $SEARCHFLT $VALSORTOUT1 > $CMPOUT
85 if test $?
!= 0 ; then
86 echo "Comparison failed"
87 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
91 echo "Reconfiguring slapd to test valsort descending"
93 $LDAPMODIFY -x -D cn
=config
-h $LOCALHOST -p $PORT1 -y $CONFIGPWF > \
94 $TESTOUT 2>&1 << EOMODS
96 dn: olcOverlay={0}valsort,olcDatabase={1}$BACKEND,cn=config
98 replace: olcValSortAttr
99 olcValSortAttr: employeeType "ou=users,o=valsort" weighted alpha-descend
100 olcValSortAttr: ou "ou=users,o=valsort" weighted
101 olcValSortAttr: mailPreferenceOption "ou=users,o=valsort" numeric-descend
102 olcValSortAttr: departmentNumber "ou=users,o=valsort" alpha-descend
103 olcValSortAttr: sn "ou=users,o=valsort" alpha-descend
108 if test $RC != 0 ; then
109 echo "ldapmodify failed ($RC)!"
110 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
114 echo "Testing descending and weighted sort"
116 $LDAPSEARCH -b "$VALSORTBASEDN" -h $LOCALHOST -p $PORT1 \
117 "$FILTER" > $SEARCHOUT 2>&1
120 if test $RC != 0 ; then
121 echo "ldapsearch failed ($RC)!"
122 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
126 echo "Filtering ldapsearch results..."
127 .
$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
128 echo "Comparing filter output..."
129 $CMP $SEARCHFLT $VALSORTOUT2 > $CMPOUT
131 if test $?
!= 0 ; then
132 echo "Comparison failed"
133 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
137 echo "Adding a valsort record with weighted ou..."
139 $LDAPADD -D "$VALSORTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
140 > /dev
/null
<< EOTVALSORT1
141 dn: uid=dave,ou=users,o=valsort
142 objectClass: OpenLDAPperson
146 businessCategory: otest
151 employeeType: {1}contractor
159 if test $RC != 0 ; then
160 echo "ldapadd failed ($RC)!"
161 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
165 #echo ----------------------
166 #$LDAPSEARCH -b "o=valsort" -h $LOCALHOST -p $PORT1
168 echo "Adding a non-weighted valsort record with ou..."
170 $LDAPADD -D "$VALSORTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
171 $TESTOUT 2>&1 << EOTVALSORT2
172 dn: uid=bill,ou=users,o=valsort
173 objectClass: OpenLDAPperson
177 businessCategory: rtest
182 employeeType: {1}contractor
190 if test $RC != 19 ; then
191 echo "valsort check failed ($RC)!"
192 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
196 $LDAPSEARCH -b "$VALSORTBASEDN" -h $LOCALHOST -p $PORT1 \
197 "$FILTER" > $SEARCHOUT 2>&1
200 if test $RC != 0 ; then
201 echo "ldapsearch failed ($RC)!"
202 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
206 echo "Filtering ldapsearch results..."
207 .
$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
208 echo "Comparing filter output..."
209 $CMP $SEARCHFLT $VALSORTOUT3 > $CMPOUT
211 if test $?
!= 0 ; then
212 echo "Comparison failed"
213 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
217 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
219 test $KILLSERVERS != no
&& wait
221 echo ">>>>> Test succeeded"