]> git.sur5r.net Git - openldap/blob - tests/scripts/test039-glue-ldap-concurrency
ITS#4049: oldPassword cannot be ignored, error for now
[openldap] / tests / scripts / test039-glue-ldap-concurrency
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2005 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
11 ##
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>.
15
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 echo ""
20
21 if test $BACKLDAP = ldapno ; then 
22         echo "ldap backend not available, test skipped"
23         exit 0
24 fi
25
26 if test $RWM = rwmno ; then 
27         echo "rwm (rewrite/remap) overlay not available, test skipped"
28         exit 0
29 fi 
30
31 rm -rf $TESTDIR
32
33 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
34
35 echo "Starting slapd on TCP/IP port $PORT1..."
36 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
37 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
38 PID=$!
39 if test $WAIT != 0 ; then
40     echo PID $PID
41     read foo
42 fi
43 KILLPIDS="$PID"
44
45 echo "Using ldapsearch to check that slapd is running..."
46 for i in 0 1 2 3 4 5; do
47         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
48                 'objectclass=*' > /dev/null 2>&1
49         RC=$?
50         if test $RC = 0 ; then
51                 break
52         fi
53         echo "Waiting 5 seconds for slapd to start..."
54         sleep 5
55 done
56 if test $RC != 0 ; then
57         echo "ldapsearch failed ($RC)!"
58         test $KILLSERVERS != no && kill -HUP $KILLPIDS
59         exit $RC
60 fi
61
62 echo "Using ldapadd to populate the database..."
63 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
64         $LDIFORDERED > $TESTOUT 2>&1
65 RC=$?
66 if test $RC != 0 ; then
67         echo "ldapadd failed ($RC)!"
68         test $KILLSERVERS != no && kill -HUP $KILLPIDS
69         exit $RC
70 fi
71
72 echo "Starting slapd on TCP/IP port $PORT2..."
73 . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
74 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
75 PID=$!
76 if test $WAIT != 0 ; then
77     echo PID $PID
78     read foo
79 fi
80 KILLPIDS="$KILLPIDS $PID"
81
82 echo "Using ldapsearch to check that slapd is running..."
83 for i in 0 1 2 3 4 5; do
84         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
85                 'objectclass=*' > /dev/null 2>&1
86         RC=$?
87         if test $RC = 0 ; then
88                 break
89         fi
90         echo "Waiting 5 seconds for slapd to start..."
91         sleep 5
92 done
93 if test $RC != 0 ; then
94         echo "ldapsearch failed ($RC)!"
95         test $KILLSERVERS != no && kill -HUP $KILLPIDS
96         exit $RC
97 fi
98
99 echo "Using ldapadd to populate the database..."
100 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
101         $LDIFMETA >> $TESTOUT 2>&1
102 RC=$?
103 if test $RC != 0 ; then
104         echo "ldapadd failed ($RC)!"
105         test $KILLSERVERS != no && kill -HUP $KILLPIDS
106         exit $RC
107 fi
108
109 echo "Starting slapd on TCP/IP port $PORT3..."
110 . $CONFFILTER $BACKEND $MONITORDB < $GLUELDAPCONF > $CONF3
111 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
112 PID=$!
113 if test $WAIT != 0 ; then
114     echo PID $PID
115     read foo
116 fi
117 KILLPIDS="$KILLPIDS $PID"
118
119 echo "Using ldapsearch to check that slapd is running..."
120 for i in 0 1 2 3 4 5; do
121         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
122                 'objectclass=*' > /dev/null 2>&1
123         RC=$?
124         if test $RC = 0 ; then
125                 break
126         fi
127         echo "Waiting 5 seconds for slapd to start..."
128         sleep 5
129 done
130 if test $RC != 0 ; then
131         echo "ldapsearch failed ($RC)!"
132         test $KILLSERVERS != no && kill -HUP $KILLPIDS
133         exit $RC
134 fi
135
136 cat /dev/null > $SEARCHOUT
137
138 mkdir -p $TESTDIR/$DATADIR
139 METABASEDN="o=Example,c=US"
140 for f in $DATADIR/do_* ; do
141         sed -e "s;$BASEDN;$METABASEDN;" $f > $TESTDIR/$f
142 done
143
144 # add a read that matches only the local database, but selects 
145 # also the remote as candidate; this should be removed to compare
146 # execution times with test008...
147 for f in $TESTDIR/$DATADIR/do_read.* ; do
148         echo "ou=Meta,$METABASEDN" >> $f
149 done
150
151 # add a read that matches a referral in the local database only, 
152 # but selects also the remote as candidate; this should be removed 
153 # to compare execution times with test008...
154 for f in $TESTDIR/$DATADIR/do_read.* ; do
155         echo "cn=Somewhere,ou=Meta,$METABASEDN" >> $f
156 done
157
158 echo "Using tester for concurrent server access..."
159 $SLAPDTESTER -P "$PROGDIR" -d "$TESTDIR/$DATADIR" -h $LOCALHOST -p $PORT3 -D "cn=Manager,$METABASEDN" -w $PASSWD -l 50 # -r 20
160 RC=$?
161
162 if test $RC != 0 ; then
163         echo "slapd-tester failed ($RC)!"
164         test $KILLSERVERS != no && kill -HUP $KILLPIDS
165         exit $RC
166 fi 
167
168 echo "Using ldapsearch to retrieve all the entries..."
169 $LDAPSEARCH -S "" -b "$METABASEDN" -h $LOCALHOST -p $PORT3 \
170                         '(objectClass=*)' > $SEARCHOUT 2>&1
171 RC=$?
172
173 test $KILLSERVERS != no && kill -HUP $KILLPIDS
174
175 if test $RC != 0 ; then
176         echo "ldapsearch failed ($RC)!"
177         exit $RC
178 fi
179
180 echo "Filtering ldapsearch results..."
181 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
182 echo "Filtering original ldif used to create database..."
183 . $LDIFFILTER < $METACONCURRENCYOUT > $LDIFFLT
184 echo "Comparing filter output..."
185 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
186
187 if test $? != 0 ; then
188         echo "comparison failed - meta search/modification didn't succeed"
189         exit 1
190 fi
191
192 echo ">>>>> Test succeeded"
193 exit 0
194