3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-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 $BACKLDAP = "ldapno" ; then
20 echo "LDAP backend not available, test skipped"
24 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
26 echo "Running slapadd to build slapd database..."
27 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF1 > $ADDCONF
28 . $CONFFILTER < $LDIFCHAIN1 > $SEARCHOUT
29 $SLAPADD -f $ADDCONF -l $SEARCHOUT
31 if test $RC != 0 ; then
32 echo "slapadd 1 failed ($RC)!"
36 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF2 > $ADDCONF
37 . $CONFFILTER < $LDIFCHAIN2 > $SEARCHOUT
38 $SLAPADD -f $ADDCONF -l $SEARCHOUT
40 if test $RC != 0 ; then
41 echo "slapadd 2 failed ($RC)!"
45 echo "Starting first slapd on TCP/IP port $PORT1..."
46 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF1 > $CONF1
47 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
49 if test $WAIT != 0 ; then
54 echo "Starting second slapd on TCP/IP port $PORT2..."
55 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF2 > $CONF2
56 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
58 if test $WAIT != 0 ; then
63 KILLPIDS="$PID1 $PID2"
65 echo "Using ldapsearch to check that first slapd is running..."
66 for i in 0 1 2 3 4 5; do
67 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
68 'objectclass=*' > /dev/null 2>&1
70 if test $RC = 0 ; then
73 echo "Waiting 5 seconds for slapd to start..."
77 echo "Using ldapsearch to check that second slapd is running..."
78 for i in 0 1 2 3 4 5; do
79 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
80 'objectclass=*' > /dev/null 2>&1
82 if test $RC = 0 ; then
85 echo "Waiting 5 seconds for slapd to start..."
89 BASE="dc=example,dc=com"
91 for P in $PORT1 $PORT2 ; do
92 echo "Testing ldapsearch as anonymous for \"$BASE\" on port $P..."
93 $LDAPSEARCH -h $LOCALHOST -p $P -b "$BASE" -S "" \
97 if test $RC != 0 ; then
98 echo "ldapsearch failed ($RC)!"
99 test $KILLSERVERS != no && kill -HUP $KILLPIDS
103 echo "Filtering ldapsearch results..."
104 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
105 echo "Filtering original ldif used to create database..."
106 . $LDIFFILTER < $CHAINOUT > $LDIFFLT
107 echo "Comparing filter output..."
108 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
110 if test $? != 0 ; then
111 echo "comparison failed - chained search as anonymous didn't succeed"
112 test $KILLSERVERS != no && kill -HUP $KILLPIDS
117 test $KILLSERVERS != no && kill -HUP $KILLPIDS
119 echo ">>>>> Test succeeded"